[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.audio-video.bink.php
1 <?php
2 /////////////////////////////////////////////////////////////////
3 /// getID3() by James Heinrich <info@getid3.org> //
4 // available at https://github.com/JamesHeinrich/getID3 //
5 // or https://www.getid3.org //
6 // or http://getid3.sourceforge.net //
7 // see readme.txt for more details //
8 /////////////////////////////////////////////////////////////////
9 // //
10 // module.audio.bink.php //
11 // module for analyzing Bink or Smacker audio-video files //
12 // dependencies: NONE //
13 // ///
14 /////////////////////////////////////////////////////////////////
15
16
17 class getid3_bink extends getid3_handler
18 {
19 /**
20 * @return bool
21 */
22 public function Analyze() {
23 $info = &$this->getid3->info;
24
25 $this->error('Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']');
26
27 $this->fseek($info['avdataoffset']);
28 $fileTypeID = $this->fread(3);
29 switch ($fileTypeID) {
30 case 'BIK':
31 return $this->ParseBink();
32 break;
33
34 case 'SMK':
35 return $this->ParseSmacker();
36 break;
37
38 default:
39 $this->error('Expecting "BIK" or "SMK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($fileTypeID).'"');
40 return false;
41 break;
42 }
43
44 return true;
45
46 }
47
48 /**
49 * @return bool
50 */
51 public function ParseBink() {
52 $info = &$this->getid3->info;
53 $info['fileformat'] = 'bink';
54 $info['video']['dataformat'] = 'bink';
55
56 $fileData = 'BIK'.$this->fread(13);
57
58 $info['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
59 $info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
60
61 if (($info['avdataend'] - $info['avdataoffset']) != ($info['bink']['data_size'] + 8)) {
62 $this->error('Probably truncated file: expecting '.$info['bink']['data_size'].' bytes, found '.($info['avdataend'] - $info['avdataoffset']));
63 }
64
65 return true;
66 }
67
68 /**
69 * @return bool
70 */
71 public function ParseSmacker() {
72 $info = &$this->getid3->info;
73 $info['fileformat'] = 'smacker';
74 $info['video']['dataformat'] = 'smacker';
75
76 return true;
77 }
78
79 }