[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ID3/ -> module.audio-video.asf.php (source)

   1  <?php
   2  /////////////////////////////////////////////////////////////////
   3  /// getID3() by James Heinrich <info@getid3.org>               //
   4  //  available at https://github.com/JamesHeinrich/getID3       //
   5  //            or https://www.getid3.org                        //
   6  //            or http://getid3.sourceforge.net                 //
   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  
  16  if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
  17      exit;
  18  }
  19  getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
  20  
  21  class getid3_asf extends getid3_handler
  22  {
  23      protected static $ASFIndexParametersObjectIndexSpecifiersIndexTypes = array(
  24          1 => 'Nearest Past Data Packet',
  25          2 => 'Nearest Past Media Object',
  26          3 => 'Nearest Past Cleanpoint'
  27      );
  28  
  29      protected static $ASFMediaObjectIndexParametersObjectIndexSpecifiersIndexTypes = array(
  30          1 => 'Nearest Past Data Packet',
  31          2 => 'Nearest Past Media Object',
  32          3 => 'Nearest Past Cleanpoint',
  33          0xFF => 'Frame Number Offset'
  34      );
  35  
  36      protected static $ASFTimecodeIndexParametersObjectIndexSpecifiersIndexTypes = array(
  37          2 => 'Nearest Past Media Object',
  38          3 => 'Nearest Past Cleanpoint'
  39      );
  40  
  41      /**
  42       * @param getID3 $getid3
  43       */
  44  	public function __construct(getID3 $getid3) {
  45          parent::__construct($getid3);  // extends getid3_handler::__construct()
  46  
  47          // initialize all GUID constants
  48          $GUIDarray = $this->KnownGUIDs();
  49          foreach ($GUIDarray as $GUIDname => $hexstringvalue) {
  50              if (!defined($GUIDname)) {
  51                  define($GUIDname, $this->GUIDtoBytestring($hexstringvalue));
  52              }
  53          }
  54      }
  55  
  56      /**
  57       * @return bool
  58       */
  59  	public function Analyze() {
  60          $info = &$this->getid3->info;
  61  
  62          // Shortcuts
  63          $thisfile_audio = &$info['audio'];
  64          $thisfile_video = &$info['video'];
  65          $info['asf']  = array();
  66          $thisfile_asf = &$info['asf'];
  67          $thisfile_asf['comments'] = array();
  68          $thisfile_asf_comments    = &$thisfile_asf['comments'];
  69          $thisfile_asf['header_object'] = array();
  70          $thisfile_asf_headerobject     = &$thisfile_asf['header_object'];
  71  
  72  
  73          // ASF structure:
  74          // * Header Object [required]
  75          //   * File Properties Object [required]   (global file attributes)
  76          //   * Stream Properties Object [required] (defines media stream & characteristics)
  77          //   * Header Extension Object [required]  (additional functionality)
  78          //   * Content Description Object          (bibliographic information)
  79          //   * Script Command Object               (commands for during playback)
  80          //   * Marker Object                       (named jumped points within the file)
  81          // * Data Object [required]
  82          //   * Data Packets
  83          // * Index Object
  84  
  85          // Header Object: (mandatory, one only)
  86          // Field Name                   Field Type   Size (bits)
  87          // Object ID                    GUID         128             // GUID for header object - GETID3_ASF_Header_Object
  88          // Object Size                  QWORD        64              // size of header object, including 30 bytes of Header Object header
  89          // Number of Header Objects     DWORD        32              // number of objects in header object
  90          // Reserved1                    BYTE         8               // hardcoded: 0x01
  91          // Reserved2                    BYTE         8               // hardcoded: 0x02
  92  
  93          $info['fileformat'] = 'asf';
  94  
  95          $this->fseek($info['avdataoffset']);
  96          $HeaderObjectData = $this->fread(30);
  97  
  98          $thisfile_asf_headerobject['objectid']      = substr($HeaderObjectData, 0, 16);
  99          $thisfile_asf_headerobject['objectid_guid'] = $this->BytestringToGUID($thisfile_asf_headerobject['objectid']);
 100          if ($thisfile_asf_headerobject['objectid'] != GETID3_ASF_Header_Object) {
 101              unset($info['fileformat'], $info['asf']);
 102              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).'}');
 103          }
 104          $thisfile_asf_headerobject['objectsize']    = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 16, 8));
 105          $thisfile_asf_headerobject['headerobjects'] = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 24, 4));
 106          $thisfile_asf_headerobject['reserved1']     = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 28, 1));
 107          $thisfile_asf_headerobject['reserved2']     = getid3_lib::LittleEndian2Int(substr($HeaderObjectData, 29, 1));
 108  
 109          $NextObjectOffset = $this->ftell();
 110          $ASFHeaderData = $this->fread($thisfile_asf_headerobject['objectsize'] - 30);
 111          $offset = 0;
 112          $thisfile_asf_streambitratepropertiesobject = array();
 113          $thisfile_asf_codeclistobject = array();
 114          $StreamPropertiesObjectData = array();
 115  
 116          for ($HeaderObjectsCounter = 0; $HeaderObjectsCounter < $thisfile_asf_headerobject['headerobjects']; $HeaderObjectsCounter++) {
 117              $NextObjectGUID = substr($ASFHeaderData, $offset, 16);
 118              $offset += 16;
 119              $NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID);
 120              $NextObjectSize = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 121              $offset += 8;
 122              switch ($NextObjectGUID) {
 123  
 124                  case GETID3_ASF_File_Properties_Object:
 125                      // File Properties Object: (mandatory, one only)
 126                      // Field Name                   Field Type   Size (bits)
 127                      // Object ID                    GUID         128             // GUID for file properties object - GETID3_ASF_File_Properties_Object
 128                      // Object Size                  QWORD        64              // size of file properties object, including 104 bytes of File Properties Object header
 129                      // File ID                      GUID         128             // unique ID - identical to File ID in Data Object
 130                      // File Size                    QWORD        64              // entire file in bytes. Invalid if Broadcast Flag == 1
 131                      // Creation Date                QWORD        64              // date & time of file creation. Maybe invalid if Broadcast Flag == 1
 132                      // Data Packets Count           QWORD        64              // number of data packets in Data Object. Invalid if Broadcast Flag == 1
 133                      // Play Duration                QWORD        64              // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1
 134                      // Send Duration                QWORD        64              // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1
 135                      // 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
 136                      // Flags                        DWORD        32              //
 137                      // * Broadcast Flag             bits         1  (0x01)       // file is currently being written, some header values are invalid
 138                      // * Seekable Flag              bits         1  (0x02)       // is file seekable
 139                      // * Reserved                   bits         30 (0xFFFFFFFC) // reserved - set to zero
 140                      // Minimum Data Packet Size     DWORD        32              // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1
 141                      // Maximum Data Packet Size     DWORD        32              // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1
 142                      // Maximum Bitrate              DWORD        32              // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead
 143  
 144                      // shortcut
 145                      $thisfile_asf['file_properties_object'] = array();
 146                      $thisfile_asf_filepropertiesobject      = &$thisfile_asf['file_properties_object'];
 147  
 148                      $thisfile_asf_filepropertiesobject['offset']             = $NextObjectOffset + $offset;
 149                      $thisfile_asf_filepropertiesobject['objectid']           = $NextObjectGUID;
 150                      $thisfile_asf_filepropertiesobject['objectid_guid']      = $NextObjectGUIDtext;
 151                      $thisfile_asf_filepropertiesobject['objectsize']         = $NextObjectSize;
 152                      $thisfile_asf_filepropertiesobject['fileid']             = substr($ASFHeaderData, $offset, 16);
 153                      $offset += 16;
 154                      $thisfile_asf_filepropertiesobject['fileid_guid']        = $this->BytestringToGUID($thisfile_asf_filepropertiesobject['fileid']);
 155                      $thisfile_asf_filepropertiesobject['filesize']           = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 156                      $offset += 8;
 157                      $thisfile_asf_filepropertiesobject['creation_date']      = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 158                      $thisfile_asf_filepropertiesobject['creation_date_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_filepropertiesobject['creation_date']);
 159                      $offset += 8;
 160                      $thisfile_asf_filepropertiesobject['data_packets']       = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 161                      $offset += 8;
 162                      $thisfile_asf_filepropertiesobject['play_duration']      = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 163                      $offset += 8;
 164                      $thisfile_asf_filepropertiesobject['send_duration']      = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 165                      $offset += 8;
 166                      $thisfile_asf_filepropertiesobject['preroll']            = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 167                      $offset += 8;
 168                      $thisfile_asf_filepropertiesobject['flags_raw']          = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 169                      $offset += 4;
 170                      $thisfile_asf_filepropertiesobject['flags']['broadcast'] = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0001);
 171                      $thisfile_asf_filepropertiesobject['flags']['seekable']  = (bool) ($thisfile_asf_filepropertiesobject['flags_raw'] & 0x0002);
 172  
 173                      $thisfile_asf_filepropertiesobject['min_packet_size']    = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 174                      $offset += 4;
 175                      $thisfile_asf_filepropertiesobject['max_packet_size']    = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 176                      $offset += 4;
 177                      $thisfile_asf_filepropertiesobject['max_bitrate']        = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 178                      $offset += 4;
 179  
 180                      if ($thisfile_asf_filepropertiesobject['flags']['broadcast']) {
 181  
 182                          // broadcast flag is set, some values invalid
 183                          unset($thisfile_asf_filepropertiesobject['filesize']);
 184                          unset($thisfile_asf_filepropertiesobject['data_packets']);
 185                          unset($thisfile_asf_filepropertiesobject['play_duration']);
 186                          unset($thisfile_asf_filepropertiesobject['send_duration']);
 187                          unset($thisfile_asf_filepropertiesobject['min_packet_size']);
 188                          unset($thisfile_asf_filepropertiesobject['max_packet_size']);
 189  
 190                      } else {
 191  
 192                          // broadcast flag NOT set, perform calculations
 193                          $info['playtime_seconds'] = ($thisfile_asf_filepropertiesobject['play_duration'] / 10000000) - ($thisfile_asf_filepropertiesobject['preroll'] / 1000);
 194  
 195                          //$info['bitrate'] = $thisfile_asf_filepropertiesobject['max_bitrate'];
 196                          $info['bitrate'] = getid3_lib::SafeDiv($thisfile_asf_filepropertiesobject['filesize'] * 8, $info['playtime_seconds']);
 197                      }
 198                      break;
 199  
 200                  case GETID3_ASF_Stream_Properties_Object:
 201                      // Stream Properties Object: (mandatory, one per media stream)
 202                      // Field Name                   Field Type   Size (bits)
 203                      // Object ID                    GUID         128             // GUID for stream properties object - GETID3_ASF_Stream_Properties_Object
 204                      // Object Size                  QWORD        64              // size of stream properties object, including 78 bytes of Stream Properties Object header
 205                      // Stream Type                  GUID         128             // GETID3_ASF_Audio_Media, GETID3_ASF_Video_Media or GETID3_ASF_Command_Media
 206                      // Error Correction Type        GUID         128             // GETID3_ASF_Audio_Spread for audio-only streams, GETID3_ASF_No_Error_Correction for other stream types
 207                      // Time Offset                  QWORD        64              // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream
 208                      // Type-Specific Data Length    DWORD        32              // number of bytes for Type-Specific Data field
 209                      // Error Correction Data Length DWORD        32              // number of bytes for Error Correction Data field
 210                      // Flags                        WORD         16              //
 211                      // * Stream Number              bits         7 (0x007F)      // number of this stream.  1 <= valid <= 127
 212                      // * Reserved                   bits         8 (0x7F80)      // reserved - set to zero
 213                      // * Encrypted Content Flag     bits         1 (0x8000)      // stream contents encrypted if set
 214                      // Reserved                     DWORD        32              // reserved - set to zero
 215                      // Type-Specific Data           BYTESTREAM   variable        // type-specific format data, depending on value of Stream Type
 216                      // Error Correction Data        BYTESTREAM   variable        // error-correction-specific format data, depending on value of Error Correct Type
 217  
 218                      // There is one GETID3_ASF_Stream_Properties_Object for each stream (audio, video) but the
 219                      // stream number isn't known until halfway through decoding the structure, hence it
 220                      // it is decoded to a temporary variable and then stuck in the appropriate index later
 221  
 222                      $StreamPropertiesObjectData['offset']             = $NextObjectOffset + $offset;
 223                      $StreamPropertiesObjectData['objectid']           = $NextObjectGUID;
 224                      $StreamPropertiesObjectData['objectid_guid']      = $NextObjectGUIDtext;
 225                      $StreamPropertiesObjectData['objectsize']         = $NextObjectSize;
 226                      $StreamPropertiesObjectData['stream_type']        = substr($ASFHeaderData, $offset, 16);
 227                      $offset += 16;
 228                      $StreamPropertiesObjectData['stream_type_guid']   = $this->BytestringToGUID($StreamPropertiesObjectData['stream_type']);
 229                      $StreamPropertiesObjectData['error_correct_type'] = substr($ASFHeaderData, $offset, 16);
 230                      $offset += 16;
 231                      $StreamPropertiesObjectData['error_correct_guid'] = $this->BytestringToGUID($StreamPropertiesObjectData['error_correct_type']);
 232                      $StreamPropertiesObjectData['time_offset']        = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 233                      $offset += 8;
 234                      $StreamPropertiesObjectData['type_data_length']   = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 235                      $offset += 4;
 236                      $StreamPropertiesObjectData['error_data_length']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 237                      $offset += 4;
 238                      $StreamPropertiesObjectData['flags_raw']          = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 239                      $offset += 2;
 240                      $StreamPropertiesObjectStreamNumber               = $StreamPropertiesObjectData['flags_raw'] & 0x007F;
 241                      $StreamPropertiesObjectData['flags']['encrypted'] = (bool) ($StreamPropertiesObjectData['flags_raw'] & 0x8000);
 242  
 243                      $offset += 4; // reserved - DWORD
 244                      $StreamPropertiesObjectData['type_specific_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['type_data_length']);
 245                      $offset += $StreamPropertiesObjectData['type_data_length'];
 246                      $StreamPropertiesObjectData['error_correct_data'] = substr($ASFHeaderData, $offset, $StreamPropertiesObjectData['error_data_length']);
 247                      $offset += $StreamPropertiesObjectData['error_data_length'];
 248  
 249                      switch ($StreamPropertiesObjectData['stream_type']) {
 250  
 251                          case GETID3_ASF_Audio_Media:
 252                              $thisfile_audio['dataformat']   = (!empty($thisfile_audio['dataformat'])   ? $thisfile_audio['dataformat']   : 'asf');
 253                              $thisfile_audio['bitrate_mode'] = (!empty($thisfile_audio['bitrate_mode']) ? $thisfile_audio['bitrate_mode'] : 'cbr');
 254  
 255                              $audiodata = getid3_riff::parseWAVEFORMATex(substr($StreamPropertiesObjectData['type_specific_data'], 0, 16));
 256                              unset($audiodata['raw']);
 257                              $thisfile_audio = getid3_lib::array_merge_noclobber($audiodata, $thisfile_audio);
 258                              break;
 259  
 260                          case GETID3_ASF_Video_Media:
 261                              $thisfile_video['dataformat']   = (!empty($thisfile_video['dataformat'])   ? $thisfile_video['dataformat']   : 'asf');
 262                              $thisfile_video['bitrate_mode'] = (!empty($thisfile_video['bitrate_mode']) ? $thisfile_video['bitrate_mode'] : 'cbr');
 263                              break;
 264  
 265                          case GETID3_ASF_Command_Media:
 266                          default:
 267                              // do nothing
 268                              break;
 269  
 270                      }
 271  
 272                      $thisfile_asf['stream_properties_object'][$StreamPropertiesObjectStreamNumber] = $StreamPropertiesObjectData;
 273                      unset($StreamPropertiesObjectData); // clear for next stream, if any
 274                      break;
 275  
 276                  case GETID3_ASF_Header_Extension_Object:
 277                      // Header Extension Object: (mandatory, one only)
 278                      // Field Name                   Field Type   Size (bits)
 279                      // Object ID                    GUID         128             // GUID for Header Extension object - GETID3_ASF_Header_Extension_Object
 280                      // Object Size                  QWORD        64              // size of Header Extension object, including 46 bytes of Header Extension Object header
 281                      // Reserved Field 1             GUID         128             // hardcoded: GETID3_ASF_Reserved_1
 282                      // Reserved Field 2             WORD         16              // hardcoded: 0x00000006
 283                      // Header Extension Data Size   DWORD        32              // in bytes. valid: 0, or > 24. equals object size minus 46
 284                      // Header Extension Data        BYTESTREAM   variable        // array of zero or more extended header objects
 285  
 286                      // shortcut
 287                      $thisfile_asf['header_extension_object'] = array();
 288                      $thisfile_asf_headerextensionobject      = &$thisfile_asf['header_extension_object'];
 289  
 290                      $thisfile_asf_headerextensionobject['offset']              = $NextObjectOffset + $offset;
 291                      $thisfile_asf_headerextensionobject['objectid']            = $NextObjectGUID;
 292                      $thisfile_asf_headerextensionobject['objectid_guid']       = $NextObjectGUIDtext;
 293                      $thisfile_asf_headerextensionobject['objectsize']          = $NextObjectSize;
 294                      $thisfile_asf_headerextensionobject['reserved_1']          = substr($ASFHeaderData, $offset, 16);
 295                      $offset += 16;
 296                      $thisfile_asf_headerextensionobject['reserved_1_guid']     = $this->BytestringToGUID($thisfile_asf_headerextensionobject['reserved_1']);
 297                      if ($thisfile_asf_headerextensionobject['reserved_1'] != GETID3_ASF_Reserved_1) {
 298                          $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).')');
 299                          //return false;
 300                          break;
 301                      }
 302                      $thisfile_asf_headerextensionobject['reserved_2']          = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 303                      $offset += 2;
 304                      if ($thisfile_asf_headerextensionobject['reserved_2'] != 6) {
 305                          $this->warning('header_extension_object.reserved_2 ('.$thisfile_asf_headerextensionobject['reserved_2'].') does not match expected value of "6"');
 306                          //return false;
 307                          break;
 308                      }
 309                      $thisfile_asf_headerextensionobject['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 310                      $offset += 4;
 311                      $thisfile_asf_headerextensionobject['extension_data']      =                              substr($ASFHeaderData, $offset, $thisfile_asf_headerextensionobject['extension_data_size']);
 312                      $unhandled_sections = 0;
 313                      $thisfile_asf_headerextensionobject['extension_data_parsed'] = $this->HeaderExtensionObjectDataParse($thisfile_asf_headerextensionobject['extension_data'], $unhandled_sections);
 314                      if ($unhandled_sections === 0) {
 315                          unset($thisfile_asf_headerextensionobject['extension_data']);
 316                      }
 317                      $offset += $thisfile_asf_headerextensionobject['extension_data_size'];
 318                      break;
 319  
 320                  case GETID3_ASF_Codec_List_Object:
 321                      // Codec List Object: (optional, one only)
 322                      // Field Name                   Field Type   Size (bits)
 323                      // Object ID                    GUID         128             // GUID for Codec List object - GETID3_ASF_Codec_List_Object
 324                      // Object Size                  QWORD        64              // size of Codec List object, including 44 bytes of Codec List Object header
 325                      // Reserved                     GUID         128             // hardcoded: 86D15241-311D-11D0-A3A4-00A0C90348F6
 326                      // Codec Entries Count          DWORD        32              // number of entries in Codec Entries array
 327                      // Codec Entries                array of:    variable        //
 328                      // * Type                       WORD         16              // 0x0001 = Video Codec, 0x0002 = Audio Codec, 0xFFFF = Unknown Codec
 329                      // * Codec Name Length          WORD         16              // number of Unicode characters stored in the Codec Name field
 330                      // * Codec Name                 WCHAR        variable        // array of Unicode characters - name of codec used to create the content
 331                      // * Codec Description Length   WORD         16              // number of Unicode characters stored in the Codec Description field
 332                      // * Codec Description          WCHAR        variable        // array of Unicode characters - description of format used to create the content
 333                      // * Codec Information Length   WORD         16              // number of Unicode characters stored in the Codec Information field
 334                      // * Codec Information          BYTESTREAM   variable        // opaque array of information bytes about the codec used to create the content
 335  
 336                      // shortcut
 337                      $thisfile_asf['codec_list_object'] = array();
 338                      /** @var mixed[] $thisfile_asf_codeclistobject */
 339                      $thisfile_asf_codeclistobject      = &$thisfile_asf['codec_list_object']; // @phpstan-ignore-line
 340  
 341                      $thisfile_asf_codeclistobject['offset']                    = $NextObjectOffset + $offset;
 342                      $thisfile_asf_codeclistobject['objectid']                  = $NextObjectGUID;
 343                      $thisfile_asf_codeclistobject['objectid_guid']             = $NextObjectGUIDtext;
 344                      $thisfile_asf_codeclistobject['objectsize']                = $NextObjectSize;
 345                      $thisfile_asf_codeclistobject['reserved']                  = substr($ASFHeaderData, $offset, 16);
 346                      $offset += 16;
 347                      $thisfile_asf_codeclistobject['reserved_guid']             = $this->BytestringToGUID($thisfile_asf_codeclistobject['reserved']);
 348                      if ($thisfile_asf_codeclistobject['reserved'] != $this->GUIDtoBytestring('86D15241-311D-11D0-A3A4-00A0C90348F6')) {
 349                          $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}');
 350                          //return false;
 351                          break;
 352                      }
 353                      $thisfile_asf_codeclistobject['codec_entries_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 354                      if ($thisfile_asf_codeclistobject['codec_entries_count'] > 0) {
 355                          $thisfile_asf_codeclistobject['codec_entries'] = array();
 356                      }
 357                      $offset += 4;
 358                      for ($CodecEntryCounter = 0; $CodecEntryCounter < $thisfile_asf_codeclistobject['codec_entries_count']; $CodecEntryCounter++) {
 359                          // shortcut
 360                          $thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter] = array();
 361                          $thisfile_asf_codeclistobject_codecentries_current = &$thisfile_asf_codeclistobject['codec_entries'][$CodecEntryCounter];
 362  
 363                          $thisfile_asf_codeclistobject_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 364                          $offset += 2;
 365                          $thisfile_asf_codeclistobject_codecentries_current['type'] = self::codecListObjectTypeLookup($thisfile_asf_codeclistobject_codecentries_current['type_raw']);
 366  
 367                          $CodecNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
 368                          $offset += 2;
 369                          $thisfile_asf_codeclistobject_codecentries_current['name'] = substr($ASFHeaderData, $offset, $CodecNameLength);
 370                          $offset += $CodecNameLength;
 371  
 372                          $CodecDescriptionLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
 373                          $offset += 2;
 374                          $thisfile_asf_codeclistobject_codecentries_current['description'] = substr($ASFHeaderData, $offset, $CodecDescriptionLength);
 375                          $offset += $CodecDescriptionLength;
 376  
 377                          $CodecInformationLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 378                          $offset += 2;
 379                          $thisfile_asf_codeclistobject_codecentries_current['information'] = substr($ASFHeaderData, $offset, $CodecInformationLength);
 380                          $offset += $CodecInformationLength;
 381  
 382                          if ($thisfile_asf_codeclistobject_codecentries_current['type_raw'] == 2) { // audio codec
 383  
 384                              if (strpos($thisfile_asf_codeclistobject_codecentries_current['description'], ',') === false) {
 385                                  $this->warning('[asf][codec_list_object][codec_entries]['.$CodecEntryCounter.'][description] expected to contain comma-separated list of parameters: "'.$thisfile_asf_codeclistobject_codecentries_current['description'].'"');
 386                              } else {
 387  
 388                                  list($AudioCodecBitrate, $AudioCodecFrequency, $AudioCodecChannels) = explode(',', $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']));
 389                                  $thisfile_audio['codec'] = $this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['name']);
 390  
 391                                  if (!isset($thisfile_audio['bitrate']) && strstr($AudioCodecBitrate, 'kbps')) {
 392                                      $thisfile_audio['bitrate'] = (int) trim(str_replace('kbps', '', $AudioCodecBitrate)) * 1000;
 393                                  }
 394                                  //if (!isset($thisfile_video['bitrate']) && isset($thisfile_audio['bitrate']) && isset($thisfile_asf['file_properties_object']['max_bitrate']) && ($thisfile_asf_codeclistobject['codec_entries_count'] > 1)) {
 395                                  if (empty($thisfile_video['bitrate']) && !empty($thisfile_audio['bitrate']) && !empty($info['bitrate'])) {
 396                                      //$thisfile_video['bitrate'] = $thisfile_asf['file_properties_object']['max_bitrate'] - $thisfile_audio['bitrate'];
 397                                      $thisfile_video['bitrate'] = $info['bitrate'] - $thisfile_audio['bitrate'];
 398                                  }
 399  
 400                                  $AudioCodecFrequency = (int) trim(str_replace('kHz', '', $AudioCodecFrequency));
 401                                  switch ($AudioCodecFrequency) {
 402                                      case 8:
 403                                      case 8000:
 404                                          $thisfile_audio['sample_rate'] = 8000;
 405                                          break;
 406  
 407                                      case 11:
 408                                      case 11025:
 409                                          $thisfile_audio['sample_rate'] = 11025;
 410                                          break;
 411  
 412                                      case 12:
 413                                      case 12000:
 414                                          $thisfile_audio['sample_rate'] = 12000;
 415                                          break;
 416  
 417                                      case 16:
 418                                      case 16000:
 419                                          $thisfile_audio['sample_rate'] = 16000;
 420                                          break;
 421  
 422                                      case 22:
 423                                      case 22050:
 424                                          $thisfile_audio['sample_rate'] = 22050;
 425                                          break;
 426  
 427                                      case 24:
 428                                      case 24000:
 429                                          $thisfile_audio['sample_rate'] = 24000;
 430                                          break;
 431  
 432                                      case 32:
 433                                      case 32000:
 434                                          $thisfile_audio['sample_rate'] = 32000;
 435                                          break;
 436  
 437                                      case 44:
 438                                      case 441000:
 439                                          $thisfile_audio['sample_rate'] = 44100;
 440                                          break;
 441  
 442                                      case 48:
 443                                      case 48000:
 444                                          $thisfile_audio['sample_rate'] = 48000;
 445                                          break;
 446  
 447                                      default:
 448                                          $this->warning('unknown frequency: "'.$AudioCodecFrequency.'" ('.$this->TrimConvert($thisfile_asf_codeclistobject_codecentries_current['description']).')');
 449                                          break;
 450                                  }
 451  
 452                                  if (!isset($thisfile_audio['channels'])) {
 453                                      if (strstr($AudioCodecChannels, 'stereo')) {
 454                                          $thisfile_audio['channels'] = 2;
 455                                      } elseif (strstr($AudioCodecChannels, 'mono')) {
 456                                          $thisfile_audio['channels'] = 1;
 457                                      }
 458                                  }
 459  
 460                              }
 461                          }
 462                      }
 463                      break;
 464  
 465                  case GETID3_ASF_Script_Command_Object:
 466                      // Script Command Object: (optional, one only)
 467                      // Field Name                   Field Type   Size (bits)
 468                      // Object ID                    GUID         128             // GUID for Script Command object - GETID3_ASF_Script_Command_Object
 469                      // Object Size                  QWORD        64              // size of Script Command object, including 44 bytes of Script Command Object header
 470                      // Reserved                     GUID         128             // hardcoded: 4B1ACBE3-100B-11D0-A39B-00A0C90348F6
 471                      // Commands Count               WORD         16              // number of Commands structures in the Script Commands Objects
 472                      // Command Types Count          WORD         16              // number of Command Types structures in the Script Commands Objects
 473                      // Command Types                array of:    variable        //
 474                      // * Command Type Name Length   WORD         16              // number of Unicode characters for Command Type Name
 475                      // * Command Type Name          WCHAR        variable        // array of Unicode characters - name of a type of command
 476                      // Commands                     array of:    variable        //
 477                      // * Presentation Time          DWORD        32              // presentation time of that command, in milliseconds
 478                      // * Type Index                 WORD         16              // type of this command, as a zero-based index into the array of Command Types of this object
 479                      // * Command Name Length        WORD         16              // number of Unicode characters for Command Name
 480                      // * Command Name               WCHAR        variable        // array of Unicode characters - name of this command
 481  
 482                      // shortcut
 483                      $thisfile_asf['script_command_object'] = array();
 484                      $thisfile_asf_scriptcommandobject      = &$thisfile_asf['script_command_object'];
 485  
 486                      $thisfile_asf_scriptcommandobject['offset']               = $NextObjectOffset + $offset;
 487                      $thisfile_asf_scriptcommandobject['objectid']             = $NextObjectGUID;
 488                      $thisfile_asf_scriptcommandobject['objectid_guid']        = $NextObjectGUIDtext;
 489                      $thisfile_asf_scriptcommandobject['objectsize']           = $NextObjectSize;
 490                      $thisfile_asf_scriptcommandobject['reserved']             = substr($ASFHeaderData, $offset, 16);
 491                      $offset += 16;
 492                      $thisfile_asf_scriptcommandobject['reserved_guid']        = $this->BytestringToGUID($thisfile_asf_scriptcommandobject['reserved']);
 493                      if ($thisfile_asf_scriptcommandobject['reserved'] != $this->GUIDtoBytestring('4B1ACBE3-100B-11D0-A39B-00A0C90348F6')) {
 494                          $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}');
 495                          //return false;
 496                          break;
 497                      }
 498                      $thisfile_asf_scriptcommandobject['commands_count']       = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 499                      $offset += 2;
 500                      $thisfile_asf_scriptcommandobject['command_types_count']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 501                      $offset += 2;
 502                      if ($thisfile_asf_scriptcommandobject['command_types_count'] > 0) {
 503                          $thisfile_asf_scriptcommandobject['command_types'] = array();
 504                          for ($CommandTypesCounter = 0; $CommandTypesCounter < (int) $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) {
 505                              $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
 506                              $offset += 2;
 507                              $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter] = array();
 508                              $thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
 509                              $offset += $CommandTypeNameLength;
 510                          }
 511                      }
 512                      for ($CommandsCounter = 0; $CommandsCounter < (int) $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
 513                          $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['presentation_time']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 514                          $offset += 4;
 515                          $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['type_index']         = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 516                          $offset += 2;
 517  
 518                          $CommandTypeNameLength = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
 519                          $offset += 2;
 520                          $thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
 521                          $offset += $CommandTypeNameLength;
 522                      }
 523                      break;
 524  
 525                  case GETID3_ASF_Marker_Object:
 526                      // Marker Object: (optional, one only)
 527                      // Field Name                   Field Type   Size (bits)
 528                      // Object ID                    GUID         128             // GUID for Marker object - GETID3_ASF_Marker_Object
 529                      // Object Size                  QWORD        64              // size of Marker object, including 48 bytes of Marker Object header
 530                      // Reserved                     GUID         128             // hardcoded: 4CFEDB20-75F6-11CF-9C0F-00A0C90349CB
 531                      // Markers Count                DWORD        32              // number of Marker structures in Marker Object
 532                      // Reserved                     WORD         16              // hardcoded: 0x0000
 533                      // Name Length                  WORD         16              // number of bytes in the Name field
 534                      // Name                         WCHAR        variable        // name of the Marker Object
 535                      // Markers                      array of:    variable        //
 536                      // * Offset                     QWORD        64              // byte offset into Data Object
 537                      // * Presentation Time          QWORD        64              // in 100-nanosecond units
 538                      // * Entry Length               WORD         16              // length in bytes of (Send Time + Flags + Marker Description Length + Marker Description + Padding)
 539                      // * Send Time                  DWORD        32              // in milliseconds
 540                      // * Flags                      DWORD        32              // hardcoded: 0x00000000
 541                      // * Marker Description Length  DWORD        32              // number of bytes in Marker Description field
 542                      // * Marker Description         WCHAR        variable        // array of Unicode characters - description of marker entry
 543                      // * Padding                    BYTESTREAM   variable        // optional padding bytes
 544  
 545                      // shortcut
 546                      $thisfile_asf['marker_object'] = array();
 547                      $thisfile_asf_markerobject     = &$thisfile_asf['marker_object'];
 548  
 549                      $thisfile_asf_markerobject['offset']               = $NextObjectOffset + $offset;
 550                      $thisfile_asf_markerobject['objectid']             = $NextObjectGUID;
 551                      $thisfile_asf_markerobject['objectid_guid']        = $NextObjectGUIDtext;
 552                      $thisfile_asf_markerobject['objectsize']           = $NextObjectSize;
 553                      $thisfile_asf_markerobject['reserved']             = substr($ASFHeaderData, $offset, 16);
 554                      $offset += 16;
 555                      $thisfile_asf_markerobject['reserved_guid']        = $this->BytestringToGUID($thisfile_asf_markerobject['reserved']);
 556                      if ($thisfile_asf_markerobject['reserved'] != $this->GUIDtoBytestring('4CFEDB20-75F6-11CF-9C0F-00A0C90349CB')) {
 557                          $this->warning('marker_object.reserved GUID {'.$this->BytestringToGUID($thisfile_asf_markerobject['reserved']).'} does not match expected "GETID3_ASF_Reserved_1" GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}');
 558                          break;
 559                      }
 560                      $thisfile_asf_markerobject['markers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 561                      /** @var int|float|false $totalMakersCount */
 562                      $totalMakersCount = $thisfile_asf_markerobject['markers_count'];
 563                      $offset += 4;
 564                      $thisfile_asf_markerobject['reserved_2'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 565                      $offset += 2;
 566                      if ($thisfile_asf_markerobject['reserved_2'] != 0) {
 567                          $this->warning('marker_object.reserved_2 ('.$thisfile_asf_markerobject['reserved_2'].') does not match expected value of "0"');
 568                          break;
 569                      }
 570                      $thisfile_asf_markerobject['name_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 571                      $offset += 2;
 572                      $thisfile_asf_markerobject['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['name_length']);
 573                      $offset += $thisfile_asf_markerobject['name_length'];
 574                      for ($MarkersCounter = 0; $MarkersCounter < $totalMakersCount; $MarkersCounter++) {
 575                          $thisfile_asf_markerobject['markers'][$MarkersCounter] = array();
 576                          $thisfile_asf_markerobject['markers'][$MarkersCounter]['offset']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 577                          $offset += 8;
 578                          $thisfile_asf_markerobject['markers'][$MarkersCounter]['presentation_time']         = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
 579                          $offset += 8;
 580                          $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length']              = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 581                          $offset += 2;
 582                          $thisfile_asf_markerobject['markers'][$MarkersCounter]['send_time']                 = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 583                          $offset += 4;
 584                          $thisfile_asf_markerobject['markers'][$MarkersCounter]['flags']                     = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 585                          $offset += 4;
 586                          $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 587                          $offset += 4;
 588                          $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description']        = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length']);
 589                          $offset += $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'];
 590                          $PaddingLength = $thisfile_asf_markerobject['markers'][$MarkersCounter]['entry_length'] - 4 -  4 - 4 - $thisfile_asf_markerobject['markers'][$MarkersCounter]['marker_description_length'];
 591                          if ($PaddingLength > 0) {
 592                              $thisfile_asf_markerobject['markers'][$MarkersCounter]['padding']               = substr($ASFHeaderData, $offset, $PaddingLength);
 593                              $offset += $PaddingLength;
 594                          }
 595                      }
 596                      break;
 597  
 598                  case GETID3_ASF_Bitrate_Mutual_Exclusion_Object:
 599                      // Bitrate Mutual Exclusion Object: (optional)
 600                      // Field Name                   Field Type   Size (bits)
 601                      // Object ID                    GUID         128             // GUID for Bitrate Mutual Exclusion object - GETID3_ASF_Bitrate_Mutual_Exclusion_Object
 602                      // Object Size                  QWORD        64              // size of Bitrate Mutual Exclusion object, including 42 bytes of Bitrate Mutual Exclusion Object header
 603                      // Exlusion Type                GUID         128             // nature of mutual exclusion relationship. one of: (GETID3_ASF_Mutex_Bitrate, GETID3_ASF_Mutex_Unknown)
 604                      // Stream Numbers Count         WORD         16              // number of video streams
 605                      // Stream Numbers               WORD         variable        // array of mutually exclusive video stream numbers. 1 <= valid <= 127
 606  
 607                      // shortcut
 608                      $thisfile_asf['bitrate_mutual_exclusion_object'] = array();
 609                      $thisfile_asf_bitratemutualexclusionobject       = &$thisfile_asf['bitrate_mutual_exclusion_object'];
 610  
 611                      $thisfile_asf_bitratemutualexclusionobject['offset']               = $NextObjectOffset + $offset;
 612                      $thisfile_asf_bitratemutualexclusionobject['objectid']             = $NextObjectGUID;
 613                      $thisfile_asf_bitratemutualexclusionobject['objectid_guid']        = $NextObjectGUIDtext;
 614                      $thisfile_asf_bitratemutualexclusionobject['objectsize']           = $NextObjectSize;
 615                      $thisfile_asf_bitratemutualexclusionobject['reserved']             = substr($ASFHeaderData, $offset, 16);
 616                      $thisfile_asf_bitratemutualexclusionobject['reserved_guid']        = $this->BytestringToGUID($thisfile_asf_bitratemutualexclusionobject['reserved']);
 617                      $offset += 16;
 618                      if (($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Bitrate) && ($thisfile_asf_bitratemutualexclusionobject['reserved'] != GETID3_ASF_Mutex_Unknown)) {
 619                          $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).'}');
 620                          //return false;
 621                          break;
 622                      }
 623                      $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 624                      $offset += 2;
 625                      for ($StreamNumberCounter = 0; $StreamNumberCounter < (int) $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) {
 626                          $thisfile_asf_bitratemutualexclusionobject['stream_numbers'][$StreamNumberCounter] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 627                          $offset += 2;
 628                      }
 629                      break;
 630  
 631                  case GETID3_ASF_Error_Correction_Object:
 632                      // Error Correction Object: (optional, one only)
 633                      // Field Name                   Field Type   Size (bits)
 634                      // Object ID                    GUID         128             // GUID for Error Correction object - GETID3_ASF_Error_Correction_Object
 635                      // Object Size                  QWORD        64              // size of Error Correction object, including 44 bytes of Error Correction Object header
 636                      // Error Correction Type        GUID         128             // type of error correction. one of: (GETID3_ASF_No_Error_Correction, GETID3_ASF_Audio_Spread)
 637                      // Error Correction Data Length DWORD        32              // number of bytes in Error Correction Data field
 638                      // Error Correction Data        BYTESTREAM   variable        // structure depends on value of Error Correction Type field
 639  
 640                      // shortcut
 641                      $thisfile_asf['error_correction_object'] = array();
 642                      $thisfile_asf_errorcorrectionobject      = &$thisfile_asf['error_correction_object'];
 643  
 644                      $thisfile_asf_errorcorrectionobject['offset']                = $NextObjectOffset + $offset;
 645                      $thisfile_asf_errorcorrectionobject['objectid']              = $NextObjectGUID;
 646                      $thisfile_asf_errorcorrectionobject['objectid_guid']         = $NextObjectGUIDtext;
 647                      $thisfile_asf_errorcorrectionobject['objectsize']            = $NextObjectSize;
 648                      $thisfile_asf_errorcorrectionobject['error_correction_type'] = substr($ASFHeaderData, $offset, 16);
 649                      $offset += 16;
 650                      $thisfile_asf_errorcorrectionobject['error_correction_guid'] = $this->BytestringToGUID($thisfile_asf_errorcorrectionobject['error_correction_type']);
 651                      $thisfile_asf_errorcorrectionobject['error_correction_data_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 652                      $offset += 4;
 653                      switch ($thisfile_asf_errorcorrectionobject['error_correction_type']) {
 654                          case GETID3_ASF_No_Error_Correction:
 655                              // should be no data, but just in case there is, skip to the end of the field
 656                              $offset += $thisfile_asf_errorcorrectionobject['error_correction_data_length'];
 657                              break;
 658  
 659                          case GETID3_ASF_Audio_Spread:
 660                              // Field Name                   Field Type   Size (bits)
 661                              // Span                         BYTE         8               // number of packets over which audio will be spread.
 662                              // Virtual Packet Length        WORD         16              // size of largest audio payload found in audio stream
 663                              // Virtual Chunk Length         WORD         16              // size of largest audio payload found in audio stream
 664                              // Silence Data Length          WORD         16              // number of bytes in Silence Data field
 665                              // Silence Data                 BYTESTREAM   variable        // hardcoded: 0x00 * (Silence Data Length) bytes
 666  
 667                              $thisfile_asf_errorcorrectionobject['span']                  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 1));
 668                              $offset += 1;
 669                              $thisfile_asf_errorcorrectionobject['virtual_packet_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 670                              $offset += 2;
 671                              $thisfile_asf_errorcorrectionobject['virtual_chunk_length']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 672                              $offset += 2;
 673                              $thisfile_asf_errorcorrectionobject['silence_data_length']   = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 674                              $offset += 2;
 675                              $thisfile_asf_errorcorrectionobject['silence_data']          = substr($ASFHeaderData, $offset, $thisfile_asf_errorcorrectionobject['silence_data_length']);
 676                              $offset += $thisfile_asf_errorcorrectionobject['silence_data_length'];
 677                              break;
 678  
 679                          default:
 680                              $this->warning('error_correction_object.error_correction_type GUID {'.$this->BytestringToGUID($thisfile_asf_errorcorrectionobject['error_correction_type']).'} 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).'}');
 681                              //return false;
 682                              break;
 683                      }
 684  
 685                      break;
 686  
 687                  case GETID3_ASF_Content_Description_Object:
 688                      // Content Description Object: (optional, one only)
 689                      // Field Name                   Field Type   Size (bits)
 690                      // Object ID                    GUID         128             // GUID for Content Description object - GETID3_ASF_Content_Description_Object
 691                      // Object Size                  QWORD        64              // size of Content Description object, including 34 bytes of Content Description Object header
 692                      // Title Length                 WORD         16              // number of bytes in Title field
 693                      // Author Length                WORD         16              // number of bytes in Author field
 694                      // Copyright Length             WORD         16              // number of bytes in Copyright field
 695                      // Description Length           WORD         16              // number of bytes in Description field
 696                      // Rating Length                WORD         16              // number of bytes in Rating field
 697                      // Title                        WCHAR        16              // array of Unicode characters - Title
 698                      // Author                       WCHAR        16              // array of Unicode characters - Author
 699                      // Copyright                    WCHAR        16              // array of Unicode characters - Copyright
 700                      // Description                  WCHAR        16              // array of Unicode characters - Description
 701                      // Rating                       WCHAR        16              // array of Unicode characters - Rating
 702  
 703                      // shortcut
 704                      $thisfile_asf['content_description_object'] = array();
 705                      $thisfile_asf_contentdescriptionobject      = &$thisfile_asf['content_description_object'];
 706  
 707                      $thisfile_asf_contentdescriptionobject['offset']                = $NextObjectOffset + $offset;
 708                      $thisfile_asf_contentdescriptionobject['objectid']              = $NextObjectGUID;
 709                      $thisfile_asf_contentdescriptionobject['objectid_guid']         = $NextObjectGUIDtext;
 710                      $thisfile_asf_contentdescriptionobject['objectsize']            = $NextObjectSize;
 711                      $thisfile_asf_contentdescriptionobject['title_length']          = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 712                      $offset += 2;
 713                      $thisfile_asf_contentdescriptionobject['author_length']         = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 714                      $offset += 2;
 715                      $thisfile_asf_contentdescriptionobject['copyright_length']      = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 716                      $offset += 2;
 717                      $thisfile_asf_contentdescriptionobject['description_length']    = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 718                      $offset += 2;
 719                      $thisfile_asf_contentdescriptionobject['rating_length']         = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 720                      $offset += 2;
 721                      $thisfile_asf_contentdescriptionobject['title']                 = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['title_length']);
 722                      $offset += $thisfile_asf_contentdescriptionobject['title_length'];
 723                      $thisfile_asf_contentdescriptionobject['author']                = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['author_length']);
 724                      $offset += $thisfile_asf_contentdescriptionobject['author_length'];
 725                      $thisfile_asf_contentdescriptionobject['copyright']             = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['copyright_length']);
 726                      $offset += $thisfile_asf_contentdescriptionobject['copyright_length'];
 727                      $thisfile_asf_contentdescriptionobject['description']           = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['description_length']);
 728                      $offset += $thisfile_asf_contentdescriptionobject['description_length'];
 729                      $thisfile_asf_contentdescriptionobject['rating']                = substr($ASFHeaderData, $offset, $thisfile_asf_contentdescriptionobject['rating_length']);
 730                      $offset += $thisfile_asf_contentdescriptionobject['rating_length'];
 731  
 732                      $ASFcommentKeysToCopy = array('title'=>'title', 'author'=>'artist', 'copyright'=>'copyright', 'description'=>'comment', 'rating'=>'rating');
 733                      foreach ($ASFcommentKeysToCopy as $keytocopyfrom => $keytocopyto) {
 734                          if (!empty($thisfile_asf_contentdescriptionobject[$keytocopyfrom])) {
 735                              $thisfile_asf_comments[$keytocopyto][] = $this->TrimTerm($thisfile_asf_contentdescriptionobject[$keytocopyfrom]);
 736                          }
 737                      }
 738                      break;
 739  
 740                  case GETID3_ASF_Extended_Content_Description_Object:
 741                      // Extended Content Description Object: (optional, one only)
 742                      // Field Name                   Field Type   Size (bits)
 743                      // Object ID                    GUID         128             // GUID for Extended Content Description object - GETID3_ASF_Extended_Content_Description_Object
 744                      // Object Size                  QWORD        64              // size of ExtendedContent Description object, including 26 bytes of Extended Content Description Object header
 745                      // Content Descriptors Count    WORD         16              // number of entries in Content Descriptors list
 746                      // Content Descriptors          array of:    variable        //
 747                      // * Descriptor Name Length     WORD         16              // size in bytes of Descriptor Name field
 748                      // * Descriptor Name            WCHAR        variable        // array of Unicode characters - Descriptor Name
 749                      // * Descriptor Value Data Type WORD         16              // Lookup array:
 750                                                                                      // 0x0000 = Unicode String (variable length)
 751                                                                                      // 0x0001 = BYTE array     (variable length)
 752                                                                                      // 0x0002 = BOOL           (DWORD, 32 bits)
 753                                                                                      // 0x0003 = DWORD          (DWORD, 32 bits)
 754                                                                                      // 0x0004 = QWORD          (QWORD, 64 bits)
 755                                                                                      // 0x0005 = WORD           (WORD,  16 bits)
 756                      // * Descriptor Value Length    WORD         16              // number of bytes stored in Descriptor Value field
 757                      // * Descriptor Value           variable     variable        // value for Content Descriptor
 758  
 759                      // shortcut
 760                      $thisfile_asf['extended_content_description_object'] = array();
 761                      $thisfile_asf_extendedcontentdescriptionobject       = &$thisfile_asf['extended_content_description_object'];
 762  
 763                      $thisfile_asf_extendedcontentdescriptionobject['offset']                    = $NextObjectOffset + $offset;
 764                      $thisfile_asf_extendedcontentdescriptionobject['objectid']                  = $NextObjectGUID;
 765                      $thisfile_asf_extendedcontentdescriptionobject['objectid_guid']             = $NextObjectGUIDtext;
 766                      $thisfile_asf_extendedcontentdescriptionobject['objectsize']                = $NextObjectSize;
 767                      $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 768                      $offset += 2;
 769                      for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < (int) $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) {
 770                          // shortcut
 771                          $thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter] = array();
 772                          $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current                 = &$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter];
 773  
 774                          $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['base_offset']  = $offset + 30;
 775                          $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length']  = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 776                          $offset += 2;
 777                          $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']         = substr($ASFHeaderData, $offset, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length']);
 778                          $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name_length'];
 779                          $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']   = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 780                          $offset += 2;
 781                          $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 782                          $offset += 2;
 783                          $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']        = substr($ASFHeaderData, $offset, $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length']);
 784                          $offset += $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'];
 785                          switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']) {
 786                              case 0x0000: // Unicode string
 787                                  break;
 788  
 789                              case 0x0001: // BYTE array
 790                                  // do nothing
 791                                  break;
 792  
 793                              case 0x0002: // BOOL
 794                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = (bool) getid3_lib::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
 795                                  break;
 796  
 797                              case 0x0003: // DWORD
 798                              case 0x0004: // QWORD
 799                              case 0x0005: // WORD
 800                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = getid3_lib::LittleEndian2Int($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
 801                                  break;
 802  
 803                              default:
 804                                  $this->warning('extended_content_description.content_descriptors.'.$ExtendedContentDescriptorsCounter.'.value_type is invalid ('.$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type'].')');
 805                                  //return false;
 806                                  break;
 807                          }
 808                          switch ($this->TrimConvert(strtolower($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']))) {
 809  
 810                              case 'wm/albumartist':
 811                              case 'artist':
 812                                  // Note: not 'artist', that comes from 'author' tag
 813                                  $thisfile_asf_comments['albumartist'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 814                                  break;
 815  
 816                              case 'wm/albumtitle':
 817                              case 'album':
 818                                  $thisfile_asf_comments['album']  = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 819                                  break;
 820  
 821                              case 'wm/genre':
 822                              case 'genre':
 823                                  $thisfile_asf_comments['genre'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 824                                  break;
 825  
 826                              case 'wm/partofset':
 827                                  $thisfile_asf_comments['partofset'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 828                                  break;
 829  
 830                              case 'wm/tracknumber':
 831                              case 'tracknumber':
 832                                  // be careful casting to int: casting unicode strings to int gives unexpected results (stops parsing at first non-numeric character)
 833                                  $thisfile_asf_comments['track_number'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 834                                  foreach ($thisfile_asf_comments['track_number'] as $key => $value) {
 835                                      if (preg_match('/^[0-9\x00]+$/', $value)) {
 836                                          $thisfile_asf_comments['track_number'][$key] = intval(str_replace("\x00", '', $value));
 837                                      }
 838                                  }
 839                                  break;
 840  
 841                              case 'wm/track':
 842                                  if (empty($thisfile_asf_comments['track_number'])) {
 843                                      $thisfile_asf_comments['track_number'] = array(1 + (int) $this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 844                                  }
 845                                  break;
 846  
 847                              case 'wm/year':
 848                              case 'year':
 849                              case 'date':
 850                                  $thisfile_asf_comments['year'] = array( $this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 851                                  break;
 852  
 853                              case 'wm/lyrics':
 854                              case 'lyrics':
 855                                  $thisfile_asf_comments['lyrics'] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 856                                  break;
 857  
 858                              case 'isvbr':
 859                                  if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']) {
 860                                      $thisfile_audio['bitrate_mode'] = 'vbr';
 861                                      $thisfile_video['bitrate_mode'] = 'vbr';
 862                                  }
 863                                  break;
 864  
 865                              case 'id3':
 866                                  $this->getid3->include_module('tag.id3v2');
 867  
 868                                  $getid3_id3v2 = new getid3_id3v2($this->getid3);
 869                                  $getid3_id3v2->AnalyzeString($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
 870                                  unset($getid3_id3v2);
 871  
 872                                  if ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_length'] > 1024) {
 873                                      $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'] = '<value too large to display>';
 874                                  }
 875                                  break;
 876  
 877                              case 'wm/encodingtime':
 878                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix'] = $this->FILETIMEtoUNIXtime($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
 879                                  $thisfile_asf_comments['encoding_time_unix'] = array($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['encoding_time_unix']);
 880                                  break;
 881  
 882                              case 'wm/picture':
 883                                  $WMpicture = $this->ASF_WMpicture($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
 884                                  foreach ($WMpicture as $key => $value) {
 885                                      $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current[$key] = $value;
 886                                  }
 887                                  unset($WMpicture);
 888  /*
 889                                  $wm_picture_offset = 0;
 890                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id'] = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 1));
 891                                  $wm_picture_offset += 1;
 892                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type']    = self::WMpictureTypeLookup($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_type_id']);
 893                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_size']    = getid3_lib::LittleEndian2Int(substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 4));
 894                                  $wm_picture_offset += 4;
 895  
 896                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = '';
 897                                  do {
 898                                      $next_byte_pair = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 2);
 899                                      $wm_picture_offset += 2;
 900                                      $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] .= $next_byte_pair;
 901                                  } while ($next_byte_pair !== "\x00\x00");
 902  
 903                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_description'] = '';
 904                                  do {
 905                                      $next_byte_pair = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset, 2);
 906                                      $wm_picture_offset += 2;
 907                                      $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_description'] .= $next_byte_pair;
 908                                  } while ($next_byte_pair !== "\x00\x00");
 909  
 910                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['dataoffset'] = $wm_picture_offset;
 911                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'] = substr($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value'], $wm_picture_offset);
 912                                  unset($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']);
 913  
 914                                  $imageinfo = array();
 915                                  $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = '';
 916                                  $imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], $imageinfo);
 917                                  unset($imageinfo);
 918                                  if (!empty($imagechunkcheck)) {
 919                                      $thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
 920                                  }
 921                                  if (!isset($thisfile_asf_comments['picture'])) {
 922                                      $thisfile_asf_comments['picture'] = array();
 923                                  }
 924                                  $thisfile_asf_comments['picture'][] = array('data'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['data'], 'image_mime'=>$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['image_mime']);
 925  */
 926                                  break;
 927  
 928                              default:
 929                                  switch ($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value_type']) {
 930                                      case 0: // Unicode string
 931                                          if (substr($this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name']), 0, 3) == 'WM/') {
 932                                              $thisfile_asf_comments[str_replace('wm/', '', strtolower($this->TrimConvert($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['name'])))] = array($this->TrimTerm($thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current['value']));
 933                                          }
 934                                          break;
 935  
 936                                      case 1:
 937                                          break;
 938                                  }
 939                                  break;
 940                          }
 941  
 942                      }
 943                      break;
 944  
 945                  case GETID3_ASF_Stream_Bitrate_Properties_Object:
 946                      // Stream Bitrate Properties Object: (optional, one only)
 947                      // Field Name                   Field Type   Size (bits)
 948                      // Object ID                    GUID         128             // GUID for Stream Bitrate Properties object - GETID3_ASF_Stream_Bitrate_Properties_Object
 949                      // Object Size                  QWORD        64              // size of Extended Content Description object, including 26 bytes of Stream Bitrate Properties Object header
 950                      // Bitrate Records Count        WORD         16              // number of records in Bitrate Records
 951                      // Bitrate Records              array of:    variable        //
 952                      // * Flags                      WORD         16              //
 953                      // * * Stream Number            bits         7  (0x007F)     // number of this stream
 954                      // * * Reserved                 bits         9  (0xFF80)     // hardcoded: 0
 955                      // * Average Bitrate            DWORD        32              // in bits per second
 956  
 957                      // shortcut
 958                      $thisfile_asf['stream_bitrate_properties_object'] = array();
 959                      $thisfile_asf_streambitratepropertiesobject       = &$thisfile_asf['stream_bitrate_properties_object'];
 960  
 961                      $thisfile_asf_streambitratepropertiesobject['offset']                    = $NextObjectOffset + $offset;
 962                      $thisfile_asf_streambitratepropertiesobject['objectid']                  = $NextObjectGUID;
 963                      $thisfile_asf_streambitratepropertiesobject['objectid_guid']             = $NextObjectGUIDtext;
 964                      $thisfile_asf_streambitratepropertiesobject['objectsize']                = $NextObjectSize;
 965                      $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']     = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 966                      $offset += 2;
 967                      for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < (int) $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
 968                          $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter] = array();
 969                          $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
 970                          $offset += 2;
 971                          $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x007F;
 972                          $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['bitrate'] = getid3_lib::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
 973                          $offset += 4;
 974                      }
 975                      break;
 976  
 977                  case GETID3_ASF_Padding_Object:
 978                      // Padding Object: (optional)
 979                      // Field Name                   Field Type   Size (bits)
 980                      // Object ID                    GUID         128             // GUID for Padding object - GETID3_ASF_Padding_Object
 981                      // Object Size                  QWORD        64              // size of Padding object, including 24 bytes of ASF Padding Object header
 982                      // Padding Data                 BYTESTREAM   variable        // ignore
 983  
 984                      // shortcut
 985                      $thisfile_asf['padding_object'] = array();
 986                      $thisfile_asf_paddingobject     = &$thisfile_asf['padding_object'];
 987  
 988                      $thisfile_asf_paddingobject['offset']                    = $NextObjectOffset + $offset;
 989                      $thisfile_asf_paddingobject['objectid']                  = $NextObjectGUID;
 990                      $thisfile_asf_paddingobject['objectid_guid']             = $NextObjectGUIDtext;
 991                      $thisfile_asf_paddingobject['objectsize']                = $NextObjectSize;
 992                      $thisfile_asf_paddingobject['padding_length']            = $thisfile_asf_paddingobject['objectsize'] - 16 - 8;
 993                      $thisfile_asf_paddingobject['padding']                   = substr($ASFHeaderData, $offset, $thisfile_asf_paddingobject['padding_length']);
 994                      $offset += ($NextObjectSize - 16 - 8);
 995                      break;
 996  
 997                  case GETID3_ASF_Extended_Content_Encryption_Object:
 998                  case GETID3_ASF_Content_Encryption_Object:
 999                      // WMA DRM - just ignore
1000                      $offset += ($NextObjectSize - 16 - 8);
1001                      break;
1002  
1003                  default:
1004                      // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
1005                      if ($this->GUIDname($NextObjectGUIDtext)) {
1006                          $this->warning('unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8));
1007                      } else {
1008                          $this->warning('unknown GUID {'.$NextObjectGUIDtext.'} in ASF header at offset '.($offset - 16 - 8));
1009                      }
1010                      $offset += ($NextObjectSize - 16 - 8);
1011                      break;
1012              }
1013          }
1014          if (isset($thisfile_asf_streambitratepropertiesobject['bitrate_records_count'])) {
1015              $ASFbitrateAudio = 0;
1016              $ASFbitrateVideo = 0;
1017              for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < (int) $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
1018                  if (isset($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter])) {
1019                      switch ($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter]['type_raw']) {
1020                          case 1:
1021                              $ASFbitrateVideo += $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['bitrate'];
1022                              break;
1023  
1024                          case 2:
1025                              $ASFbitrateAudio += $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['bitrate'];
1026                              break;
1027  
1028                          default:
1029                              // do nothing
1030                              break;
1031                      }
1032                  }
1033              }
1034              if ($ASFbitrateAudio > 0) {
1035                  $thisfile_audio['bitrate'] = $ASFbitrateAudio;
1036              }
1037              if ($ASFbitrateVideo > 0) {
1038                  $thisfile_video['bitrate'] = $ASFbitrateVideo;
1039              }
1040          }
1041          if (isset($thisfile_asf['stream_properties_object'])) {
1042  
1043              $thisfile_audio['bitrate'] = 0;
1044              $thisfile_video['bitrate'] = 0;
1045  
1046              foreach ($thisfile_asf['stream_properties_object'] as $streamnumber => $streamdata) {
1047  
1048                  switch ($streamdata['stream_type']) {
1049                      case GETID3_ASF_Audio_Media:
1050                          // Field Name                   Field Type   Size (bits)
1051                          // Codec ID / Format Tag        WORD         16              // unique ID of audio codec - defined as wFormatTag field of WAVEFORMATEX structure
1052                          // Number of Channels           WORD         16              // number of channels of audio - defined as nChannels field of WAVEFORMATEX structure
1053                          // Samples Per Second           DWORD        32              // in Hertz - defined as nSamplesPerSec field of WAVEFORMATEX structure
1054                          // Average number of Bytes/sec  DWORD        32              // bytes/sec of audio stream  - defined as nAvgBytesPerSec field of WAVEFORMATEX structure
1055                          // Block Alignment              WORD         16              // block size in bytes of audio codec - defined as nBlockAlign field of WAVEFORMATEX structure
1056                          // Bits per sample              WORD         16              // bits per sample of mono data. set to zero for variable bitrate codecs. defined as wBitsPerSample field of WAVEFORMATEX structure
1057                          // Codec Specific Data Size     WORD         16              // size in bytes of Codec Specific Data buffer - defined as cbSize field of WAVEFORMATEX structure
1058                          // Codec Specific Data          BYTESTREAM   variable        // array of codec-specific data bytes
1059  
1060                          // shortcut
1061                          $thisfile_asf['audio_media'][$streamnumber] = array();
1062                          $thisfile_asf_audiomedia_currentstream      = &$thisfile_asf['audio_media'][$streamnumber];
1063  
1064                          $audiomediaoffset = 0;
1065  
1066                          $thisfile_asf_audiomedia_currentstream = getid3_riff::parseWAVEFORMATex(substr($streamdata['type_specific_data'], $audiomediaoffset, 16));
1067                          $audiomediaoffset += 16;
1068  
1069                          $thisfile_audio['lossless'] = false;
1070                          switch ($thisfile_asf_audiomedia_currentstream['raw']['wFormatTag']) {
1071                              case 0x0001: // PCM
1072                              case 0x0163: // WMA9 Lossless
1073                                  $thisfile_audio['lossless'] = true;
1074                                  break;
1075                          }
1076  
1077                          if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line
1078                              foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { // @phpstan-ignore-line
1079                                  if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
1080                                      $thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate'];
1081                                      $thisfile_audio['bitrate'] += $dataarray['bitrate'];
1082                                      break;
1083                                  }
1084                              }
1085                          } else {
1086                              if (!empty($thisfile_asf_audiomedia_currentstream['bytes_sec'])) {
1087                                  $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bytes_sec'] * 8;
1088                              } elseif (!empty($thisfile_asf_audiomedia_currentstream['bitrate'])) {
1089                                  $thisfile_audio['bitrate'] += $thisfile_asf_audiomedia_currentstream['bitrate'];
1090                              }
1091                          }
1092                          $thisfile_audio['streams'][$streamnumber]                = $thisfile_asf_audiomedia_currentstream;
1093                          $thisfile_audio['streams'][$streamnumber]['wformattag']  = $thisfile_asf_audiomedia_currentstream['raw']['wFormatTag'];
1094                          $thisfile_audio['streams'][$streamnumber]['lossless']    = $thisfile_audio['lossless'];
1095                          $thisfile_audio['streams'][$streamnumber]['bitrate']     = $thisfile_audio['bitrate'];
1096                          $thisfile_audio['streams'][$streamnumber]['dataformat']  = 'wma';
1097                          unset($thisfile_audio['streams'][$streamnumber]['raw']);
1098  
1099                          $thisfile_asf_audiomedia_currentstream['codec_data_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $audiomediaoffset, 2));
1100                          $audiomediaoffset += 2;
1101                          $thisfile_asf_audiomedia_currentstream['codec_data']      = substr($streamdata['type_specific_data'], $audiomediaoffset, $thisfile_asf_audiomedia_currentstream['codec_data_size']);
1102                          $audiomediaoffset += $thisfile_asf_audiomedia_currentstream['codec_data_size'];
1103  
1104                          break;
1105  
1106                      case GETID3_ASF_Video_Media:
1107                          // Field Name                   Field Type   Size (bits)
1108                          // Encoded Image Width          DWORD        32              // width of image in pixels
1109                          // Encoded Image Height         DWORD        32              // height of image in pixels
1110                          // Reserved Flags               BYTE         8               // hardcoded: 0x02
1111                          // Format Data Size             WORD         16              // size of Format Data field in bytes
1112                          // Format Data                  array of:    variable        //
1113                          // * Format Data Size           DWORD        32              // number of bytes in Format Data field, in bytes - defined as biSize field of BITMAPINFOHEADER structure
1114                          // * Image Width                LONG         32              // width of encoded image in pixels - defined as biWidth field of BITMAPINFOHEADER structure
1115                          // * Image Height               LONG         32              // height of encoded image in pixels - defined as biHeight field of BITMAPINFOHEADER structure
1116                          // * Reserved                   WORD         16              // hardcoded: 0x0001 - defined as biPlanes field of BITMAPINFOHEADER structure
1117                          // * Bits Per Pixel Count       WORD         16              // bits per pixel - defined as biBitCount field of BITMAPINFOHEADER structure
1118                          // * Compression ID             FOURCC       32              // fourcc of video codec - defined as biCompression field of BITMAPINFOHEADER structure
1119                          // * Image Size                 DWORD        32              // image size in bytes - defined as biSizeImage field of BITMAPINFOHEADER structure
1120                          // * Horizontal Pixels / Meter  DWORD        32              // horizontal resolution of target device in pixels per meter - defined as biXPelsPerMeter field of BITMAPINFOHEADER structure
1121                          // * Vertical Pixels / Meter    DWORD        32              // vertical resolution of target device in pixels per meter - defined as biYPelsPerMeter field of BITMAPINFOHEADER structure
1122                          // * Colors Used Count          DWORD        32              // number of color indexes in the color table that are actually used - defined as biClrUsed field of BITMAPINFOHEADER structure
1123                          // * Important Colors Count     DWORD        32              // number of color index required for displaying bitmap. if zero, all colors are required. defined as biClrImportant field of BITMAPINFOHEADER structure
1124                          // * Codec Specific Data        BYTESTREAM   variable        // array of codec-specific data bytes
1125  
1126                          // shortcut
1127                          $thisfile_asf['video_media'][$streamnumber] = array();
1128                          $thisfile_asf_videomedia_currentstream      = &$thisfile_asf['video_media'][$streamnumber];
1129  
1130                          $videomediaoffset = 0;
1131                          $thisfile_asf_videomedia_currentstream['image_width']                     = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1132                          $videomediaoffset += 4;
1133                          $thisfile_asf_videomedia_currentstream['image_height']                    = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1134                          $videomediaoffset += 4;
1135                          $thisfile_asf_videomedia_currentstream['flags']                           = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 1));
1136                          $videomediaoffset += 1;
1137                          $thisfile_asf_videomedia_currentstream['format_data_size']                = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
1138                          $videomediaoffset += 2;
1139                          $thisfile_asf_videomedia_currentstream['format_data']['format_data_size'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1140                          $videomediaoffset += 4;
1141                          $thisfile_asf_videomedia_currentstream['format_data']['image_width']      = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1142                          $videomediaoffset += 4;
1143                          $thisfile_asf_videomedia_currentstream['format_data']['image_height']     = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1144                          $videomediaoffset += 4;
1145                          $thisfile_asf_videomedia_currentstream['format_data']['reserved']         = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
1146                          $videomediaoffset += 2;
1147                          $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel']   = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 2));
1148                          $videomediaoffset += 2;
1149                          $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']     = substr($streamdata['type_specific_data'], $videomediaoffset, 4);
1150                          $videomediaoffset += 4;
1151                          $thisfile_asf_videomedia_currentstream['format_data']['image_size']       = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1152                          $videomediaoffset += 4;
1153                          $thisfile_asf_videomedia_currentstream['format_data']['horizontal_pels']  = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1154                          $videomediaoffset += 4;
1155                          $thisfile_asf_videomedia_currentstream['format_data']['vertical_pels']    = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1156                          $videomediaoffset += 4;
1157                          $thisfile_asf_videomedia_currentstream['format_data']['colors_used']      = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1158                          $videomediaoffset += 4;
1159                          $thisfile_asf_videomedia_currentstream['format_data']['colors_important'] = getid3_lib::LittleEndian2Int(substr($streamdata['type_specific_data'], $videomediaoffset, 4));
1160                          $videomediaoffset += 4;
1161                          $thisfile_asf_videomedia_currentstream['format_data']['codec_data']       = substr($streamdata['type_specific_data'], $videomediaoffset);
1162  
1163                          if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line
1164                              foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { // @phpstan-ignore-line
1165                                  if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
1166                                      $thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate'];
1167                                      $thisfile_video['streams'][$streamnumber]['bitrate'] = $dataarray['bitrate'];
1168                                      $thisfile_video['bitrate'] += $dataarray['bitrate'];
1169                                      break;
1170                                  }
1171                              }
1172                          }
1173  
1174                          $thisfile_asf_videomedia_currentstream['format_data']['codec'] = getid3_riff::fourccLookup($thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc']);
1175  
1176                          $thisfile_video['streams'][$streamnumber]['fourcc']          = $thisfile_asf_videomedia_currentstream['format_data']['codec_fourcc'];
1177                          $thisfile_video['streams'][$streamnumber]['codec']           = $thisfile_asf_videomedia_currentstream['format_data']['codec'];
1178                          $thisfile_video['streams'][$streamnumber]['resolution_x']    = $thisfile_asf_videomedia_currentstream['image_width'];
1179                          $thisfile_video['streams'][$streamnumber]['resolution_y']    = $thisfile_asf_videomedia_currentstream['image_height'];
1180                          $thisfile_video['streams'][$streamnumber]['bits_per_sample'] = $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel'];
1181                          break;
1182  
1183                      default:
1184                          break;
1185                  }
1186              }
1187          }
1188  
1189          while ($this->ftell() < $info['avdataend']) {
1190              $NextObjectDataHeader = $this->fread(24);
1191              $offset = 0;
1192              $NextObjectGUID = substr($NextObjectDataHeader, 0, 16);
1193              $offset += 16;
1194              $NextObjectGUIDtext = $this->BytestringToGUID($NextObjectGUID);
1195              $NextObjectSize = getid3_lib::LittleEndian2Int(substr($NextObjectDataHeader, $offset, 8));
1196              $offset += 8;
1197  
1198              switch ($NextObjectGUID) {
1199                  case GETID3_ASF_Data_Object:
1200                      // Data Object: (mandatory, one only)
1201                      // Field Name                       Field Type   Size (bits)
1202                      // Object ID                        GUID         128             // GUID for Data object - GETID3_ASF_Data_Object
1203                      // Object Size                      QWORD        64              // size of Data object, including 50 bytes of Data Object header. may be 0 if FilePropertiesObject.BroadcastFlag == 1
1204                      // File ID                          GUID         128             // unique identifier. identical to File ID field in Header Object
1205                      // Total Data Packets               QWORD        64              // number of Data Packet entries in Data Object. invalid if FilePropertiesObject.BroadcastFlag == 1
1206                      // Reserved                         WORD         16              // hardcoded: 0x0101
1207  
1208                      // shortcut
1209                      $thisfile_asf['data_object'] = array();
1210                      $thisfile_asf_dataobject     = &$thisfile_asf['data_object'];
1211  
1212                      $DataObjectData = $NextObjectDataHeader.$this->fread(50 - 24);
1213                      $offset = 24;
1214  
1215                      $thisfile_asf_dataobject['objectid']           = $NextObjectGUID;
1216                      $thisfile_asf_dataobject['objectid_guid']      = $NextObjectGUIDtext;
1217                      $thisfile_asf_dataobject['objectsize']         = $NextObjectSize;
1218  
1219                      $thisfile_asf_dataobject['fileid']             = substr($DataObjectData, $offset, 16);
1220                      $offset += 16;
1221                      $thisfile_asf_dataobject['fileid_guid']        = $this->BytestringToGUID($thisfile_asf_dataobject['fileid']);
1222                      $thisfile_asf_dataobject['total_data_packets'] = getid3_lib::LittleEndian2Int(substr($DataObjectData, $offset, 8));
1223                      $offset += 8;
1224                      $thisfile_asf_dataobject['reserved']           = getid3_lib::LittleEndian2Int(substr($DataObjectData, $offset, 2));
1225                      $offset += 2;
1226                      if ($thisfile_asf_dataobject['reserved'] != 0x0101) {
1227                          $this->warning('data_object.reserved (0x'.sprintf('%04X', $thisfile_asf_dataobject['reserved']).') does not match expected value of "0x0101"');
1228                          //return false;
1229                          break;
1230                      }
1231  
1232                      // Data Packets                     array of:    variable        //
1233                      // * Error Correction Flags         BYTE         8               //
1234                      // * * Error Correction Data Length bits         4               // if Error Correction Length Type == 00, size of Error Correction Data in bytes, else hardcoded: 0000
1235                      // * * Opaque Data Present          bits         1               //
1236                      // * * Error Correction Length Type bits         2               // number of bits for size of the error correction data. hardcoded: 00
1237                      // * * Error Correction Present     bits         1               // If set, use Opaque Data Packet structure, else use Payload structure
1238                      // * Error Correction Data
1239  
1240                      $info['avdataoffset'] = $this->ftell();
1241                      $this->fseek(($thisfile_asf_dataobject['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data
1242                      $info['avdataend'] = $this->ftell();
1243                      break;
1244  
1245                  case GETID3_ASF_Simple_Index_Object:
1246                      // Simple Index Object: (optional, recommended, one per video stream)
1247                      // Field Name                       Field Type   Size (bits)
1248                      // Object ID                        GUID         128             // GUID for Simple Index object - GETID3_ASF_Data_Object
1249                      // Object Size                      QWORD        64              // size of Simple Index object, including 56 bytes of Simple Index Object header
1250                      // File ID                          GUID         128             // unique identifier. may be zero or identical to File ID field in Data Object and Header Object
1251                      // Index Entry Time Interval        QWORD        64              // interval between index entries in 100-nanosecond units
1252                      // Maximum Packet Count             DWORD        32              // maximum packet count for all index entries
1253                      // Index Entries Count              DWORD        32              // number of Index Entries structures
1254                      // Index Entries                    array of:    variable        //
1255                      // * Packet Number                  DWORD        32              // number of the Data Packet associated with this index entry
1256                      // * Packet Count                   WORD         16              // number of Data Packets to sent at this index entry
1257  
1258                      // shortcut
1259                      $thisfile_asf['simple_index_object'] = array();
1260                      $thisfile_asf_simpleindexobject      = &$thisfile_asf['simple_index_object'];
1261  
1262                      $SimpleIndexObjectData = $NextObjectDataHeader.$this->fread(56 - 24);
1263                      $offset = 24;
1264  
1265                      $thisfile_asf_simpleindexobject['objectid']                  = $NextObjectGUID;
1266                      $thisfile_asf_simpleindexobject['objectid_guid']             = $NextObjectGUIDtext;
1267                      $thisfile_asf_simpleindexobject['objectsize']                = $NextObjectSize;
1268  
1269                      $thisfile_asf_simpleindexobject['fileid']                    =                  substr($SimpleIndexObjectData, $offset, 16);
1270                      $offset += 16;
1271                      $thisfile_asf_simpleindexobject['fileid_guid']               = $this->BytestringToGUID($thisfile_asf_simpleindexobject['fileid']);
1272                      $thisfile_asf_simpleindexobject['index_entry_time_interval'] = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 8));
1273                      $offset += 8;
1274                      $thisfile_asf_simpleindexobject['maximum_packet_count']      = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
1275                      $offset += 4;
1276                      $thisfile_asf_simpleindexobject['index_entries_count']       = getid3_lib::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
1277                      /** @var int|float|false $totalIndexEntriesCount */
1278                      $totalIndexEntriesCount = $thisfile_asf_simpleindexobject['index_entries_count'];
1279                      $offset += 4;
1280  
1281                      $IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $totalIndexEntriesCount);
1282                      for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $totalIndexEntriesCount; $IndexEntriesCounter++) {
1283                          $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]                  = array();
1284                          $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
1285                          $offset += 4;
1286                          $thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_count']  = getid3_lib::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
1287                          $offset += 2;
1288                      }
1289  
1290                      break;
1291  
1292                  case GETID3_ASF_Index_Object:
1293                      // 6.2 ASF top-level Index Object (optional but recommended when appropriate, 0 or 1)
1294                      // Field Name                       Field Type   Size (bits)
1295                      // Object ID                        GUID         128             // GUID for the Index Object - GETID3_ASF_Index_Object
1296                      // Object Size                      QWORD        64              // Specifies the size, in bytes, of the Index Object, including at least 34 bytes of Index Object header
1297                      // Index Entry Time Interval        DWORD        32              // Specifies the time interval between each index entry in ms.
1298                      // Index Specifiers Count           WORD         16              // Specifies the number of Index Specifiers structures in this Index Object.
1299                      // Index Blocks Count               DWORD        32              // Specifies the number of Index Blocks structures in this Index Object.
1300  
1301                      // Index Entry Time Interval        DWORD        32              // Specifies the time interval between index entries in milliseconds.  This value cannot be 0.
1302                      // Index Specifiers Count           WORD         16              // Specifies the number of entries in the Index Specifiers list.  Valid values are 1 and greater.
1303                      // Index Specifiers                 array of:    varies          //
1304                      // * Stream Number                  WORD         16              // Specifies the stream number that the Index Specifiers refer to. Valid values are between 1 and 127.
1305                      // * Index Type                     WORD         16              // Specifies Index Type values as follows:
1306                                                                                      //   1 = Nearest Past Data Packet - indexes point to the data packet whose presentation time is closest to the index entry time.
1307                                                                                      //   2 = Nearest Past Media Object - indexes point to the closest data packet containing an entire object or first fragment of an object.
1308                                                                                      //   3 = Nearest Past Cleanpoint. - indexes point to the closest data packet containing an entire object (or first fragment of an object) that has the Cleanpoint Flag set.
1309                                                                                      //   Nearest Past Cleanpoint is the most common type of index.
1310                      // Index Entry Count                DWORD        32              // Specifies the number of Index Entries in the block.
1311                      // * Block Positions                QWORD        varies          // Specifies a list of byte offsets of the beginnings of the blocks relative to the beginning of the first Data Packet (i.e., the beginning of the Data Object + 50 bytes). The number of entries in this list is specified by the value of the Index Specifiers Count field. The order of those byte offsets is tied to the order in which Index Specifiers are listed.
1312                      // * Index Entries                  array of:    varies          //
1313                      // * * Offsets                      DWORD        varies          // An offset value of 0xffffffff indicates an invalid offset value
1314  
1315                      // shortcut
1316                      $thisfile_asf['asf_index_object'] = array();
1317                      $thisfile_asf_asfindexobject      = &$thisfile_asf['asf_index_object'];
1318  
1319                      $ASFIndexObjectData = $NextObjectDataHeader.$this->fread(34 - 24);
1320                      $offset = 24;
1321  
1322                      $thisfile_asf_asfindexobject['objectid']                  = $NextObjectGUID;
1323                      $thisfile_asf_asfindexobject['objectid_guid']             = $NextObjectGUIDtext;
1324                      $thisfile_asf_asfindexobject['objectsize']                = $NextObjectSize;
1325  
1326                      $thisfile_asf_asfindexobject['entry_time_interval']       = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
1327                      $offset += 4;
1328                      $thisfile_asf_asfindexobject['index_specifiers_count']    = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
1329                      $offset += 2;
1330                      $thisfile_asf_asfindexobject['index_blocks_count']        = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
1331                      $offset += 4;
1332  
1333                      $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count']);
1334                      for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
1335                          $IndexSpecifierStreamNumber = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
1336                          $offset += 2;
1337                          $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]                    = array();
1338                          $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number']   = $IndexSpecifierStreamNumber;
1339                          $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']      = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
1340                          $offset += 2;
1341                          $thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type_text'] = $this->ASFIndexObjectIndexTypeLookup($thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type']);
1342                      }
1343  
1344                      $ASFIndexObjectData .= $this->fread(4);
1345                      $thisfile_asf_asfindexobject['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
1346                      /** @var int|float|false $totalIndexEntryCount */
1347                      $totalIndexEntryCount = $thisfile_asf_asfindexobject['index_entry_count'];
1348                      $offset += 4;
1349  
1350                      $ASFIndexObjectData .= $this->fread(8 * $thisfile_asf_asfindexobject['index_specifiers_count']);
1351                      for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
1352                          $thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8));
1353                          $offset += 8;
1354                      }
1355  
1356                      $ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']);
1357                      for ($IndexEntryCounter = 0; $IndexEntryCounter < $totalIndexEntryCount; $IndexEntryCounter++) {
1358                          for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
1359                              $thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = getid3_lib::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
1360                              $offset += 4;
1361                          }
1362                      }
1363                      break;
1364  
1365  
1366                  default:
1367                      // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
1368                      if ($this->GUIDname($NextObjectGUIDtext)) {
1369                          $this->warning('unhandled GUID "'.$this->GUIDname($NextObjectGUIDtext).'" {'.$NextObjectGUIDtext.'} in ASF body at offset '.($offset - 16 - 8));
1370                      } else {
1371                          $this->warning('unknown GUID {'.$NextObjectGUIDtext.'} in ASF body at offset '.($this->ftell() - 16 - 8));
1372                      }
1373                      $this->fseek(($NextObjectSize - 16 - 8), SEEK_CUR);
1374                      break;
1375              }
1376          }
1377  
1378          if (isset($thisfile_asf_codeclistobject['codec_entries']) && is_array($thisfile_asf_codeclistobject['codec_entries'])) {
1379              foreach ($thisfile_asf_codeclistobject['codec_entries'] as $streamnumber => $streamdata) {
1380                  switch ($streamdata['information']) {
1381                      case 'WMV1':
1382                      case 'WMV2':
1383                      case 'WMV3':
1384                      case 'MSS1':
1385                      case 'MSS2':
1386                      case 'WMVA':
1387                      case 'WVC1':
1388                      case 'WMVP':
1389                      case 'WVP2':
1390                          $thisfile_video['dataformat'] = 'wmv';
1391                          $info['mime_type'] = 'video/x-ms-wmv';
1392                          break;
1393  
1394                      case 'MP42':
1395                      case 'MP43':
1396                      case 'MP4S':
1397                      case 'mp4s':
1398                          $thisfile_video['dataformat'] = 'asf';
1399                          $info['mime_type'] = 'video/x-ms-asf';
1400                          break;
1401  
1402                      default:
1403                          switch ($streamdata['type_raw']) {
1404                              case 1:
1405                                  if (strstr($this->TrimConvert($streamdata['name']), 'Windows Media')) {
1406                                      $thisfile_video['dataformat'] = 'wmv';
1407                                      if ($info['mime_type'] == 'video/x-ms-asf') {
1408                                          $info['mime_type'] = 'video/x-ms-wmv';
1409                                      }
1410                                  }
1411                                  break;
1412  
1413                              case 2:
1414                                  if (strstr($this->TrimConvert($streamdata['name']), 'Windows Media')) {
1415                                      $thisfile_audio['dataformat'] = 'wma';
1416                                      if ($info['mime_type'] == 'video/x-ms-asf') {
1417                                          $info['mime_type'] = 'audio/x-ms-wma';
1418                                      }
1419                                  }
1420                                  break;
1421  
1422                          }
1423                          break;
1424                  }
1425              }
1426          }
1427  
1428          switch (isset($thisfile_audio['codec']) ? $thisfile_audio['codec'] : '') {
1429              case 'MPEG Layer-3':
1430                  $thisfile_audio['dataformat'] = 'mp3';
1431                  break;
1432  
1433              default:
1434                  break;
1435          }
1436  
1437          if (isset($thisfile_asf_codeclistobject['codec_entries'])) {
1438              foreach ($thisfile_asf_codeclistobject['codec_entries'] as $streamnumber => $streamdata) {
1439                  switch ($streamdata['type_raw']) {
1440  
1441                      case 1: // video
1442                          $thisfile_video['encoder'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][$streamnumber]['name']);
1443                          break;
1444  
1445                      case 2: // audio
1446                          $thisfile_audio['encoder'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][$streamnumber]['name']);
1447  
1448                          // AH 2003-10-01
1449                          $thisfile_audio['encoder_options'] = $this->TrimConvert($thisfile_asf_codeclistobject['codec_entries'][0]['description']);
1450  
1451                          $thisfile_audio['codec']   = $thisfile_audio['encoder'];
1452                          break;
1453  
1454                      default:
1455                          $this->warning('Unknown streamtype: [codec_list_object][codec_entries]['.$streamnumber.'][type_raw] == '.$streamdata['type_raw']);
1456                          break;
1457  
1458                  }
1459              }
1460          }
1461  
1462          if (isset($info['audio'])) {
1463              $thisfile_audio['lossless']           = (isset($thisfile_audio['lossless'])           ? $thisfile_audio['lossless']           : false);
1464              $thisfile_audio['dataformat']         = (!empty($thisfile_audio['dataformat'])        ? $thisfile_audio['dataformat']         : 'asf');
1465          }
1466          if (!empty($thisfile_video['dataformat'])) {
1467              $thisfile_video['lossless']           = (isset($thisfile_audio['lossless'])           ? $thisfile_audio['lossless']           : false);
1468              $thisfile_video['pixel_aspect_ratio'] = (isset($thisfile_audio['pixel_aspect_ratio']) ? $thisfile_audio['pixel_aspect_ratio'] : (float) 1);
1469              $thisfile_video['dataformat']         = (!empty($thisfile_video['dataformat'])        ? $thisfile_video['dataformat']         : 'asf');
1470          }
1471          if (!empty($thisfile_video['streams'])) {
1472              $thisfile_video['resolution_x'] = 0;
1473              $thisfile_video['resolution_y'] = 0;
1474              foreach ($thisfile_video['streams'] as $key => $valuearray) {
1475                  if (($valuearray['resolution_x'] > $thisfile_video['resolution_x']) || ($valuearray['resolution_y'] > $thisfile_video['resolution_y'])) {
1476                      $thisfile_video['resolution_x'] = $valuearray['resolution_x'];
1477                      $thisfile_video['resolution_y'] = $valuearray['resolution_y'];
1478                  }
1479              }
1480          }
1481          $info['bitrate'] = 0 + (isset($thisfile_audio['bitrate']) ? $thisfile_audio['bitrate'] : 0) + (isset($thisfile_video['bitrate']) ? $thisfile_video['bitrate'] : 0);
1482  
1483          if ((!isset($info['playtime_seconds']) || ($info['playtime_seconds'] <= 0)) && ($info['bitrate'] > 0)) {
1484              $info['playtime_seconds'] = ($info['filesize'] - $info['avdataoffset']) / ($info['bitrate'] / 8);
1485          }
1486  
1487          return true;
1488      }
1489  
1490      /**
1491       * @param int $CodecListType
1492       *
1493       * @return string
1494       */
1495  	public static function codecListObjectTypeLookup($CodecListType) {
1496          static $lookup = array(
1497              0x0001 => 'Video Codec',
1498              0x0002 => 'Audio Codec',
1499              0xFFFF => 'Unknown Codec'
1500          );
1501  
1502          return (isset($lookup[$CodecListType]) ? $lookup[$CodecListType] : 'Invalid Codec Type');
1503      }
1504  
1505      /**
1506       * @return array
1507       */
1508  	public static function KnownGUIDs() {
1509          static $GUIDarray = array(
1510              'GETID3_ASF_Extended_Stream_Properties_Object'   => '14E6A5CB-C672-4332-8399-A96952065B5A',
1511              'GETID3_ASF_Padding_Object'                      => '1806D474-CADF-4509-A4BA-9AABCB96AAE8',
1512              'GETID3_ASF_Payload_Ext_Syst_Pixel_Aspect_Ratio' => '1B1EE554-F9EA-4BC8-821A-376B74E4C4B8',
1513              'GETID3_ASF_Script_Command_Object'               => '1EFB1A30-0B62-11D0-A39B-00A0C90348F6',
1514              'GETID3_ASF_No_Error_Correction'                 => '20FB5700-5B55-11CF-A8FD-00805F5C442B',
1515              'GETID3_ASF_Content_Branding_Object'             => '2211B3FA-BD23-11D2-B4B7-00A0C955FC6E',
1516              'GETID3_ASF_Content_Encryption_Object'           => '2211B3FB-BD23-11D2-B4B7-00A0C955FC6E',
1517              'GETID3_ASF_Digital_Signature_Object'            => '2211B3FC-BD23-11D2-B4B7-00A0C955FC6E',
1518              'GETID3_ASF_Extended_Content_Encryption_Object'  => '298AE614-2622-4C17-B935-DAE07EE9289C',
1519              'GETID3_ASF_Simple_Index_Object'                 => '33000890-E5B1-11CF-89F4-00A0C90349CB',
1520              'GETID3_ASF_Degradable_JPEG_Media'               => '35907DE0-E415-11CF-A917-00805F5C442B',
1521              'GETID3_ASF_Payload_Extension_System_Timecode'   => '399595EC-8667-4E2D-8FDB-98814CE76C1E',
1522              'GETID3_ASF_Binary_Media'                        => '3AFB65E2-47EF-40F2-AC2C-70A90D71D343',
1523              'GETID3_ASF_Timecode_Index_Object'               => '3CB73FD0-0C4A-4803-953D-EDF7B6228F0C',
1524              'GETID3_ASF_Metadata_Library_Object'             => '44231C94-9498-49D1-A141-1D134E457054',
1525              'GETID3_ASF_Reserved_3'                          => '4B1ACBE3-100B-11D0-A39B-00A0C90348F6',
1526              'GETID3_ASF_Reserved_4'                          => '4CFEDB20-75F6-11CF-9C0F-00A0C90349CB',
1527              'GETID3_ASF_Command_Media'                       => '59DACFC0-59E6-11D0-A3AC-00A0C90348F6',
1528              'GETID3_ASF_Header_Extension_Object'             => '5FBF03B5-A92E-11CF-8EE3-00C00C205365',
1529              'GETID3_ASF_Media_Object_Index_Parameters_Obj'   => '6B203BAD-3F11-4E84-ACA8-D7613DE2CFA7',
1530              'GETID3_ASF_Header_Object'                       => '75B22630-668E-11CF-A6D9-00AA0062CE6C',
1531              'GETID3_ASF_Content_Description_Object'          => '75B22633-668E-11CF-A6D9-00AA0062CE6C',
1532              'GETID3_ASF_Error_Correction_Object'             => '75B22635-668E-11CF-A6D9-00AA0062CE6C',
1533              'GETID3_ASF_Data_Object'                         => '75B22636-668E-11CF-A6D9-00AA0062CE6C',
1534              'GETID3_ASF_Web_Stream_Media_Subtype'            => '776257D4-C627-41CB-8F81-7AC7FF1C40CC',
1535              'GETID3_ASF_Stream_Bitrate_Properties_Object'    => '7BF875CE-468D-11D1-8D82-006097C9A2B2',
1536              'GETID3_ASF_Language_List_Object'                => '7C4346A9-EFE0-4BFC-B229-393EDE415C85',
1537              'GETID3_ASF_Codec_List_Object'                   => '86D15240-311D-11D0-A3A4-00A0C90348F6',
1538              'GETID3_ASF_Reserved_2'                          => '86D15241-311D-11D0-A3A4-00A0C90348F6',
1539              'GETID3_ASF_File_Properties_Object'              => '8CABDCA1-A947-11CF-8EE4-00C00C205365',
1540              'GETID3_ASF_File_Transfer_Media'                 => '91BD222C-F21C-497A-8B6D-5AA86BFC0185',
1541              'GETID3_ASF_Old_RTP_Extension_Data'              => '96800C63-4C94-11D1-837B-0080C7A37F95',
1542              'GETID3_ASF_Advanced_Mutual_Exclusion_Object'    => 'A08649CF-4775-4670-8A16-6E35357566CD',
1543              'GETID3_ASF_Bandwidth_Sharing_Object'            => 'A69609E6-517B-11D2-B6AF-00C04FD908E9',
1544              'GETID3_ASF_Reserved_1'                          => 'ABD3D211-A9BA-11cf-8EE6-00C00C205365',
1545              'GETID3_ASF_Bandwidth_Sharing_Exclusive'         => 'AF6060AA-5197-11D2-B6AF-00C04FD908E9',
1546              'GETID3_ASF_Bandwidth_Sharing_Partial'           => 'AF6060AB-5197-11D2-B6AF-00C04FD908E9',
1547              'GETID3_ASF_JFIF_Media'                          => 'B61BE100-5B4E-11CF-A8FD-00805F5C442B',
1548              'GETID3_ASF_Stream_Properties_Object'            => 'B7DC0791-A9B7-11CF-8EE6-00C00C205365',
1549              'GETID3_ASF_Video_Media'                         => 'BC19EFC0-5B4D-11CF-A8FD-00805F5C442B',
1550              'GETID3_ASF_Audio_Spread'                        => 'BFC3CD50-618F-11CF-8BB2-00AA00B4E220',
1551              'GETID3_ASF_Metadata_Object'                     => 'C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA',
1552              'GETID3_ASF_Payload_Ext_Syst_Sample_Duration'    => 'C6BD9450-867F-4907-83A3-C77921B733AD',
1553              'GETID3_ASF_Group_Mutual_Exclusion_Object'       => 'D1465A40-5A79-4338-B71B-E36B8FD6C249',
1554              'GETID3_ASF_Extended_Content_Description_Object' => 'D2D0A440-E307-11D2-97F0-00A0C95EA850',
1555              'GETID3_ASF_Stream_Prioritization_Object'        => 'D4FED15B-88D3-454F-81F0-ED5C45999E24',
1556              'GETID3_ASF_Payload_Ext_System_Content_Type'     => 'D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC',
1557              'GETID3_ASF_Old_File_Properties_Object'          => 'D6E229D0-35DA-11D1-9034-00A0C90349BE',
1558              'GETID3_ASF_Old_ASF_Header_Object'               => 'D6E229D1-35DA-11D1-9034-00A0C90349BE',
1559              'GETID3_ASF_Old_ASF_Data_Object'                 => 'D6E229D2-35DA-11D1-9034-00A0C90349BE',
1560              'GETID3_ASF_Index_Object'                        => 'D6E229D3-35DA-11D1-9034-00A0C90349BE',
1561              'GETID3_ASF_Old_Stream_Properties_Object'        => 'D6E229D4-35DA-11D1-9034-00A0C90349BE',
1562              'GETID3_ASF_Old_Content_Description_Object'      => 'D6E229D5-35DA-11D1-9034-00A0C90349BE',
1563              'GETID3_ASF_Old_Script_Command_Object'           => 'D6E229D6-35DA-11D1-9034-00A0C90349BE',
1564              'GETID3_ASF_Old_Marker_Object'                   => 'D6E229D7-35DA-11D1-9034-00A0C90349BE',
1565              'GETID3_ASF_Old_Component_Download_Object'       => 'D6E229D8-35DA-11D1-9034-00A0C90349BE',
1566              'GETID3_ASF_Old_Stream_Group_Object'             => 'D6E229D9-35DA-11D1-9034-00A0C90349BE',
1567              'GETID3_ASF_Old_Scalable_Object'                 => 'D6E229DA-35DA-11D1-9034-00A0C90349BE',
1568              'GETID3_ASF_Old_Prioritization_Object'           => 'D6E229DB-35DA-11D1-9034-00A0C90349BE',
1569              'GETID3_ASF_Bitrate_Mutual_Exclusion_Object'     => 'D6E229DC-35DA-11D1-9034-00A0C90349BE',
1570              'GETID3_ASF_Old_Inter_Media_Dependency_Object'   => 'D6E229DD-35DA-11D1-9034-00A0C90349BE',
1571              'GETID3_ASF_Old_Rating_Object'                   => 'D6E229DE-35DA-11D1-9034-00A0C90349BE',
1572              'GETID3_ASF_Index_Parameters_Object'             => 'D6E229DF-35DA-11D1-9034-00A0C90349BE',
1573              'GETID3_ASF_Old_Color_Table_Object'              => 'D6E229E0-35DA-11D1-9034-00A0C90349BE',
1574              'GETID3_ASF_Old_Language_List_Object'            => 'D6E229E1-35DA-11D1-9034-00A0C90349BE',
1575              'GETID3_ASF_Old_Audio_Media'                     => 'D6E229E2-35DA-11D1-9034-00A0C90349BE',
1576              'GETID3_ASF_Old_Video_Media'                     => 'D6E229E3-35DA-11D1-9034-00A0C90349BE',
1577              'GETID3_ASF_Old_Image_Media'                     => 'D6E229E4-35DA-11D1-9034-00A0C90349BE',
1578              'GETID3_ASF_Old_Timecode_Media'                  => 'D6E229E5-35DA-11D1-9034-00A0C90349BE',
1579              'GETID3_ASF_Old_Text_Media'                      => 'D6E229E6-35DA-11D1-9034-00A0C90349BE',
1580              'GETID3_ASF_Old_MIDI_Media'                      => 'D6E229E7-35DA-11D1-9034-00A0C90349BE',
1581              'GETID3_ASF_Old_Command_Media'                   => 'D6E229E8-35DA-11D1-9034-00A0C90349BE',
1582              'GETID3_ASF_Old_No_Error_Concealment'            => 'D6E229EA-35DA-11D1-9034-00A0C90349BE',
1583              'GETID3_ASF_Old_Scrambled_Audio'                 => 'D6E229EB-35DA-11D1-9034-00A0C90349BE',
1584              'GETID3_ASF_Old_No_Color_Table'                  => 'D6E229EC-35DA-11D1-9034-00A0C90349BE',
1585              'GETID3_ASF_Old_SMPTE_Time'                      => 'D6E229ED-35DA-11D1-9034-00A0C90349BE',
1586              'GETID3_ASF_Old_ASCII_Text'                      => 'D6E229EE-35DA-11D1-9034-00A0C90349BE',
1587              'GETID3_ASF_Old_Unicode_Text'                    => 'D6E229EF-35DA-11D1-9034-00A0C90349BE',
1588              'GETID3_ASF_Old_HTML_Text'                       => 'D6E229F0-35DA-11D1-9034-00A0C90349BE',
1589              'GETID3_ASF_Old_URL_Command'                     => 'D6E229F1-35DA-11D1-9034-00A0C90349BE',
1590              'GETID3_ASF_Old_Filename_Command'                => 'D6E229F2-35DA-11D1-9034-00A0C90349BE',
1591              'GETID3_ASF_Old_ACM_Codec'                       => 'D6E229F3-35DA-11D1-9034-00A0C90349BE',
1592              'GETID3_ASF_Old_VCM_Codec'                       => 'D6E229F4-35DA-11D1-9034-00A0C90349BE',
1593              'GETID3_ASF_Old_QuickTime_Codec'                 => 'D6E229F5-35DA-11D1-9034-00A0C90349BE',
1594              'GETID3_ASF_Old_DirectShow_Transform_Filter'     => 'D6E229F6-35DA-11D1-9034-00A0C90349BE',
1595              'GETID3_ASF_Old_DirectShow_Rendering_Filter'     => 'D6E229F7-35DA-11D1-9034-00A0C90349BE',
1596              'GETID3_ASF_Old_No_Enhancement'                  => 'D6E229F8-35DA-11D1-9034-00A0C90349BE',
1597              'GETID3_ASF_Old_Unknown_Enhancement_Type'        => 'D6E229F9-35DA-11D1-9034-00A0C90349BE',
1598              'GETID3_ASF_Old_Temporal_Enhancement'            => 'D6E229FA-35DA-11D1-9034-00A0C90349BE',
1599              'GETID3_ASF_Old_Spatial_Enhancement'             => 'D6E229FB-35DA-11D1-9034-00A0C90349BE',
1600              'GETID3_ASF_Old_Quality_Enhancement'             => 'D6E229FC-35DA-11D1-9034-00A0C90349BE',
1601              'GETID3_ASF_Old_Number_of_Channels_Enhancement'  => 'D6E229FD-35DA-11D1-9034-00A0C90349BE',
1602              'GETID3_ASF_Old_Frequency_Response_Enhancement'  => 'D6E229FE-35DA-11D1-9034-00A0C90349BE',
1603              'GETID3_ASF_Old_Media_Object'                    => 'D6E229FF-35DA-11D1-9034-00A0C90349BE',
1604              'GETID3_ASF_Mutex_Language'                      => 'D6E22A00-35DA-11D1-9034-00A0C90349BE',
1605              'GETID3_ASF_Mutex_Bitrate'                       => 'D6E22A01-35DA-11D1-9034-00A0C90349BE',
1606              'GETID3_ASF_Mutex_Unknown'                       => 'D6E22A02-35DA-11D1-9034-00A0C90349BE',
1607              'GETID3_ASF_Old_ASF_Placeholder_Object'          => 'D6E22A0E-35DA-11D1-9034-00A0C90349BE',
1608              'GETID3_ASF_Old_Data_Unit_Extension_Object'      => 'D6E22A0F-35DA-11D1-9034-00A0C90349BE',
1609              'GETID3_ASF_Web_Stream_Format'                   => 'DA1E6B13-8359-4050-B398-388E965BF00C',
1610              'GETID3_ASF_Payload_Ext_System_File_Name'        => 'E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B',
1611              'GETID3_ASF_Marker_Object'                       => 'F487CD01-A951-11CF-8EE6-00C00C205365',
1612              'GETID3_ASF_Timecode_Index_Parameters_Object'    => 'F55E496D-9797-4B5D-8C8B-604DFE9BFB24',
1613              'GETID3_ASF_Audio_Media'                         => 'F8699E40-5B4D-11CF-A8FD-00805F5C442B',
1614              'GETID3_ASF_Media_Object_Index_Object'           => 'FEB103F8-12AD-4C64-840F-2A1D2F7AD48C',
1615              'GETID3_ASF_Alt_Extended_Content_Encryption_Obj' => 'FF889EF1-ADEE-40DA-9E71-98704BB928CE',
1616              'GETID3_ASF_Index_Placeholder_Object'            => 'D9AADE20-7C17-4F9C-BC28-8555DD98E2A2', // https://metacpan.org/dist/Audio-WMA/source/WMA.pm
1617              'GETID3_ASF_Compatibility_Object'                => '26F18B5D-4584-47EC-9F5F-0E651F0452C9', // https://metacpan.org/dist/Audio-WMA/source/WMA.pm
1618              'GETID3_ASF_Media_Object_Index_Parameters_Object'=> '6B203BAD-3F11-48E4-ACA8-D7613DE2CFA7',
1619          );
1620          return $GUIDarray;
1621      }
1622  
1623      /**
1624       * @param string $GUIDstring
1625       *
1626       * @return string|false
1627       */
1628  	public static function GUIDname($GUIDstring) {
1629          static $GUIDarray = array();
1630          if (empty($GUIDarray)) {
1631              $GUIDarray = self::KnownGUIDs();
1632          }
1633          return array_search($GUIDstring, $GUIDarray);
1634      }
1635  
1636      /**
1637       * @param int $id
1638       *
1639       * @return string
1640       */
1641  	public static function ASFIndexObjectIndexTypeLookup($id) {
1642          static $ASFIndexObjectIndexTypeLookup = array();
1643          if (empty($ASFIndexObjectIndexTypeLookup)) {
1644              $ASFIndexObjectIndexTypeLookup[1] = 'Nearest Past Data Packet';
1645              $ASFIndexObjectIndexTypeLookup[2] = 'Nearest Past Media Object';
1646              $ASFIndexObjectIndexTypeLookup[3] = 'Nearest Past Cleanpoint';
1647          }
1648          return (isset($ASFIndexObjectIndexTypeLookup[$id]) ? $ASFIndexObjectIndexTypeLookup[$id] : 'invalid');
1649      }
1650  
1651      /**
1652       * @param string $GUIDstring
1653       *
1654       * @return string
1655       */
1656  	public static function GUIDtoBytestring($GUIDstring) {
1657          // Microsoft defines these 16-byte (128-bit) GUIDs in the strangest way:
1658          // first 4 bytes are in little-endian order
1659          // next 2 bytes are appended in little-endian order
1660          // next 2 bytes are appended in little-endian order
1661          // next 2 bytes are appended in big-endian order
1662          // next 6 bytes are appended in big-endian order
1663  
1664          // AaBbCcDd-EeFf-GgHh-IiJj-KkLlMmNnOoPp is stored as this 16-byte string:
1665          // $Dd $Cc $Bb $Aa $Ff $Ee $Hh $Gg $Ii $Jj $Kk $Ll $Mm $Nn $Oo $Pp
1666  
1667          $hexbytecharstring  = chr(hexdec(substr($GUIDstring,  6, 2)));
1668          $hexbytecharstring .= chr(hexdec(substr($GUIDstring,  4, 2)));
1669          $hexbytecharstring .= chr(hexdec(substr($GUIDstring,  2, 2)));
1670          $hexbytecharstring .= chr(hexdec(substr($GUIDstring,  0, 2)));
1671  
1672          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 11, 2)));
1673          $hexbytecharstring .= chr(hexdec(substr($GUIDstring,  9, 2)));
1674  
1675          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 16, 2)));
1676          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 14, 2)));
1677  
1678          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 19, 2)));
1679          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 21, 2)));
1680  
1681          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 24, 2)));
1682          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 26, 2)));
1683          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 28, 2)));
1684          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 30, 2)));
1685          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 32, 2)));
1686          $hexbytecharstring .= chr(hexdec(substr($GUIDstring, 34, 2)));
1687  
1688          return $hexbytecharstring;
1689      }
1690  
1691      /**
1692       * @param string $Bytestring
1693       *
1694       * @return string
1695       */
1696  	public static function BytestringToGUID($Bytestring) {
1697          $GUIDstring  = str_pad(dechex(ord($Bytestring[3])),  2, '0', STR_PAD_LEFT);
1698          $GUIDstring .= str_pad(dechex(ord($Bytestring[2])),  2, '0', STR_PAD_LEFT);
1699          $GUIDstring .= str_pad(dechex(ord($Bytestring[1])),  2, '0', STR_PAD_LEFT);
1700          $GUIDstring .= str_pad(dechex(ord($Bytestring[0])),  2, '0', STR_PAD_LEFT);
1701          $GUIDstring .= '-';
1702          $GUIDstring .= str_pad(dechex(ord($Bytestring[5])),  2, '0', STR_PAD_LEFT);
1703          $GUIDstring .= str_pad(dechex(ord($Bytestring[4])),  2, '0', STR_PAD_LEFT);
1704          $GUIDstring .= '-';
1705          $GUIDstring .= str_pad(dechex(ord($Bytestring[7])),  2, '0', STR_PAD_LEFT);
1706          $GUIDstring .= str_pad(dechex(ord($Bytestring[6])),  2, '0', STR_PAD_LEFT);
1707          $GUIDstring .= '-';
1708          $GUIDstring .= str_pad(dechex(ord($Bytestring[8])),  2, '0', STR_PAD_LEFT);
1709          $GUIDstring .= str_pad(dechex(ord($Bytestring[9])),  2, '0', STR_PAD_LEFT);
1710          $GUIDstring .= '-';
1711          $GUIDstring .= str_pad(dechex(ord($Bytestring[10])), 2, '0', STR_PAD_LEFT);
1712          $GUIDstring .= str_pad(dechex(ord($Bytestring[11])), 2, '0', STR_PAD_LEFT);
1713          $GUIDstring .= str_pad(dechex(ord($Bytestring[12])), 2, '0', STR_PAD_LEFT);
1714          $GUIDstring .= str_pad(dechex(ord($Bytestring[13])), 2, '0', STR_PAD_LEFT);
1715          $GUIDstring .= str_pad(dechex(ord($Bytestring[14])), 2, '0', STR_PAD_LEFT);
1716          $GUIDstring .= str_pad(dechex(ord($Bytestring[15])), 2, '0', STR_PAD_LEFT);
1717  
1718          return strtoupper($GUIDstring);
1719      }
1720  
1721      /**
1722       * @param int  $FILETIME
1723       * @param bool $round
1724       *
1725       * @return float|int
1726       */
1727  	public static function FILETIMEtoUNIXtime($FILETIME, $round=true) {
1728          // FILETIME is a 64-bit unsigned integer representing
1729          // the number of 100-nanosecond intervals since January 1, 1601
1730          // UNIX timestamp is number of seconds since January 1, 1970
1731          // 116444736000000000 = 10000000 * 60 * 60 * 24 * 365 * 369 + 89 leap days
1732          if ($round) {
1733              return intval(round(($FILETIME - 116444736000000000) / 10000000));
1734          }
1735          return ($FILETIME - 116444736000000000) / 10000000;
1736      }
1737  
1738      /**
1739       * @param int $WMpictureType
1740       *
1741       * @return string
1742       */
1743  	public static function WMpictureTypeLookup($WMpictureType) {
1744          static $lookup = null;
1745          if ($lookup === null) {
1746              $lookup = array(
1747                  0x03 => 'Front Cover',
1748                  0x04 => 'Back Cover',
1749                  0x00 => 'User Defined',
1750                  0x05 => 'Leaflet Page',
1751                  0x06 => 'Media Label',
1752                  0x07 => 'Lead Artist',
1753                  0x08 => 'Artist',
1754                  0x09 => 'Conductor',
1755                  0x0A => 'Band',
1756                  0x0B => 'Composer',
1757                  0x0C => 'Lyricist',
1758                  0x0D => 'Recording Location',
1759                  0x0E => 'During Recording',
1760                  0x0F => 'During Performance',
1761                  0x10 => 'Video Screen Capture',
1762                  0x12 => 'Illustration',
1763                  0x13 => 'Band Logotype',
1764                  0x14 => 'Publisher Logotype'
1765              );
1766              $lookup = array_map(function($str) {
1767                  return getid3_lib::iconv_fallback('UTF-8', 'UTF-16LE', $str);
1768              }, $lookup);
1769          }
1770  
1771          return (isset($lookup[$WMpictureType]) ? $lookup[$WMpictureType] : '');
1772      }
1773  
1774      /**
1775       * @param string $asf_header_extension_object_data
1776       * @param int    $unhandled_sections
1777       *
1778       * @return array
1779       */
1780  	public function HeaderExtensionObjectDataParse(&$asf_header_extension_object_data, &$unhandled_sections) {
1781          // https://web.archive.org/web/20140419205228/http://msdn.microsoft.com/en-us/library/bb643323.aspx
1782  
1783          $offset = 0;
1784          $objectOffset = 0;
1785          $HeaderExtensionObjectParsed = array();
1786          while ($objectOffset < strlen($asf_header_extension_object_data)) {
1787              $offset = $objectOffset;
1788              $thisObject = array();
1789  
1790              $thisObject['guid']                              =                              substr($asf_header_extension_object_data, $offset, 16);
1791              $offset += 16;
1792              $thisObject['guid_text'] = $this->BytestringToGUID($thisObject['guid']);
1793              $thisObject['guid_name'] = $this->GUIDname($thisObject['guid_text']);
1794  
1795              $thisObject['size']                              = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  8));
1796              $offset += 8;
1797              if ($thisObject['size'] <= 0) {
1798                  break;
1799              }
1800  
1801              switch ($thisObject['guid']) {
1802                  case GETID3_ASF_Extended_Stream_Properties_Object:
1803                      $thisObject['start_time']                        = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  8));
1804                      $offset += 8;
1805                      $thisObject['start_time_unix']                   = $this->FILETIMEtoUNIXtime($thisObject['start_time']);
1806  
1807                      $thisObject['end_time']                          = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  8));
1808                      $offset += 8;
1809                      $thisObject['end_time_unix']                     = $this->FILETIMEtoUNIXtime($thisObject['end_time']);
1810  
1811                      $thisObject['data_bitrate']                      = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1812                      $offset += 4;
1813  
1814                      $thisObject['buffer_size']                       = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1815                      $offset += 4;
1816  
1817                      $thisObject['initial_buffer_fullness']           = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1818                      $offset += 4;
1819  
1820                      $thisObject['alternate_data_bitrate']            = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1821                      $offset += 4;
1822  
1823                      $thisObject['alternate_buffer_size']             = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1824                      $offset += 4;
1825  
1826                      $thisObject['alternate_initial_buffer_fullness'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1827                      $offset += 4;
1828  
1829                      $thisObject['maximum_object_size']               = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1830                      $offset += 4;
1831  
1832                      $thisObject['flags_raw']                         = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1833                      $offset += 4;
1834                      $thisObject['flags']['reliable']                = (bool) $thisObject['flags_raw'] & 0x00000001;
1835                      $thisObject['flags']['seekable']                = (bool) $thisObject['flags_raw'] & 0x00000002;
1836                      $thisObject['flags']['no_cleanpoints']          = (bool) $thisObject['flags_raw'] & 0x00000004;
1837                      $thisObject['flags']['resend_live_cleanpoints'] = (bool) $thisObject['flags_raw'] & 0x00000008;
1838  
1839                      $thisObject['stream_number']                     = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1840                      $offset += 2;
1841  
1842                      $thisObject['stream_language_id_index']          = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1843                      $offset += 2;
1844  
1845                      $thisObject['average_time_per_frame']            = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  8));
1846                      $offset += 8;
1847  
1848                      $thisObject['stream_name_count']                 = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1849                      $offset += 2;
1850  
1851                      $thisObject['payload_extension_system_count']    = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1852                      $offset += 2;
1853  
1854                      for ($i = 0; $i < $thisObject['stream_name_count']; $i++) {
1855                          $streamName = array();
1856  
1857                          $streamName['language_id_index']             = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1858                          $offset += 2;
1859  
1860                          $streamName['stream_name_length']            = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1861                          $offset += 2;
1862  
1863                          $streamName['stream_name']                   =                              substr($asf_header_extension_object_data, $offset,  $streamName['stream_name_length']);
1864                          $offset += $streamName['stream_name_length'];
1865  
1866                          $thisObject['stream_names'][$i] = $streamName;
1867                      }
1868  
1869                      for ($i = 0; $i < $thisObject['payload_extension_system_count']; $i++) {
1870                          $payloadExtensionSystem = array();
1871  
1872                          $payloadExtensionSystem['extension_system_id']   =                              substr($asf_header_extension_object_data, $offset, 16);
1873                          $offset += 16;
1874                          $payloadExtensionSystem['extension_system_id_text'] = $this->BytestringToGUID($payloadExtensionSystem['extension_system_id']);
1875  
1876                          $payloadExtensionSystem['extension_system_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1877                          $offset += 2;
1878                          if ($payloadExtensionSystem['extension_system_size'] <= 0) {
1879                              break 2;
1880                          }
1881  
1882                          $payloadExtensionSystem['extension_system_info_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1883                          $offset += 4;
1884  
1885                          $payloadExtensionSystem['extension_system_info'] = substr($asf_header_extension_object_data, $offset,  $payloadExtensionSystem['extension_system_info_length']);
1886                          $offset += $payloadExtensionSystem['extension_system_info_length'];
1887  
1888                          $thisObject['payload_extension_systems'][$i] = $payloadExtensionSystem;
1889                      }
1890  
1891                      break;
1892  
1893                  case GETID3_ASF_Advanced_Mutual_Exclusion_Object:
1894                      $thisObject['exclusion_type']       = substr($asf_header_extension_object_data, $offset, 16);
1895                      $offset += 16;
1896                      $thisObject['exclusion_type_text']  = $this->BytestringToGUID($thisObject['exclusion_type']);
1897  
1898                      $thisObject['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1899                      $offset += 2;
1900  
1901                      for ($i = 0; $i < $thisObject['stream_numbers_count']; $i++) {
1902                          $thisObject['stream_numbers'][$i] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1903                          $offset += 2;
1904                      }
1905  
1906                      break;
1907  
1908                  case GETID3_ASF_Stream_Prioritization_Object:
1909                      $thisObject['priority_records_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1910                      $offset += 2;
1911  
1912                      for ($i = 0; $i < $thisObject['priority_records_count']; $i++) {
1913                          $priorityRecord = array();
1914  
1915                          $priorityRecord['stream_number'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1916                          $offset += 2;
1917  
1918                          $priorityRecord['flags_raw']     = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
1919                          $offset += 2;
1920                          $priorityRecord['flags']['mandatory'] = (bool) $priorityRecord['flags_raw'] & 0x00000001;
1921  
1922                          $thisObject['priority_records'][$i] = $priorityRecord;
1923                      }
1924  
1925                      break;
1926  
1927                  case GETID3_ASF_Padding_Object:
1928                      // padding, skip it
1929                      break;
1930  
1931                  case GETID3_ASF_Metadata_Object:
1932                      $thisObject['description_record_counts'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1933                      $offset += 2;
1934  
1935                      for ($i = 0; $i < $thisObject['description_record_counts']; $i++) {
1936                          $descriptionRecord = array();
1937  
1938                          $descriptionRecord['reserved_1']         = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2)); // must be zero
1939                          $offset += 2;
1940  
1941                          $descriptionRecord['stream_number']      = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1942                          $offset += 2;
1943  
1944                          $descriptionRecord['name_length']        = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1945                          $offset += 2;
1946  
1947                          $descriptionRecord['data_type']          = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1948                          $offset += 2;
1949                          $descriptionRecord['data_type_text'] = self::metadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']);
1950  
1951                          $descriptionRecord['data_length']        = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
1952                          $offset += 4;
1953  
1954                          $descriptionRecord['name']               =                              substr($asf_header_extension_object_data, $offset,  $descriptionRecord['name_length']);
1955                          $offset += $descriptionRecord['name_length'];
1956  
1957                          $descriptionRecord['data']               =                              substr($asf_header_extension_object_data, $offset,  $descriptionRecord['data_length']);
1958                          $offset += $descriptionRecord['data_length'];
1959                          switch ($descriptionRecord['data_type']) {
1960                              case 0x0000: // Unicode string
1961                                  break;
1962  
1963                              case 0x0001: // BYTE array
1964                                  // do nothing
1965                                  break;
1966  
1967                              case 0x0002: // BOOL
1968                                  $descriptionRecord['data'] = (bool) getid3_lib::LittleEndian2Int($descriptionRecord['data']);
1969                                  break;
1970  
1971                              case 0x0003: // DWORD
1972                              case 0x0004: // QWORD
1973                              case 0x0005: // WORD
1974                                  $descriptionRecord['data'] = getid3_lib::LittleEndian2Int($descriptionRecord['data']);
1975                                  break;
1976  
1977                              case 0x0006: // GUID
1978                                  $descriptionRecord['data_text'] = $this->BytestringToGUID($descriptionRecord['data']);
1979                                  break;
1980                          }
1981  
1982                          $thisObject['description_record'][$i] = $descriptionRecord;
1983                      }
1984                      break;
1985  
1986                  case GETID3_ASF_Language_List_Object:
1987                      $thisObject['language_id_record_counts'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
1988                      $offset += 2;
1989  
1990                      for ($i = 0; $i < $thisObject['language_id_record_counts']; $i++) {
1991                          $languageIDrecord = array();
1992  
1993                          $languageIDrecord['language_id_length']         = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  1));
1994                          $offset += 1;
1995  
1996                          $languageIDrecord['language_id']                =                              substr($asf_header_extension_object_data, $offset,  $languageIDrecord['language_id_length']);
1997                          $offset += $languageIDrecord['language_id_length'];
1998  
1999                          $thisObject['language_id_record'][$i] = $languageIDrecord;
2000                      }
2001                      break;
2002  
2003                  case GETID3_ASF_Metadata_Library_Object:
2004                      $thisObject['description_records_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
2005                      $offset += 2;
2006  
2007                      for ($i = 0; $i < $thisObject['description_records_count']; $i++) {
2008                          $descriptionRecord = array();
2009  
2010                          $descriptionRecord['language_list_index'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
2011                          $offset += 2;
2012  
2013                          $descriptionRecord['stream_number']       = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
2014                          $offset += 2;
2015  
2016                          $descriptionRecord['name_length']         = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
2017                          $offset += 2;
2018  
2019                          $descriptionRecord['data_type']           = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  2));
2020                          $offset += 2;
2021                          $descriptionRecord['data_type_text'] = self::metadataLibraryObjectDataTypeLookup($descriptionRecord['data_type']);
2022  
2023                          $descriptionRecord['data_length']         = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset,  4));
2024                          $offset += 4;
2025  
2026                          $descriptionRecord['name']                =                              substr($asf_header_extension_object_data, $offset,  $descriptionRecord['name_length']);
2027                          $offset += $descriptionRecord['name_length'];
2028  
2029                          $descriptionRecord['data']                =                              substr($asf_header_extension_object_data, $offset,  $descriptionRecord['data_length']);
2030                          $offset += $descriptionRecord['data_length'];
2031  
2032                          if (preg_match('#^WM/Picture$#', str_replace("\x00", '', trim($descriptionRecord['name'])))) {
2033                              $WMpicture = $this->ASF_WMpicture($descriptionRecord['data']);
2034                              foreach ($WMpicture as $key => $value) {
2035                                  $descriptionRecord['data'] = $WMpicture;
2036                              }
2037                              unset($WMpicture);
2038                          }
2039  
2040                          $thisObject['description_record'][$i] = $descriptionRecord;
2041                      }
2042                      break;
2043  
2044                  case GETID3_ASF_Index_Parameters_Object:
2045                      $thisObject['index_entry_time_interval'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
2046                      $offset += 4;
2047  
2048                      $thisObject['index_specifiers_count']    = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2049                      $offset += 2;
2050  
2051                      for ($i = 0; $i < $thisObject['index_specifiers_count']; $i++) {
2052                          $indexSpecifier = array();
2053  
2054                          $indexSpecifier['stream_number']   = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2055                          $offset += 2;
2056  
2057                          $indexSpecifier['index_type']      = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2058                          $offset += 2;
2059                          $indexSpecifier['index_type_text'] = isset(static::$ASFIndexParametersObjectIndexSpecifiersIndexTypes[$indexSpecifier['index_type']])
2060                              ? static::$ASFIndexParametersObjectIndexSpecifiersIndexTypes[$indexSpecifier['index_type']]
2061                              : 'invalid'
2062                          ;
2063  
2064                          $thisObject['index_specifiers'][$i] = $indexSpecifier;
2065                      }
2066  
2067                      break;
2068  
2069                  case GETID3_ASF_Media_Object_Index_Parameters_Object:
2070                      $thisObject['index_entry_count_interval'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
2071                      $offset += 4;
2072  
2073                      $thisObject['index_specifiers_count']     = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2074                      $offset += 2;
2075  
2076                      for ($i = 0; $i < $thisObject['index_specifiers_count']; $i++) {
2077                          $indexSpecifier = array();
2078  
2079                          $indexSpecifier['stream_number']   = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2080                          $offset += 2;
2081  
2082                          $indexSpecifier['index_type']      = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2083                          $offset += 2;
2084                          $indexSpecifier['index_type_text'] = isset(static::$ASFMediaObjectIndexParametersObjectIndexSpecifiersIndexTypes[$indexSpecifier['index_type']])
2085                              ? static::$ASFMediaObjectIndexParametersObjectIndexSpecifiersIndexTypes[$indexSpecifier['index_type']]
2086                              : 'invalid'
2087                          ;
2088  
2089                          $thisObject['index_specifiers'][$i] = $indexSpecifier;
2090                      }
2091  
2092                      break;
2093  
2094                  case GETID3_ASF_Timecode_Index_Parameters_Object:
2095                      // 4.11    Timecode Index Parameters Object (mandatory only if TIMECODE index is present in file, 0 or 1)
2096                      // Field name                     Field type   Size (bits)
2097                      // Object ID                      GUID         128             // GUID for the Timecode Index Parameters Object - ASF_Timecode_Index_Parameters_Object
2098                      // Object Size                    QWORD        64              // Specifies the size, in bytes, of the Timecode Index Parameters Object. Valid values are at least 34 bytes.
2099                      // Index Entry Count Interval     DWORD        32              // This value is ignored for the Timecode Index Parameters Object.
2100                      // Index Specifiers Count         WORD         16              // Specifies the number of entries in the Index Specifiers list. Valid values are 1 and greater.
2101                      // Index Specifiers               array of:    varies          //
2102                      // * Stream Number                WORD         16              // Specifies the stream number that the Index Specifiers refer to. Valid values are between 1 and 127.
2103                      // * Index Type                   WORD         16              // Specifies the type of index. Values are defined as follows (1 is not a valid value):
2104                                                                                     // 2 = Nearest Past Media Object - indexes point to the closest data packet containing an entire video frame or the first fragment of a video frame
2105                                                                                     // 3 = Nearest Past Cleanpoint - indexes point to the closest data packet containing an entire video frame (or first fragment of a video frame) that is a key frame.
2106                                                                                     // Nearest Past Media Object is the most common value
2107  
2108                      $thisObject['index_entry_count_interval'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 4));
2109                      $offset += 4;
2110  
2111                      $thisObject['index_specifiers_count']     = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2112                      $offset += 2;
2113  
2114                      for ($i = 0; $i < $thisObject['index_specifiers_count']; $i++) {
2115                          $indexSpecifier = array();
2116  
2117                          $indexSpecifier['stream_number']   = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2118                          $offset += 2;
2119  
2120                          $indexSpecifier['index_type']      = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 2));
2121                          $offset += 2;
2122                          $indexSpecifier['index_type_text'] = isset(static::$ASFTimecodeIndexParametersObjectIndexSpecifiersIndexTypes[$indexSpecifier['index_type']])
2123                              ? static::$ASFTimecodeIndexParametersObjectIndexSpecifiersIndexTypes[$indexSpecifier['index_type']]
2124                              : 'invalid'
2125                          ;
2126  
2127                          $thisObject['index_specifiers'][$i] = $indexSpecifier;
2128                      }
2129  
2130                      break;
2131  
2132                  case GETID3_ASF_Compatibility_Object:
2133                      $thisObject['profile'] = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 1));
2134                      $offset += 1;
2135  
2136                      $thisObject['mode']    = getid3_lib::LittleEndian2Int(substr($asf_header_extension_object_data, $offset, 1));
2137                      $offset += 1;
2138  
2139                      break;
2140  
2141                  default:
2142                      $unhandled_sections++;
2143                      if ($this->GUIDname($thisObject['guid_text'])) {
2144                          $this->warning('unhandled Header Extension Object GUID "'.$this->GUIDname($thisObject['guid_text']).'" {'.$thisObject['guid_text'].'} at offset '.($offset - 16 - 8));
2145                      } else {
2146                          $this->warning('unknown Header Extension Object GUID {'.$thisObject['guid_text'].'} in at offset '.($offset - 16 - 8));
2147                      }
2148                      break;
2149              }
2150              $HeaderExtensionObjectParsed[] = $thisObject;
2151  
2152              $objectOffset += $thisObject['size'];
2153          }
2154          return $HeaderExtensionObjectParsed;
2155      }
2156  
2157      /**
2158       * @param int $id
2159       *
2160       * @return string
2161       */
2162  	public static function metadataLibraryObjectDataTypeLookup($id) {
2163          static $lookup = array(
2164              0x0000 => 'Unicode string', // The data consists of a sequence of Unicode characters
2165              0x0001 => 'BYTE array',     // The type of the data is implementation-specific
2166              0x0002 => 'BOOL',           // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer. Only 0x0000 or 0x0001 are permitted values
2167              0x0003 => 'DWORD',          // The data is 4 bytes long and should be interpreted as a 32-bit unsigned integer
2168              0x0004 => 'QWORD',          // The data is 8 bytes long and should be interpreted as a 64-bit unsigned integer
2169              0x0005 => 'WORD',           // The data is 2 bytes long and should be interpreted as a 16-bit unsigned integer
2170              0x0006 => 'GUID',           // The data is 16 bytes long and should be interpreted as a 128-bit GUID
2171          );
2172          return (isset($lookup[$id]) ? $lookup[$id] : 'invalid');
2173      }
2174  
2175      /**
2176       * @param string $data
2177       *
2178       * @return array
2179       */
2180  	public function ASF_WMpicture(&$data) {
2181          //typedef struct _WMPicture{
2182          //  LPWSTR  pwszMIMEType;
2183          //  BYTE  bPictureType;
2184          //  LPWSTR  pwszDescription;
2185          //  DWORD  dwDataLen;
2186          //  BYTE*  pbData;
2187          //} WM_PICTURE;
2188  
2189          $WMpicture = array();
2190  
2191          $offset = 0;
2192          $WMpicture['image_type_id'] = getid3_lib::LittleEndian2Int(substr($data, $offset, 1));
2193          $offset += 1;
2194          $WMpicture['image_type']    = self::WMpictureTypeLookup($WMpicture['image_type_id']);
2195          $WMpicture['image_size']    = getid3_lib::LittleEndian2Int(substr($data, $offset, 4));
2196          $offset += 4;
2197  
2198          $WMpicture['image_mime'] = '';
2199          do {
2200              $next_byte_pair = substr($data, $offset, 2);
2201              $offset += 2;
2202              $WMpicture['image_mime'] .= $next_byte_pair;
2203          } while ($next_byte_pair !== "\x00\x00");
2204  
2205          $WMpicture['image_description'] = '';
2206          do {
2207              $next_byte_pair = substr($data, $offset, 2);
2208              $offset += 2;
2209              $WMpicture['image_description'] .= $next_byte_pair;
2210          } while ($next_byte_pair !== "\x00\x00");
2211  
2212          $WMpicture['dataoffset'] = $offset;
2213          $WMpicture['data'] = substr($data, $offset);
2214  
2215          $imageinfo = array();
2216          $WMpicture['image_mime'] = '';
2217          $imagechunkcheck = getid3_lib::GetDataImageSize($WMpicture['data'], $imageinfo);
2218          unset($imageinfo);
2219          if (!empty($imagechunkcheck)) {
2220              $WMpicture['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
2221          }
2222          if (!isset($this->getid3->info['asf']['comments']['picture'])) {
2223              $this->getid3->info['asf']['comments']['picture'] = array();
2224          }
2225          $this->getid3->info['asf']['comments']['picture'][] = array('data'=>$WMpicture['data'], 'image_mime'=>$WMpicture['image_mime']);
2226  
2227          return $WMpicture;
2228      }
2229  
2230      /**
2231       * Remove terminator 00 00 and convert UTF-16LE to Latin-1.
2232       *
2233       * @param string $string
2234       *
2235       * @return string
2236       */
2237  	public static function TrimConvert($string) {
2238          return trim(getid3_lib::iconv_fallback('UTF-16LE', 'ISO-8859-1', self::TrimTerm($string)), ' ');
2239      }
2240  
2241      /**
2242       * Remove terminator 00 00.
2243       *
2244       * @param string $string
2245       *
2246       * @return string
2247       */
2248  	public static function TrimTerm($string) {
2249          // remove terminator, only if present (it should be, but...)
2250          if (substr($string, -2) === "\x00\x00") {
2251              $string = substr($string, 0, -2);
2252          }
2253          return $string;
2254      }
2255  
2256  }


Generated : Wed Apr 15 08:20:10 2026 Cross-referenced by PHPXref