/lib/getid3/module.audio.aa.php

  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. // also https://github.com/JamesHeinrich/getID3 // 
  7. ///////////////////////////////////////////////////////////////// 
  8. // See readme.txt for more details // 
  9. ///////////////////////////////////////////////////////////////// 
  10. // // 
  11. // module.audio.aa.php // 
  12. // module for analyzing Audible Audiobook files // 
  13. // dependencies: NONE // 
  14. // /// 
  15. ///////////////////////////////////////////////////////////////// 
  16.  
  17.  
  18. class getid3_aa extends getid3_handler 
  19.  
  20. public function Analyze() { 
  21. $info = &$this->getid3->info; 
  22.  
  23. $this->fseek($info['avdataoffset']); 
  24. $AAheader = $this->fread(8); 
  25.  
  26. $magic = "\x57\x90\x75\x36"; 
  27. if (substr($AAheader, 4, 4) != $magic) { 
  28. $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($AAheader, 4, 4)).'"'; 
  29. return false; 
  30.  
  31. // shortcut 
  32. $info['aa'] = array(); 
  33. $thisfile_aa = &$info['aa']; 
  34.  
  35. $info['fileformat'] = 'aa'; 
  36. $info['audio']['dataformat'] = 'aa'; 
  37. $info['error'][] = 'Audible Audiobook (.aa) parsing not enabled in this version of getID3() ['.$this->getid3->version().']'; 
  38. return false; 
  39. $info['audio']['bitrate_mode'] = 'cbr'; // is it? 
  40. $thisfile_aa['encoding'] = 'ISO-8859-1'; 
  41.  
  42. $thisfile_aa['filesize'] = getid3_lib::BigEndian2Int(substr($AUheader, 0, 4)); 
  43. if ($thisfile_aa['filesize'] > ($info['avdataend'] - $info['avdataoffset'])) { 
  44. $info['warning'][] = 'Possible truncated file - expecting "'.$thisfile_aa['filesize'].'" bytes of data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"'; 
  45.  
  46. $info['audio']['bits_per_sample'] = 16; // is it? 
  47. $info['audio']['sample_rate'] = $thisfile_aa['sample_rate']; 
  48. $info['audio']['channels'] = $thisfile_aa['channels']; 
  49.  
  50. //$info['playtime_seconds'] = 0; 
  51. //$info['audio']['bitrate'] = 0; 
  52.  
  53. return true; 
  54.  
.