/wp-includes/ID3/module.audio-video.asf.php

https://bitbucket.org/skyarch-iijima/wordpress · PHP · 2013 lines · 1371 code · 274 blank · 368 comment · 132 complexity · 0a250d84a4380f86fa833b65d67d79f3 MD5 · raw file

Large files are truncated click here to view the full file

  1. <?php
  2. /////////////////////////////////////////////////////////////////
  3. /// getID3() by James Heinrich <info@getid3.org> //
  4. // available at http://getid3.sourceforge.net //
  5. // or http://www.getid3.org //
  6. // also https://github.com/JamesHeinrich/getID3 //
  7. /////////////////////////////////////////////////////////////////
  8. // See readme.txt for more details //
  9. /////////////////////////////////////////////////////////////////
  10. // //
  11. // module.audio-video.asf.php //
  12. // module for analyzing ASF, WMA and WMV files //
  13. // dependencies: module.audio-video.riff.php //
  14. // ///
  15. /////////////////////////////////////////////////////////////////
  16. getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
  17. class getid3_asf extends getid3_handler {
  18. public function __construct(getID3 $getid3) {
  19. parent::__construct($getid3); // extends getid3_handler::__construct()
  20. // initialize all GUID constants
  21. $GUIDarray = $this->KnownGUIDs();
  22. foreach ($GUIDarray as $GUIDname => $hexstringvalue) {
  23. if (!defined($GUIDname)) {
  24. define($GUIDname, $this->GUIDtoBytestring($hexstringvalue));
  25. }
  26. }
  27. }
  28. public function Analyze() {
  29. $info = &$this->getid3->info;
  30. // Shortcuts
  31. $thisfile_audio = &$info['audio'];
  32. $thisfile_video = &$info['video'];
  33. $info['asf'] = array();
  34. $thisfile_asf = &$info['asf'];
  35. $thisfile_asf['comments'] = array();
  36. $thisfile_asf_comments = &$thisfile_asf['comments'];
  37. $thisfile_asf['header_object'] = array();
  38. $thisfile_asf_headerobject = &$thisfile_asf['header_object'];
  39. // ASF structure:
  40. // * Header Object [required]
  41. // * File Properties Object [required] (global file attributes)
  42. // * Stream Properties Object [required] (defines media stream & characteristics)
  43. // * Header Extension Object [required] (additional functionality)
  44. // * Content Description Object (bibliographic information)
  45. // * Script Command Object (commands for during playback)
  46. // * Marker Object (named jumped points within the file)
  47. // * Data Object [required]
  48. // * Data Packets
  49. // * Index Object
  50. // Header Object: (mandatory, one only)
  51. // Field Name Field Type Size (bits)
  52. // Object ID GUID 128 // GUID for header object - GETID3_ASF_Header_Object
  53. // Object Size QWORD 64 // size of header object, including 30 bytes of Header Object header
  54. // Number of Header Objects DWORD 32 // number of objects in header object
  55. // Reserved1 BYTE 8 // hardcoded: 0x01
  56. // Reserved2 BYTE 8 // hardcoded: 0x02
  57. $info['fileformat'] = 'asf';
  58. $this->fseek($info['avdataoffset']);
  59. $HeaderObjectData = $this->fread(30);
  60. $thisfile_asf_headerobject['objectid'] = substr($HeaderObjectData, 0, 16);
  61. $thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']);
  62. if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) {
  63. unset($info['fileformat'], $info['asf']);
  64. 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).'}');
  65. }
  66. $thisfile_asf_headerobject['objectsize'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8));
  67. $thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4));
  68. $thisfile_asf_headerobject['reserved1'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1));
  69. $thisfile_asf_headerobject['reserved2'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1));
  70. $NextObjectOffset = $this->ftell();
  71. $ASFHeaderData = $this->fread($thisfile_asf_headerobject['objectsize'] - 30);
  72. $offset = 0;
  73. for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) {
  74. $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
  75. $offset += 16;
  76. $NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID);
  77. $NextObjectSize = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  78. $offset += 8;
  79. switch ($NextObjectGUID) {
  80. case GETID3_ASF_File_Properties_Object:
  81. // File Properties Object: (mandatory, one only)
  82. // Field Name Field Type Size (bits)
  83. // Object ID GUID 128 // GUID for file properties object - GETID3_ASF_File_Properties_Object
  84. // Object Size QWORD 64 // size of file properties object, including 104 bytes of File Properties Object header
  85. // File ID GUID 128 // unique ID - identical to File ID in Data Object
  86. // File Size QWORD 64 // entire file in bytes. Invalid if Broadcast Flag == 1
  87. // Creation Date QWORD 64 // date & time of file creation. Maybe invalid if Broadcast Flag == 1
  88. // Data Packets Count QWORD 64 // number of data packets in Data Object. Invalid if Broadcast Flag == 1
  89. // Play Duration QWORD 64 // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1
  90. // Send Duration QWORD 64 // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1
  91. // 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
  92. // Flags DWORD 32 //
  93. // * Broadcast Flag bits 1 (0x01) // file is currently being written, some header values are invalid
  94. // * Seekable Flag bits 1 (0x02) // is file seekable
  95. // * Reserved bits 30 (0xFFFFFFFC) // reserved - set to zero
  96. // Minimum Data Packet Size DWORD 32 // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1
  97. // Maximum Data Packet Size DWORD 32 // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1
  98. // Maximum Bitrate DWORD 32 // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead
  99. // shortcut
  100. $thisfile_asf['file_properties_object'] = array();
  101. $thisfile_asf_filepropertiesobject = &$thisfile_asf['file_properties_object'];
  102. $thisfile_asf_filepropertiesobject['offset'] = $NextObjectOffset + $offset;
  103. $thisfile_asf_filepropertiesobject['objectid'] = $NextObjectGUID;
  104. $thisfile_asf_filepropertiesobject['objectid_guid'] = $NextObjectGUIDtext;
  105. $thisfile_asf_filepropertiesobject['objectsize'] = $NextObjectSize;
  106. $thisfile_asf_filepropertiesobject['fileid'] = substr($ASFHeaderData, $offset, 16);
  107. $offset += 16;
  108. $thisfile_asf_filepropertiesobject['fileid_guid'] = $this->BytestringToGUID($thisfile_asf_filepropertiesobject['fileid']);
  109. $thisfile_asf_filepropertiesobject['filesize'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  110. $offset += 8;
  111. $thisfile_asf_filepropertiesobject['creation_date'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  112. $thisfile_asf_filepropertiesobject['creation_date_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_filepropertiesobject['creation_date']);
  113. $offset += 8;
  114. $thisfile_asf_filepropertiesobject['data_packets'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  115. $offset += 8;
  116. $thisfile_asf_filepropertiesobject['play_duration'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  117. $offset += 8;
  118. $thisfile_asf_filepropertiesobject['send_duration'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  119. $offset += 8;
  120. $thisfile_asf_filepropertiesobject['preroll'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  121. $offset += 8;
  122. $thisfile_asf_filepropertiesobject['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  123. $offset += 4;
  124. $thisfile_asf_filepropertiesobject['flags']['broadcast'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0001);
  125. $thisfile_asf_filepropertiesobject['flags']['seekable'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0002);
  126. $thisfile_asf_filepropertiesobject['min_packet_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  127. $offset += 4;
  128. $thisfile_asf_filepropertiesobject['max_packet_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  129. $offset += 4;
  130. $thisfile_asf_filepropertiesobject['max_bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  131. $offset += 4;
  132. if ($thisfile_asf_filepropertiesobject['flags']['broadcast']) {
  133. // broadcast flag is set, some values invalid
  134. unset($thisfile_asf_filepropertiesobject['filesize']);
  135. unset($thisfile_asf_filepropertiesobject['data_packets']);
  136. unset($thisfile_asf_filepropertiesobject['play_duration']);
  137. unset($thisfile_asf_filepropertiesobject['send_duration']);
  138. unset($thisfile_asf_filepropertiesobject['min_packet_size']);
  139. unset($thisfile_asf_filepropertiesobject['max_packet_size']);
  140. } else {
  141. // broadcast flag NOT set, perform calculations
  142. $info['playtime_seconds'] = ($thisfile_asf_filepropertiesobject['play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject['preroll'] / 1000);
  143. //$info['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate'];
  144. $info['bitrate'] = ((isset($thisfile_asf_filepropertiesobject['filesize']) ? $thisfile_asf_filepropertiesobject['filesize'] : $info['filesize']) * 8) / $info['playtime_seconds'];
  145. }
  146. break;
  147. case GETID3_ASF_Stream_Properties_Object:
  148. // Stream Properties Object: (mandatory, one per media stream)
  149. // Field Name Field Type Size (bits)
  150. // Object ID GUID 128 // GUID for stream properties object - GETID3_ASF_Stream_Properties_Object
  151. // Object Size QWORD 64 // size of stream properties object, including 78 bytes of Stream Properties Object header
  152. // Stream Type GUID 128 // GETID3_ASF_Audio_Media, GETID3_ASF_Video_Media or GETID3_ASF_Command_Media
  153. // Error Correction Type GUID 128 // GETID3_ASF_Audio_Spread for audio-only streams, GETID3_ASF_No_Error_Correction for other stream types
  154. // Time Offset QWORD 64 // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream
  155. // Type-Specific Data Length DWORD 32 // number of bytes for Type-Specific Data field
  156. // Error Correction Data Length DWORD 32 // number of bytes for Error Correction Data field
  157. // Flags WORD 16 //
  158. // * Stream Number bits 7 (0x007F) // number of this stream. 1 <= valid <= 127
  159. // * Reserved bits 8 (0x7F80) // reserved - set to zero
  160. // * Encrypted Content Flag bits 1 (0x8000) // stream contents encrypted if set
  161. // Reserved DWORD 32 // reserved - set to zero
  162. // Type-Specific Data BYTESTREAM variable // type-specific format data, depending on value of Stream Type
  163. // Error Correction Data BYTESTREAM variable // error-correction-specific format data, depending on value of Error Correct Type
  164. // There is one GETID3_ASF_Stream_Properties_Object for each stream (audio, video) but the
  165. // stream number isn't known until halfway through decoding the structure, hence it
  166. // it is decoded to a temporary variable and then stuck in the appropriate index later
  167. $StreamPropertiesObjectData['offset'] = $NextObjectOffset + $offset;
  168. $StreamPropertiesObjectData['objectid'] = $NextObjectGUID;
  169. $StreamPropertiesObjectData['objectid_guid'] = $NextObjectGUIDtext;
  170. $StreamPropertiesObjectData['objectsize'] = $NextObjectSize;
  171. $StreamPropertiesObjectData['stream_type'] = substr($ASFHeaderData, $offset, 16);
  172. $offset += 16;
  173. $StreamPropertiesObjectData['stream_type_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['stream_type']);
  174. $StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16);
  175. $offset += 16;
  176. $StreamPropertiesObjectData['error_correct_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['error_correct_type']);
  177. $StreamPropertiesObjectData['time_offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  178. $offset += 8;
  179. $StreamPropertiesObjectData['type_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  180. $offset += 4;
  181. $StreamPropertiesObjectData['error_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  182. $offset += 4;
  183. $StreamPropertiesObjectData['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  184. $offset += 2;
  185. $StreamPropertiesObjectStreamNumber = $StreamPropertiesObjectData['flags_raw'] & 0x007F;
  186. $StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);
  187. $offset += 4; // reserved - DWORD
  188. $StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']);
  189. $offset += $StreamPropertiesObjectData['type_data_length'];
  190. $StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']);
  191. $offset += $StreamPropertiesObjectData['error_data_length'];
  192. switch ($StreamPropertiesObjectData['stream_type']) {
  193. case GETID3_ASF_Audio_Media:
  194. $thisfile_audio['dataformat'] = (!empty($thisfile_audio['dataformat']) ? $thisfile_audio['dataformat'] : 'asf');
  195. $thisfile_audio['bitrate_mode'] = (!empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr');
  196. $audiodata = getid3_riff::parseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
  197. unset($audiodata['raw']);
  198. $thisfile_audio = getid3_lib::array_merge_noclobber($audiodata, $thisfile_audio);
  199. break;
  200. case GETID3_ASF_Video_Media:
  201. $thisfile_video['dataformat'] = (!empty($thisfile_video['dataformat']) ? $thisfile_video['dataformat'] : 'asf');
  202. $thisfile_video['bitrate_mode'] = (!empty($thisfile_video['bitrate_mode']) ? $thisfile_video['bitrate_mode'] : 'cbr');
  203. break;
  204. case GETID3_ASF_Command_Media:
  205. default:
  206. // do nothing
  207. break;
  208. }
  209. $thisfile_asf['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
  210. unset($StreamPropertiesObjectData); // clear for next stream, if any
  211. break;
  212. case GETID3_ASF_Header_Extension_Object:
  213. // Header Extension Object: (mandatory, one only)
  214. // Field Name Field Type Size (bits)
  215. // Object ID GUID 128 // GUID for Header Extension object - GETID3_ASF_Header_Extension_Object
  216. // Object Size QWORD 64 // size of Header Extension object, including 46 bytes of Header Extension Object header
  217. // Reserved Field 1 GUID 128 // hardcoded: GETID3_ASF_Reserved_1
  218. // Reserved Field 2 WORD 16 // hardcoded: 0x00000006
  219. // Header Extension Data Size DWORD 32 // in bytes. valid: 0, or > 24. equals object size minus 46
  220. // Header Extension Data BYTESTREAM variable // array of zero or more extended header objects
  221. // shortcut
  222. $thisfile_asf['header_extension_object'] = array();
  223. $thisfile_asf_headerextensionobject = &$thisfile_asf['header_extension_object'];
  224. $thisfile_asf_headerextensionobject['offset'] = $NextObjectOffset + $offset;
  225. $thisfile_asf_headerextensionobject['objectid'] = $NextObjectGUID;
  226. $thisfile_asf_headerextensionobject['objectid_guid'] = $NextObjectGUIDtext;
  227. $thisfile_asf_headerextensionobject['objectsize'] = $NextObjectSize;
  228. $thisfile_asf_headerextensionobject['reserved_1'] = substr($ASFHeaderData, $offset, 16);
  229. $offset += 16;
  230. $thisfile_asf_headerextensionobject['reserved_1_guid'] = $this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']);
  231. if ($thisfile_asf_headerextensionobject['reserved_1'] != GETID3_ASF_Reserved_1) {
  232. $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).')');
  233. //return false;
  234. break;
  235. }
  236. $thisfile_asf_headerextensionobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  237. $offset += 2;
  238. if ($thisfile_asf_headerextensionobject['reserved_2'] != 6) {
  239. $this->warning('header_extension_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_headerextensionobject['reserved_2']).') does not match expected value of "6"');
  240. //return false;
  241. break;
  242. }
  243. $thisfile_asf_headerextensionobject['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  244. $offset += 4;
  245. $thisfile_asf_headerextensionobject['extension_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']);
  246. $unhandled_sections = 0;
  247. $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections);
  248. if ($unhandled_sections === 0) {
  249. unset($thisfile_asf_headerextensionobject['extension_data']);
  250. }
  251. $offset += $thisfile_asf_headerextensionobject['extension_data_size'];
  252. break;
  253. case GETID3_ASF_Codec_List_Object:
  254. // Codec List Object: (optional, one only)
  255. // Field Name Field Type Size (bits)
  256. // Object ID GUID 128 // GUID for Codec List object - GETID3_ASF_Codec_List_Object
  257. // Object Size QWORD 64 // size of Codec List object, including 44 bytes of Codec List Object header
  258. // Reserved GUID 128 // hardcoded: 86D15241-311D-11D0-A3A4-00A0C90348F6
  259. // Codec Entries Count DWORD 32 // number of entries in Codec Entries array
  260. // Codec Entries array of: variable //
  261. // * Type WORD 16 // 0x0001 = Video Codec, 0x0002 = Audio Codec, 0xFFFF = Unknown Codec
  262. // * Codec Name Length WORD 16 // number of Unicode characters stored in the Codec Name field
  263. // * Codec Name WCHAR variable // array of Unicode characters - name of codec used to create the content
  264. // * Codec Description Length WORD 16 // number of Unicode characters stored in the Codec Description field
  265. // * Codec Description WCHAR variable // array of Unicode characters - description of format used to create the content
  266. // * Codec Information Length WORD 16 // number of Unicode characters stored in the Codec Information field
  267. // * Codec Information BYTESTREAM variable // opaque array of information bytes about the codec used to create the content
  268. // shortcut
  269. $thisfile_asf['codec_list_object'] = array();
  270. $thisfile_asf_codeclistobject = &$thisfile_asf['codec_list_object'];
  271. $thisfile_asf_codeclistobject['offset'] = $NextObjectOffset + $offset;
  272. $thisfile_asf_codeclistobject['objectid'] = $NextObjectGUID;
  273. $thisfile_asf_codeclistobject['objectid_guid'] = $NextObjectGUIDtext;
  274. $thisfile_asf_codeclistobject['objectsize'] = $NextObjectSize;
  275. $thisfile_asf_codeclistobject['reserved'] = substr($ASFHeaderData, $offset, 16);
  276. $offset += 16;
  277. $thisfile_asf_codeclistobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']);
  278. if ($thisfile_asf_codeclistobject['reserved'] != $this->GUIDtoBytestring('86D15241-311D-11D0-A3A4-00A0C90348F6')) {
  279. $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}');
  280. //return false;
  281. break;
  282. }
  283. $thisfile_asf_codeclistobject['codec_entries_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  284. $offset += 4;
  285. for ($CodecEntryCounter = 0; $CodecEntryCounter < $thisfile_asf_codeclistobject['codec_entries_count']; $CodecEntryCounter++) {
  286. // shortcut
  287. $thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter] = array();
  288. $thisfile_asf_codeclistobject_codecentries_current = &$thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter];
  289. $thisfile_asf_codeclistobject_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  290. $offset += 2;
  291. $thisfile_asf_codeclistobject_codecentries_current['type'] = self::codecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']);
  292. $CodecNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
  293. $offset += 2;
  294. $thisfile_asf_codeclistobject_codecentries_current['name'] = substr($ASFHeaderData, $offset, $CodecNameLength);
  295. $offset += $CodecNameLength;
  296. $CodecDescriptionLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
  297. $offset += 2;
  298. $thisfile_asf_codeclistobject_codecentries_current['description'] = substr($ASFHeaderData, $offset, $CodecDescriptionLength);
  299. $offset += $CodecDescriptionLength;
  300. $CodecInformationLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  301. $offset += 2;
  302. $thisfile_asf_codeclistobject_codecentries_current['information'] = substr($ASFHeaderData, $offset, $CodecInformationLength);
  303. $offset += $CodecInformationLength;
  304. if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) { // audio codec
  305. if (strpos($thisfile_asf_codeclistobject_codecentries_current['description'], ',') === false) {
  306. $this->warning('[asf][codec_list_object][codec_entries]['.$CodecEntryCounter.'][description] expected to contain comma-separated list of parameters: "'.$thisfile_asf_codeclistobject_codecentries_current['description'].'"');
  307. } else {
  308. list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']));
  309. $thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
  310. if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
  311. $thisfile_audio['bitrate'] = (int) (trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000);
  312. }
  313. //if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) {
  314. if (empty($thisfile_video['bitrate']) && !empty($thisfile_audio['bitrate']) && !empty($info['bitrate'])) {
  315. //$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate'];
  316. $thisfile_video['bitrate'] = $info['bitrate'] - $thisfile_audio['bitrate'];
  317. }
  318. $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency));
  319. switch ($AudioCodecFrequency) {
  320. case 8:
  321. case 8000:
  322. $thisfile_audio['sample_rate'] = 8000;
  323. break;
  324. case 11:
  325. case 11025:
  326. $thisfile_audio['sample_rate'] = 11025;
  327. break;
  328. case 12:
  329. case 12000:
  330. $thisfile_audio['sample_rate'] = 12000;
  331. break;
  332. case 16:
  333. case 16000:
  334. $thisfile_audio['sample_rate'] = 16000;
  335. break;
  336. case 22:
  337. case 22050:
  338. $thisfile_audio['sample_rate'] = 22050;
  339. break;
  340. case 24:
  341. case 24000:
  342. $thisfile_audio['sample_rate'] = 24000;
  343. break;
  344. case 32:
  345. case 32000:
  346. $thisfile_audio['sample_rate'] = 32000;
  347. break;
  348. case 44:
  349. case 441000:
  350. $thisfile_audio['sample_rate'] = 44100;
  351. break;
  352. case 48:
  353. case 48000:
  354. $thisfile_audio['sample_rate'] = 48000;
  355. break;
  356. default:
  357. $this->warning('unknown frequency: "'.$AudioCodecFrequency.'" ('.$this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']).')');
  358. break;
  359. }
  360. if (!isset($thisfile_audio['channels'])) {
  361. if (strstr($AudioCodecChannels, 'stereo')) {
  362. $thisfile_audio['channels'] = 2;
  363. } elseif (strstr($AudioCodecChannels, 'mono')) {
  364. $thisfile_audio['channels'] = 1;
  365. }
  366. }
  367. }
  368. }
  369. }
  370. break;
  371. case GETID3_ASF_Script_Command_Object:
  372. // Script Command Object: (optional, one only)
  373. // Field Name Field Type Size (bits)
  374. // Object ID GUID 128 // GUID for Script Command object - GETID3_ASF_Script_Command_Object
  375. // Object Size QWORD 64 // size of Script Command object, including 44 bytes of Script Command Object header
  376. // Reserved GUID 128 // hardcoded: 4B1ACBE3-100B-11D0-A39B-00A0C90348F6
  377. // Commands Count WORD 16 // number of Commands structures in the Script Commands Objects
  378. // Command Types Count WORD 16 // number of Command Types structures in the Script Commands Objects
  379. // Command Types array of: variable //
  380. // * Command Type Name Length WORD 16 // number of Unicode characters for Command Type Name
  381. // * Command Type Name WCHAR variable // array of Unicode characters - name of a type of command
  382. // Commands array of: variable //
  383. // * Presentation Time DWORD 32 // presentation time of that command, in milliseconds
  384. // * Type Index WORD 16 // type of this command, as a zero-based index into the array of Command Types of this object
  385. // * Command Name Length WORD 16 // number of Unicode characters for Command Name
  386. // * Command Name WCHAR variable // array of Unicode characters - name of this command
  387. // shortcut
  388. $thisfile_asf['script_command_object'] = array();
  389. $thisfile_asf_scriptcommandobject = &$thisfile_asf['script_command_object'];
  390. $thisfile_asf_scriptcommandobject['offset'] = $NextObjectOffset + $offset;
  391. $thisfile_asf_scriptcommandobject['objectid'] = $NextObjectGUID;
  392. $thisfile_asf_scriptcommandobject['objectid_guid'] = $NextObjectGUIDtext;
  393. $thisfile_asf_scriptcommandobject['objectsize'] = $NextObjectSize;
  394. $thisfile_asf_scriptcommandobject['reserved'] = substr($ASFHeaderData, $offset, 16);
  395. $offset += 16;
  396. $thisfile_asf_scriptcommandobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']);
  397. if ($thisfile_asf_scriptcommandobject['reserved'] != $this->GUIDtoBytestring('4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) {
  398. $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}');
  399. //return false;
  400. break;
  401. }
  402. $thisfile_asf_scriptcommandobject['commands_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  403. $offset += 2;
  404. $thisfile_asf_scriptcommandobject['command_types_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  405. $offset += 2;
  406. for ($CommandTypesCounter = 0; $CommandTypesCounter < $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) {
  407. $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
  408. $offset += 2;
  409. $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
  410. $offset += $CommandTypeNameLength;
  411. }
  412. for ($CommandsCounter = 0; $CommandsCounter < $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
  413. $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  414. $offset += 4;
  415. $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['type_index'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  416. $offset += 2;
  417. $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
  418. $offset += 2;
  419. $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
  420. $offset += $CommandTypeNameLength;
  421. }
  422. break;
  423. case GETID3_ASF_Marker_Object:
  424. // Marker Object: (optional, one only)
  425. // Field Name Field Type Size (bits)
  426. // Object ID GUID 128 // GUID for Marker object - GETID3_ASF_Marker_Object
  427. // Object Size QWORD 64 // size of Marker object, including 48 bytes of Marker Object header
  428. // Reserved GUID 128 // hardcoded: 4CFEDB20-75F6-11CF-9C0F-00A0C90349CB
  429. // Markers Count DWORD 32 // number of Marker structures in Marker Object
  430. // Reserved WORD 16 // hardcoded: 0x0000
  431. // Name Length WORD 16 // number of bytes in the Name field
  432. // Name WCHAR variable // name of the Marker Object
  433. // Markers array of: variable //
  434. // * Offset QWORD 64 // byte offset into Data Object
  435. // * Presentation Time QWORD 64 // in 100-nanosecond units
  436. // * Entry Length WORD 16 // length in bytes of (Send Time + Flags + Marker Description Length + Marker Description + Padding)
  437. // * Send Time DWORD 32 // in milliseconds
  438. // * Flags DWORD 32 // hardcoded: 0x00000000
  439. // * Marker Description Length DWORD 32 // number of bytes in Marker Description field
  440. // * Marker Description WCHAR variable // array of Unicode characters - description of marker entry
  441. // * Padding BYTESTREAM variable // optional padding bytes
  442. // shortcut
  443. $thisfile_asf['marker_object'] = array();
  444. $thisfile_asf_markerobject = &$thisfile_asf['marker_object'];
  445. $thisfile_asf_markerobject['offset'] = $NextObjectOffset + $offset;
  446. $thisfile_asf_markerobject['objectid'] = $NextObjectGUID;
  447. $thisfile_asf_markerobject['objectid_guid'] = $NextObjectGUIDtext;
  448. $thisfile_asf_markerobject['objectsize'] = $NextObjectSize;
  449. $thisfile_asf_markerobject['reserved'] = substr($ASFHeaderData, $offset, 16);
  450. $offset += 16;
  451. $thisfile_asf_markerobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_markerobject['reserved']);
  452. if ($thisfile_asf_markerobject['reserved'] != $this->GUIDtoBytestring('4CFEDB20-75F6-11CF-9C0F-00A0C90349CB')) {
  453. $this->warning('marker_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_markerobject['reserved_1']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}');
  454. break;
  455. }
  456. $thisfile_asf_markerobject['markers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  457. $offset += 4;
  458. $thisfile_asf_markerobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  459. $offset += 2;
  460. if ($thisfile_asf_markerobject['reserved_2'] != 0) {
  461. $this->warning('marker_object.reserved_2 ('.getid3_lib::PrintHexBytes($thisfile_asf_markerobject['reserved_2']).') does not match expected value of "0"');
  462. break;
  463. }
  464. $thisfile_asf_markerobject['name_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  465. $offset += 2;
  466. $thisfile_asf_markerobject['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['name_length']);
  467. $offset += $thisfile_asf_markerobject['name_length'];
  468. for ($MarkersCounter = 0; $MarkersCounter < $thisfile_asf_markerobject['markers_count']; $MarkersCounter++) {
  469. $thisfile_asf_markerobject['markers'][$MarkersCounter]['offset'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  470. $offset += 8;
  471. $thisfile_asf_markerobject['markers'][$MarkersCounter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
  472. $offset += 8;
  473. $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  474. $offset += 2;
  475. $thisfile_asf_markerobject['markers'][$MarkersCounter]['send_time'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  476. $offset += 4;
  477. $thisfile_asf_markerobject['markers'][$MarkersCounter]['flags'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  478. $offset += 4;
  479. $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  480. $offset += 4;
  481. $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length']);
  482. $offset += $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'];
  483. $PaddingLength = $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] - 4 - 4 - 4 - $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'];
  484. if ($PaddingLength > 0) {
  485. $thisfile_asf_markerobject['markers'][$MarkersCounter]['padding'] = substr($ASFHeaderData, $offset, $PaddingLength);
  486. $offset += $PaddingLength;
  487. }
  488. }
  489. break;
  490. case GETID3_ASF_Bitrate_Mutual_Exclusion_Object:
  491. // Bitrate Mutual Exclusion Object: (optional)
  492. // Field Name Field Type Size (bits)
  493. // Object ID GUID 128 // GUID for Bitrate Mutual Exclusion object - GETID3_ASF_Bitrate_Mutual_Exclusion_Object
  494. // Object Size QWORD 64 // size of Bitrate Mutual Exclusion object, including 42 bytes of Bitrate Mutual Exclusion Object header
  495. // Exlusion Type GUID 128 // nature of mutual exclusion relationship. one of: (GETID3_ASF_Mutex_Bitrate, GETID3_ASF_Mutex_Unknown)
  496. // Stream Numbers Count WORD 16 // number of video streams
  497. // Stream Numbers WORD variable // array of mutually exclusive video stream numbers. 1 <= valid <= 127
  498. // shortcut
  499. $thisfile_asf['bitrate_mutual_exclusion_object'] = array();
  500. $thisfile_asf_bitratemutualexclusionobject = &$thisfile_asf['bitrate_mutual_exclusion_object'];
  501. $thisfile_asf_bitratemutualexclusionobject['offset'] = $NextObjectOffset + $offset;
  502. $thisfile_asf_bitratemutualexclusionobject['objectid'] = $NextObjectGUID;
  503. $thisfile_asf_bitratemutualexclusionobject['objectid_guid'] = $NextObjectGUIDtext;
  504. $thisfile_asf_bitratemutualexclusionobject['objectsize'] = $NextObjectSize;
  505. $thisfile_asf_bitratemutualexclusionobject['reserved'] = substr($ASFHeaderData, $offset, 16);
  506. $thisfile_asf_bitratemutualexclusionobject['reserved_guid'] = $this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']);
  507. $offset += 16;
  508. if (($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Bitrate) && ($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Unknown)) {
  509. $this->warning('bitrate_mutual_exclusion_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']).'} does not match expected "GETID3_ASF_Mutex_Bitrate" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Bitrate).'} or "GETID3_ASF_Mutex_Unknown" GUID {'.$this->BytestringToGUID(GETID3_ASF_Mutex_Unknown).'}');
  510. //return false;
  511. break;
  512. }
  513. $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  514. $offset += 2;
  515. for ($StreamNumberCounter = 0; $StreamNumberCounter < $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) {
  516. $thisfile_asf_bitratemutualexclusionobject['stream_numbers'][$StreamNumberCounter] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  517. $offset += 2;
  518. }
  519. break;
  520. case GETID3_ASF_Error_Correction_Object:
  521. // Error Correction Object: (optional, one only)
  522. // Field Name Field Type Size (bits)
  523. // Object ID GUID 128 // GUID for Error Correction object - GETID3_ASF_Error_Correction_Object
  524. // Object Size QWORD 64 // size of Error Correction object, including 44 bytes of Error Correction Object header
  525. // Error Correction Type GUID 128 // type of error correction. one of: (GETID3_ASF_No_Error_Correction, GETID3_ASF_Audio_Spread)
  526. // Error Correction Data Length DWORD 32 // number of bytes in Error Correction Data field
  527. // Error Correction Data BYTESTREAM variable // structure depends on value of Error Correction Type field
  528. // shortcut
  529. $thisfile_asf['error_correction_object'] = array();
  530. $thisfile_asf_errorcorrectionobject = &$thisfile_asf['error_correction_object'];
  531. $thisfile_asf_errorcorrectionobject['offset'] = $NextObjectOffset + $offset;
  532. $thisfile_asf_errorcorrectionobject['objectid'] = $NextObjectGUID;
  533. $thisfile_asf_errorcorrectionobject['objectid_guid'] = $NextObjectGUIDtext;
  534. $thisfile_asf_errorcorrectionobject['objectsize'] = $NextObjectSize;
  535. $thisfile_asf_errorcorrectionobject['error_correction_type'] = substr($ASFHeaderData, $offset, 16);
  536. $offset += 16;
  537. $thisfile_asf_errorcorrectionobject['error_correction_guid'] = $this->BytestringToGUID($thisfile_asf_errorcorrectionobject['error_correction_type']);
  538. $thisfile_asf_errorcorrectionobject['error_correction_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
  539. $offset += 4;
  540. switch ($thisfile_asf_errorcorrectionobject['error_correction_type']) {
  541. case GETID3_ASF_No_Error_Correction:
  542. // should be no data, but just in case there is, skip to the end of the field
  543. $offset += $thisfile_asf_errorcorrectionobject['error_correction_data_length'];
  544. break;
  545. case GETID3_ASF_Audio_Spread:
  546. // Field Name Field Type Size (bits)
  547. // Span BYTE 8 // number of packets over which audio will be spread.
  548. // Virtual Packet Length WORD 16 // size of largest audio payload found in audio stream
  549. // Virtual Chunk Length WORD 16 // size of largest audio payload found in audio stream
  550. // Silence Data Length WORD 16 // number of bytes in Silence Data field
  551. // Silence Data BYTESTREAM variable // hardcoded: 0x00 * (Silence Data Length) bytes
  552. $thisfile_asf_errorcorrectionobject['span'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 1));
  553. $offset += 1;
  554. $thisfile_asf_errorcorrectionobject['virtual_packet_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  555. $offset += 2;
  556. $thisfile_asf_errorcorrectionobject['virtual_chunk_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  557. $offset += 2;
  558. $thisfile_asf_errorcorrectionobject['silence_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  559. $offset += 2;
  560. $thisfile_asf_errorcorrectionobject['silence_data'] = substr($ASFHeaderData, $offset, $thisfile_asf_errorcorrectionobject['silence_data_length']);
  561. $offset += $thisfile_asf_errorcorrectionobject['silence_data_length'];
  562. break;
  563. default:
  564. $this->warning('error_correction_object.error_correction_type GUID {'.$this->BytestringToGUID($thisfile_asf_errorcorrectionobject['reserved']).'} does not match expected "GETID3_ASF_No_Error_Correction" GUID {'.$this->BytestringToGUID(GETID3_ASF_No_Error_Correction).'} or "GETID3_ASF_Audio_Spread" GUID {'.$this->BytestringToGUID(GETID3_ASF_Audio_Spread).'}');
  565. //return false;
  566. break;
  567. }
  568. break;
  569. case GETID3_ASF_Content_Description_Object:
  570. // Content Description Object: (optional, one only)
  571. // Field Name Field Type Size (bits)
  572. // Object ID GUID 128 // GUID for Content Description object - GETID3_ASF_Content_Description_Object
  573. // Object Size QWORD 64 // size of Content Description object, including 34 bytes of Content Description Object header
  574. // Title Length WORD 16 // number of bytes in Title field
  575. // Author Length WORD 16 // number of bytes in Author field
  576. // Copyright Length WORD 16 // number of bytes in Copyright field
  577. // Description Length WORD 16 // number of bytes in Description field
  578. // Rating Length WORD 16 // number of bytes in Rating field
  579. // Title WCHAR 16 // array of Unicode characters - Title
  580. // Author WCHAR 16 // array of Unicode characters - Author
  581. // Copyright WCHAR 16 // array of Unicode characters - Copyright
  582. // Description WCHAR 16 // array of Unicode characters - Description
  583. // Rating WCHAR 16 // array of Unicode characters - Rating
  584. // shortcut
  585. $thisfile_asf['content_description_object'] = array();
  586. $thisfile_asf_contentdescriptionobject = &$thisfile_asf['content_description_object'];
  587. $thisfile_asf_contentdescriptionobject['offset'] = $NextObjectOffset + $offset;
  588. $thisfile_asf_contentdescriptionobject['objectid'] = $NextObjectGUID;
  589. $thisfile_asf_contentdescriptionobject['objectid_guid'] = $NextObjectGUIDtext;
  590. $thisfile_asf_contentdescriptionobject['objectsize'] = $NextObjectSize;
  591. $thisfile_asf_contentdescriptionobject['title_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  592. $offset += 2;
  593. $thisfile_asf_contentdescriptionobject['author_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  594. $offset += 2;
  595. $thisfile_asf_contentdescriptionobject['copyright_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  596. $offset += 2;
  597. $thisfile_asf_contentdescriptionobject['description_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  598. $offset += 2;
  599. $thisfile_asf_contentdescriptionobject['rating_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
  600. $offset += 2;
  601. $thisfile_asf_contentdescriptionobject['title'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['title_length']);
  602. $offset += $thisfile_asf_contentdescriptionobject['title_length'];
  603. $thisfile_asf_contentdescriptionobject['author'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['author_length']);
  604. $offset += $thisfile_asf_contentdescriptionobject['author_length'];
  605. $thisfile_asf_contentdescriptionobject['copyright'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['copyright_length']);
  606. $offset += $thisfile_asf_contentdescriptionobject['copyright_length'];
  607. $thisfile_asf_contentdescriptionobject['description'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['description_length']);
  608. $offset += $thisfile_asf_contentdescriptionobject['description_length'];
  609. $thisfile_asf_contentdescriptionobject['rating'] = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['rating_length']);
  610. $offset += $thisfile_asf_contentdescriptionobject['rating_length'];
  611. $ASFcommentKeysToCopy = array('title'=>'title', 'author'=>'artist', 'copyright'=>'copyright', 'description'=>'comment', 'rating'=>'rating');
  612. foreach ($ASFcommentKeysToCopy as $keytocopyfrom => $keytocopyto) {
  613. if (!empty($thisfile_asf_contentdescriptionobject[$keytocopyfrom])) {
  614. $thisfile_asf_comments[$keytocopyto][] = $this->TrimTerm($thisfile_asf_contentdescriptionobject[$keytocopyfrom]);
  615. }
  616. }
  617. break;
  618. case GETID3_ASF_Extended_Content_Description_Object:
  619. // Extended Content Description Object: (optional, one only)
  620. // Field Name Field Type Size (bits)
  621. // Object ID GUID 128 // GUID for Extended Content Description object - GETID3_ASF_Extended_Content_Description_Object
  622. // Object Size QWORD 64 // size of ExtendedContent Description object, including 26 bytes of Extended Content Description Object header
  623. // Content Descriptors Count WORD 16 // number of entries in Content Descriptors list
  624. // Content Descriptors array of: variable //
  625. // * Descriptor Name Length WORD 16 // size in bytes of Descriptor Name field
  626. // * Descriptor Name WCHAR variable // array of Unicode characters - Descriptor Name
  627. // * Descriptor Value Data Type WORD 16 // Lookup array:
  628. // 0x0000 = Unicode String (variable length)
  629. // 0x0001 = BYTE array (variable length)
  630. // 0x0002 = BOOL (DWORD, 32 bits)
  631. // 0x0003 = DWORD (DWORD, 32 bits)…