PageRenderTime 54ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/mp3player/player/php/getid3/module.audio-video.asf.php

https://github.com/josephrmoore/mp3player
PHP | 1689 lines | 1155 code | 207 blank | 327 comment | 119 complexity | ee4ba02b3f796224b78f2d3a6d1c1129 MD5 | raw file

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

Large files files are truncated, but you can click here to view the full file