1 <?php |
1 <?php |
2 ///////////////////////////////////////////////////////////////// |
2 ///////////////////////////////////////////////////////////////// |
3 /// getID3() by James Heinrich <info@getid3.org> // |
3 /// getID3() by James Heinrich <info@getid3.org> // |
4 // available at http://getid3.sourceforge.net // |
4 // available at http://getid3.sourceforge.net // |
5 // or http://www.getid3.org // |
5 // or http://www.getid3.org // |
|
6 // also https://github.com/JamesHeinrich/getID3 // |
6 ///////////////////////////////////////////////////////////////// |
7 ///////////////////////////////////////////////////////////////// |
7 // See readme.txt for more details // |
8 // See readme.txt for more details // |
8 ///////////////////////////////////////////////////////////////// |
9 ///////////////////////////////////////////////////////////////// |
9 // // |
10 // // |
10 // module.audio-video.asf.php // |
11 // module.audio-video.asf.php // |
64 // Reserved1 BYTE 8 // hardcoded: 0x01 |
64 // Reserved1 BYTE 8 // hardcoded: 0x01 |
65 // Reserved2 BYTE 8 // hardcoded: 0x02 |
65 // Reserved2 BYTE 8 // hardcoded: 0x02 |
66 |
66 |
67 $info['fileformat'] = 'asf'; |
67 $info['fileformat'] = 'asf'; |
68 |
68 |
69 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET); |
69 $this->fseek($info['avdataoffset']); |
70 $HeaderObjectData = fread($this->getid3->fp, 30); |
70 $HeaderObjectData = $this->fread(30); |
71 |
71 |
72 $thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16); |
72 $thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16); |
73 $thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']); |
73 $thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']); |
74 if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) { |
74 if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) { |
75 $info['warning'][] = 'ASF header GUID {'.$this->BytestringToGUID($thisfile_asf_headerobject['objectid']).'} does not match expected "GETID3_ASF_Header_Object" GUID {'.$this->BytestringToGUID(GETID3_ASF_Header_Object).'}'; |
75 unset($info['fileformat'], $info['asf']); |
76 unset($info['fileformat']); |
76 return $this->error('ASF header GUID {'.$this->BytestringToGUID($thisfile_asf_headerobject['objectid']).'} does not match expected "GETID3_ASF_Header_Object" GUID {'.$this->BytestringToGUID(GETID3_ASF_Header_Object).'}'); |
77 unset($info['asf']); |
|
78 return false; |
|
79 break; |
|
80 } |
77 } |
81 $thisfile_asf_headerobject['objectsize'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8)); |
78 $thisfile_asf_headerobject['objectsize'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8)); |
82 $thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4)); |
79 $thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4)); |
83 $thisfile_asf_headerobject['reserved1'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1)); |
80 $thisfile_asf_headerobject['reserved1'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1)); |
84 $thisfile_asf_headerobject['reserved2'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1)); |
81 $thisfile_asf_headerobject['reserved2'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1)); |
85 |
82 |
86 $NextObjectOffset = ftell($this->getid3->fp); |
83 $NextObjectOffset = $this->ftell(); |
87 $ASFHeaderData = fread($this->getid3->fp, $thisfile_asf_headerobject['objectsize'] - 30); |
84 $ASFHeaderData = $this->fread($thisfile_asf_headerobject['objectsize'] - 30); |
88 $offset = 0; |
85 $offset = 0; |
89 |
86 |
90 for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) { |
87 for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) { |
91 $NextObjectGUID = substr($ASFHeaderData, $offset, 16); |
88 $NextObjectGUID = substr($ASFHeaderData, $offset, 16); |
92 $offset += 16; |
89 $offset += 16; |
282 } |
279 } |
283 $thisfile_asf_headerextensionobject['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); |
280 $thisfile_asf_headerextensionobject['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4)); |
284 $offset += 4; |
281 $offset += 4; |
285 $thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']); |
282 $thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']); |
286 $unhandled_sections = 0; |
283 $unhandled_sections = 0; |
287 $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->ASF_HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections); |
284 $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections); |
288 if ($unhandled_sections === 0) { |
285 if ($unhandled_sections === 0) { |
289 unset($thisfile_asf_headerextensionobject['extension_data']); |
286 unset($thisfile_asf_headerextensionobject['extension_data']); |
290 } |
287 } |
291 $offset += $thisfile_asf_headerextensionobject['extension_data_size']; |
288 $offset += $thisfile_asf_headerextensionobject['extension_data_size']; |
292 break; |
289 break; |
330 $thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter] = array(); |
327 $thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter] = array(); |
331 $thisfile_asf_codeclistobject_codecentries_current = &$thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter]; |
328 $thisfile_asf_codeclistobject_codecentries_current = &$thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter]; |
332 |
329 |
333 $thisfile_asf_codeclistobject_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); |
330 $thisfile_asf_codeclistobject_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)); |
334 $offset += 2; |
331 $offset += 2; |
335 $thisfile_asf_codeclistobject_codecentries_current['type'] = $this->ASFCodecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']); |
332 $thisfile_asf_codeclistobject_codecentries_current['type'] = self::codecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']); |
336 |
333 |
337 $CodecNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character |
334 $CodecNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character |
338 $offset += 2; |
335 $offset += 2; |
339 $thisfile_asf_codeclistobject_codecentries_current['name'] = substr($ASFHeaderData, $offset, $CodecNameLength); |
336 $thisfile_asf_codeclistobject_codecentries_current['name'] = substr($ASFHeaderData, $offset, $CodecNameLength); |
340 $offset += $CodecNameLength; |
337 $offset += $CodecNameLength; |
824 $thisfile_video['bitrate_mode'] = 'vbr'; |
821 $thisfile_video['bitrate_mode'] = 'vbr'; |
825 } |
822 } |
826 break; |
823 break; |
827 |
824 |
828 case 'id3': |
825 case 'id3': |
829 // id3v2 module might not be loaded |
826 $this->getid3->include_module('tag.id3v2'); |
830 if (class_exists('getid3_id3v2')) { |
827 |
831 $tempfile = tempnam(GETID3_TEMP_DIR, 'getID3'); |
828 $getid3_id3v2 = new getid3_id3v2($this->getid3); |
832 $tempfilehandle = fopen($tempfile, 'wb'); |
829 $getid3_id3v2->AnalyzeString($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); |
833 $tempThisfileInfo = array('encoding'=>$info['encoding']); |
830 unset($getid3_id3v2); |
834 fwrite($tempfilehandle, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); |
831 |
835 fclose($tempfilehandle); |
832 if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'] > 1024) { |
836 |
833 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = '<value too large to display>'; |
837 $getid3_temp = new getID3(); |
|
838 $getid3_temp->openfile($tempfile); |
|
839 $getid3_id3v2 = new getid3_id3v2($getid3_temp); |
|
840 $getid3_id3v2->Analyze(); |
|
841 $info['id3v2'] = $getid3_temp->info['id3v2']; |
|
842 unset($getid3_temp, $getid3_id3v2); |
|
843 |
|
844 unlink($tempfile); |
|
845 } |
834 } |
846 break; |
835 break; |
847 |
836 |
848 case 'wm/encodingtime': |
837 case 'wm/encodingtime': |
849 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); |
838 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']); |
858 unset($WMpicture); |
847 unset($WMpicture); |
859 /* |
848 /* |
860 $wm_picture_offset = 0; |
849 $wm_picture_offset = 0; |
861 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 1)); |
850 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 1)); |
862 $wm_picture_offset += 1; |
851 $wm_picture_offset += 1; |
863 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type'] = $this->WMpictureTypeLookup($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id']); |
852 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type'] = self::WMpictureTypeLookup($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id']); |
864 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 4)); |
853 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_size'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 4)); |
865 $wm_picture_offset += 4; |
854 $wm_picture_offset += 4; |
866 |
855 |
867 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = ''; |
856 $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = ''; |
868 do { |
857 do { |
1205 // * * Opaque Data Present bits 1 // |
1194 // * * Opaque Data Present bits 1 // |
1206 // * * Error Correction Length Type bits 2 // number of bits for size of the error correction data. hardcoded: 00 |
1195 // * * Error Correction Length Type bits 2 // number of bits for size of the error correction data. hardcoded: 00 |
1207 // * * Error Correction Present bits 1 // If set, use Opaque Data Packet structure, else use Payload structure |
1196 // * * Error Correction Present bits 1 // If set, use Opaque Data Packet structure, else use Payload structure |
1208 // * Error Correction Data |
1197 // * Error Correction Data |
1209 |
1198 |
1210 $info['avdataoffset'] = ftell($this->getid3->fp); |
1199 $info['avdataoffset'] = $this->ftell(); |
1211 fseek($this->getid3->fp, ($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data |
1200 $this->fseek(($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data |
1212 $info['avdataend'] = ftell($this->getid3->fp); |
1201 $info['avdataend'] = $this->ftell(); |
1213 break; |
1202 break; |
1214 |
1203 |
1215 case GETID3_ASF_Simple_Index_Object: |
1204 case GETID3_ASF_Simple_Index_Object: |
1216 // Simple Index Object: (optional, recommended, one per video stream) |
1205 // Simple Index Object: (optional, recommended, one per video stream) |
1217 // Field Name Field Type Size (bits) |
1206 // Field Name Field Type Size (bits) |
1244 $thisfile_asf_simpleindexobject['maximum_packet_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); |
1233 $thisfile_asf_simpleindexobject['maximum_packet_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); |
1245 $offset += 4; |
1234 $offset += 4; |
1246 $thisfile_asf_simpleindexobject['index_entries_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); |
1235 $thisfile_asf_simpleindexobject['index_entries_count'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4)); |
1247 $offset += 4; |
1236 $offset += 4; |
1248 |
1237 |
1249 $IndexEntriesData = $SimpleIndexObjectData.fread($this->getid3->fp, 6 * $thisfile_asf_simpleindexobject['index_entries_count']); |
1238 $IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $thisfile_asf_simpleindexobject['index_entries_count']); |
1250 for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) { |
1239 for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) { |
1251 $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); |
1240 $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); |
1252 $offset += 4; |
1241 $offset += 4; |
1253 $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_count'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); |
1242 $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_count'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4)); |
1254 $offset += 2; |
1243 $offset += 2; |
1295 $thisfile_asf_asfindexobject['index_specifiers_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); |
1284 $thisfile_asf_asfindexobject['index_specifiers_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); |
1296 $offset += 2; |
1285 $offset += 2; |
1297 $thisfile_asf_asfindexobject['index_blocks_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); |
1286 $thisfile_asf_asfindexobject['index_blocks_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); |
1298 $offset += 4; |
1287 $offset += 4; |
1299 |
1288 |
1300 $ASFIndexObjectData .= fread($this->getid3->fp, 4 * $thisfile_asf_asfindexobject['index_specifiers_count']); |
1289 $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count']); |
1301 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { |
1290 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { |
1302 $IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); |
1291 $IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); |
1303 $offset += 2; |
1292 $offset += 2; |
1304 $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number'] = $IndexSpecifierStreamNumber; |
1293 $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number'] = $IndexSpecifierStreamNumber; |
1305 $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); |
1294 $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2)); |
1306 $offset += 2; |
1295 $offset += 2; |
1307 $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = $this->ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']); |
1296 $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = $this->ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']); |
1308 } |
1297 } |
1309 |
1298 |
1310 $ASFIndexObjectData .= fread($this->getid3->fp, 4); |
1299 $ASFIndexObjectData .= $this->fread(4); |
1311 $thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); |
1300 $thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); |
1312 $offset += 4; |
1301 $offset += 4; |
1313 |
1302 |
1314 $ASFIndexObjectData .= fread($this->getid3->fp, 8 * $thisfile_asf_asfindexobject['index_specifiers_count']); |
1303 $ASFIndexObjectData .= $this->fread(8 * $thisfile_asf_asfindexobject['index_specifiers_count']); |
1315 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { |
1304 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { |
1316 $thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8)); |
1305 $thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8)); |
1317 $offset += 8; |
1306 $offset += 8; |
1318 } |
1307 } |
1319 |
1308 |
1320 $ASFIndexObjectData .= fread($this->getid3->fp, 4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']); |
1309 $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']); |
1321 for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) { |
1310 for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) { |
1322 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { |
1311 for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) { |
1323 $thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); |
1312 $thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4)); |
1324 $offset += 4; |
1313 $offset += 4; |
1325 } |
1314 } |
1330 default: |
1319 default: |
1331 // Implementations shall ignore any standard or non-standard object that they do not know how to handle. |
1320 // Implementations shall ignore any standard or non-standard object that they do not know how to handle. |
1332 if ($this->GUIDname($NextObjectGUIDtext)) { |
1321 if ($this->GUIDname($NextObjectGUIDtext)) { |
1333 $info['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF body at offset '.($offset - 16 - 8); |
1322 $info['warning'][] = 'unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF body at offset '.($offset - 16 - 8); |
1334 } else { |
1323 } else { |
1335 $info['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.(ftell($this->getid3->fp) - 16 - 8); |
1324 $info['warning'][] = 'unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.($this->ftell() - 16 - 8); |
1336 } |
1325 } |
1337 fseek($this->getid3->fp, ($NextObjectSize - 16 - 8), SEEK_CUR); |
1326 $this->fseek(($NextObjectSize - 16 - 8), SEEK_CUR); |
1338 break; |
1327 break; |
1339 } |
1328 } |
1340 } |
1329 } |
1341 |
1330 |
1342 if (isset($thisfile_asf_codeclistobject['codec_entries']) && is_array($thisfile_asf_codeclistobject['codec_entries'])) { |
1331 if (isset($thisfile_asf_codeclistobject['codec_entries']) && is_array($thisfile_asf_codeclistobject['codec_entries'])) { |
1431 $thisfile_video['lossless'] = (isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false); |
1420 $thisfile_video['lossless'] = (isset($thisfile_audio['lossless']) ? $thisfile_audio['lossless'] : false); |
1432 $thisfile_video['pixel_aspect_ratio'] = (isset($thisfile_audio['pixel_aspect_ratio']) ? $thisfile_audio['pixel_aspect_ratio'] : (float) 1); |
1421 $thisfile_video['pixel_aspect_ratio'] = (isset($thisfile_audio['pixel_aspect_ratio']) ? $thisfile_audio['pixel_aspect_ratio'] : (float) 1); |
1433 $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf'); |
1422 $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf'); |
1434 } |
1423 } |
1435 if (!empty($thisfile_video['streams'])) { |
1424 if (!empty($thisfile_video['streams'])) { |
1436 $thisfile_video['streams']['resolution_x'] = 0; |
1425 $thisfile_video['resolution_x'] = 0; |
1437 $thisfile_video['streams']['resolution_y'] = 0; |
1426 $thisfile_video['resolution_y'] = 0; |
1438 foreach ($thisfile_video['streams'] as $key => $valuearray) { |
1427 foreach ($thisfile_video['streams'] as $key => $valuearray) { |
1439 if (($valuearray['resolution_x'] > $thisfile_video['streams']['resolution_x']) || ($valuearray['resolution_y'] > $thisfile_video['streams']['resolution_y'])) { |
1428 if (($valuearray['resolution_x'] > $thisfile_video['resolution_x']) || ($valuearray['resolution_y'] > $thisfile_video['resolution_y'])) { |
1440 $thisfile_video['resolution_x'] = $valuearray['resolution_x']; |
1429 $thisfile_video['resolution_x'] = $valuearray['resolution_x']; |
1441 $thisfile_video['resolution_y'] = $valuearray['resolution_y']; |
1430 $thisfile_video['resolution_y'] = $valuearray['resolution_y']; |
1442 } |
1431 } |
1443 } |
1432 } |
1444 } |
1433 } |
1449 } |
1438 } |
1450 |
1439 |
1451 return true; |
1440 return true; |
1452 } |
1441 } |
1453 |
1442 |
1454 public static function ASFCodecListObjectTypeLookup($CodecListType) { |
1443 public static function codecListObjectTypeLookup($CodecListType) { |
1455 static $ASFCodecListObjectTypeLookup = array(); |
1444 static $lookup = array( |
1456 if (empty($ASFCodecListObjectTypeLookup)) { |
1445 0x0001 => 'Video Codec', |
1457 $ASFCodecListObjectTypeLookup[0x0001] = 'Video Codec'; |
1446 0x0002 => 'Audio Codec', |
1458 $ASFCodecListObjectTypeLookup[0x0002] = 'Audio Codec'; |
1447 0xFFFF => 'Unknown Codec' |
1459 $ASFCodecListObjectTypeLookup[0xFFFF] = 'Unknown Codec'; |
1448 ); |
1460 } |
1449 |
1461 |
1450 return (isset($lookup[$CodecListType]) ? $lookup[$CodecListType] : 'Invalid Codec Type'); |
1462 return (isset($ASFCodecListObjectTypeLookup[$CodecListType]) ? $ASFCodecListObjectTypeLookup[$CodecListType] : 'Invalid Codec Type'); |
|
1463 } |
1451 } |
1464 |
1452 |
1465 public static function KnownGUIDs() { |
1453 public static function KnownGUIDs() { |
1466 static $GUIDarray = array( |
1454 static $GUIDarray = array( |
1467 'GETID3_ASF_Extended_Stream_Properties_Object' => '14E6A5CB-C672-4332-8399-A96952065B5A', |
1455 'GETID3_ASF_Extended_Stream_Properties_Object' => '14E6A5CB-C672-4332-8399-A96952065B5A', |
1664 } |
1652 } |
1665 return ($FILETIME - 116444736000000000) / 10000000; |
1653 return ($FILETIME - 116444736000000000) / 10000000; |
1666 } |
1654 } |
1667 |
1655 |
1668 public static function WMpictureTypeLookup($WMpictureType) { |
1656 public static function WMpictureTypeLookup($WMpictureType) { |
1669 static $WMpictureTypeLookup = array(); |
1657 static $lookup = null; |
1670 if (empty($WMpictureTypeLookup)) { |
1658 if ($lookup === null) { |
1671 $WMpictureTypeLookup[0x03] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Front Cover'); |
1659 $lookup = array( |
1672 $WMpictureTypeLookup[0x04] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Back Cover'); |
1660 0x03 => 'Front Cover', |
1673 $WMpictureTypeLookup[0x00] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'User Defined'); |
1661 0x04 => 'Back Cover', |
1674 $WMpictureTypeLookup[0x05] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Leaflet Page'); |
1662 0x00 => 'User Defined', |
1675 $WMpictureTypeLookup[0x06] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Media Label'); |
1663 0x05 => 'Leaflet Page', |
1676 $WMpictureTypeLookup[0x07] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Lead Artist'); |
1664 0x06 => 'Media Label', |
1677 $WMpictureTypeLookup[0x08] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Artist'); |
1665 0x07 => 'Lead Artist', |
1678 $WMpictureTypeLookup[0x09] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Conductor'); |
1666 0x08 => 'Artist', |
1679 $WMpictureTypeLookup[0x0A] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Band'); |
1667 0x09 => 'Conductor', |
1680 $WMpictureTypeLookup[0x0B] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Composer'); |
1668 0x0A => 'Band', |
1681 $WMpictureTypeLookup[0x0C] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Lyricist'); |
1669 0x0B => 'Composer', |
1682 $WMpictureTypeLookup[0x0D] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Recording Location'); |
1670 0x0C => 'Lyricist', |
1683 $WMpictureTypeLookup[0x0E] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'During Recording'); |
1671 0x0D => 'Recording Location', |
1684 $WMpictureTypeLookup[0x0F] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'During Performance'); |
1672 0x0E => 'During Recording', |
1685 $WMpictureTypeLookup[0x10] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Video Screen Capture'); |
1673 0x0F => 'During Performance', |
1686 $WMpictureTypeLookup[0x12] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Illustration'); |
1674 0x10 => 'Video Screen Capture', |
1687 $WMpictureTypeLookup[0x13] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Band Logotype'); |
1675 0x12 => 'Illustration', |
1688 $WMpictureTypeLookup[0x14] = getid3_lib::iconv_fallback('ISO-8859-1', 'UTF-16LE', 'Publisher Logotype'); |
1676 0x13 => 'Band Logotype', |
|
1677 0x14 => 'Publisher Logotype' |
|
1678 ); |
|
1679 $lookup = array_map(function($str) { |
|
1680 return getid3_lib::iconv_fallback('UTF-8', 'UTF-16LE', $str); |
|
1681 }, $lookup); |
1689 } |
1682 } |
1690 return (isset($WMpictureTypeLookup[$WMpictureType]) ? $WMpictureTypeLookup[$WMpictureType] : ''); |
1683 |
|
1684 return (isset($lookup[$WMpictureType]) ? $lookup[$WMpictureType] : ''); |
1691 } |
1685 } |
1692 |
1686 |
1693 public function ASF_HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) { |
1687 public function HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) { |
1694 // http://msdn.microsoft.com/en-us/library/bb643323.aspx |
1688 // http://msdn.microsoft.com/en-us/library/bb643323.aspx |
1695 |
1689 |
1696 $offset = 0; |
1690 $offset = 0; |
1697 $objectOffset = 0; |
1691 $objectOffset = 0; |
1698 $HeaderExtensionObjectParsed = array(); |
1692 $HeaderExtensionObjectParsed = array(); |
1823 $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); |
1817 $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); |
1824 $offset += 2; |
1818 $offset += 2; |
1825 |
1819 |
1826 $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); |
1820 $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); |
1827 $offset += 2; |
1821 $offset += 2; |
1828 $descriptionRecord['data_type_text'] = $this->ASFmetadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']); |
1822 $descriptionRecord['data_type_text'] = self::metadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']); |
1829 |
1823 |
1830 $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); |
1824 $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); |
1831 $offset += 4; |
1825 $offset += 4; |
1832 |
1826 |
1833 $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']); |
1827 $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']); |
1895 $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); |
1889 $descriptionRecord['name_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); |
1896 $offset += 2; |
1890 $offset += 2; |
1897 |
1891 |
1898 $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); |
1892 $descriptionRecord['data_type'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2)); |
1899 $offset += 2; |
1893 $offset += 2; |
1900 $descriptionRecord['data_type_text'] = $this->ASFmetadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']); |
1894 $descriptionRecord['data_type_text'] = self::metadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']); |
1901 |
1895 |
1902 $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); |
1896 $descriptionRecord['data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4)); |
1903 $offset += 4; |
1897 $offset += 4; |
1904 |
1898 |
1905 $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']); |
1899 $descriptionRecord['name'] = substr($asf_header_extension_object_data, $offset, $descriptionRecord['name_length']); |
1935 } |
1929 } |
1936 return $HeaderExtensionObjectParsed; |
1930 return $HeaderExtensionObjectParsed; |
1937 } |
1931 } |
1938 |
1932 |
1939 |
1933 |
1940 public static function ASFmetadataLibraryObjectDataTypeLookup($id) { |
1934 public static function metadataLibraryObjectDataTypeLookup($id) { |
1941 static $ASFmetadataLibraryObjectDataTypeLookup = array( |
1935 static $lookup = array( |
1942 0x0000 => 'Unicode string', // The data consists of a sequence of Unicode characters |
1936 0x0000 => 'Unicode string', // The data consists of a sequence of Unicode characters |
1943 0x0001 => 'BYTE array', // The type of the data is implementation-specific |
1937 0x0001 => 'BYTE array', // The type of the data is implementation-specific |
1944 0x0002 => 'BOOL', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values |
1938 0x0002 => 'BOOL', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values |
1945 0x0003 => 'DWORD', // The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer |
1939 0x0003 => 'DWORD', // The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer |
1946 0x0004 => 'QWORD', // The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer |
1940 0x0004 => 'QWORD', // The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer |
1947 0x0005 => 'WORD', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer |
1941 0x0005 => 'WORD', // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer |
1948 0x0006 => 'GUID', // The data is 16 bytes long and should be interpreted as a 128-bit GUID |
1942 0x0006 => 'GUID', // The data is 16 bytes long and should be interpreted as a 128-bit GUID |
1949 ); |
1943 ); |
1950 return (isset($ASFmetadataLibraryObjectDataTypeLookup[$id]) ? $ASFmetadataLibraryObjectDataTypeLookup[$id] : 'invalid'); |
1944 return (isset($lookup[$id]) ? $lookup[$id] : 'invalid'); |
1951 } |
1945 } |
1952 |
1946 |
1953 public function ASF_WMpicture(&$data) { |
1947 public function ASF_WMpicture(&$data) { |
1954 //typedef struct _WMPicture{ |
1948 //typedef struct _WMPicture{ |
1955 // LPWSTR pwszMIMEType; |
1949 // LPWSTR pwszMIMEType; |