module.audio.aa.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /////////////////////////////////////////////////////////////////
  3. /// getID3() by James Heinrich <info@getid3.org> //
  4. // available at http://getid3.sourceforge.net //
  5. // or http://www.getid3.org //
  6. /////////////////////////////////////////////////////////////////
  7. // See readme.txt for more details //
  8. /////////////////////////////////////////////////////////////////
  9. // //
  10. // module.audio.aa.php //
  11. // module for analyzing Audible Audiobook files //
  12. // dependencies: NONE //
  13. // ///
  14. /////////////////////////////////////////////////////////////////
  15. class getid3_aa extends getid3_handler
  16. {
  17. function Analyze() {
  18. $info = &$this->getid3->info;
  19. fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
  20. $AAheader = fread($this->getid3->fp, 8);
  21. $magic = "\x57\x90\x75\x36";
  22. if (substr($AAheader, 4, 4) != $magic) {
  23. $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($AAheader, 4, 4)).'"';
  24. return false;
  25. }
  26. // shortcut
  27. $info['aa'] = array();
  28. $thisfile_au = &$info['aa'];
  29. $info['fileformat'] = 'aa';
  30. $info['audio']['dataformat'] = 'aa';
  31. $info['audio']['bitrate_mode'] = 'cbr'; // is it?
  32. $thisfile_au['encoding'] = 'ISO-8859-1';
  33. $thisfile_au['filesize'] = getid3_lib::BigEndian2Int(substr($AUheader, 0, 4));
  34. if ($thisfile_au['filesize'] > ($info['avdataend'] - $info['avdataoffset'])) {
  35. $info['warning'][] = 'Possible truncated file - expecting "'.$thisfile_au['filesize'].'" bytes of data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"';
  36. }
  37. $info['audio']['bits_per_sample'] = 16; // is it?
  38. $info['audio']['sample_rate'] = $thisfile_au['sample_rate'];
  39. $info['audio']['channels'] = $thisfile_au['channels'];
  40. //$info['playtime_seconds'] = 0;
  41. //$info['audio']['bitrate'] = 0;
  42. return true;
  43. }
  44. }
  45. ?>