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 16if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 17 exit; 18} 19 20class getid3_bink extends getid3_handler 21{ 22 /** 23 * @return bool 24 */ 25 public function Analyze() { 26 $info = &$this->getid3->info; 27 28 $this->error('Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']'); 29 30 $this->fseek($info['avdataoffset']); 31 $fileTypeID = $this->fread(3); 32 switch ($fileTypeID) { 33 case 'BIK': 34 return $this->ParseBink(); 35 36 case 'SMK': 37 return $this->ParseSmacker(); 38 39 default: 40 $this->error('Expecting "BIK" or "SMK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($fileTypeID).'"'); 41 return false; 42 } 43 } 44 45 /** 46 * @return bool 47 */ 48 public function ParseBink() { 49 $info = &$this->getid3->info; 50 $info['fileformat'] = 'bink'; 51 $info['video']['dataformat'] = 'bink'; 52 53 $fileData = 'BIK'.$this->fread(13); 54 55 $info['bink']['data_size'] = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4)); 56 $info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2)); 57 58 if (($info['avdataend'] - $info['avdataoffset']) != ($info['bink']['data_size'] + 8)) { 59 $this->error('Probably truncated file: expecting '.$info['bink']['data_size'].' bytes, found '.($info['avdataend'] - $info['avdataoffset'])); 60 } 61 62 return true; 63 } 64 65 /** 66 * @return bool 67 */ 68 public function ParseSmacker() { 69 $info = &$this->getid3->info; 70 $info['fileformat'] = 'smacker'; 71 $info['video']['dataformat'] = 'smacker'; 72 73 return true; 74 } 75 76} 77