File indexing completed on 2024-05-12 05:58:13

0001 <?php
0002 /////////////////////////////////////////////////////////////////
0003 /// getID3() by James Heinrich <info@getid3.org>               //
0004 //  available at http://getid3.sourceforge.net                 //
0005 //            or http://www.getid3.org                         //
0006 //          also https://github.com/JamesHeinrich/getID3       //
0007 /////////////////////////////////////////////////////////////////
0008 // See readme.txt for more details                             //
0009 /////////////////////////////////////////////////////////////////
0010 //                                                             //
0011 // module.audio.aa.php                                         //
0012 // module for analyzing Audible Audiobook files                //
0013 // dependencies: NONE                                          //
0014 //                                                            ///
0015 /////////////////////////////////////////////////////////////////
0016 
0017 
0018 class getid3_aa extends getid3_handler
0019 {
0020 
0021   public function Analyze() {
0022     $info = &$this->getid3->info;
0023 
0024     $this->fseek($info['avdataoffset']);
0025     $AAheader  = $this->fread(8);
0026 
0027     $magic = "\x57\x90\x75\x36";
0028     if (substr($AAheader, 4, 4) != $magic) {
0029       $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($AAheader, 4, 4)).'"';
0030       return false;
0031     }
0032 
0033     // shortcut
0034     $info['aa'] = array();
0035     $thisfile_aa = &$info['aa'];
0036 
0037     $info['fileformat']            = 'aa';
0038     $info['audio']['dataformat']   = 'aa';
0039 $info['error'][] = 'Audible Audiobook (.aa) parsing not enabled in this version of getID3() ['.$this->getid3->version().']';
0040 return false;
0041     $info['audio']['bitrate_mode'] = 'cbr'; // is it?
0042     $thisfile_aa['encoding']       = 'ISO-8859-1';
0043 
0044     $thisfile_aa['filesize'] = getid3_lib::BigEndian2Int(substr($AUheader,  0, 4));
0045     if ($thisfile_aa['filesize'] > ($info['avdataend'] - $info['avdataoffset'])) {
0046       $info['warning'][] = 'Possible truncated file - expecting "'.$thisfile_aa['filesize'].'" bytes of data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"';
0047     }
0048 
0049     $info['audio']['bits_per_sample'] = 16; // is it?
0050     $info['audio']['sample_rate'] = $thisfile_aa['sample_rate'];
0051     $info['audio']['channels']    = $thisfile_aa['channels'];
0052 
0053     //$info['playtime_seconds'] = 0;
0054     //$info['audio']['bitrate'] = 0;
0055 
0056     return true;
0057   }
0058 
0059 }