Edit File by line
/home/zeestwma/richards.../wp-inclu.../ID3
File: module.audio-video.asf.php
<?php
[0] Fix | Delete
/////////////////////////////////////////////////////////////////
[1] Fix | Delete
/// getID3() by James Heinrich <info@getid3.org> //
[2] Fix | Delete
// available at https://github.com/JamesHeinrich/getID3 //
[3] Fix | Delete
// or https://www.getid3.org //
[4] Fix | Delete
// or http://getid3.sourceforge.net //
[5] Fix | Delete
// see readme.txt for more details //
[6] Fix | Delete
/////////////////////////////////////////////////////////////////
[7] Fix | Delete
// //
[8] Fix | Delete
// module.audio-video.asf.php //
[9] Fix | Delete
// module for analyzing ASF, WMA and WMV files //
[10] Fix | Delete
// dependencies: module.audio-video.riff.php //
[11] Fix | Delete
// ///
[12] Fix | Delete
/////////////////////////////////////////////////////////////////
[13] Fix | Delete
[14] Fix | Delete
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
[15] Fix | Delete
exit;
[16] Fix | Delete
}
[17] Fix | Delete
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
[18] Fix | Delete
[19] Fix | Delete
class getid3_asf extends getid3_handler
[20] Fix | Delete
{
[21] Fix | Delete
protected static $ASFIndexParametersObjectIndexSpecifiersIndexTypes = array(
[22] Fix | Delete
1 => 'Nearest Past Data Packet',
[23] Fix | Delete
2 => 'Nearest Past Media Object',
[24] Fix | Delete
3 => 'Nearest Past Cleanpoint'
[25] Fix | Delete
);
[26] Fix | Delete
[27] Fix | Delete
protected static $ASFMediaObjectIndexParametersObjectIndexSpecifiersIndexTypes = array(
[28] Fix | Delete
1 => 'Nearest Past Data Packet',
[29] Fix | Delete
2 => 'Nearest Past Media Object',
[30] Fix | Delete
3 => 'Nearest Past Cleanpoint',
[31] Fix | Delete
0xFF => 'Frame Number Offset'
[32] Fix | Delete
);
[33] Fix | Delete
[34] Fix | Delete
protected static $ASFTimecodeIndexParametersObjectIndexSpecifiersIndexTypes = array(
[35] Fix | Delete
2 => 'Nearest Past Media Object',
[36] Fix | Delete
3 => 'Nearest Past Cleanpoint'
[37] Fix | Delete
);
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* @param getID3 $getid3
[41] Fix | Delete
*/
[42] Fix | Delete
public function __construct(getID3 $getid3) {
[43] Fix | Delete
parent::__construct($getid3); // extends getid3_handler::__construct()
[44] Fix | Delete
[45] Fix | Delete
// initialize all GUID constants
[46] Fix | Delete
$GUIDarray = $this->KnownGUIDs();
[47] Fix | Delete
foreach ($GUIDarray as $GUIDname => $hexstringvalue) {
[48] Fix | Delete
if (!defined($GUIDname)) {
[49] Fix | Delete
define($GUIDname, $this->GUIDtoBytestring($hexstringvalue));
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* @return bool
[56] Fix | Delete
*/
[57] Fix | Delete
public function Analyze() {
[58] Fix | Delete
$info = &$this->getid3->info;
[59] Fix | Delete
[60] Fix | Delete
// Shortcuts
[61] Fix | Delete
$thisfile_audio = &$info['audio'];
[62] Fix | Delete
$thisfile_video = &$info['video'];
[63] Fix | Delete
$info['asf'] = array();
[64] Fix | Delete
$thisfile_asf = &$info['asf'];
[65] Fix | Delete
$thisfile_asf['comments'] = array();
[66] Fix | Delete
$thisfile_asf_comments = &$thisfile_asf['comments'];
[67] Fix | Delete
$thisfile_asf['header_object'] = array();
[68] Fix | Delete
$thisfile_asf_headerobject = &$thisfile_asf['header_object'];
[69] Fix | Delete
[70] Fix | Delete
[71] Fix | Delete
// ASF structure:
[72] Fix | Delete
// * Header Object [required]
[73] Fix | Delete
// * File Properties Object [required] (global file attributes)
[74] Fix | Delete
// * Stream Properties Object [required] (defines media stream & characteristics)
[75] Fix | Delete
// * Header Extension Object [required] (additional functionality)
[76] Fix | Delete
// * Content Description Object (bibliographic information)
[77] Fix | Delete
// * Script Command Object (commands for during playback)
[78] Fix | Delete
// * Marker Object (named jumped points within the file)
[79] Fix | Delete
// * Data Object [required]
[80] Fix | Delete
// * Data Packets
[81] Fix | Delete
// * Index Object
[82] Fix | Delete
[83] Fix | Delete
// Header Object: (mandatory, one only)
[84] Fix | Delete
// Field Name Field Type Size (bits)
[85] Fix | Delete
// Object ID GUID 128 // GUID for header object - GETID3_ASF_Header_Object
[86] Fix | Delete
// Object Size QWORD 64 // size of header object, including 30 bytes of Header Object header
[87] Fix | Delete
// Number of Header Objects DWORD 32 // number of objects in header object
[88] Fix | Delete
// Reserved1 BYTE 8 // hardcoded: 0x01
[89] Fix | Delete
// Reserved2 BYTE 8 // hardcoded: 0x02
[90] Fix | Delete
[91] Fix | Delete
$info['fileformat'] = 'asf';
[92] Fix | Delete
[93] Fix | Delete
$this->fseek($info['avdataoffset']);
[94] Fix | Delete
$HeaderObjectData = $this->fread(30);
[95] Fix | Delete
[96] Fix | Delete
$thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16);
[97] Fix | Delete
$thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']);
[98] Fix | Delete
if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) {
[99] Fix | Delete
unset($info['fileformat'], $info['asf']);
[100] Fix | Delete
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).'}');
[101] Fix | Delete
}
[102] Fix | Delete
$thisfile_asf_headerobject['objectsize'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8));
[103] Fix | Delete
$thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4));
[104] Fix | Delete
$thisfile_asf_headerobject['reserved1'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1));
[105] Fix | Delete
$thisfile_asf_headerobject['reserved2'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1));
[106] Fix | Delete
[107] Fix | Delete
$NextObjectOffset = $this->ftell();
[108] Fix | Delete
$ASFHeaderData = $this->fread($thisfile_asf_headerobject['objectsize'] - 30);
[109] Fix | Delete
$offset = 0;
[110] Fix | Delete
$thisfile_asf_streambitratepropertiesobject = array();
[111] Fix | Delete
$thisfile_asf_codeclistobject = array();
[112] Fix | Delete
$StreamPropertiesObjectData = array();
[113] Fix | Delete
[114] Fix | Delete
for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) {
[115] Fix | Delete
$NextObjectGUID = substr($ASFHeaderData, $offset, 16);
[116] Fix | Delete
$offset += 16;
[117] Fix | Delete
$NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID);
[118] Fix | Delete
$NextObjectSize = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
[119] Fix | Delete
$offset += 8;
[120] Fix | Delete
switch ($NextObjectGUID) {
[121] Fix | Delete
[122] Fix | Delete
case GETID3_ASF_File_Properties_Object:
[123] Fix | Delete
// File Properties Object: (mandatory, one only)
[124] Fix | Delete
// Field Name Field Type Size (bits)
[125] Fix | Delete
// Object ID GUID 128 // GUID for file properties object - GETID3_ASF_File_Properties_Object
[126] Fix | Delete
// Object Size QWORD 64 // size of file properties object, including 104 bytes of File Properties Object header
[127] Fix | Delete
// File ID GUID 128 // unique ID - identical to File ID in Data Object
[128] Fix | Delete
// File Size QWORD 64 // entire file in bytes. Invalid if Broadcast Flag == 1
[129] Fix | Delete
// Creation Date QWORD 64 // date & time of file creation. Maybe invalid if Broadcast Flag == 1
[130] Fix | Delete
// Data Packets Count QWORD 64 // number of data packets in Data Object. Invalid if Broadcast Flag == 1
[131] Fix | Delete
// Play Duration QWORD 64 // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1
[132] Fix | Delete
// Send Duration QWORD 64 // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1
[133] Fix | Delete
// Preroll QWORD 64 // time to buffer data before starting to play file, in 1-millisecond units. If <> 0, PlayDuration and PresentationTime have been offset by this amount
[134] Fix | Delete
// Flags DWORD 32 //
[135] Fix | Delete
// * Broadcast Flag bits 1 (0x01) // file is currently being written, some header values are invalid
[136] Fix | Delete
// * Seekable Flag bits 1 (0x02) // is file seekable
[137] Fix | Delete
// * Reserved bits 30 (0xFFFFFFFC) // reserved - set to zero
[138] Fix | Delete
// Minimum Data Packet Size DWORD 32 // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1
[139] Fix | Delete
// Maximum Data Packet Size DWORD 32 // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1
[140] Fix | Delete
// Maximum Bitrate DWORD 32 // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead
[141] Fix | Delete
[142] Fix | Delete
// shortcut
[143] Fix | Delete
$thisfile_asf['file_properties_object'] = array();
[144] Fix | Delete
$thisfile_asf_filepropertiesobject = &$thisfile_asf['file_properties_object'];
[145] Fix | Delete
[146] Fix | Delete
$thisfile_asf_filepropertiesobject['offset'] = $NextObjectOffset + $offset;
[147] Fix | Delete
$thisfile_asf_filepropertiesobject['objectid'] = $NextObjectGUID;
[148] Fix | Delete
$thisfile_asf_filepropertiesobject['objectid_guid'] = $NextObjectGUIDtext;
[149] Fix | Delete
$thisfile_asf_filepropertiesobject['objectsize'] = $NextObjectSize;
[150] Fix | Delete
$thisfile_asf_filepropertiesobject['fileid'] = substr($ASFHeaderData, $offset, 16);
[151] Fix | Delete
$offset += 16;
[152] Fix | Delete
$thisfile_asf_filepropertiesobject['fileid_guid'] = $this->BytestringToGUID($thisfile_asf_filepropertiesobject['fileid']);
[153] Fix | Delete
$thisfile_asf_filepropertiesobject['filesize'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
[154] Fix | Delete
$offset += 8;
[155] Fix | Delete
$thisfile_asf_filepropertiesobject['creation_date'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
[156] Fix | Delete
$thisfile_asf_filepropertiesobject['creation_date_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_filepropertiesobject['creation_date']);
[157] Fix | Delete
$offset += 8;
[158] Fix | Delete
$thisfile_asf_filepropertiesobject['data_packets'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
[159] Fix | Delete
$offset += 8;
[160] Fix | Delete
$thisfile_asf_filepropertiesobject['play_duration'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
[161] Fix | Delete
$offset += 8;
[162] Fix | Delete
$thisfile_asf_filepropertiesobject['send_duration'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
[163] Fix | Delete
$offset += 8;
[164] Fix | Delete
$thisfile_asf_filepropertiesobject['preroll'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
[165] Fix | Delete
$offset += 8;
[166] Fix | Delete
$thisfile_asf_filepropertiesobject['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
[167] Fix | Delete
$offset += 4;
[168] Fix | Delete
$thisfile_asf_filepropertiesobject['flags']['broadcast'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0001);
[169] Fix | Delete
$thisfile_asf_filepropertiesobject['flags']['seekable'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0002);
[170] Fix | Delete
[171] Fix | Delete
$thisfile_asf_filepropertiesobject['min_packet_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
[172] Fix | Delete
$offset += 4;
[173] Fix | Delete
$thisfile_asf_filepropertiesobject['max_packet_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
[174] Fix | Delete
$offset += 4;
[175] Fix | Delete
$thisfile_asf_filepropertiesobject['max_bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
[176] Fix | Delete
$offset += 4;
[177] Fix | Delete
[178] Fix | Delete
if ($thisfile_asf_filepropertiesobject['flags']['broadcast']) {
[179] Fix | Delete
[180] Fix | Delete
// broadcast flag is set, some values invalid
[181] Fix | Delete
unset($thisfile_asf_filepropertiesobject['filesize']);
[182] Fix | Delete
unset($thisfile_asf_filepropertiesobject['data_packets']);
[183] Fix | Delete
unset($thisfile_asf_filepropertiesobject['play_duration']);
[184] Fix | Delete
unset($thisfile_asf_filepropertiesobject['send_duration']);
[185] Fix | Delete
unset($thisfile_asf_filepropertiesobject['min_packet_size']);
[186] Fix | Delete
unset($thisfile_asf_filepropertiesobject['max_packet_size']);
[187] Fix | Delete
[188] Fix | Delete
} else {
[189] Fix | Delete
[190] Fix | Delete
// broadcast flag NOT set, perform calculations
[191] Fix | Delete
$info['playtime_seconds'] = ($thisfile_asf_filepropertiesobject['play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject['preroll'] / 1000);
[192] Fix | Delete
[193] Fix | Delete
//$info['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate'];
[194] Fix | Delete
$info['bitrate'] = getid3_lib::SafeDiv($thisfile_asf_filepropertiesobject['filesize'] * 8, $info['playtime_seconds']);
[195] Fix | Delete
}
[196] Fix | Delete
break;
[197] Fix | Delete
[198] Fix | Delete
case GETID3_ASF_Stream_Properties_Object:
[199] Fix | Delete
// Stream Properties Object: (mandatory, one per media stream)
[200] Fix | Delete
// Field Name Field Type Size (bits)
[201] Fix | Delete
// Object ID GUID 128 // GUID for stream properties object - GETID3_ASF_Stream_Properties_Object
[202] Fix | Delete
// Object Size QWORD 64 // size of stream properties object, including 78 bytes of Stream Properties Object header
[203] Fix | Delete
// Stream Type GUID 128 // GETID3_ASF_Audio_Media, GETID3_ASF_Video_Media or GETID3_ASF_Command_Media
[204] Fix | Delete
// Error Correction Type GUID 128 // GETID3_ASF_Audio_Spread for audio-only streams, GETID3_ASF_No_Error_Correction for other stream types
[205] Fix | Delete
// Time Offset QWORD 64 // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream
[206] Fix | Delete
// Type-Specific Data Length DWORD 32 // number of bytes for Type-Specific Data field
[207] Fix | Delete
// Error Correction Data Length DWORD 32 // number of bytes for Error Correction Data field
[208] Fix | Delete
// Flags WORD 16 //
[209] Fix | Delete
// * Stream Number bits 7 (0x007F) // number of this stream. 1 <= valid <= 127
[210] Fix | Delete
// * Reserved bits 8 (0x7F80) // reserved - set to zero
[211] Fix | Delete
// * Encrypted Content Flag bits 1 (0x8000) // stream contents encrypted if set
[212] Fix | Delete
// Reserved DWORD 32 // reserved - set to zero
[213] Fix | Delete
// Type-Specific Data BYTESTREAM variable // type-specific format data, depending on value of Stream Type
[214] Fix | Delete
// Error Correction Data BYTESTREAM variable // error-correction-specific format data, depending on value of Error Correct Type
[215] Fix | Delete
[216] Fix | Delete
// There is one GETID3_ASF_Stream_Properties_Object for each stream (audio, video) but the
[217] Fix | Delete
// stream number isn't known until halfway through decoding the structure, hence it
[218] Fix | Delete
// it is decoded to a temporary variable and then stuck in the appropriate index later
[219] Fix | Delete
[220] Fix | Delete
$StreamPropertiesObjectData['offset'] = $NextObjectOffset + $offset;
[221] Fix | Delete
$StreamPropertiesObjectData['objectid'] = $NextObjectGUID;
[222] Fix | Delete
$StreamPropertiesObjectData['objectid_guid'] = $NextObjectGUIDtext;
[223] Fix | Delete
$StreamPropertiesObjectData['objectsize'] = $NextObjectSize;
[224] Fix | Delete
$StreamPropertiesObjectData['stream_type'] = substr($ASFHeaderData, $offset, 16);
[225] Fix | Delete
$offset += 16;
[226] Fix | Delete
$StreamPropertiesObjectData['stream_type_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['stream_type']);
[227] Fix | Delete
$StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16);
[228] Fix | Delete
$offset += 16;
[229] Fix | Delete
$StreamPropertiesObjectData['error_correct_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['error_correct_type']);
[230] Fix | Delete
$StreamPropertiesObjectData['time_offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
[231] Fix | Delete
$offset += 8;
[232] Fix | Delete
$StreamPropertiesObjectData['type_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
[233] Fix | Delete
$offset += 4;
[234] Fix | Delete
$StreamPropertiesObjectData['error_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
[235] Fix | Delete
$offset += 4;
[236] Fix | Delete
$StreamPropertiesObjectData['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
[237] Fix | Delete
$offset += 2;
[238] Fix | Delete
$StreamPropertiesObjectStreamNumber = $StreamPropertiesObjectData['flags_raw'] & 0x007F;
[239] Fix | Delete
$StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);
[240] Fix | Delete
[241] Fix | Delete
$offset += 4; // reserved - DWORD
[242] Fix | Delete
$StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']);
[243] Fix | Delete
$offset += $StreamPropertiesObjectData['type_data_length'];
[244] Fix | Delete
$StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']);
[245] Fix | Delete
$offset += $StreamPropertiesObjectData['error_data_length'];
[246] Fix | Delete
[247] Fix | Delete
switch ($StreamPropertiesObjectData['stream_type']) {
[248] Fix | Delete
[249] Fix | Delete
case GETID3_ASF_Audio_Media:
[250] Fix | Delete
$thisfile_audio['dataformat'] = (!empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf');
[251] Fix | Delete
$thisfile_audio['bitrate_mode'] = (!empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr');
[252] Fix | Delete
[253] Fix | Delete
$audiodata = getid3_riff::parseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
[254] Fix | Delete
unset($audiodata['raw']);
[255] Fix | Delete
$thisfile_audio = getid3_lib::array_merge_noclobber($audiodata, $thisfile_audio);
[256] Fix | Delete
break;
[257] Fix | Delete
[258] Fix | Delete
case GETID3_ASF_Video_Media:
[259] Fix | Delete
$thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf');
[260] Fix | Delete
$thisfile_video['bitrate_mode'] = (!empty($thisfile_video['bitrate_mode']) ? $thisfile_video['bitrate_mode'] : 'cbr');
[261] Fix | Delete
break;
[262] Fix | Delete
[263] Fix | Delete
case GETID3_ASF_Command_Media:
[264] Fix | Delete
default:
[265] Fix | Delete
// do nothing
[266] Fix | Delete
break;
[267] Fix | Delete
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
$thisfile_asf['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
[271] Fix | Delete
unset($StreamPropertiesObjectData); // clear for next stream, if any
[272] Fix | Delete
break;
[273] Fix | Delete
[274] Fix | Delete
case GETID3_ASF_Header_Extension_Object:
[275] Fix | Delete
// Header Extension Object: (mandatory, one only)
[276] Fix | Delete
// Field Name Field Type Size (bits)
[277] Fix | Delete
// Object ID GUID 128 // GUID for Header Extension object - GETID3_ASF_Header_Extension_Object
[278] Fix | Delete
// Object Size QWORD 64 // size of Header Extension object, including 46 bytes of Header Extension Object header
[279] Fix | Delete
// Reserved Field 1 GUID 128 // hardcoded: GETID3_ASF_Reserved_1
[280] Fix | Delete
// Reserved Field 2 WORD 16 // hardcoded: 0x00000006
[281] Fix | Delete
// Header Extension Data Size DWORD 32 // in bytes. valid: 0, or > 24. equals object size minus 46
[282] Fix | Delete
// Header Extension Data BYTESTREAM variable // array of zero or more extended header objects
[283] Fix | Delete
[284] Fix | Delete
// shortcut
[285] Fix | Delete
$thisfile_asf['header_extension_object'] = array();
[286] Fix | Delete
$thisfile_asf_headerextensionobject = &$thisfile_asf['header_extension_object'];
[287] Fix | Delete
[288] Fix | Delete
$thisfile_asf_headerextensionobject['offset'] = $NextObjectOffset + $offset;
[289] Fix | Delete
$thisfile_asf_headerextensionobject['objectid'] = $NextObjectGUID;
[290] Fix | Delete
$thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext;
[291] Fix | Delete
$thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize;
[292] Fix | Delete
$thisfile_asf_headerextensionobject['reserved_1'] = substr($ASFHeaderData, $offset, 16);
[293] Fix | Delete
$offset += 16;
[294] Fix | Delete
$thisfile_asf_headerextensionobject['reserved_1_guid'] = $this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']);
[295] Fix | Delete
if ($thisfile_asf_headerextensionobject['reserved_1'] != GETID3_ASF_Reserved_1) {
[296] Fix | Delete
$this->warning('header_extension_object.reserved_1 GUID ('.$this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']).') does not match expected "GETID3_ASF_Reserved_1" GUID ('.$this->BytestringToGUID(GETID3_ASF_Reserved_1).')');
[297] Fix | Delete
//return false;
[298] Fix | Delete
break;
[299] Fix | Delete
}
[300] Fix | Delete
$thisfile_asf_headerextensionobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
[301] Fix | Delete
$offset += 2;
[302] Fix | Delete
if ($thisfile_asf_headerextensionobject['reserved_2'] != 6) {
[303] Fix | Delete
$this->warning('header_extension_object.reserved_2 ('.$thisfile_asf_headerextensionobject['reserved_2'].') does not match expected value of "6"');
[304] Fix | Delete
//return false;
[305] Fix | Delete
break;
[306] Fix | Delete
}
[307] Fix | Delete
$thisfile_asf_headerextensionobject['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
[308] Fix | Delete
$offset += 4;
[309] Fix | Delete
$thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']);
[310] Fix | Delete
$unhandled_sections = 0;
[311] Fix | Delete
$thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections);
[312] Fix | Delete
if ($unhandled_sections === 0) {
[313] Fix | Delete
unset($thisfile_asf_headerextensionobject['extension_data']);
[314] Fix | Delete
}
[315] Fix | Delete
$offset += $thisfile_asf_headerextensionobject['extension_data_size'];
[316] Fix | Delete
break;
[317] Fix | Delete
[318] Fix | Delete
case GETID3_ASF_Codec_List_Object:
[319] Fix | Delete
// Codec List Object: (optional, one only)
[320] Fix | Delete
// Field Name Field Type Size (bits)
[321] Fix | Delete
// Object ID GUID 128 // GUID for Codec List object - GETID3_ASF_Codec_List_Object
[322] Fix | Delete
// Object Size QWORD 64 // size of Codec List object, including 44 bytes of Codec List Object header
[323] Fix | Delete
// Reserved GUID 128 // hardcoded: 86D15241-311D-11D0-A3A4-00A0C90348F6
[324] Fix | Delete
// Codec Entries Count DWORD 32 // number of entries in Codec Entries array
[325] Fix | Delete
// Codec Entries array of: variable //
[326] Fix | Delete
// * Type WORD 16 // 0x0001 = Video Codec, 0x0002 = Audio Codec, 0xFFFF = Unknown Codec
[327] Fix | Delete
// * Codec Name Length WORD 16 // number of Unicode characters stored in the Codec Name field
[328] Fix | Delete
// * Codec Name WCHAR variable // array of Unicode characters - name of codec used to create the content
[329] Fix | Delete
// * Codec Description Length WORD 16 // number of Unicode characters stored in the Codec Description field
[330] Fix | Delete
// * Codec Description WCHAR variable // array of Unicode characters - description of format used to create the content
[331] Fix | Delete
// * Codec Information Length WORD 16 // number of Unicode characters stored in the Codec Information field
[332] Fix | Delete
// * Codec Information BYTESTREAM variable // opaque array of information bytes about the codec used to create the content
[333] Fix | Delete
[334] Fix | Delete
// shortcut
[335] Fix | Delete
$thisfile_asf['codec_list_object'] = array();
[336] Fix | Delete
/** @var mixed[] $thisfile_asf_codeclistobject */
[337] Fix | Delete
$thisfile_asf_codeclistobject = &$thisfile_asf['codec_list_object'];
[338] Fix | Delete
[339] Fix | Delete
$thisfile_asf_codeclistobject['offset'] = $NextObjectOffset + $offset;
[340] Fix | Delete
$thisfile_asf_codeclistobject['objectid'] = $NextObjectGUID;
[341] Fix | Delete
$thisfile_asf_codeclistobject['objectid_guid'] = $NextObjectGUIDtext;
[342] Fix | Delete
$thisfile_asf_codeclistobject['objectsize'] = $NextObjectSize;
[343] Fix | Delete
$thisfile_asf_codeclistobject['reserved'] = substr($ASFHeaderData, $offset, 16);
[344] Fix | Delete
$offset += 16;
[345] Fix | Delete
$thisfile_asf_codeclistobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']);
[346] Fix | Delete
if ($thisfile_asf_codeclistobject['reserved'] != $this->GUIDtoBytestring('86D15241-311D-11D0-A3A4-00A0C90348F6')) {
[347] Fix | Delete
$this->warning('codec_list_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}');
[348] Fix | Delete
//return false;
[349] Fix | Delete
break;
[350] Fix | Delete
}
[351] Fix | Delete
$thisfile_asf_codeclistobject['codec_entries_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
[352] Fix | Delete
if ($thisfile_asf_codeclistobject['codec_entries_count'] > 0) {
[353] Fix | Delete
$thisfile_asf_codeclistobject['codec_entries'] = array();
[354] Fix | Delete
}
[355] Fix | Delete
$offset += 4;
[356] Fix | Delete
for ($CodecEntryCounter = 0; $CodecEntryCounter < $thisfile_asf_codeclistobject['codec_entries_count']; $CodecEntryCounter++) {
[357] Fix | Delete
// shortcut
[358] Fix | Delete
$thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter] = array();
[359] Fix | Delete
$thisfile_asf_codeclistobject_codecentries_current = &$thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter];
[360] Fix | Delete
[361] Fix | Delete
$thisfile_asf_codeclistobject_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
[362] Fix | Delete
$offset += 2;
[363] Fix | Delete
$thisfile_asf_codeclistobject_codecentries_current['type'] = self::codecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']);
[364] Fix | Delete
[365] Fix | Delete
$CodecNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
[366] Fix | Delete
$offset += 2;
[367] Fix | Delete
$thisfile_asf_codeclistobject_codecentries_current['name'] = substr($ASFHeaderData, $offset, $CodecNameLength);
[368] Fix | Delete
$offset += $CodecNameLength;
[369] Fix | Delete
[370] Fix | Delete
$CodecDescriptionLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
[371] Fix | Delete
$offset += 2;
[372] Fix | Delete
$thisfile_asf_codeclistobject_codecentries_current['description'] = substr($ASFHeaderData, $offset, $CodecDescriptionLength);
[373] Fix | Delete
$offset += $CodecDescriptionLength;
[374] Fix | Delete
[375] Fix | Delete
$CodecInformationLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
[376] Fix | Delete
$offset += 2;
[377] Fix | Delete
$thisfile_asf_codeclistobject_codecentries_current['information'] = substr($ASFHeaderData, $offset, $CodecInformationLength);
[378] Fix | Delete
$offset += $CodecInformationLength;
[379] Fix | Delete
[380] Fix | Delete
if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) { // audio codec
[381] Fix | Delete
[382] Fix | Delete
if (strpos($thisfile_asf_codeclistobject_codecentries_current['description'], ',') === false) {
[383] Fix | Delete
$this->warning('[asf][codec_list_object][codec_entries]['.$CodecEntryCounter.'][description] expected to contain comma-separated list of parameters: "'.$thisfile_asf_codeclistobject_codecentries_current['description'].'"');
[384] Fix | Delete
} else {
[385] Fix | Delete
[386] Fix | Delete
list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']));
[387] Fix | Delete
$thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
[388] Fix | Delete
[389] Fix | Delete
if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
[390] Fix | Delete
$thisfile_audio['bitrate'] = (int) trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000;
[391] Fix | Delete
}
[392] Fix | Delete
//if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) {
[393] Fix | Delete
if (empty($thisfile_video['bitrate']) && !empty($thisfile_audio['bitrate']) && !empty($info['bitrate'])) {
[394] Fix | Delete
//$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate'];
[395] Fix | Delete
$thisfile_video['bitrate'] = $info['bitrate'] - $thisfile_audio['bitrate'];
[396] Fix | Delete
}
[397] Fix | Delete
[398] Fix | Delete
$AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency));
[399] Fix | Delete
switch ($AudioCodecFrequency) {
[400] Fix | Delete
case 8:
[401] Fix | Delete
case 8000:
[402] Fix | Delete
$thisfile_audio['sample_rate'] = 8000;
[403] Fix | Delete
break;
[404] Fix | Delete
[405] Fix | Delete
case 11:
[406] Fix | Delete
case 11025:
[407] Fix | Delete
$thisfile_audio['sample_rate'] = 11025;
[408] Fix | Delete
break;
[409] Fix | Delete
[410] Fix | Delete
case 12:
[411] Fix | Delete
case 12000:
[412] Fix | Delete
$thisfile_audio['sample_rate'] = 12000;
[413] Fix | Delete
break;
[414] Fix | Delete
[415] Fix | Delete
case 16:
[416] Fix | Delete
case 16000:
[417] Fix | Delete
$thisfile_audio['sample_rate'] = 16000;
[418] Fix | Delete
break;
[419] Fix | Delete
[420] Fix | Delete
case 22:
[421] Fix | Delete
case 22050:
[422] Fix | Delete
$thisfile_audio['sample_rate'] = 22050;
[423] Fix | Delete
break;
[424] Fix | Delete
[425] Fix | Delete
case 24:
[426] Fix | Delete
case 24000:
[427] Fix | Delete
$thisfile_audio['sample_rate'] = 24000;
[428] Fix | Delete
break;
[429] Fix | Delete
[430] Fix | Delete
case 32:
[431] Fix | Delete
case 32000:
[432] Fix | Delete
$thisfile_audio['sample_rate'] = 32000;
[433] Fix | Delete
break;
[434] Fix | Delete
[435] Fix | Delete
case 44:
[436] Fix | Delete
case 441000:
[437] Fix | Delete
$thisfile_audio['sample_rate'] = 44100;
[438] Fix | Delete
break;
[439] Fix | Delete
[440] Fix | Delete
case 48:
[441] Fix | Delete
case 48000:
[442] Fix | Delete
$thisfile_audio['sample_rate'] = 48000;
[443] Fix | Delete
break;
[444] Fix | Delete
[445] Fix | Delete
default:
[446] Fix | Delete
$this->warning('unknown frequency: "'.$AudioCodecFrequency.'" ('.$this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']).')');
[447] Fix | Delete
break;
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
if (!isset($thisfile_audio['channels'])) {
[451] Fix | Delete
if (strstr($AudioCodecChannels, 'stereo')) {
[452] Fix | Delete
$thisfile_audio['channels'] = 2;
[453] Fix | Delete
} elseif (strstr($AudioCodecChannels, 'mono')) {
[454] Fix | Delete
$thisfile_audio['channels'] = 1;
[455] Fix | Delete
}
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
}
[459] Fix | Delete
}
[460] Fix | Delete
}
[461] Fix | Delete
break;
[462] Fix | Delete
[463] Fix | Delete
case GETID3_ASF_Script_Command_Object:
[464] Fix | Delete
// Script Command Object: (optional, one only)
[465] Fix | Delete
// Field Name Field Type Size (bits)
[466] Fix | Delete
// Object ID GUID 128 // GUID for Script Command object - GETID3_ASF_Script_Command_Object
[467] Fix | Delete
// Object Size QWORD 64 // size of Script Command object, including 44 bytes of Script Command Object header
[468] Fix | Delete
// Reserved GUID 128 // hardcoded: 4B1ACBE3-100B-11D0-A39B-00A0C90348F6
[469] Fix | Delete
// Commands Count WORD 16 // number of Commands structures in the Script Commands Objects
[470] Fix | Delete
// Command Types Count WORD 16 // number of Command Types structures in the Script Commands Objects
[471] Fix | Delete
// Command Types array of: variable //
[472] Fix | Delete
// * Command Type Name Length WORD 16 // number of Unicode characters for Command Type Name
[473] Fix | Delete
// * Command Type Name WCHAR variable // array of Unicode characters - name of a type of command
[474] Fix | Delete
// Commands array of: variable //
[475] Fix | Delete
// * Presentation Time DWORD 32 // presentation time of that command, in milliseconds
[476] Fix | Delete
// * Type Index WORD 16 // type of this command, as a zero-based index into the array of Command Types of this object
[477] Fix | Delete
// * Command Name Length WORD 16 // number of Unicode characters for Command Name
[478] Fix | Delete
// * Command Name WCHAR variable // array of Unicode characters - name of this command
[479] Fix | Delete
[480] Fix | Delete
// shortcut
[481] Fix | Delete
$thisfile_asf['script_command_object'] = array();
[482] Fix | Delete
$thisfile_asf_scriptcommandobject = &$thisfile_asf['script_command_object'];
[483] Fix | Delete
[484] Fix | Delete
$thisfile_asf_scriptcommandobject['offset'] = $NextObjectOffset + $offset;
[485] Fix | Delete
$thisfile_asf_scriptcommandobject['objectid'] = $NextObjectGUID;
[486] Fix | Delete
$thisfile_asf_scriptcommandobject['objectid_guid'] = $NextObjectGUIDtext;
[487] Fix | Delete
$thisfile_asf_scriptcommandobject['objectsize'] = $NextObjectSize;
[488] Fix | Delete
$thisfile_asf_scriptcommandobject['reserved'] = substr($ASFHeaderData, $offset, 16);
[489] Fix | Delete
$offset += 16;
[490] Fix | Delete
$thisfile_asf_scriptcommandobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']);
[491] Fix | Delete
if ($thisfile_asf_scriptcommandobject['reserved'] != $this->GUIDtoBytestring('4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) {
[492] Fix | Delete
$this->warning('script_command_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}');
[493] Fix | Delete
//return false;
[494] Fix | Delete
break;
[495] Fix | Delete
}
[496] Fix | Delete
$thisfile_asf_scriptcommandobject['commands_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
[497] Fix | Delete
$offset += 2;
[498] Fix | Delete
$thisfile_asf_scriptcommandobject['command_types_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function