[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.audio.aa.php
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
17
18 class getid3_aa extends getid3_handler
19 {
20 /**
21 * @return bool
22 */
23 public function Analyze() {
24 $info = &$this->getid3->info;
25
26 $this->fseek($info['avdataoffset']);
27 $AAheader = $this->fread(8);
28
29 $magic = "\x57\x90\x75\x36";
30 if (substr($AAheader, 4, 4) != $magic) {
31 $this->error('Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($AAheader, 4, 4)).'"');
32 return false;
33 }
34
35 // shortcut
36 $info['aa'] = array();
37 $thisfile_aa = &$info['aa'];
38
39 $info['fileformat'] = 'aa';
40 $info['audio']['dataformat'] = 'aa';
41 $this->error('Audible Audiobook (.aa) parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
42 return false;
43 $info['audio']['bitrate_mode'] = 'cbr'; // is it?
44 $thisfile_aa['encoding'] = 'ISO-8859-1';
45
46 $thisfile_aa['filesize'] = getid3_lib::BigEndian2Int(substr($AAheader, 0, 4));
47 if ($thisfile_aa['filesize'] > ($info['avdataend'] - $info['avdataoffset'])) {
48 $this->warning('Possible truncated file - expecting "'.$thisfile_aa['filesize'].'" bytes of data, only found '.($info['avdataend'] - $info['avdataoffset']).' bytes"');
49 }
50
51 $info['audio']['bits_per_sample'] = 16; // is it?
52 $info['audio']['sample_rate'] = $thisfile_aa['sample_rate'];
53 $info['audio']['channels'] = $thisfile_aa['channels'];
54
55 //$info['playtime_seconds'] = 0;
56 //$info['audio']['bitrate'] = 0;
57
58 return true;
59 }
60
61 }