File indexing completed on 2024-12-22 05:33:10

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.bink.php                                       //
0012 // module for analyzing Bink or Smacker audio-video files      //
0013 // dependencies: NONE                                          //
0014 //                                                            ///
0015 /////////////////////////////////////////////////////////////////
0016 
0017 
0018 class getid3_bink extends getid3_handler
0019 {
0020 
0021   public function Analyze() {
0022     $info = &$this->getid3->info;
0023 
0024 $info['error'][] = 'Bink / Smacker files not properly processed by this version of getID3() ['.$this->getid3->version().']';
0025 
0026     $this->fseek($info['avdataoffset']);
0027     $fileTypeID = $this->fread(3);
0028     switch ($fileTypeID) {
0029       case 'BIK':
0030         return $this->ParseBink();
0031         break;
0032 
0033       case 'SMK':
0034         return $this->ParseSmacker();
0035         break;
0036 
0037       default:
0038         $info['error'][] = 'Expecting "BIK" or "SMK" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($fileTypeID).'"';
0039         return false;
0040         break;
0041     }
0042 
0043     return true;
0044 
0045   }
0046 
0047   public function ParseBink() {
0048     $info = &$this->getid3->info;
0049     $info['fileformat']          = 'bink';
0050     $info['video']['dataformat'] = 'bink';
0051 
0052     $fileData = 'BIK'.$this->fread(13);
0053 
0054     $info['bink']['data_size']   = getid3_lib::LittleEndian2Int(substr($fileData, 4, 4));
0055     $info['bink']['frame_count'] = getid3_lib::LittleEndian2Int(substr($fileData, 8, 2));
0056 
0057     if (($info['avdataend'] - $info['avdataoffset']) != ($info['bink']['data_size'] + 8)) {
0058       $info['error'][] = 'Probably truncated file: expecting '.$info['bink']['data_size'].' bytes, found '.($info['avdataend'] - $info['avdataoffset']);
0059     }
0060 
0061     return true;
0062   }
0063 
0064   public function ParseSmacker() {
0065     $info = &$this->getid3->info;
0066     $info['fileformat']          = 'smacker';
0067     $info['video']['dataformat'] = 'smacker';
0068 
0069     return true;
0070   }
0071 
0072 }