1<?php 2 3///////////////////////////////////////////////////////////////// 4/// getID3() by James Heinrich <info@getid3.org> // 5// available at https://github.com/JamesHeinrich/getID3 // 6// or https://www.getid3.org // 7// or http://getid3.sourceforge.net // 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 17if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 18 exit; 19} 20 21class getid3_aa extends getid3_handler 22{ 23 /** 24 * @return bool 25 */ 26 public function Analyze() { 27 $info = &$this->getid3->info; 28 29 $this->fseek($info['avdataoffset']); 30 $AAheader = $this->fread(8); 31 32 $magic = "\x57\x90\x75\x36"; 33 if (substr($AAheader, 4, 4) != $magic) { 34 $this->error('Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($AAheader, 4, 4)).'"'); 35 return false; 36 } 37 38 // shortcut 39 $info['aa'] = array(); 40 $thisfile_aa = &$info['aa']; 41 42 $info['fileformat'] = 'aa'; 43 $info['audio']['dataformat'] = 'aa'; 44 $this->error('Audible Audiobook (.aa) parsing not enabled in this version of getID3() ['.$this->getid3->version().']'); 45 return false; 46 $info['audio']['bitrate_mode'] = 'cbr'; // is it? 47 $thisfile_aa['encoding'] = 'ISO-8859-1'; 48 49 $thisfile_aa['filesize'] = getid3_lib::BigEndian2Int(substr($AAheader, 0, 4)); 50 if ($thisfile_aa['filesize'] > ($info['avdataend'] - $info['avdataoffset'])) { 51 $this->warning('Possible truncated file - expecting "'.$thisfile_aa['filesize'].'" bytes of data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"'); 52 } 53 54 $info['audio']['bits_per_sample'] = 16; // is it? 55 $info['audio']['sample_rate'] = $thisfile_aa['sample_rate']; 56 $info['audio']['channels'] = $thisfile_aa['channels']; 57 58 //$info['playtime_seconds'] = 0; 59 //$info['audio']['bitrate'] = 0; 60 61 return true; 62 } 63 64} 65