diff e2gallerypro/e2upload/Backend/Assets/getid3/module.audio-video.asf.php @ 3:3f6b44aa6b35 judyates

[svn r4] added ability to buy stuff, from a Prints page, but it doesn't work well with the css, and it also has not been fitted into the perl make system.
author rlm
date Mon, 22 Feb 2010 08:02:39 -0500
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/e2gallerypro/e2upload/Backend/Assets/getid3/module.audio-video.asf.php	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,1846 @@
     1.4 +<?php
     1.5 +// +----------------------------------------------------------------------+
     1.6 +// | PHP version 5                                                        |
     1.7 +// +----------------------------------------------------------------------+
     1.8 +// | Copyright (c) 2002-2006 James Heinrich, Allan Hansen                 |
     1.9 +// +----------------------------------------------------------------------+
    1.10 +// | This source file is subject to version 2 of the GPL license,         |
    1.11 +// | that is bundled with this package in the file license.txt and is     |
    1.12 +// | available through the world-wide-web at the following url:           |
    1.13 +// | http://www.gnu.org/copyleft/gpl.html                                 |
    1.14 +// +----------------------------------------------------------------------+
    1.15 +// | getID3() - http://getid3.sourceforge.net or http://www.getid3.org    |
    1.16 +// +----------------------------------------------------------------------+
    1.17 +// | Authors: James Heinrich <infoØgetid3*org>                            |
    1.18 +// |          Allan Hansen <ahØartemis*dk>                                |
    1.19 +// +----------------------------------------------------------------------+
    1.20 +// | module.audio-video.php                                               |
    1.21 +// | Module for analyzing Microsoft ASF, WMA and WMV files.               |
    1.22 +// | dependencies: module.audio-video.riff.php                            |
    1.23 +// +----------------------------------------------------------------------+
    1.24 +//
    1.25 +// $Id: module.audio-video.asf.php,v 1.7 2006/12/01 22:39:48 ah Exp $
    1.26 +
    1.27 +        
    1.28 +        
    1.29 +class getid3_asf extends getid3_handler
    1.30 +{
    1.31 +
    1.32 +    const Extended_Stream_Properties_Object   = '14E6A5CB-C672-4332-8399-A96952065B5A';
    1.33 +    const Padding_Object                      = '1806D474-CADF-4509-A4BA-9AABCB96AAE8';
    1.34 +    const Payload_Ext_Syst_Pixel_Aspect_Ratio = '1B1EE554-F9EA-4BC8-821A-376B74E4C4B8';
    1.35 +    const Script_Command_Object               = '1EFB1A30-0B62-11D0-A39B-00A0C90348F6';
    1.36 +    const No_Error_Correction                 = '20FB5700-5B55-11CF-A8FD-00805F5C442B';
    1.37 +    const Content_Branding_Object             = '2211B3FA-BD23-11D2-B4B7-00A0C955FC6E';
    1.38 +    const Content_Encryption_Object           = '2211B3FB-BD23-11D2-B4B7-00A0C955FC6E';
    1.39 +    const Digital_Signature_Object            = '2211B3FC-BD23-11D2-B4B7-00A0C955FC6E';
    1.40 +    const Extended_Content_Encryption_Object  = '298AE614-2622-4C17-B935-DAE07EE9289C';
    1.41 +    const Simple_Index_Object                 = '33000890-E5B1-11CF-89F4-00A0C90349CB';
    1.42 +    const Degradable_JPEG_Media               = '35907DE0-E415-11CF-A917-00805F5C442B';
    1.43 +    const Payload_Extension_System_Timecode   = '399595EC-8667-4E2D-8FDB-98814CE76C1E';
    1.44 +    const Binary_Media                        = '3AFB65E2-47EF-40F2-AC2C-70A90D71D343';
    1.45 +    const Timecode_Index_Object               = '3CB73FD0-0C4A-4803-953D-EDF7B6228F0C';
    1.46 +    const Metadata_Library_Object             = '44231C94-9498-49D1-A141-1D134E457054';
    1.47 +    const Reserved_3                          = '4B1ACBE3-100B-11D0-A39B-00A0C90348F6';
    1.48 +    const Reserved_4                          = '4CFEDB20-75F6-11CF-9C0F-00A0C90349CB';
    1.49 +    const Command_Media                       = '59DACFC0-59E6-11D0-A3AC-00A0C90348F6';
    1.50 +    const Header_Extension_Object             = '5FBF03B5-A92E-11CF-8EE3-00C00C205365';
    1.51 +    const Media_Object_Index_Parameters_Obj   = '6B203BAD-3F11-4E84-ACA8-D7613DE2CFA7';
    1.52 +    const Header_Object                       = '75B22630-668E-11CF-A6D9-00AA0062CE6C';
    1.53 +    const Content_Description_Object          = '75B22633-668E-11CF-A6D9-00AA0062CE6C';
    1.54 +    const Error_Correction_Object             = '75B22635-668E-11CF-A6D9-00AA0062CE6C';
    1.55 +    const Data_Object                         = '75B22636-668E-11CF-A6D9-00AA0062CE6C';
    1.56 +    const Web_Stream_Media_Subtype            = '776257D4-C627-41CB-8F81-7AC7FF1C40CC';
    1.57 +    const Stream_Bitrate_Properties_Object    = '7BF875CE-468D-11D1-8D82-006097C9A2B2';
    1.58 +    const Language_List_Object                = '7C4346A9-EFE0-4BFC-B229-393EDE415C85';
    1.59 +    const Codec_List_Object                   = '86D15240-311D-11D0-A3A4-00A0C90348F6';
    1.60 +    const Reserved_2                          = '86D15241-311D-11D0-A3A4-00A0C90348F6';
    1.61 +    const File_Properties_Object              = '8CABDCA1-A947-11CF-8EE4-00C00C205365';
    1.62 +    const File_Transfer_Media                 = '91BD222C-F21C-497A-8B6D-5AA86BFC0185';
    1.63 +    const Old_RTP_Extension_Data              = '96800C63-4C94-11D1-837B-0080C7A37F95';
    1.64 +    const Advanced_Mutual_Exclusion_Object    = 'A08649CF-4775-4670-8A16-6E35357566CD';
    1.65 +    const Bandwidth_Sharing_Object            = 'A69609E6-517B-11D2-B6AF-00C04FD908E9';
    1.66 +    const Reserved_1                          = 'ABD3D211-A9BA-11CF-8EE6-00C00C205365';
    1.67 +    const Bandwidth_Sharing_Exclusive         = 'AF6060AA-5197-11D2-B6AF-00C04FD908E9';
    1.68 +    const Bandwidth_Sharing_Partial           = 'AF6060AB-5197-11D2-B6AF-00C04FD908E9';
    1.69 +    const JFIF_Media                          = 'B61BE100-5B4E-11CF-A8FD-00805F5C442B';
    1.70 +    const Stream_Properties_Object            = 'B7DC0791-A9B7-11CF-8EE6-00C00C205365';
    1.71 +    const Video_Media                         = 'BC19EFC0-5B4D-11CF-A8FD-00805F5C442B';
    1.72 +    const Audio_Spread                        = 'BFC3CD50-618F-11CF-8BB2-00AA00B4E220';
    1.73 +    const Metadata_Object                     = 'C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA';
    1.74 +    const Payload_Ext_Syst_Sample_Duration    = 'C6BD9450-867F-4907-83A3-C77921B733AD';
    1.75 +    const Group_Mutual_Exclusion_Object       = 'D1465A40-5A79-4338-B71B-E36B8FD6C249';
    1.76 +    const Extended_Content_Description_Object = 'D2D0A440-E307-11D2-97F0-00A0C95EA850';
    1.77 +    const Stream_Prioritization_Object        = 'D4FED15B-88D3-454F-81F0-ED5C45999E24';
    1.78 +    const Payload_Ext_System_Content_Type     = 'D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC';
    1.79 +    const Old_File_Properties_Object          = 'D6E229D0-35DA-11D1-9034-00A0C90349BE';
    1.80 +    const Old_ASF_Header_Object               = 'D6E229D1-35DA-11D1-9034-00A0C90349BE';
    1.81 +    const Old_ASF_Data_Object                 = 'D6E229D2-35DA-11D1-9034-00A0C90349BE';
    1.82 +    const Index_Object                        = 'D6E229D3-35DA-11D1-9034-00A0C90349BE';
    1.83 +    const Old_Stream_Properties_Object        = 'D6E229D4-35DA-11D1-9034-00A0C90349BE';
    1.84 +    const Old_Content_Description_Object      = 'D6E229D5-35DA-11D1-9034-00A0C90349BE';
    1.85 +    const Old_Script_Command_Object           = 'D6E229D6-35DA-11D1-9034-00A0C90349BE';
    1.86 +    const Old_Marker_Object                   = 'D6E229D7-35DA-11D1-9034-00A0C90349BE';
    1.87 +    const Old_Component_Download_Object       = 'D6E229D8-35DA-11D1-9034-00A0C90349BE';
    1.88 +    const Old_Stream_Group_Object             = 'D6E229D9-35DA-11D1-9034-00A0C90349BE';
    1.89 +    const Old_Scalable_Object                 = 'D6E229DA-35DA-11D1-9034-00A0C90349BE';
    1.90 +    const Old_Prioritization_Object           = 'D6E229DB-35DA-11D1-9034-00A0C90349BE';
    1.91 +    const Bitrate_Mutual_Exclusion_Object     = 'D6E229DC-35DA-11D1-9034-00A0C90349BE';
    1.92 +    const Old_Inter_Media_Dependency_Object   = 'D6E229DD-35DA-11D1-9034-00A0C90349BE';
    1.93 +    const Old_Rating_Object                   = 'D6E229DE-35DA-11D1-9034-00A0C90349BE';
    1.94 +    const Index_Parameters_Object             = 'D6E229DF-35DA-11D1-9034-00A0C90349BE';
    1.95 +    const Old_Color_Table_Object              = 'D6E229E0-35DA-11D1-9034-00A0C90349BE';
    1.96 +    const Old_Language_List_Object            = 'D6E229E1-35DA-11D1-9034-00A0C90349BE';
    1.97 +    const Old_Audio_Media                     = 'D6E229E2-35DA-11D1-9034-00A0C90349BE';
    1.98 +    const Old_Video_Media                     = 'D6E229E3-35DA-11D1-9034-00A0C90349BE';
    1.99 +    const Old_Image_Media                     = 'D6E229E4-35DA-11D1-9034-00A0C90349BE';
   1.100 +    const Old_Timecode_Media                  = 'D6E229E5-35DA-11D1-9034-00A0C90349BE';
   1.101 +    const Old_Text_Media                      = 'D6E229E6-35DA-11D1-9034-00A0C90349BE';
   1.102 +    const Old_MIDI_Media                      = 'D6E229E7-35DA-11D1-9034-00A0C90349BE';
   1.103 +    const Old_Command_Media                   = 'D6E229E8-35DA-11D1-9034-00A0C90349BE';
   1.104 +    const Old_No_Error_Concealment            = 'D6E229EA-35DA-11D1-9034-00A0C90349BE';
   1.105 +    const Old_Scrambled_Audio                 = 'D6E229EB-35DA-11D1-9034-00A0C90349BE';
   1.106 +    const Old_No_Color_Table                  = 'D6E229EC-35DA-11D1-9034-00A0C90349BE';
   1.107 +    const Old_SMPTE_Time                      = 'D6E229ED-35DA-11D1-9034-00A0C90349BE';
   1.108 +    const Old_ASCII_Text                      = 'D6E229EE-35DA-11D1-9034-00A0C90349BE';
   1.109 +    const Old_Unicode_Text                    = 'D6E229EF-35DA-11D1-9034-00A0C90349BE';
   1.110 +    const Old_HTML_Text                       = 'D6E229F0-35DA-11D1-9034-00A0C90349BE';
   1.111 +    const Old_URL_Command                     = 'D6E229F1-35DA-11D1-9034-00A0C90349BE';
   1.112 +    const Old_Filename_Command                = 'D6E229F2-35DA-11D1-9034-00A0C90349BE';
   1.113 +    const Old_ACM_Codec                       = 'D6E229F3-35DA-11D1-9034-00A0C90349BE';
   1.114 +    const Old_VCM_Codec                       = 'D6E229F4-35DA-11D1-9034-00A0C90349BE';
   1.115 +    const Old_QuickTime_Codec                 = 'D6E229F5-35DA-11D1-9034-00A0C90349BE';
   1.116 +    const Old_DirectShow_Transform_Filter     = 'D6E229F6-35DA-11D1-9034-00A0C90349BE';
   1.117 +    const Old_DirectShow_Rendering_Filter     = 'D6E229F7-35DA-11D1-9034-00A0C90349BE';
   1.118 +    const Old_No_Enhancement                  = 'D6E229F8-35DA-11D1-9034-00A0C90349BE';
   1.119 +    const Old_Unknown_Enhancement_Type        = 'D6E229F9-35DA-11D1-9034-00A0C90349BE';
   1.120 +    const Old_Temporal_Enhancement            = 'D6E229FA-35DA-11D1-9034-00A0C90349BE';
   1.121 +    const Old_Spatial_Enhancement             = 'D6E229FB-35DA-11D1-9034-00A0C90349BE';
   1.122 +    const Old_Quality_Enhancement             = 'D6E229FC-35DA-11D1-9034-00A0C90349BE';
   1.123 +    const Old_Number_of_Channels_Enhancement  = 'D6E229FD-35DA-11D1-9034-00A0C90349BE';
   1.124 +    const Old_Frequency_Response_Enhancement  = 'D6E229FE-35DA-11D1-9034-00A0C90349BE';
   1.125 +    const Old_Media_Object                    = 'D6E229FF-35DA-11D1-9034-00A0C90349BE';
   1.126 +    const Mutex_Language                      = 'D6E22A00-35DA-11D1-9034-00A0C90349BE';
   1.127 +    const Mutex_Bitrate                       = 'D6E22A01-35DA-11D1-9034-00A0C90349BE';
   1.128 +    const Mutex_Unknown                       = 'D6E22A02-35DA-11D1-9034-00A0C90349BE';
   1.129 +    const Old_ASF_Placeholder_Object          = 'D6E22A0E-35DA-11D1-9034-00A0C90349BE';
   1.130 +    const Old_Data_Unit_Extension_Object      = 'D6E22A0F-35DA-11D1-9034-00A0C90349BE';
   1.131 +    const Web_Stream_Format                   = 'DA1E6B13-8359-4050-B398-388E965BF00C';
   1.132 +    const Payload_Ext_System_File_Name        = 'E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B';
   1.133 +    const Marker_Object                       = 'F487CD01-A951-11CF-8EE6-00C00C205365';
   1.134 +    const Timecode_Index_Parameters_Object    = 'F55E496D-9797-4B5D-8C8B-604DFE9BFB24';
   1.135 +    const Audio_Media                         = 'F8699E40-5B4D-11CF-A8FD-00805F5C442B';
   1.136 +    const Media_Object_Index_Object           = 'FEB103F8-12AD-4C64-840F-2A1D2F7AD48C';
   1.137 +    const Alt_Extended_Content_Encryption_Obj = 'FF889EF1-ADEE-40DA-9E71-98704BB928CE';
   1.138 +
   1.139 +
   1.140 +
   1.141 +    public function Analyze() {
   1.142 +
   1.143 +        $getid3 = $this->getid3;
   1.144 +        
   1.145 +        $getid3->include_module('audio-video.riff');
   1.146 +
   1.147 +        !isset($getid3->info['audio']) and $getid3->info['audio'] = array ();
   1.148 +        !isset($getid3->info['video']) and $getid3->info['video'] = array ();
   1.149 +        $getid3->info['asf']['comments'] = $getid3->info['asf']['header_object'] = array ();
   1.150 +            
   1.151 +        $info_audio             = &$getid3->info['audio'];
   1.152 +        $info_video             = &$getid3->info['video'];
   1.153 +        $info_asf               = &$getid3->info['asf'];
   1.154 +        $info_asf_comments      = &$info_asf['comments'];
   1.155 +        $info_asf_header_object = &$info_asf['header_object'];
   1.156 +
   1.157 +        // ASF structure:
   1.158 +        // * Header Object [required]
   1.159 +        //   * File Properties Object [required]   (global file attributes)
   1.160 +        //   * Stream Properties Object [required] (defines media stream & characteristics)
   1.161 +        //   * Header Extension Object [required]  (additional functionality)
   1.162 +        //   * Content Description Object          (bibliographic information)
   1.163 +        //   * Script Command Object               (commands for during playback)
   1.164 +        //   * Marker Object                       (named jumped points within the file)
   1.165 +        // * Data Object [required]
   1.166 +        //   * Data Packets
   1.167 +        // * Index Object
   1.168 +
   1.169 +        // Header Object: (mandatory, one only)
   1.170 +        // Field Name                   Field Type   Size (bits)
   1.171 +        // Object ID                    GUID         128             // GUID for header object - getid3_asf::Header_Object
   1.172 +        // Object Size                  QWORD        64              // size of header object, including 30 bytes of Header Object header
   1.173 +        // Number of Header Objects     DWORD        32              // number of objects in header object
   1.174 +        // Reserved1                    BYTE         8               // hardcoded: 0x01
   1.175 +        // Reserved2                    BYTE         8               // hardcoded: 0x02
   1.176 +
   1.177 +        $getid3->info['fileformat'] = 'asf';
   1.178 +
   1.179 +        fseek($getid3->fp, $getid3->info['avdataoffset'], SEEK_SET);
   1.180 +        $header_object_data = fread($getid3->fp, 30);
   1.181 +
   1.182 +        $info_asf_header_object['objectid_guid'] = getid3_asf::BytestringToGUID(substr($header_object_data, 0, 16));
   1.183 +        
   1.184 +        if ($info_asf_header_object['objectid_guid'] != getid3_asf::Header_Object) {
   1.185 +            throw new getid3_exception('ASF header GUID {'.$info_asf_header_object['objectid_guid'].'} does not match expected "getid3_asf::Header_Object" GUID {'.getid3_asf::Header_Object.'}');
   1.186 +        }
   1.187 +        
   1.188 +        getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_header_object, $header_object_data, 16,
   1.189 +            array (
   1.190 +                'objectsize'    => 8,
   1.191 +                'headerobjects' => 4,
   1.192 +                'reserved1'     => 1,
   1.193 +                'reserved2'     => 1
   1.194 +            )
   1.195 +        );
   1.196 +
   1.197 +        $asf_header_data = fread($getid3->fp, $info_asf_header_object['objectsize'] - 30);
   1.198 +        $offset = 0;
   1.199 +
   1.200 +        for ($header_objects_counter = 0; $header_objects_counter < $info_asf_header_object['headerobjects']; $header_objects_counter++) {
   1.201 +            
   1.202 +            $next_object_guid = substr($asf_header_data, $offset, 16);
   1.203 +            $offset += 16;
   1.204 +            
   1.205 +            $next_object_size = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 8));
   1.206 +            $offset += 8;
   1.207 +            
   1.208 +            $next_object_guidtext = getid3_asf::BytestringToGUID($next_object_guid);
   1.209 +            
   1.210 +            switch ($next_object_guidtext) {
   1.211 +
   1.212 +                case getid3_asf::File_Properties_Object:
   1.213 +                
   1.214 +                    // File Properties Object: (mandatory, one only)
   1.215 +                    // Field Name                   Field Type   Size (bits)
   1.216 +                    // Object ID                    GUID         128             // GUID for file properties object - getid3_asf::File_Properties_Object
   1.217 +                    // Object Size                  QWORD        64              // size of file properties object, including 104 bytes of File Properties Object header
   1.218 +                    // File ID                      GUID         128             // unique ID - identical to File ID in Data Object
   1.219 +                    // File Size                    QWORD        64              // entire file in bytes. Invalid if Broadcast Flag == 1
   1.220 +                    // Creation Date                QWORD        64              // date & time of file creation. Maybe invalid if Broadcast Flag == 1
   1.221 +                    // Data Packets Count           QWORD        64              // number of data packets in Data Object. Invalid if Broadcast Flag == 1
   1.222 +                    // Play Duration                QWORD        64              // playtime, in 100-nanosecond units. Invalid if Broadcast Flag == 1
   1.223 +                    // Send Duration                QWORD        64              // time needed to send file, in 100-nanosecond units. Players can ignore this value. Invalid if Broadcast Flag == 1
   1.224 +                    // 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
   1.225 +                    // Flags                        DWORD        32              //
   1.226 +                    // * Broadcast Flag             bits         1  (0x01)       // file is currently being written, some header values are invalid
   1.227 +                    // * Seekable Flag              bits         1  (0x02)       // is file seekable
   1.228 +                    // * Reserved                   bits         30 (0xFFFFFFFC) // reserved - set to zero
   1.229 +                    // Minimum Data Packet Size     DWORD        32              // in bytes. should be same as Maximum Data Packet Size. Invalid if Broadcast Flag == 1
   1.230 +                    // Maximum Data Packet Size     DWORD        32              // in bytes. should be same as Minimum Data Packet Size. Invalid if Broadcast Flag == 1
   1.231 +                    // Maximum Bitrate              DWORD        32              // maximum instantaneous bitrate in bits per second for entire file, including all data streams and ASF overhead
   1.232 +
   1.233 +                    $info_asf['file_properties_object'] = array ();
   1.234 +                    $info_asf_file_properties_object = &$info_asf['file_properties_object'];
   1.235 +
   1.236 +                    $info_asf_file_properties_object['objectid_guid']      = $next_object_guidtext;
   1.237 +                    $info_asf_file_properties_object['objectsize']         = $next_object_size;
   1.238 +                    
   1.239 +                    $info_asf_file_properties_object['fileid_guid']        = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
   1.240 +                    $offset += 16;
   1.241 +
   1.242 +                    getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_file_properties_object, $asf_header_data, $offset,
   1.243 +                        array (
   1.244 +                            'filesize'        => 8,
   1.245 +                            'creation_date'   => 8,
   1.246 +                            'data_packets'    => 8,
   1.247 +                            'play_duration'   => 8,
   1.248 +                            'send_duration'   => 8,
   1.249 +                            'preroll'         => 8,
   1.250 +                            'flags_raw'       => 4,
   1.251 +                            'min_packet_size' => 4,
   1.252 +                            'max_packet_size' => 4,
   1.253 +                            'max_bitrate'     => 4
   1.254 +                        )
   1.255 +                    );
   1.256 +                    
   1.257 +                    $offset += 64   ;
   1.258 +                    
   1.259 +                    $info_asf_file_properties_object['creation_date_unix'] = getid3_asf::FiletimeToUNIXtime($info_asf_file_properties_object['creation_date']);
   1.260 +                    $info_asf_file_properties_object['flags']['broadcast'] = (bool)($info_asf_file_properties_object['flags_raw'] & 0x0001);
   1.261 +                    $info_asf_file_properties_object['flags']['seekable']  = (bool)($info_asf_file_properties_object['flags_raw'] & 0x0002);
   1.262 +
   1.263 +                    $getid3->info['playtime_seconds'] = ($info_asf_file_properties_object['play_duration'] / 10000000) - ($info_asf_file_properties_object['preroll'] / 1000);
   1.264 +                    $getid3->info['bitrate']          = ($info_asf_file_properties_object['filesize'] * 8) / $getid3->info['playtime_seconds'];
   1.265 +                    break;
   1.266 +
   1.267 +
   1.268 +                case getid3_asf::Stream_Properties_Object:
   1.269 +                    
   1.270 +                    // Stream Properties Object: (mandatory, one per media stream)
   1.271 +                    // Field Name                   Field Type   Size (bits)
   1.272 +                    // Object ID                    GUID         128             // GUID for stream properties object - getid3_asf::Stream_Properties_Object
   1.273 +                    // Object Size                  QWORD        64              // size of stream properties object, including 78 bytes of Stream Properties Object header
   1.274 +                    // Stream Type                  GUID         128             // getid3_asf::Audio_Media, getid3_asf::Video_Media or getid3_asf::Command_Media
   1.275 +                    // Error Correction Type        GUID         128             // getid3_asf::Audio_Spread for audio-only streams, getid3_asf::No_Error_Correction for other stream types
   1.276 +                    // Time Offset                  QWORD        64              // 100-nanosecond units. typically zero. added to all timestamps of samples in the stream
   1.277 +                    // Type-Specific Data Length    DWORD        32              // number of bytes for Type-Specific Data field
   1.278 +                    // Error Correction Data Length DWORD        32              // number of bytes for Error Correction Data field
   1.279 +                    // Flags                        WORD         16              //
   1.280 +                    // * Stream Number              bits         7 (0x007F)      // number of this stream.  1 <= valid <= 127
   1.281 +                    // * Reserved                   bits         8 (0x7F80)      // reserved - set to zero
   1.282 +                    // * Encrypted Content Flag     bits         1 (0x8000)      // stream contents encrypted if set
   1.283 +                    // Reserved                     DWORD        32              // reserved - set to zero
   1.284 +                    // Type-Specific Data           BYTESTREAM   variable        // type-specific format data, depending on value of Stream Type
   1.285 +                    // Error Correction Data        BYTESTREAM   variable        // error-correction-specific format data, depending on value of Error Correct Type
   1.286 +
   1.287 +                    // There is one getid3_asf::Stream_Properties_Object for each stream (audio, video) but the
   1.288 +                    // stream number isn't known until halfway through decoding the structure, hence it
   1.289 +                    // it is decoded to a temporary variable and then stuck in the appropriate index later
   1.290 +
   1.291 +                    $stream_properties_object_data['objectid_guid']      = $next_object_guidtext;
   1.292 +                    $stream_properties_object_data['objectsize']         = $next_object_size;
   1.293 +                    
   1.294 +                    getid3_lib::ReadSequence('LittleEndian2Int', $stream_properties_object_data, $asf_header_data, $offset,
   1.295 +                        array (
   1.296 +                            'stream_type'        => -16,
   1.297 +                            'error_correct_type' => -16,
   1.298 +                            'time_offset'        => 8,
   1.299 +                            'type_data_length'   => 4,
   1.300 +                            'error_data_length'  => 4,
   1.301 +                            'flags_raw'          => 2
   1.302 +                        )
   1.303 +                    );
   1.304 +
   1.305 +                    $stream_properties_stream_number                     =        $stream_properties_object_data['flags_raw'] & 0x007F;
   1.306 +                    $stream_properties_object_data['flags']['encrypted'] = (bool)($stream_properties_object_data['flags_raw'] & 0x8000);
   1.307 +
   1.308 +                    $stream_properties_object_data['stream_type_guid']   = getid3_asf::BytestringToGUID($stream_properties_object_data['stream_type']);
   1.309 +                    $stream_properties_object_data['error_correct_guid'] = getid3_asf::BytestringToGUID($stream_properties_object_data['error_correct_type']);
   1.310 +
   1.311 +                    $offset += 54; // 50 bytes + 4 bytes reserved - DWORD
   1.312 +                    
   1.313 +                    $stream_properties_object_data['type_specific_data'] = substr($asf_header_data, $offset, $stream_properties_object_data['type_data_length']);
   1.314 +                    $offset += $stream_properties_object_data['type_data_length'];
   1.315 +                    
   1.316 +                    $stream_properties_object_data['error_correct_data'] = substr($asf_header_data, $offset, $stream_properties_object_data['error_data_length']);
   1.317 +                    $offset += $stream_properties_object_data['error_data_length'];
   1.318 +
   1.319 +                    switch ($stream_properties_object_data['stream_type_guid']) {
   1.320 +
   1.321 +                        case getid3_asf::Audio_Media:
   1.322 +                    
   1.323 +                            $info_audio['dataformat']   = (@$info_audio['dataformat']   ? $info_audio['dataformat']   : 'asf');
   1.324 +                            $info_audio['bitrate_mode'] = (@$info_audio['bitrate_mode'] ? $info_audio['bitrate_mode'] : 'cbr');
   1.325 +
   1.326 +                            $audiodata = getid3_riff::RIFFparseWAVEFORMATex(substr($stream_properties_object_data['type_specific_data'], 0, 16));
   1.327 +                            unset($audiodata['raw']);
   1.328 +                            $info_audio = getid3_riff::array_merge_noclobber($audiodata, $info_audio);
   1.329 +                            break;
   1.330 +
   1.331 +
   1.332 +                        case getid3_asf::Video_Media:
   1.333 +
   1.334 +                            $info_video['dataformat']   = (@$info_video['dataformat']   ? $info_video['dataformat']   : 'asf');
   1.335 +                            $info_video['bitrate_mode'] = (@$info_video['bitrate_mode'] ? $info_video['bitrate_mode'] : 'cbr');
   1.336 +                            break;
   1.337 +
   1.338 +
   1.339 +                        /* does nothing but eat memory
   1.340 +                        case getid3_asf::Command_Media:
   1.341 +                        default:
   1.342 +                            // do nothing
   1.343 +                            break;
   1.344 +                        */
   1.345 +                    }
   1.346 +
   1.347 +                    $info_asf['stream_properties_object'][$stream_properties_stream_number] = $stream_properties_object_data;
   1.348 +                    unset($stream_properties_object_data); // clear for next stream, if any
   1.349 +                    break;
   1.350 +                    
   1.351 +
   1.352 +                case getid3_asf::Header_Extension_Object:
   1.353 +                    
   1.354 +                    // Header Extension Object: (mandatory, one only)
   1.355 +                    // Field Name                   Field Type   Size (bits)
   1.356 +                    // Object ID                    GUID         128             // GUID for Header Extension object - getid3_asf::Header_Extension_Object
   1.357 +                    // Object Size                  QWORD        64              // size of Header Extension object, including 46 bytes of Header Extension Object header
   1.358 +                    // Reserved Field 1             GUID         128             // hardcoded: getid3_asf::Reserved_1
   1.359 +                    // Reserved Field 2             WORD         16              // hardcoded: 0x00000006
   1.360 +                    // Header Extension Data Size   DWORD        32              // in bytes. valid: 0, or > 24. equals object size minus 46
   1.361 +                    // Header Extension Data        BYTESTREAM   variable        // array of zero or more extended header objects
   1.362 +
   1.363 +                    $info_asf['header_extension_object'] = array ();
   1.364 +                    $info_asf_header_extension_object    = &$info_asf['header_extension_object'];
   1.365 +
   1.366 +                    $info_asf_header_extension_object['objectid_guid']   = $next_object_guidtext;
   1.367 +                    $info_asf_header_extension_object['objectsize']      = $next_object_size;
   1.368 +                    $info_asf_header_extension_object['reserved_1_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
   1.369 +                    $offset += 16;
   1.370 +                    
   1.371 +                    if ($info_asf_header_extension_object['reserved_1_guid'] != getid3_asf::Reserved_1) {
   1.372 +                        $getid3->warning('header_extension_object.reserved_1 GUID ('.$info_asf_header_extension_object['reserved_1_guid'].') does not match expected "getid3_asf::Reserved_1" GUID ('.getid3_asf::Reserved_1.')');
   1.373 +                        break;
   1.374 +                    }
   1.375 +                    
   1.376 +                    $info_asf_header_extension_object['reserved_2'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.377 +                    $offset += 2;
   1.378 +                    
   1.379 +                    if ($info_asf_header_extension_object['reserved_2'] != 6) {
   1.380 +                        $getid3->warning('header_extension_object.reserved_2 ('.getid3_lib::PrintHexBytes($info_asf_header_extension_object['reserved_2']).') does not match expected value of "6"');
   1.381 +                        break;
   1.382 +                    }
   1.383 +                    
   1.384 +                    $info_asf_header_extension_object['extension_data_size'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
   1.385 +                    $offset += 4;
   1.386 +                    
   1.387 +                    $info_asf_header_extension_object['extension_data'] = substr($asf_header_data, $offset, $info_asf_header_extension_object['extension_data_size']);
   1.388 +                    $offset += $info_asf_header_extension_object['extension_data_size'];
   1.389 +                    break;
   1.390 +                    
   1.391 +
   1.392 +                case getid3_asf::Codec_List_Object:
   1.393 +                    
   1.394 +                    // Codec List Object: (optional, one only)
   1.395 +                    // Field Name                   Field Type   Size (bits)
   1.396 +                    // Object ID                    GUID         128             // GUID for Codec List object - getid3_asf::Codec_List_Object
   1.397 +                    // Object Size                  QWORD        64              // size of Codec List object, including 44 bytes of Codec List Object header
   1.398 +                    // Reserved                     GUID         128             // hardcoded: 86D15241-311D-11D0-A3A4-00A0C90348F6
   1.399 +                    // Codec Entries Count          DWORD        32              // number of entries in Codec Entries array
   1.400 +                    // Codec Entries                array of:    variable        //
   1.401 +                    // * Type                       WORD         16              // 0x0001 = Video Codec, 0x0002 = Audio Codec, 0xFFFF = Unknown Codec
   1.402 +                    // * Codec Name Length          WORD         16              // number of Unicode characters stored in the Codec Name field
   1.403 +                    // * Codec Name                 WCHAR        variable        // array of Unicode characters - name of codec used to create the content
   1.404 +                    // * Codec Description Length   WORD         16              // number of Unicode characters stored in the Codec Description field
   1.405 +                    // * Codec Description          WCHAR        variable        // array of Unicode characters - description of format used to create the content
   1.406 +                    // * Codec Information Length   WORD         16              // number of Unicode characters stored in the Codec Information field
   1.407 +                    // * Codec Information          BYTESTREAM   variable        // opaque array of information bytes about the codec used to create the content
   1.408 +
   1.409 +                    $info_asf['codec_list_object'] = array ();
   1.410 +                    $info_asf_codec_list_object      = &$info_asf['codec_list_object'];
   1.411 +
   1.412 +                    $info_asf_codec_list_object['objectid_guid'] = $next_object_guidtext;
   1.413 +                    $info_asf_codec_list_object['objectsize']    = $next_object_size;
   1.414 +                    
   1.415 +                    $info_asf_codec_list_object['reserved_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
   1.416 +                    $offset += 16;
   1.417 +                    
   1.418 +                    if ($info_asf_codec_list_object['reserved_guid'] != '86D15241-311D-11D0-A3A4-00A0C90348F6') {
   1.419 +                        $getid3->warning('codec_list_object.reserved GUID {'.$info_asf_codec_list_object['reserved_guid'].'} does not match expected "getid3_asf::Reserved_1" GUID {86D15241-311D-11D0-A3A4-00A0C90348F6}');
   1.420 +                        break;
   1.421 +                    }
   1.422 +                    
   1.423 +                    $info_asf_codec_list_object['codec_entries_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
   1.424 +                    $offset += 4;
   1.425 +                    
   1.426 +                    for ($codec_entry_counter = 0; $codec_entry_counter < $info_asf_codec_list_object['codec_entries_count']; $codec_entry_counter++) {
   1.427 +                        
   1.428 +                        $info_asf_codec_list_object['codec_entries'][$codec_entry_counter] = array ();
   1.429 +                        $info_asf_codec_list_object_codecentries_current = &$info_asf_codec_list_object['codec_entries'][$codec_entry_counter];
   1.430 +
   1.431 +                        $info_asf_codec_list_object_codecentries_current['type_raw'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.432 +                        $offset += 2;
   1.433 +                        
   1.434 +                        $info_asf_codec_list_object_codecentries_current['type'] = getid3_asf::ASFCodecListObjectTypeLookup($info_asf_codec_list_object_codecentries_current['type_raw']);
   1.435 +
   1.436 +                        $codec_name_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2)) * 2; // 2 bytes per character
   1.437 +                        $offset += 2;
   1.438 +                        
   1.439 +                        $info_asf_codec_list_object_codecentries_current['name'] = substr($asf_header_data, $offset, $codec_name_length);
   1.440 +                        $offset += $codec_name_length;
   1.441 +
   1.442 +                        $codec_description_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2)) * 2; // 2 bytes per character
   1.443 +                        $offset += 2;
   1.444 +                        
   1.445 +                        $info_asf_codec_list_object_codecentries_current['description'] = substr($asf_header_data, $offset, $codec_description_length);
   1.446 +                        $offset += $codec_description_length;
   1.447 +
   1.448 +                        $codec_information_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.449 +                        $offset += 2;
   1.450 +                        
   1.451 +                        $info_asf_codec_list_object_codecentries_current['information'] = substr($asf_header_data, $offset, $codec_information_length);
   1.452 +                        $offset += $codec_information_length;
   1.453 +
   1.454 +                        if ($info_asf_codec_list_object_codecentries_current['type_raw'] == 2) {
   1.455 +                            
   1.456 +                            // audio codec
   1.457 +                            if (strpos($info_asf_codec_list_object_codecentries_current['description'], ',') === false) {
   1.458 +                                throw new getid3_exception('[asf][codec_list_object][codec_entries]['.$codec_entry_counter.'][description] expected to contain comma-seperated list of parameters: "'.$info_asf_codec_list_object_codecentries_current['description'].'"');
   1.459 +                            }
   1.460 +                            list($audio_codec_bitrate, $audio_codec_frequency, $audio_codec_channels) = explode(',', $this->TrimConvert($info_asf_codec_list_object_codecentries_current['description']));
   1.461 +                            $info_audio['codec'] = $this->TrimConvert($info_asf_codec_list_object_codecentries_current['name']);
   1.462 +
   1.463 +                            if (!isset($info_audio['bitrate']) && strstr($audio_codec_bitrate, 'kbps')) {
   1.464 +                                $info_audio['bitrate'] = (int)(trim(str_replace('kbps', '', $audio_codec_bitrate)) * 1000);
   1.465 +                            }
   1.466 +
   1.467 +                            if (!isset($info_video['bitrate']) && isset($info_audio['bitrate']) && isset($info_asf['file_properties_object']['max_bitrate']) && ($info_asf_codec_list_object['codec_entries_count'] > 1)) {
   1.468 +                                $info_video['bitrate'] = $info_asf['file_properties_object']['max_bitrate'] - $info_audio['bitrate'];
   1.469 +                            }
   1.470 +                            
   1.471 +                            if (!@$info_video['bitrate'] && @$info_audio['bitrate'] && @$getid3->info['bitrate']) {
   1.472 +								$info_video['bitrate'] = $getid3->info['bitrate'] - $info_audio['bitrate'];
   1.473 +							}
   1.474 +
   1.475 +                            $audio_codec_frequency = (int)trim(str_replace('kHz', '', $audio_codec_frequency));
   1.476 +
   1.477 +                            static $sample_rate_lookup = array (
   1.478 +                                8  =>  8000,    8000 =>  8000,
   1.479 +                                11 => 11025,   11025 => 11025,
   1.480 +                                12 => 12000,   12000 => 12000,
   1.481 +                                16 => 16000,   16000 => 16000,
   1.482 +                                22 => 22050,   22050 => 22050,
   1.483 +                                24 => 24000,   24000 => 24000,
   1.484 +                                32 => 32000,   32000 => 32000,
   1.485 +                                44 => 44100,   44100 => 44100,
   1.486 +                                48 => 48000,   48000 => 48000,
   1.487 +                            );
   1.488 +
   1.489 +                            $info_audio['sample_rate'] = @$sample_rate_lookup[$audio_codec_frequency];
   1.490 +
   1.491 +                            if (!$info_audio['sample_rate']) {
   1.492 +                                $getid3->warning('unknown frequency: "'.$audio_codec_frequency.'" ('.$this->TrimConvert($info_asf_codec_list_object_codecentries_current['description']).')');
   1.493 +                                break;
   1.494 +                            }
   1.495 +
   1.496 +                            if (!isset($info_audio['channels'])) {
   1.497 +                                if (strstr($audio_codec_channels, 'stereo')) {
   1.498 +                                    $info_audio['channels'] = 2;
   1.499 +                                } elseif (strstr($audio_codec_channels, 'mono')) {
   1.500 +                                    $info_audio['channels'] = 1;
   1.501 +                                }
   1.502 +                            }
   1.503 +                        }
   1.504 +                    }
   1.505 +                    break;
   1.506 +
   1.507 +
   1.508 +                case getid3_asf::Script_Command_Object:
   1.509 +
   1.510 +                    // Script Command Object: (optional, one only)
   1.511 +                    // Field Name                   Field Type   Size (bits)
   1.512 +                    // Object ID                    GUID         128             // GUID for Script Command object - getid3_asf::Script_Command_Object
   1.513 +                    // Object Size                  QWORD        64              // size of Script Command object, including 44 bytes of Script Command Object header
   1.514 +                    // Reserved                     GUID         128             // hardcoded: 4B1ACBE3-100B-11D0-A39B-00A0C90348F6
   1.515 +                    // Commands Count               WORD         16              // number of Commands structures in the Script Commands Objects
   1.516 +                    // Command Types Count          WORD         16              // number of Command Types structures in the Script Commands Objects
   1.517 +                    // Command Types                array of:    variable        //
   1.518 +                    // * Command Type Name Length   WORD         16              // number of Unicode characters for Command Type Name
   1.519 +                    // * Command Type Name          WCHAR        variable        // array of Unicode characters - name of a type of command
   1.520 +                    // Commands                     array of:    variable        //
   1.521 +                    // * Presentation Time          DWORD        32              // presentation time of that command, in milliseconds
   1.522 +                    // * Type Index                 WORD         16              // type of this command, as a zero-based index into the array of Command Types of this object
   1.523 +                    // * Command Name Length        WORD         16              // number of Unicode characters for Command Name
   1.524 +                    // * Command Name               WCHAR        variable        // array of Unicode characters - name of this command
   1.525 +
   1.526 +                    // shortcut
   1.527 +                    $info_asf['script_command_object'] = array ();
   1.528 +                    $info_asf_script_command_object    = &$info_asf['script_command_object'];
   1.529 +
   1.530 +                    $info_asf_script_command_object['objectid_guid'] = $next_object_guidtext;
   1.531 +                    $info_asf_script_command_object['objectsize']    = $next_object_size;
   1.532 +                    $info_asf_script_command_object['reserved_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
   1.533 +                    $offset += 16;
   1.534 +                    
   1.535 +                    if ($info_asf_script_command_object['reserved_guid'] != '4B1ACBE3-100B-11D0-A39B-00A0C90348F6') {
   1.536 +                        $getid3->warning('script_command_object.reserved GUID {'.$info_asf_script_command_object['reserved_guid'].'} does not match expected GUID {4B1ACBE3-100B-11D0-A39B-00A0C90348F6}');
   1.537 +                        break;
   1.538 +                    }
   1.539 +                    
   1.540 +                    $info_asf_script_command_object['commands_count']       = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.541 +                    $offset += 2;
   1.542 +                    
   1.543 +                    $info_asf_script_command_object['command_types_count']  = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.544 +                    $offset += 2;
   1.545 +                    
   1.546 +                    for ($command_types_counter = 0; $command_types_counter < $info_asf_script_command_object['command_types_count']; $command_types_counter++) {
   1.547 +                        
   1.548 +                        $command_type_name_length = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2)) * 2; // 2 bytes per character
   1.549 +                        $offset += 2;
   1.550 +                        
   1.551 +                        $info_asf_script_command_object['command_types'][$command_types_counter]['name'] = substr($asf_header_data, $offset, $command_type_name_length);
   1.552 +                        $offset += $command_type_name_length;
   1.553 +                    }
   1.554 +                    
   1.555 +                    for ($commands_counter = 0; $commands_counter < $info_asf_script_command_object['commands_count']; $commands_counter++) {
   1.556 +                        
   1.557 +                        $info_asf_script_command_object['commands'][$commands_counter]['presentation_time'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
   1.558 +                        $offset += 4;
   1.559 +                        
   1.560 +                        $info_asf_script_command_object['commands'][$commands_counter]['type_index']        = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.561 +                        $offset += 2;
   1.562 +
   1.563 +                        $command_type_name_length                                                           = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2)) * 2; // 2 bytes per character
   1.564 +                        $offset += 2;
   1.565 +                        
   1.566 +                        $info_asf_script_command_object['commands'][$commands_counter]['name']              = substr($asf_header_data, $offset, $command_type_name_length);
   1.567 +                        $offset += $command_type_name_length;
   1.568 +                    }
   1.569 +                    break;
   1.570 +
   1.571 +
   1.572 +                case getid3_asf::Marker_Object:
   1.573 +
   1.574 +                    // Marker Object: (optional, one only)
   1.575 +                    // Field Name                   Field Type   Size (bits)
   1.576 +                    // Object ID                    GUID         128             // GUID for Marker object - getid3_asf::Marker_Object
   1.577 +                    // Object Size                  QWORD        64              // size of Marker object, including 48 bytes of Marker Object header
   1.578 +                    // Reserved                     GUID         128             // hardcoded: 4CFEDB20-75F6-11CF-9C0F-00A0C90349CB
   1.579 +                    // Markers Count                DWORD        32              // number of Marker structures in Marker Object
   1.580 +                    // Reserved                     WORD         16              // hardcoded: 0x0000
   1.581 +                    // Name Length                  WORD         16              // number of bytes in the Name field
   1.582 +                    // Name                         WCHAR        variable        // name of the Marker Object
   1.583 +                    // Markers                      array of:    variable        //
   1.584 +                    // * Offset                     QWORD        64              // byte offset into Data Object
   1.585 +                    // * Presentation Time          QWORD        64              // in 100-nanosecond units
   1.586 +                    // * Entry Length               WORD         16              // length in bytes of (Send Time + Flags + Marker Description Length + Marker Description + Padding)
   1.587 +                    // * Send Time                  DWORD        32              // in milliseconds
   1.588 +                    // * Flags                      DWORD        32              // hardcoded: 0x00000000
   1.589 +                    // * Marker Description Length  DWORD        32              // number of bytes in Marker Description field
   1.590 +                    // * Marker Description         WCHAR        variable        // array of Unicode characters - description of marker entry
   1.591 +                    // * Padding                    BYTESTREAM   variable        // optional padding bytes
   1.592 +
   1.593 +                    $info_asf['marker_object'] = array ();
   1.594 +                    $info_asf_marker_object    = &$info_asf['marker_object'];
   1.595 +
   1.596 +                    $info_asf_marker_object['objectid_guid'] = $next_object_guidtext;
   1.597 +                    $info_asf_marker_object['objectsize']    = $next_object_size;
   1.598 +                    $info_asf_marker_object['reserved_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
   1.599 +                    $offset += 16;                           
   1.600 +                    
   1.601 +                    if ($info_asf_marker_object['reserved_guid'] != '4CFEDB20-75F6-11CF-9C0F-00A0C90349CB') {
   1.602 +                        $getid3->warning('marker_object.reserved GUID {'.$info_asf_marker_object['reserved_guid'].'} does not match expected GUID {4CFEDB20-75F6-11CF-9C0F-00A0C90349CB}');
   1.603 +                        break;
   1.604 +                    }
   1.605 +                    
   1.606 +                    $info_asf_marker_object['markers_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
   1.607 +                    $offset += 4;
   1.608 +                    
   1.609 +                    $info_asf_marker_object['reserved_2']    = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.610 +                    $offset += 2;
   1.611 +                    
   1.612 +                    if ($info_asf_marker_object['reserved_2'] != 0) {
   1.613 +                        $getid3->warning('marker_object.reserved_2 ('.getid3_lib::PrintHexBytes($info_asf_marker_object['reserved_2']).') does not match expected value of "0"');
   1.614 +                        break;
   1.615 +                    }
   1.616 +                    
   1.617 +                    $info_asf_marker_object['name_length']   = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.618 +                    $offset += 2;
   1.619 +                    
   1.620 +                    $info_asf_marker_object['name'] = substr($asf_header_data, $offset, $info_asf_marker_object['name_length']);
   1.621 +                    $offset += $info_asf_marker_object['name_length'];
   1.622 +                    
   1.623 +                    for ($markers_counter = 0; $markers_counter < $info_asf_marker_object['markers_count']; $markers_counter++) {
   1.624 +                        
   1.625 +                        getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_marker_object['markers'][$markers_counter], $asf_header_data, $offset,
   1.626 +                            array (
   1.627 +                                'offset'                    => 8,
   1.628 +                                'presentation_time'         => 8,
   1.629 +                                'entry_length'              => 2,
   1.630 +                                'send_time'                 => 4,
   1.631 +                                'flags'                     => 4,
   1.632 +                                'marker_description_length' => 4
   1.633 +                            )
   1.634 +                        );
   1.635 +                        $offset += 30;
   1.636 +                        
   1.637 +                        $info_asf_marker_object['markers'][$markers_counter]['marker_description'] = substr($asf_header_data, $offset, $info_asf_marker_object['markers'][$markers_counter]['marker_description_length']);
   1.638 +                        $offset += $info_asf_marker_object['markers'][$markers_counter]['marker_description_length'];
   1.639 +                        
   1.640 +                        $padding_length = $info_asf_marker_object['markers'][$markers_counter]['entry_length'] - 4 -  4 - 4 - $info_asf_marker_object['markers'][$markers_counter]['marker_description_length'];
   1.641 +                        if ($padding_length > 0) {
   1.642 +                            $info_asf_marker_object['markers'][$markers_counter]['padding'] = substr($asf_header_data, $offset, $padding_length);
   1.643 +                            $offset += $padding_length;
   1.644 +                        }
   1.645 +                    }
   1.646 +                    break;
   1.647 +                    
   1.648 +
   1.649 +                case getid3_asf::Bitrate_Mutual_Exclusion_Object:
   1.650 +                    
   1.651 +                    // Bitrate Mutual Exclusion Object: (optional)
   1.652 +                    // Field Name                   Field Type   Size (bits)
   1.653 +                    // Object ID                    GUID         128             // GUID for Bitrate Mutual Exclusion object - getid3_asf::Bitrate_Mutual_Exclusion_Object
   1.654 +                    // Object Size                  QWORD        64              // size of Bitrate Mutual Exclusion object, including 42 bytes of Bitrate Mutual Exclusion Object header
   1.655 +                    // Exlusion Type                GUID         128             // nature of mutual exclusion relationship. one of: (getid3_asf::Mutex_Bitrate, getid3_asf::Mutex_Unknown)
   1.656 +                    // Stream Numbers Count         WORD         16              // number of video streams
   1.657 +                    // Stream Numbers               WORD         variable        // array of mutually exclusive video stream numbers. 1 <= valid <= 127
   1.658 +
   1.659 +                    // shortcut
   1.660 +                    $info_asf['bitrate_mutual_exclusion_object'] = array ();
   1.661 +                    $info_asf_bitrate_mutual_exclusion_object    = &$info_asf['bitrate_mutual_exclusion_object'];
   1.662 +
   1.663 +                    $info_asf_bitrate_mutual_exclusion_object['objectid_guid'] = $next_object_guidtext;
   1.664 +                    $info_asf_bitrate_mutual_exclusion_object['objectsize']    = $next_object_size;
   1.665 +                    $info_asf_bitrate_mutual_exclusion_object['reserved_guid'] = getid3_asf::BytestringToGUID(substr($asf_header_data, $offset, 16));
   1.666 +                    $offset += 16;
   1.667 +                    
   1.668 +                    if ($info_asf_bitrate_mutual_exclusion_object['reserved_guid'] != getid3_asf::Mutex_Bitrate  &&  $info_asf_bitrate_mutual_exclusion_object['reserved_guid'] != getid3_asf::Mutex_Unknown) {
   1.669 +                        $getid3->warning('bitrate_mutual_exclusion_object.reserved GUID {'.$info_asf_bitrate_mutual_exclusion_object['reserved_guid'].'} does not match expected "getid3_asf::Mutex_Bitrate" GUID {'.getid3_asf::Mutex_Bitrate.'} or  "getid3_asf::Mutex_Unknown" GUID {'.getid3_asf::Mutex_Unknown.'}');
   1.670 +                        break;
   1.671 +                    }
   1.672 +                    
   1.673 +                    $info_asf_bitrate_mutual_exclusion_object['stream_numbers_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.674 +                    $offset += 2;
   1.675 +                    
   1.676 +                    for ($stream_number_counter = 0; $stream_number_counter < $info_asf_bitrate_mutual_exclusion_object['stream_numbers_count']; $stream_number_counter++) {
   1.677 +                        $info_asf_bitrate_mutual_exclusion_object['stream_numbers'][$stream_number_counter] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.678 +                        $offset += 2;
   1.679 +                    }
   1.680 +                    break;
   1.681 +
   1.682 +
   1.683 +                case getid3_asf::Error_Correction_Object:
   1.684 +
   1.685 +                    // Error Correction Object: (optional, one only)
   1.686 +                    // Field Name                   Field Type   Size (bits)
   1.687 +                    // Object ID                    GUID         128             // GUID for Error Correction object - getid3_asf::Error_Correction_Object
   1.688 +                    // Object Size                  QWORD        64              // size of Error Correction object, including 44 bytes of Error Correction Object header
   1.689 +                    // Error Correction Type        GUID         128             // type of error correction. one of: (getid3_asf::No_Error_Correction, getid3_asf::Audio_Spread)
   1.690 +                    // Error Correction Data Length DWORD        32              // number of bytes in Error Correction Data field
   1.691 +                    // Error Correction Data        BYTESTREAM   variable        // structure depends on value of Error Correction Type field
   1.692 +
   1.693 +                    $info_asf['error_correction_object'] = array ();
   1.694 +                    $info_asf_error_correction_object      = &$info_asf['error_correction_object'];
   1.695 +
   1.696 +                    $info_asf_error_correction_object['objectid_guid']         = $next_object_guidtext;
   1.697 +                    $info_asf_error_correction_object['objectsize']            = $next_object_size;
   1.698 +                    $info_asf_error_correction_object['error_correction_type'] = substr($asf_header_data, $offset, 16);
   1.699 +                    $offset += 16;
   1.700 +                    
   1.701 +                    $info_asf_error_correction_object['error_correction_guid']        = getid3_asf::BytestringToGUID($info_asf_error_correction_object['error_correction_type']);
   1.702 +                    $info_asf_error_correction_object['error_correction_data_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
   1.703 +                    $offset += 4;
   1.704 +                    
   1.705 +                    switch ($info_asf_error_correction_object['error_correction_type_guid']) {
   1.706 +                    
   1.707 +                        case getid3_asf::No_Error_Correction:
   1.708 +                    
   1.709 +                            // should be no data, but just in case there is, skip to the end of the field
   1.710 +                            $offset += $info_asf_error_correction_object['error_correction_data_length'];
   1.711 +                            break;
   1.712 +
   1.713 +
   1.714 +                        case getid3_asf::Audio_Spread:
   1.715 +
   1.716 +                            // Field Name                   Field Type   Size (bits)
   1.717 +                            // Span                         BYTE         8               // number of packets over which audio will be spread.
   1.718 +                            // Virtual Packet Length        WORD         16              // size of largest audio payload found in audio stream
   1.719 +                            // Virtual Chunk Length         WORD         16              // size of largest audio payload found in audio stream
   1.720 +                            // Silence Data Length          WORD         16              // number of bytes in Silence Data field
   1.721 +                            // Silence Data                 BYTESTREAM   variable        // hardcoded: 0x00 * (Silence Data Length) bytes
   1.722 +
   1.723 +                            getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_error_correction_object, $asf_header_data, $offset, 
   1.724 +                                array (
   1.725 +                                    'span'                  => 1,
   1.726 +                                    'virtual_packet_length' => 2,
   1.727 +                                    'virtual_chunk_length'  => 2,
   1.728 +                                    'silence_data_length'   => 2
   1.729 +                                )
   1.730 +                            );
   1.731 +                            $offset += 7;
   1.732 +                            
   1.733 +                            $info_asf_error_correction_object['silence_data'] = substr($asf_header_data, $offset, $info_asf_error_correction_object['silence_data_length']);
   1.734 +                            $offset += $info_asf_error_correction_object['silence_data_length'];
   1.735 +                            break;
   1.736 +
   1.737 +                        default:
   1.738 +                            $getid3->warning('error_correction_object.error_correction_type GUID {'.$info_asf_error_correction_object['reserved_guid'].'} does not match expected "getid3_asf::No_Error_Correction" GUID {'.getid3_asf::No_Error_Correction.'} or  "getid3_asf::Audio_Spread" GUID {'.getid3_asf::Audio_Spread.'}');
   1.739 +                            break;
   1.740 +                    }
   1.741 +
   1.742 +                    break;
   1.743 +
   1.744 +
   1.745 +                case getid3_asf::Content_Description_Object:
   1.746 +
   1.747 +                    // Content Description Object: (optional, one only)
   1.748 +                    // Field Name                   Field Type   Size (bits)
   1.749 +                    // Object ID                    GUID         128             // GUID for Content Description object - getid3_asf::Content_Description_Object
   1.750 +                    // Object Size                  QWORD        64              // size of Content Description object, including 34 bytes of Content Description Object header
   1.751 +                    // Title Length                 WORD         16              // number of bytes in Title field
   1.752 +                    // Author Length                WORD         16              // number of bytes in Author field
   1.753 +                    // Copyright Length             WORD         16              // number of bytes in Copyright field
   1.754 +                    // Description Length           WORD         16              // number of bytes in Description field
   1.755 +                    // Rating Length                WORD         16              // number of bytes in Rating field
   1.756 +                    // Title                        WCHAR        16              // array of Unicode characters - Title
   1.757 +                    // Author                       WCHAR        16              // array of Unicode characters - Author
   1.758 +                    // Copyright                    WCHAR        16              // array of Unicode characters - Copyright
   1.759 +                    // Description                  WCHAR        16              // array of Unicode characters - Description
   1.760 +                    // Rating                       WCHAR        16              // array of Unicode characters - Rating
   1.761 +
   1.762 +                    $info_asf['content_description_object'] = array ();
   1.763 +                    $info_asf_content_description_object      = &$info_asf['content_description_object'];
   1.764 +
   1.765 +                    $info_asf_content_description_object['objectid_guid'] = $next_object_guidtext;
   1.766 +                    $info_asf_content_description_object['objectsize']    = $next_object_size;
   1.767 +                    
   1.768 +                    getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_content_description_object, $asf_header_data, $offset, 
   1.769 +                        array (
   1.770 +                            'title_length'       => 2,
   1.771 +                            'author_length'      => 2,
   1.772 +                            'copyright_length'   => 2,
   1.773 +                            'description_length' => 2,
   1.774 +                            'rating_length'      => 2
   1.775 +                        )
   1.776 +                    );
   1.777 +                    $offset += 10;
   1.778 +                    
   1.779 +                    $info_asf_content_description_object['title']       = substr($asf_header_data, $offset, $info_asf_content_description_object['title_length']);
   1.780 +                    $offset += $info_asf_content_description_object['title_length'];
   1.781 +                    
   1.782 +                    $info_asf_content_description_object['author']      = substr($asf_header_data, $offset, $info_asf_content_description_object['author_length']);
   1.783 +                    $offset += $info_asf_content_description_object['author_length'];
   1.784 +                    
   1.785 +                    $info_asf_content_description_object['copyright']   = substr($asf_header_data, $offset, $info_asf_content_description_object['copyright_length']);
   1.786 +                    $offset += $info_asf_content_description_object['copyright_length'];
   1.787 +                    
   1.788 +                    $info_asf_content_description_object['description'] = substr($asf_header_data, $offset, $info_asf_content_description_object['description_length']);
   1.789 +                    $offset += $info_asf_content_description_object['description_length'];
   1.790 +                    
   1.791 +                    $info_asf_content_description_object['rating']      = substr($asf_header_data, $offset, $info_asf_content_description_object['rating_length']);
   1.792 +                    $offset += $info_asf_content_description_object['rating_length'];
   1.793 +
   1.794 +                    foreach (array ('title'=>'title', 'author'=>'artist', 'copyright'=>'copyright', 'description'=>'comment', 'rating'=>'rating') as $key_to_copy_from => $key_to_copy_to) {
   1.795 +                        if (!empty($info_asf_content_description_object[$key_to_copy_from])) {
   1.796 +                            $info_asf_comments[$key_to_copy_to][] = getid3_asf::TrimTerm($info_asf_content_description_object[$key_to_copy_from]);
   1.797 +                        }
   1.798 +                    }
   1.799 +                    break;
   1.800 +
   1.801 +
   1.802 +                case getid3_asf::Extended_Content_Description_Object:
   1.803 +
   1.804 +                    // Extended Content Description Object: (optional, one only)
   1.805 +                    // Field Name                   Field Type   Size (bits)
   1.806 +                    // Object ID                    GUID         128             // GUID for Extended Content Description object - getid3_asf::Extended_Content_Description_Object
   1.807 +                    // Object Size                  QWORD        64              // size of ExtendedContent Description object, including 26 bytes of Extended Content Description Object header
   1.808 +                    // Content Descriptors Count    WORD         16              // number of entries in Content Descriptors list
   1.809 +                    // Content Descriptors          array of:    variable        //
   1.810 +                    // * Descriptor Name Length     WORD         16              // size in bytes of Descriptor Name field
   1.811 +                    // * Descriptor Name            WCHAR        variable        // array of Unicode characters - Descriptor Name
   1.812 +                    // * Descriptor Value Data Type WORD         16              // Lookup array:
   1.813 +                                                                                    // 0x0000 = Unicode String (variable length)
   1.814 +                                                                                    // 0x0001 = BYTE array     (variable length)
   1.815 +                                                                                    // 0x0002 = BOOL           (DWORD, 32 bits)
   1.816 +                                                                                    // 0x0003 = DWORD          (DWORD, 32 bits)
   1.817 +                                                                                    // 0x0004 = QWORD          (QWORD, 64 bits)
   1.818 +                                                                                    // 0x0005 = WORD           (WORD,  16 bits)
   1.819 +                    // * Descriptor Value Length    WORD         16              // number of bytes stored in Descriptor Value field
   1.820 +                    // * Descriptor Value           variable     variable        // value for Content Descriptor
   1.821 +
   1.822 +                    $info_asf['extended_content_description_object'] = array ();
   1.823 +                    $info_asf_extended_content_description_object       = &$info_asf['extended_content_description_object'];
   1.824 +
   1.825 +                    $info_asf_extended_content_description_object['objectid_guid']             = $next_object_guidtext;
   1.826 +                    $info_asf_extended_content_description_object['objectsize']                = $next_object_size;
   1.827 +                    $info_asf_extended_content_description_object['content_descriptors_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.828 +                    $offset += 2;
   1.829 +                    
   1.830 +                    for ($extended_content_descriptors_counter = 0; $extended_content_descriptors_counter < $info_asf_extended_content_description_object['content_descriptors_count']; $extended_content_descriptors_counter++) {
   1.831 +                        
   1.832 +                        $info_asf_extended_content_description_object['content_descriptors'][$extended_content_descriptors_counter] = array ();
   1.833 +                        $info_asf_extended_content_description_object_content_descriptor_current                                  = &$info_asf_extended_content_description_object['content_descriptors'][$extended_content_descriptors_counter];
   1.834 +
   1.835 +                        $info_asf_extended_content_description_object_content_descriptor_current['base_offset']  = $offset + 30;
   1.836 +                        $info_asf_extended_content_description_object_content_descriptor_current['name_length']  = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.837 +                        $offset += 2;
   1.838 +                        
   1.839 +                        $info_asf_extended_content_description_object_content_descriptor_current['name']         = substr($asf_header_data, $offset, $info_asf_extended_content_description_object_content_descriptor_current['name_length']);
   1.840 +                        $offset += $info_asf_extended_content_description_object_content_descriptor_current['name_length'];
   1.841 +                        
   1.842 +                        $info_asf_extended_content_description_object_content_descriptor_current['value_type']   = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.843 +                        $offset += 2;
   1.844 +                        
   1.845 +                        $info_asf_extended_content_description_object_content_descriptor_current['value_length'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
   1.846 +                        $offset += 2;
   1.847 +                        
   1.848 +                        $info_asf_extended_content_description_object_content_descriptor_current['value']        = substr($asf_header_data, $offset, $info_asf_extended_content_description_object_content_descriptor_current['value_length']);
   1.849 +                        $offset += $info_asf_extended_content_description_object_content_descriptor_current['value_length'];
   1.850 +                        
   1.851 +                        switch ($info_asf_extended_content_description_object_content_descriptor_current['value_type']) {
   1.852 +                            
   1.853 +                            case 0x0000: // Unicode string
   1.854 +                                break;
   1.855 +
   1.856 +                            case 0x0001: // BYTE array
   1.857 +                                // do nothing
   1.858 +                                break;
   1.859 +
   1.860 +                            case 0x0002: // BOOL
   1.861 +                                $info_asf_extended_content_description_object_content_descriptor_current['value'] = (bool)getid3_lib::LittleEndian2Int($info_asf_extended_content_description_object_content_descriptor_current['value']);
   1.862 +                                break;
   1.863 +
   1.864 +                            case 0x0003: // DWORD
   1.865 +                            case 0x0004: // QWORD
   1.866 +                            case 0x0005: // WORD
   1.867 +                                $info_asf_extended_content_description_object_content_descriptor_current['value'] = getid3_lib::LittleEndian2Int($info_asf_extended_content_description_object_content_descriptor_current['value']);
   1.868 +                                break;
   1.869 +
   1.870 +                            default:
   1.871 +                                $getid3->warning('extended_content_description.content_descriptors.'.$extended_content_descriptors_counter.'.value_type is invalid ('.$info_asf_extended_content_description_object_content_descriptor_current['value_type'].')');
   1.872 +                                break;
   1.873 +                        }
   1.874 +                        
   1.875 +                        switch ($this->TrimConvert(strtolower($info_asf_extended_content_description_object_content_descriptor_current['name']))) {
   1.876 +
   1.877 +                            case 'wm/albumartist':
   1.878 +                            case 'artist':
   1.879 +                                $info_asf_comments['artist'] = array (getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value']));
   1.880 +                                break;
   1.881 +
   1.882 +
   1.883 +                            case 'wm/albumtitle':
   1.884 +                            case 'album':
   1.885 +                                $info_asf_comments['album']  = array (getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value']));
   1.886 +                                break;
   1.887 +
   1.888 +
   1.889 +                            case 'wm/genre':
   1.890 +                            case 'genre':
   1.891 +                                $genre = getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value']);
   1.892 +                                $info_asf_comments['genre'] = array ($genre);
   1.893 +                                break;
   1.894 +
   1.895 +
   1.896 +                            case 'wm/tracknumber':
   1.897 +                            case 'tracknumber':
   1.898 +                                $info_asf_comments['track'] = array (intval(getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value'])));
   1.899 +                                break;
   1.900 +
   1.901 +
   1.902 +                            case 'wm/track':
   1.903 +                                if (empty($info_asf_comments['track'])) {
   1.904 +                                    $info_asf_comments['track'] = array (1 + $this->TrimConvert($info_asf_extended_content_description_object_content_descriptor_current['value']));
   1.905 +                                }
   1.906 +                                break;
   1.907 +
   1.908 +
   1.909 +                            case 'wm/year':
   1.910 +                            case 'year':
   1.911 +                            case 'date':
   1.912 +                                $info_asf_comments['year'] = array ( getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value']));
   1.913 +                                break;
   1.914 +                                
   1.915 +                                
   1.916 +                            case 'wm/lyrics':
   1.917 +                            case 'lyrics':
   1.918 +                                $info_asf_comments['lyrics'] = array ( getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value']));
   1.919 +  	                            break;
   1.920 +                            
   1.921 +                            
   1.922 +                            case 'isvbr':
   1.923 +                                if ($info_asf_extended_content_description_object_content_descriptor_current['value']) {
   1.924 +                                    $info_audio['bitrate_mode'] = 'vbr';
   1.925 +                                    $info_video['bitrate_mode'] = 'vbr';
   1.926 +                                }
   1.927 +                                break;
   1.928 +
   1.929 +
   1.930 +                            case 'id3':
   1.931 +								
   1.932 +								// id3v2 parsing might not be enabled
   1.933 +								if (class_exists('getid3_id3v2')) {
   1.934 +									
   1.935 +									// Clone getid3 
   1.936 +                                    $clone = clone $getid3;
   1.937 +                                    
   1.938 +                                    // Analyse clone by string
   1.939 +                                    $id3v2 = new getid3_id3v2($clone);
   1.940 +                                    $id3v2->AnalyzeString($info_asf_extended_content_description_object_content_descriptor_current['value']);
   1.941 +                                    
   1.942 +                                    // Import from clone and destroy
   1.943 +                                    $getid3->info['id3v2'] = $clone->info['id3v2'];
   1.944 +                                    $getid3->warnings($clone->warnings());
   1.945 +                                    unset($clone);
   1.946 +								}
   1.947 +								break;
   1.948 +
   1.949 +
   1.950 +                            case 'wm/encodingtime':
   1.951 +                                $info_asf_extended_content_description_object_content_descriptor_current['encoding_time_unix'] = getid3_asf::FiletimeToUNIXtime($info_asf_extended_content_description_object_content_descriptor_current['value']);
   1.952 +                                $info_asf_comments['encoding_time_unix'] = array ($info_asf_extended_content_description_object_content_descriptor_current['encoding_time_unix']);
   1.953 +                                break;
   1.954 +
   1.955 +
   1.956 +                            case 'wm/picture':
   1.957 +                                
   1.958 +                                //typedef struct _WMPicture{
   1.959 +                                //  LPWSTR  pwszMIMEType;
   1.960 +                                //  BYTE  bPictureType;
   1.961 +                                //  LPWSTR  pwszDescription;
   1.962 +                                //  DWORD  dwDataLen;
   1.963 +                                //  BYTE*  pbData;
   1.964 +                                //} WM_PICTURE;
   1.965 +
   1.966 +                                $info_asf_extended_content_description_object_content_descriptor_current['image_type_id'] = getid3_lib::LittleEndian2Int($info_asf_extended_content_description_object_content_descriptor_current['value']{0});
   1.967 +                                $info_asf_extended_content_description_object_content_descriptor_current['image_type']    = getid3_asf::WMpictureTypeLookup($info_asf_extended_content_description_object_content_descriptor_current['image_type_id']);
   1.968 +                                $info_asf_extended_content_description_object_content_descriptor_current['image_size']    = getid3_lib::LittleEndian2Int(substr($info_asf_extended_content_description_object_content_descriptor_current['value'], 1, 4));
   1.969 +                                $info_asf_extended_content_description_object_content_descriptor_current['image_mime']   = '';
   1.970 +                                
   1.971 +                                $wm_picture_offset = 5;
   1.972 +                                
   1.973 +                                do {
   1.974 +                                    $next_byte_pair = substr($info_asf_extended_content_description_object_content_descriptor_current['value'], $wm_picture_offset, 2);
   1.975 +                                    $wm_picture_offset += 2;
   1.976 +                                    $info_asf_extended_content_description_object_content_descriptor_current['image_mime'] .= $next_byte_pair;
   1.977 +                                } while ($next_byte_pair !== "\x00\x00");
   1.978 +
   1.979 +                                $info_asf_extended_content_description_object_content_descriptor_current['image_description'] = '';
   1.980 +                                
   1.981 +                                do {
   1.982 +                                    $next_byte_pair = substr($info_asf_extended_content_description_object_content_descriptor_current['value'], $wm_picture_offset, 2);
   1.983 +                                    $wm_picture_offset += 2;
   1.984 +                                    $info_asf_extended_content_description_object_content_descriptor_current['image_description'] .= $next_byte_pair;
   1.985 +                                } while ($next_byte_pair !== "\x00\x00");
   1.986 +
   1.987 +                                $info_asf_extended_content_description_object_content_descriptor_current['dataoffset'] = $wm_picture_offset;
   1.988 +                                $info_asf_extended_content_description_object_content_descriptor_current['data']       = substr($info_asf_extended_content_description_object_content_descriptor_current['value'], $wm_picture_offset);
   1.989 +                                unset($info_asf_extended_content_description_object_content_descriptor_current['value']);
   1.990 +                                break;
   1.991 +
   1.992 +                            default:
   1.993 +                                switch ($info_asf_extended_content_description_object_content_descriptor_current['value_type']) {
   1.994 +                                    case 0: // Unicode string
   1.995 +                                        if (substr($this->TrimConvert($info_asf_extended_content_description_object_content_descriptor_current['name']), 0, 3) == 'WM/') {
   1.996 +                                            $info_asf_comments[str_replace('wm/', '', strtolower($this->TrimConvert($info_asf_extended_content_description_object_content_descriptor_current['name'])))] = array (getid3_asf::TrimTerm($info_asf_extended_content_description_object_content_descriptor_current['value']));
   1.997 +                                        }
   1.998 +                                        break;
   1.999 +
  1.1000 +                                    case 1:
  1.1001 +                                        break;
  1.1002 +                                }
  1.1003 +                                break;
  1.1004 +                        }
  1.1005 +
  1.1006 +                    }
  1.1007 +                    break;
  1.1008 +
  1.1009 +
  1.1010 +                case getid3_asf::Stream_Bitrate_Properties_Object:
  1.1011 +
  1.1012 +                    // Stream Bitrate Properties Object: (optional, one only)
  1.1013 +                    // Field Name                   Field Type   Size (bits)
  1.1014 +                    // Object ID                    GUID         128             // GUID for Stream Bitrate Properties object - getid3_asf::Stream_Bitrate_Properties_Object
  1.1015 +                    // Object Size                  QWORD        64              // size of Extended Content Description object, including 26 bytes of Stream Bitrate Properties Object header
  1.1016 +                    // Bitrate Records Count        WORD         16              // number of records in Bitrate Records
  1.1017 +                    // Bitrate Records              array of:    variable        //
  1.1018 +                    // * Flags                      WORD         16              //
  1.1019 +                    // * * Stream Number            bits         7  (0x007F)     // number of this stream
  1.1020 +                    // * * Reserved                 bits         9  (0xFF80)     // hardcoded: 0
  1.1021 +                    // * Average Bitrate            DWORD        32              // in bits per second
  1.1022 +
  1.1023 +                    // shortcut
  1.1024 +                    $info_asf['stream_bitrate_properties_object'] = array ();
  1.1025 +                    $info_asf_stream_bitrate_properties_object = &$info_asf['stream_bitrate_properties_object'];
  1.1026 +
  1.1027 +                    $info_asf_stream_bitrate_properties_object['objectid_guid']         = $next_object_guidtext;
  1.1028 +                    $info_asf_stream_bitrate_properties_object['objectsize']            = $next_object_size;
  1.1029 +                    $info_asf_stream_bitrate_properties_object['bitrate_records_count'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
  1.1030 +                    $offset += 2;
  1.1031 +                    
  1.1032 +                    for ($bitrate_records_counter = 0; $bitrate_records_counter < $info_asf_stream_bitrate_properties_object['bitrate_records_count']; $bitrate_records_counter++) {
  1.1033 +                    
  1.1034 +                        $info_asf_stream_bitrate_properties_object['bitrate_records'][$bitrate_records_counter]['flags_raw'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 2));
  1.1035 +                        $offset += 2;
  1.1036 +                        
  1.1037 +                        $info_asf_stream_bitrate_properties_object['bitrate_records'][$bitrate_records_counter]['flags']['stream_number'] = $info_asf_stream_bitrate_properties_object['bitrate_records'][$bitrate_records_counter]['flags_raw'] & 0x007F;
  1.1038 +                        
  1.1039 +                        $info_asf_stream_bitrate_properties_object['bitrate_records'][$bitrate_records_counter]['bitrate'] = getid3_lib::LittleEndian2Int(substr($asf_header_data, $offset, 4));
  1.1040 +                        $offset += 4;
  1.1041 +                    }
  1.1042 +                    break;
  1.1043 +
  1.1044 +
  1.1045 +                case getid3_asf::Padding_Object:
  1.1046 +
  1.1047 +                    // Padding Object: (optional)
  1.1048 +                    // Field Name                   Field Type   Size (bits)
  1.1049 +                    // Object ID                    GUID         128             // GUID for Padding object - getid3_asf::Padding_Object
  1.1050 +                    // Object Size                  QWORD        64              // size of Padding object, including 24 bytes of ASF Padding Object header
  1.1051 +                    // Padding Data                 BYTESTREAM   variable        // ignore
  1.1052 +
  1.1053 +                    // shortcut
  1.1054 +                    $info_asf['padding_object'] = array ();
  1.1055 +                    $info_asf_paddingobject     = &$info_asf['padding_object'];
  1.1056 +
  1.1057 +                    $info_asf_paddingobject['objectid_guid']  = $next_object_guidtext;
  1.1058 +                    $info_asf_paddingobject['objectsize']     = $next_object_size;
  1.1059 +                    $info_asf_paddingobject['padding_length'] = $info_asf_paddingobject['objectsize'] - 16 - 8;
  1.1060 +                    $info_asf_paddingobject['padding']        = substr($asf_header_data, $offset, $info_asf_paddingobject['padding_length']);
  1.1061 +                    $offset += ($next_object_size - 16 - 8);
  1.1062 +                    break;
  1.1063 +
  1.1064 +
  1.1065 +                case getid3_asf::Extended_Content_Encryption_Object:
  1.1066 +                case getid3_asf::Content_Encryption_Object:
  1.1067 +
  1.1068 +                    // WMA DRM - just ignore
  1.1069 +                    $offset += ($next_object_size - 16 - 8);
  1.1070 +                    break;
  1.1071 +
  1.1072 +
  1.1073 +                default:
  1.1074 +
  1.1075 +                    // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
  1.1076 +                    if (getid3_asf::GUIDname($next_object_guidtext)) {
  1.1077 +                        $getid3->warning('unhandled GUID "'.getid3_asf::GUIDname($next_object_guidtext).'" {'.$next_object_guidtext.'} in ASF header at offset '.($offset - 16 - 8));
  1.1078 +                    } else {
  1.1079 +                        $getid3->warning('unknown GUID {'.$next_object_guidtext.'} in ASF header at offset '.($offset - 16 - 8));
  1.1080 +                    }
  1.1081 +                    $offset += ($next_object_size - 16 - 8);
  1.1082 +                    break;
  1.1083 +            }
  1.1084 +        }
  1.1085 +        
  1.1086 +        if (isset($info_asf_stream_bitrate_properties['bitrate_records_count'])) {
  1.1087 +            $asf_bitrate_audio = 0;
  1.1088 +            $asf_bitrate_video = 0;
  1.1089 +
  1.1090 +            for ($bitrate_records_counter = 0; $bitrate_records_counter < $info_asf_stream_bitrate_properties['bitrate_records_count']; $bitrate_records_counter++) {
  1.1091 +                if (isset($info_asf_codec_list_object['codec_entries'][$bitrate_records_counter])) {
  1.1092 +                    switch ($info_asf_codec_list_object['codec_entries'][$bitrate_records_counter]['type_raw']) {
  1.1093 +                        
  1.1094 +                        case 1:
  1.1095 +                            $asf_bitrate_video += $info_asf_stream_bitrate_properties['bitrate_records'][$bitrate_records_counter]['bitrate'];
  1.1096 +                            break;
  1.1097 +                            
  1.1098 +                        case 2:
  1.1099 +                            $asf_bitrate_audio += $info_asf_stream_bitrate_properties['bitrate_records'][$bitrate_records_counter]['bitrate'];
  1.1100 +                            break;
  1.1101 +                    }
  1.1102 +                }
  1.1103 +            }
  1.1104 +            if ($asf_bitrate_audio > 0) {
  1.1105 +                $info_audio['bitrate'] = $asf_bitrate_audio;
  1.1106 +            }
  1.1107 +            if ($asf_bitrate_video > 0) {
  1.1108 +                $info_video['bitrate'] = $asf_bitrate_video;
  1.1109 +            }
  1.1110 +        }
  1.1111 +        
  1.1112 +        if (isset($info_asf['stream_properties_object']) && is_array($info_asf['stream_properties_object'])) {
  1.1113 +            
  1.1114 +            $info_audio['bitrate'] = 0;
  1.1115 +            $info_video['bitrate'] = 0;
  1.1116 +
  1.1117 +            foreach ($info_asf['stream_properties_object'] as $stream_number => $stream_data) {
  1.1118 +                
  1.1119 +                switch ($stream_data['stream_type_guid']) {
  1.1120 +                    
  1.1121 +                    case getid3_asf::Audio_Media:
  1.1122 +                    
  1.1123 +                        // Field Name                   Field Type   Size (bits)
  1.1124 +                        // Codec ID / Format Tag        WORD         16              // unique ID of audio codec - defined as wFormatTag field of WAVEFORMATEX structure
  1.1125 +                        // Number of Channels           WORD         16              // number of channels of audio - defined as nChannels field of WAVEFORMATEX structure
  1.1126 +                        // Samples Per Second           DWORD        32              // in Hertz - defined as nSamplesPerSec field of WAVEFORMATEX structure
  1.1127 +                        // Average number of Bytes/sec  DWORD        32              // bytes/sec of audio stream  - defined as nAvgBytesPerSec field of WAVEFORMATEX structure
  1.1128 +                        // Block Alignment              WORD         16              // block size in bytes of audio codec - defined as nBlockAlign field of WAVEFORMATEX structure
  1.1129 +                        // 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
  1.1130 +                        // Codec Specific Data Size     WORD         16              // size in bytes of Codec Specific Data buffer - defined as cbSize field of WAVEFORMATEX structure
  1.1131 +                        // Codec Specific Data          BYTESTREAM   variable        // array of codec-specific data bytes
  1.1132 +
  1.1133 +                        // shortcut
  1.1134 +                        $info_asf['audio_media'][$stream_number] = array ();
  1.1135 +                        $info_asf_audio_media_current_stream     = &$info_asf['audio_media'][$stream_number];
  1.1136 +
  1.1137 +                        $audio_media_offset = 0;
  1.1138 +
  1.1139 +                        $info_asf_audio_media_current_stream = getid3_riff::RIFFparseWAVEFORMATex(substr($stream_data['type_specific_data'], $audio_media_offset, 16));
  1.1140 +
  1.1141 +                        $audio_media_offset += 16;
  1.1142 +
  1.1143 +                        $info_audio['lossless'] = false;
  1.1144 +                        switch ($info_asf_audio_media_current_stream['raw']['wFormatTag']) {
  1.1145 +                            case 0x0001: // PCM
  1.1146 +                            case 0x0163: // WMA9 Lossless
  1.1147 +                                $info_audio['lossless'] = true;
  1.1148 +                                break;
  1.1149 +                        }
  1.1150 +
  1.1151 +                        if (!empty($info_asf['stream_bitrate_properties_object']['bitrate_records'])) {
  1.1152 +							foreach ($info_asf['stream_bitrate_properties_object']['bitrate_records'] as $data_array) {
  1.1153 +								if (@$data_array['flags']['stream_number'] == $stream_number) {
  1.1154 +									$info_asf_audio_media_current_stream['bitrate'] = $data_array['bitrate'];
  1.1155 +									$info_audio['bitrate'] += $data_array['bitrate'];
  1.1156 +									break;
  1.1157 +								}
  1.1158 +							}
  1.1159 +						} else {
  1.1160 +							if (@$info_asf_audio_media_current_stream['bytes_sec']) {
  1.1161 +								$info_audio['bitrate'] += $info_asf_audio_media_current_stream['bytes_sec'] * 8;
  1.1162 +							} elseif (@$info_asf_audio_media_current_stream['bitrate']) {
  1.1163 +								$info_audio['bitrate'] += $info_asf_audio_media_current_stream['bitrate'];
  1.1164 +							}
  1.1165 +						}
  1.1166 +                        
  1.1167 +                        $info_audio['streams'][$stream_number]                  = $info_asf_audio_media_current_stream;
  1.1168 +                        $info_audio['streams'][$stream_number]['wformattag']    = $info_asf_audio_media_current_stream['raw']['wFormatTag'];
  1.1169 +                        $info_audio['streams'][$stream_number]['lossless']      = $info_audio['lossless'];
  1.1170 +                        $info_audio['streams'][$stream_number]['bitrate']       = $info_audio['bitrate'];
  1.1171 +                        unset($info_audio['streams'][$stream_number]['raw']);
  1.1172 +
  1.1173 +                        $info_asf_audio_media_current_stream['codec_data_size'] = getid3_lib::LittleEndian2Int(substr($stream_data['type_specific_data'], $audio_media_offset, 2));
  1.1174 +                        $audio_media_offset += 2;
  1.1175 +                        
  1.1176 +                        $info_asf_audio_media_current_stream['codec_data']      = substr($stream_data['type_specific_data'], $audio_media_offset, $info_asf_audio_media_current_stream['codec_data_size']);
  1.1177 +                        $audio_media_offset += $info_asf_audio_media_current_stream['codec_data_size'];
  1.1178 +                        break;
  1.1179 +
  1.1180 +
  1.1181 +                    case getid3_asf::Video_Media:
  1.1182 +
  1.1183 +                        // Field Name                   Field Type   Size (bits)
  1.1184 +                        // Encoded Image Width          DWORD        32              // width of image in pixels
  1.1185 +                        // Encoded Image Height         DWORD        32              // height of image in pixels
  1.1186 +                        // Reserved Flags               BYTE         8               // hardcoded: 0x02
  1.1187 +                        // Format Data Size             WORD         16              // size of Format Data field in bytes
  1.1188 +                        // Format Data                  array of:    variable        //
  1.1189 +                        // * Format Data Size           DWORD        32              // number of bytes in Format Data field, in bytes - defined as biSize field of BITMAPINFOHEADER structure
  1.1190 +                        // * Image Width                LONG         32              // width of encoded image in pixels - defined as biWidth field of BITMAPINFOHEADER structure
  1.1191 +                        // * Image Height               LONG         32              // height of encoded image in pixels - defined as biHeight field of BITMAPINFOHEADER structure
  1.1192 +                        // * Reserved                   WORD         16              // hardcoded: 0x0001 - defined as biPlanes field of BITMAPINFOHEADER structure
  1.1193 +                        // * Bits Per Pixel Count       WORD         16              // bits per pixel - defined as biBitCount field of BITMAPINFOHEADER structure
  1.1194 +                        // * Compression ID             FOURCC       32              // fourcc of video codec - defined as biCompression field of BITMAPINFOHEADER structure
  1.1195 +                        // * Image Size                 DWORD        32              // image size in bytes - defined as biSizeImage field of BITMAPINFOHEADER structure
  1.1196 +                        // * Horizontal Pixels / Meter  DWORD        32              // horizontal resolution of target device in pixels per meter - defined as biXPelsPerMeter field of BITMAPINFOHEADER structure
  1.1197 +                        // * Vertical Pixels / Meter    DWORD        32              // vertical resolution of target device in pixels per meter - defined as biYPelsPerMeter field of BITMAPINFOHEADER structure
  1.1198 +                        // * Colors Used Count          DWORD        32              // number of color indexes in the color table that are actually used - defined as biClrUsed field of BITMAPINFOHEADER structure
  1.1199 +                        // * 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
  1.1200 +                        // * Codec Specific Data        BYTESTREAM   variable        // array of codec-specific data bytes
  1.1201 +
  1.1202 +                        $info_asf['video_media'][$stream_number] = array ();
  1.1203 +                        $info_asf_video_media_current_stream     = &$info_asf['video_media'][$stream_number];
  1.1204 +
  1.1205 +                        getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_video_media_current_stream, $stream_data['type_specific_data'], 0, 
  1.1206 +                            array (
  1.1207 +                                'image_width'     => 4,
  1.1208 +                                'image_height'    => 4,
  1.1209 +                                'flags'           => 1,
  1.1210 +                                'format_data_size'=> 2
  1.1211 +                            )
  1.1212 +                        );
  1.1213 +                        
  1.1214 +                        getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_video_media_current_stream['format_data'], $stream_data['type_specific_data'], 11, 
  1.1215 +                            array (
  1.1216 +                                'format_data_size' => 4,
  1.1217 +                                'image_width'      => 4,
  1.1218 +                                'image_height'     => 4,
  1.1219 +                                'reserved'         => 2,
  1.1220 +                                'bits_per_pixel'   => 2,
  1.1221 +                                'codec_fourcc'     => -4,
  1.1222 +                                'image_size'       => 4,
  1.1223 +                                'horizontal_pels'  => 4,
  1.1224 +                                'vertical_pels'    => 4,
  1.1225 +                                'colors_used'      => 4,
  1.1226 +                                'colors_important' => 4
  1.1227 +                            )
  1.1228 +                        );
  1.1229 +                            
  1.1230 +                        $info_asf_video_media_current_stream['format_data']['codec_data'] = substr($stream_data['type_specific_data'], 51);
  1.1231 +                        
  1.1232 +                        if (!empty($info_asf['stream_bitrate_properties_object']['bitrate_records'])) {
  1.1233 +                            foreach ($info_asf['stream_bitrate_properties_object']['bitrate_records'] as $data_array) {
  1.1234 +                                if (@$data_array['flags']['stream_number'] == $stream_number) {
  1.1235 +                                    $info_asf_video_media_current_stream['bitrate']   = $data_array['bitrate'];
  1.1236 +                                    $info_video['streams'][$stream_number]['bitrate'] = $data_array['bitrate'];
  1.1237 +                                    $info_video['bitrate'] += $data_array['bitrate'];
  1.1238 +                                    
  1.1239 +                                    break;
  1.1240 +                                }
  1.1241 +                            }
  1.1242 +                        }
  1.1243 +                        
  1.1244 +                        $info_asf_video_media_current_stream['format_data']['codec'] = getid3_riff::RIFFfourccLookup($info_asf_video_media_current_stream['format_data']['codec_fourcc']);
  1.1245 +
  1.1246 +                        $info_video['streams'][$stream_number]['fourcc']          = $info_asf_video_media_current_stream['format_data']['codec_fourcc'];
  1.1247 +                        $info_video['streams'][$stream_number]['codec']           = $info_asf_video_media_current_stream['format_data']['codec'];
  1.1248 +                        $info_video['streams'][$stream_number]['resolution_x']    = $info_asf_video_media_current_stream['image_width'];
  1.1249 +                        $info_video['streams'][$stream_number]['resolution_y']    = $info_asf_video_media_current_stream['image_height'];
  1.1250 +                        $info_video['streams'][$stream_number]['bits_per_sample'] = $info_asf_video_media_current_stream['format_data']['bits_per_pixel'];
  1.1251 +                        break;
  1.1252 +
  1.1253 +                    default:
  1.1254 +                        break;
  1.1255 +                }
  1.1256 +            }
  1.1257 +        }
  1.1258 +
  1.1259 +        while (ftell($getid3->fp) < $getid3->info['avdataend']) {
  1.1260 +            
  1.1261 +            $next_object_data_header = fread($getid3->fp, 24);
  1.1262 +            $offset = 0;
  1.1263 +            
  1.1264 +            $next_object_guid = substr($next_object_data_header, 0, 16);
  1.1265 +            $offset += 16;
  1.1266 +            
  1.1267 +            $next_object_guidtext = getid3_asf::BytestringToGUID($next_object_guid);
  1.1268 +            $next_object_size     = getid3_lib::LittleEndian2Int(substr($next_object_data_header, $offset, 8));
  1.1269 +            $offset += 8;
  1.1270 +
  1.1271 +            switch ($next_object_guidtext) {
  1.1272 +                
  1.1273 +                case getid3_asf::Data_Object:
  1.1274 +                
  1.1275 +                    // Data Object: (mandatory, one only)
  1.1276 +                    // Field Name                       Field Type   Size (bits)
  1.1277 +                    // Object ID                        GUID         128             // GUID for Data object - getid3_asf::Data_Object
  1.1278 +                    // Object Size                      QWORD        64              // size of Data object, including 50 bytes of Data Object header. may be 0 if FilePropertiesObject.BroadcastFlag == 1
  1.1279 +                    // File ID                          GUID         128             // unique identifier. identical to File ID field in Header Object
  1.1280 +                    // Total Data Packets               QWORD        64              // number of Data Packet entries in Data Object. invalid if FilePropertiesObject.BroadcastFlag == 1
  1.1281 +                    // Reserved                         WORD         16              // hardcoded: 0x0101
  1.1282 +
  1.1283 +                    // shortcut
  1.1284 +                    $info_asf['data_object'] = array ();
  1.1285 +                    $info_asf_data_object    = &$info_asf['data_object'];
  1.1286 +
  1.1287 +                    $data_object_data = $next_object_data_header.fread($getid3->fp, 50 - 24);
  1.1288 +                    $offset = 24;
  1.1289 +
  1.1290 +                    $info_asf_data_object['objectid_guid']      = $next_object_guidtext;
  1.1291 +                    $info_asf_data_object['objectsize']         = $next_object_size;
  1.1292 +
  1.1293 +                    $info_asf_data_object['fileid_guid']        = getid3_asf::BytestringToGUID(substr($data_object_data, $offset, 16));
  1.1294 +                    $offset += 16;
  1.1295 +                    
  1.1296 +                    $info_asf_data_object['total_data_packets'] = getid3_lib::LittleEndian2Int(substr($data_object_data, $offset, 8));
  1.1297 +                    $offset += 8;
  1.1298 +                    
  1.1299 +                    $info_asf_data_object['reserved']           = getid3_lib::LittleEndian2Int(substr($data_object_data, $offset, 2));
  1.1300 +                    $offset += 2;
  1.1301 +                    
  1.1302 +                    if ($info_asf_data_object['reserved'] != 0x0101) {
  1.1303 +                        $getid3->warning('data_object.reserved ('.getid3_lib::PrintHexBytes($info_asf_data_object['reserved']).') does not match expected value of "0x0101"');
  1.1304 +                        break;
  1.1305 +                    }
  1.1306 +
  1.1307 +                    // Data Packets                     array of:    variable        //
  1.1308 +                    // * Error Correction Flags         BYTE         8               //
  1.1309 +                    // * * Error Correction Data Length bits         4               // if Error Correction Length Type == 00, size of Error Correction Data in bytes, else hardcoded: 0000
  1.1310 +                    // * * Opaque Data Present          bits         1               //
  1.1311 +                    // * * Error Correction Length Type bits         2               // number of bits for size of the error correction data. hardcoded: 00
  1.1312 +                    // * * Error Correction Present     bits         1               // If set, use Opaque Data Packet structure, else use Payload structure
  1.1313 +                    // * Error Correction Data
  1.1314 +
  1.1315 +                    $getid3->info['avdataoffset'] = ftell($getid3->fp);
  1.1316 +                    fseek($getid3->fp, ($info_asf_data_object['objectsize'] - 50), SEEK_CUR); // skip actual audio/video data
  1.1317 +                    $getid3->info['avdataend'] = ftell($getid3->fp);
  1.1318 +                    break;
  1.1319 +
  1.1320 +
  1.1321 +                case getid3_asf::Simple_Index_Object:
  1.1322 +
  1.1323 +                    // Simple Index Object: (optional, recommended, one per video stream)
  1.1324 +                    // Field Name                       Field Type   Size (bits)
  1.1325 +                    // Object ID                        GUID         128             // GUID for Simple Index object - getid3_asf::Data_Object
  1.1326 +                    // Object Size                      QWORD        64              // size of Simple Index object, including 56 bytes of Simple Index Object header
  1.1327 +                    // File ID                          GUID         128             // unique identifier. may be zero or identical to File ID field in Data Object and Header Object
  1.1328 +                    // Index Entry Time Interval        QWORD        64              // interval between index entries in 100-nanosecond units
  1.1329 +                    // Maximum Packet Count             DWORD        32              // maximum packet count for all index entries
  1.1330 +                    // Index Entries Count              DWORD        32              // number of Index Entries structures
  1.1331 +                    // Index Entries                    array of:    variable        //
  1.1332 +                    // * Packet Number                  DWORD        32              // number of the Data Packet associated with this index entry
  1.1333 +                    // * Packet Count                   WORD         16              // number of Data Packets to sent at this index entry
  1.1334 +
  1.1335 +                    // shortcut
  1.1336 +                    $info_asf['simple_index_object'] = array ();
  1.1337 +                    $info_asf_simple_index_object    = &$info_asf['simple_index_object'];
  1.1338 +
  1.1339 +                    $info_asf_simple_index_object['objectid_guid'] = $next_object_guidtext;
  1.1340 +                    $info_asf_simple_index_object['objectsize']    = $next_object_size;
  1.1341 +
  1.1342 +                    $simple_index_object_data = $next_object_data_header.fread($getid3->fp, 56 - 24);
  1.1343 +                    
  1.1344 +                    $info_asf_simple_index_object['fileid_guid'] = getid3_asf::BytestringToGUID(substr($simple_index_object_data, 24, 16));
  1.1345 +
  1.1346 +                    getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_simple_index_object, $simple_index_object_data, 40,
  1.1347 +                        array (
  1.1348 +                            'index_entry_time_interval' => 8,
  1.1349 +                            'maximum_packet_count'      => 4,
  1.1350 +                            'index_entries_count'       => 4
  1.1351 +                        )
  1.1352 +                    );
  1.1353 +                    
  1.1354 +                    $offset = 56;
  1.1355 +
  1.1356 +                    $index_entries_data = $simple_index_object_data.fread($getid3->fp, 6 * $info_asf_simple_index_object['index_entries_count']);
  1.1357 +                    for ($index_entries_counter = 0; $index_entries_counter < $info_asf_simple_index_object['index_entries_count']; $index_entries_counter++) {
  1.1358 +                    
  1.1359 +                        $info_asf_simple_index_object['index_entries'][$index_entries_counter]['packet_number'] = getid3_lib::LittleEndian2Int(substr($index_entries_data, $offset, 4));
  1.1360 +                        $offset += 4;
  1.1361 +                    
  1.1362 +                        $info_asf_simple_index_object['index_entries'][$index_entries_counter]['packet_count']  = getid3_lib::LittleEndian2Int(substr($index_entries_data, $offset, 4));
  1.1363 +                        $offset += 2;
  1.1364 +                    }
  1.1365 +                    break;
  1.1366 +
  1.1367 +
  1.1368 +                case getid3_asf::Index_Object:
  1.1369 +
  1.1370 +                    // 6.2 ASF top-level Index Object (optional but recommended when appropriate, 0 or 1)
  1.1371 +                    // Field Name                       Field Type   Size (bits)
  1.1372 +                    // Object ID                        GUID         128             // GUID for the Index Object - getid3_asf::Index_Object
  1.1373 +                    // Object Size                      QWORD        64              // Specifies the size, in bytes, of the Index Object, including at least 34 bytes of Index Object header
  1.1374 +                    // Index Entry Time Interval        DWORD        32              // Specifies the time interval between each index entry in ms.
  1.1375 +                    // Index Specifiers Count           WORD         16              // Specifies the number of Index Specifiers structures in this Index Object.
  1.1376 +                    // Index Blocks Count               DWORD        32              // Specifies the number of Index Blocks structures in this Index Object.
  1.1377 +
  1.1378 +                    // Index Entry Time Interval        DWORD        32              // Specifies the time interval between index entries in milliseconds.  This value cannot be 0.
  1.1379 +                    // Index Specifiers Count           WORD         16              // Specifies the number of entries in the Index Specifiers list.  Valid values are 1 and greater.
  1.1380 +                    // Index Specifiers                 array of:    varies          //
  1.1381 +                    // * Stream Number                  WORD         16              // Specifies the stream number that the Index Specifiers refer to. Valid values are between 1 and 127.
  1.1382 +                    // * Index Type                     WORD         16              // Specifies Index Type values as follows:
  1.1383 +                                                                                     //   1 = Nearest Past Data Packet - indexes point to the data packet whose presentation time is closest to the index entry time.
  1.1384 +                                                                                     //   2 = Nearest Past Media Object - indexes point to the closest data packet containing an entire object or first fragment of an object.
  1.1385 +                                                                                     //   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.
  1.1386 +                                                                                     //   Nearest Past Cleanpoint is the most common type of index.
  1.1387 +                    // Index Entry Count                DWORD        32              // Specifies the number of Index Entries in the block.
  1.1388 +                    // * 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.
  1.1389 +                    // * Index Entries                  array of:    varies          //
  1.1390 +                    // * * Offsets                      DWORD        varies          // An offset value of 0xffffffff indicates an invalid offset value
  1.1391 +
  1.1392 +                    // shortcut
  1.1393 +                    $info_asf['asf_index_object'] = array ();
  1.1394 +                    $info_asf_asf_index_object      = &$info_asf['asf_index_object'];
  1.1395 +
  1.1396 +                    $asf_index_object_data = $next_object_data_header.fread($getid3->fp, 34 - 24);
  1.1397 +
  1.1398 +                    $info_asf_asf_index_object['objectid_guid'] = $next_object_guidtext;
  1.1399 +                    $info_asf_asf_index_object['objectsize']    = $next_object_size;
  1.1400 +
  1.1401 +                    getid3_lib::ReadSequence('LittleEndian2Int', $info_asf_asf_index_object, $asf_index_object_data, 24, 
  1.1402 +                        array (
  1.1403 +                            'entry_time_interval'    =>4,
  1.1404 +                            'index_specifiers_count' =>2,
  1.1405 +                            'index_blocks_count'     =>4
  1.1406 +                        )
  1.1407 +                    );
  1.1408 +
  1.1409 +                    $offset = 34;
  1.1410 +
  1.1411 +                    $asf_index_object_data .= fread($getid3->fp, 4 * $info_asf_asf_index_object['index_specifiers_count']);
  1.1412 +                    
  1.1413 +                    for ($index_specifiers_counter = 0; $index_specifiers_counter < $info_asf_asf_index_object['index_specifiers_count']; $index_specifiers_counter++) {
  1.1414 +                    
  1.1415 +                        $index_specifier_stream_number = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 2));
  1.1416 +                        $offset += 2;
  1.1417 +                        
  1.1418 +                        $info_asf_asf_index_object['index_specifiers'][$index_specifiers_counter]['stream_number']   = $index_specifier_stream_number;
  1.1419 +                        
  1.1420 +                        $info_asf_asf_index_object['index_specifiers'][$index_specifiers_counter]['index_type']      = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 2));
  1.1421 +                        $offset += 2;
  1.1422 +                        
  1.1423 +                        $info_asf_asf_index_object['index_specifiers'][$index_specifiers_counter]['index_type_text'] = getid3_asf::ASFIndexObjectIndexTypeLookup($info_asf_asf_index_object['index_specifiers'][$index_specifiers_counter]['index_type']);
  1.1424 +                    }
  1.1425 +
  1.1426 +                    $asf_index_object_data .= fread($getid3->fp, 4);
  1.1427 +                    $info_asf_asf_index_object['index_entry_count'] = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 4));
  1.1428 +                    $offset += 4;
  1.1429 +
  1.1430 +                    $asf_index_object_data .= fread($getid3->fp, 8 * $info_asf_asf_index_object['index_specifiers_count']);
  1.1431 +                    
  1.1432 +                    for ($index_specifiers_counter = 0; $index_specifiers_counter < $info_asf_asf_index_object['index_specifiers_count']; $index_specifiers_counter++) {
  1.1433 +                        $info_asf_asf_index_object['block_positions'][$index_specifiers_counter] = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 8));
  1.1434 +                        $offset += 8;
  1.1435 +                    }
  1.1436 +
  1.1437 +                    $asf_index_object_data .= fread($getid3->fp, 4 * $info_asf_asf_index_object['index_specifiers_count'] * $info_asf_asf_index_object['index_entry_count']);
  1.1438 +                    
  1.1439 +                    for ($index_entry_counter = 0; $index_entry_counter < $info_asf_asf_index_object['index_entry_count']; $index_entry_counter++) {
  1.1440 +                        for ($index_specifiers_counter = 0; $index_specifiers_counter < $info_asf_asf_index_object['index_specifiers_count']; $index_specifiers_counter++) {
  1.1441 +                            $info_asf_asf_index_object['offsets'][$index_specifiers_counter][$index_entry_counter] = getid3_lib::LittleEndian2Int(substr($asf_index_object_data, $offset, 4));
  1.1442 +                            $offset += 4;
  1.1443 +                        }
  1.1444 +                    }
  1.1445 +                    break;
  1.1446 +
  1.1447 +
  1.1448 +                default:
  1.1449 +                    
  1.1450 +                    // Implementations shall ignore any standard or non-standard object that they do not know how to handle.
  1.1451 +                    if (getid3_asf::GUIDname($next_object_guidtext)) {
  1.1452 +                        $getid3->warning('unhandled GUID "'.getid3_asf::GUIDname($next_object_guidtext).'" {'.$next_object_guidtext.'} in ASF body at offset '.($offset - 16 - 8));
  1.1453 +                    } else {
  1.1454 +                        $getid3->warning('unknown GUID {'.$next_object_guidtext.'} in ASF body at offset '.(ftell($getid3->fp) - 16 - 8));
  1.1455 +                    }
  1.1456 +                    fseek($getid3->fp, ($next_object_size - 16 - 8), SEEK_CUR);
  1.1457 +                    break;
  1.1458 +            }
  1.1459 +        }
  1.1460 +
  1.1461 +        if (isset($info_asf_codec_list_object['codec_entries']) && is_array($info_asf_codec_list_object['codec_entries'])) {
  1.1462 +            foreach ($info_asf_codec_list_object['codec_entries'] as $stream_number => $stream_data) {
  1.1463 +                switch ($stream_data['information']) {
  1.1464 +                    case 'WMV1':
  1.1465 +                    case 'WMV2':
  1.1466 +                    case 'WMV3':
  1.1467 +                    case 'MSS1':
  1.1468 +                    case 'MSS2':
  1.1469 +                    case 'WMVA':
  1.1470 +                    case 'WVC1':
  1.1471 +                    case 'WMVP':
  1.1472 +                    case 'WVP2': 
  1.1473 +                        $info_video['dataformat'] = 'wmv';
  1.1474 +                        $getid3->info['mime_type']    = 'video/x-ms-wmv';
  1.1475 +                        break;
  1.1476 +
  1.1477 +                    case 'MP42':
  1.1478 +                    case 'MP43':
  1.1479 +                    case 'MP4S':
  1.1480 +                    case 'mp4s':
  1.1481 +                        $info_video['dataformat'] = 'asf';
  1.1482 +                        $getid3->info['mime_type']    = 'video/x-ms-asf';
  1.1483 +                        break;
  1.1484 +
  1.1485 +                    default:
  1.1486 +                        switch ($stream_data['type_raw']) {
  1.1487 +                            case 1:
  1.1488 +                                if (strstr($this->TrimConvert($stream_data['name']), 'Windows Media')) {
  1.1489 +                                    $info_video['dataformat'] = 'wmv';
  1.1490 +                                    if ($getid3->info['mime_type'] == 'video/x-ms-asf') {
  1.1491 +                                        $getid3->info['mime_type'] = 'video/x-ms-wmv';
  1.1492 +                                    }
  1.1493 +                                }
  1.1494 +                                break;
  1.1495 +
  1.1496 +                            case 2:
  1.1497 +                                if (strstr($this->TrimConvert($stream_data['name']), 'Windows Media')) {
  1.1498 +                                    $info_audio['dataformat'] = 'wma';
  1.1499 +                                    if ($getid3->info['mime_type'] == 'video/x-ms-asf') {
  1.1500 +                                        $getid3->info['mime_type'] = 'audio/x-ms-wma';
  1.1501 +                                    }
  1.1502 +                                }
  1.1503 +                                break;
  1.1504 +
  1.1505 +                        }
  1.1506 +                        break;
  1.1507 +                }
  1.1508 +            }
  1.1509 +        }
  1.1510 +
  1.1511 +        switch (@$info_audio['codec']) {
  1.1512 +            case 'MPEG Layer-3':
  1.1513 +                $info_audio['dataformat'] = 'mp3';
  1.1514 +                break;
  1.1515 +
  1.1516 +            default:
  1.1517 +                break;
  1.1518 +        }
  1.1519 +
  1.1520 +        if (isset($info_asf_codec_list_object['codec_entries'])) {
  1.1521 +            foreach ($info_asf_codec_list_object['codec_entries'] as $stream_number => $stream_data) {
  1.1522 +                switch ($stream_data['type_raw']) {
  1.1523 +
  1.1524 +                    case 1: // video
  1.1525 +                        $info_video['encoder'] = $this->TrimConvert($info_asf_codec_list_object['codec_entries'][$stream_number]['name']);
  1.1526 +                        break;
  1.1527 +
  1.1528 +                    case 2: // audio
  1.1529 +                        $info_audio['encoder']         = $this->TrimConvert($info_asf_codec_list_object['codec_entries'][$stream_number]['name']);
  1.1530 +                        $info_audio['encoder_options'] = $this->TrimConvert($info_asf_codec_list_object['codec_entries'][0]['description']);
  1.1531 +                        $info_audio['codec']           = $info_audio['encoder'];
  1.1532 +                        break;
  1.1533 +
  1.1534 +                    default:
  1.1535 +                        $getid3->warning('Unknown streamtype: [codec_list_object][codec_entries]['.$stream_number.'][type_raw] == '.$stream_data['type_raw']);
  1.1536 +                        break;
  1.1537 +
  1.1538 +                }
  1.1539 +            }
  1.1540 +        }
  1.1541 +
  1.1542 +        if (isset($getid3->info['audio'])) {
  1.1543 +            $info_audio['lossless']           = (isset($info_audio['lossless'])           ? $info_audio['lossless']           : false);
  1.1544 +            $info_audio['dataformat']         = (!empty($info_audio['dataformat'])        ? $info_audio['dataformat']         : 'asf');
  1.1545 +        }
  1.1546 +        
  1.1547 +        if (!empty($info_video['dataformat'])) {
  1.1548 +            $info_video['lossless']           = (isset($info_audio['lossless'])           ? $info_audio['lossless']           : false);
  1.1549 +            $info_video['pixel_aspect_ratio'] = (isset($info_audio['pixel_aspect_ratio']) ? $info_audio['pixel_aspect_ratio'] : (float)1);
  1.1550 +            $info_video['dataformat']         = (!empty($info_video['dataformat'])        ? $info_video['dataformat']         : 'asf');
  1.1551 +        }
  1.1552 +        
  1.1553 +        $getid3->info['bitrate'] = @$info_audio['bitrate'] + @$info_video['bitrate'];
  1.1554 +              
  1.1555 +        if (empty($info_audio)) {
  1.1556 +            unset($getid3->info['audio']);
  1.1557 +        }
  1.1558 +        
  1.1559 +        if (empty($info_video)) {
  1.1560 +            unset($getid3->info['video']);
  1.1561 +        }
  1.1562 +        
  1.1563 +        return true;
  1.1564 +    }
  1.1565 +
  1.1566 +
  1.1567 +  
  1.1568 +    // Remove terminator 00 00 and convert UNICODE to Latin-1
  1.1569 +    private function TrimConvert($string) {
  1.1570 +        
  1.1571 +        // remove terminator, only if present (it should be, but...)
  1.1572 +        if (substr($string, strlen($string) - 2, 2) == "\x00\x00") {
  1.1573 +            $string = substr($string, 0, strlen($string) - 2);
  1.1574 +        }
  1.1575 +
  1.1576 +        // convert
  1.1577 +        return trim($this->getid3->iconv('UTF-16LE', 'ISO-8859-1', $string), ' ');
  1.1578 +    }
  1.1579 +
  1.1580 +
  1.1581 +
  1.1582 +    private function WMpictureTypeLookup($wm_picture_type) {
  1.1583 +        
  1.1584 +        static $lookup = array (
  1.1585 +            0x03 => 'Front Cover',
  1.1586 +            0x04 => 'Back Cover',
  1.1587 +            0x00 => 'User Defined',
  1.1588 +            0x05 => 'Leaflet Page',
  1.1589 +            0x06 => 'Media Label',
  1.1590 +            0x07 => 'Lead Artist',
  1.1591 +            0x08 => 'Artist',
  1.1592 +            0x09 => 'Conductor',
  1.1593 +            0x0A => 'Band',
  1.1594 +            0x0B => 'Composer',
  1.1595 +            0x0C => 'Lyricist',
  1.1596 +            0x0D => 'Recording Location',
  1.1597 +            0x0E => 'During Recording',
  1.1598 +            0x0F => 'During Performance',
  1.1599 +            0x10 => 'Video Screen Capture',
  1.1600 +            0x12 => 'Illustration',
  1.1601 +            0x13 => 'Band Logotype',
  1.1602 +            0x14 => 'Publisher Logotype'
  1.1603 +        );
  1.1604 +        
  1.1605 +        return isset($lookup[$wm_picture_type]) ? $this->getid3->iconv('ISO-8859-1', 'UTF-16LE', $lookup[$wm_picture_type]) : '';
  1.1606 +    }
  1.1607 +
  1.1608 +
  1.1609 +
  1.1610 +    public static function ASFCodecListObjectTypeLookup($codec_list_type) {
  1.1611 +        
  1.1612 +        static $lookup = array (
  1.1613 +            0x0001 => 'Video Codec',
  1.1614 +            0x0002 => 'Audio Codec',
  1.1615 +            0xFFFF => 'Unknown Codec'
  1.1616 +        );
  1.1617 +
  1.1618 +        return (isset($lookup[$codec_list_type]) ? $lookup[$codec_list_type] : 'Invalid Codec Type');
  1.1619 +    }
  1.1620 +
  1.1621 +
  1.1622 +
  1.1623 +    public static function GUIDname($guid_string) {
  1.1624 +        
  1.1625 +        static $lookup = array (
  1.1626 +            getid3_asf::Extended_Stream_Properties_Object   => 'Extended_Stream_Properties_Object',   
  1.1627 +            getid3_asf::Padding_Object                      => 'Padding_Object',                      
  1.1628 +            getid3_asf::Payload_Ext_Syst_Pixel_Aspect_Ratio => 'Payload_Ext_Syst_Pixel_Aspect_Ratio', 
  1.1629 +            getid3_asf::Script_Command_Object               => 'Script_Command_Object',               
  1.1630 +            getid3_asf::No_Error_Correction                 => 'No_Error_Correction',                 
  1.1631 +            getid3_asf::Content_Branding_Object             => 'Content_Branding_Object',             
  1.1632 +            getid3_asf::Content_Encryption_Object           => 'Content_Encryption_Object',           
  1.1633 +            getid3_asf::Digital_Signature_Object            => 'Digital_Signature_Object',            
  1.1634 +            getid3_asf::Extended_Content_Encryption_Object  => 'Extended_Content_Encryption_Object',  
  1.1635 +            getid3_asf::Simple_Index_Object                 => 'Simple_Index_Object',                 
  1.1636 +            getid3_asf::Degradable_JPEG_Media               => 'Degradable_JPEG_Media',               
  1.1637 +            getid3_asf::Payload_Extension_System_Timecode   => 'Payload_Extension_System_Timecode',   
  1.1638 +            getid3_asf::Binary_Media                        => 'Binary_Media',                        
  1.1639 +            getid3_asf::Timecode_Index_Object               => 'Timecode_Index_Object',               
  1.1640 +            getid3_asf::Metadata_Library_Object             => 'Metadata_Library_Object',             
  1.1641 +            getid3_asf::Reserved_3                          => 'Reserved_3',                          
  1.1642 +            getid3_asf::Reserved_4                          => 'Reserved_4',                          
  1.1643 +            getid3_asf::Command_Media                       => 'Command_Media',                       
  1.1644 +            getid3_asf::Header_Extension_Object             => 'Header_Extension_Object',             
  1.1645 +            getid3_asf::Media_Object_Index_Parameters_Obj   => 'Media_Object_Index_Parameters_Obj',   
  1.1646 +            getid3_asf::Header_Object                       => 'Header_Object',                       
  1.1647 +            getid3_asf::Content_Description_Object          => 'Content_Description_Object',          
  1.1648 +            getid3_asf::Error_Correction_Object             => 'Error_Correction_Object',             
  1.1649 +            getid3_asf::Data_Object                         => 'Data_Object',                         
  1.1650 +            getid3_asf::Web_Stream_Media_Subtype            => 'Web_Stream_Media_Subtype',            
  1.1651 +            getid3_asf::Stream_Bitrate_Properties_Object    => 'Stream_Bitrate_Properties_Object',    
  1.1652 +            getid3_asf::Language_List_Object                => 'Language_List_Object',                
  1.1653 +            getid3_asf::Codec_List_Object                   => 'Codec_List_Object',                   
  1.1654 +            getid3_asf::Reserved_2                          => 'Reserved_2',                          
  1.1655 +            getid3_asf::File_Properties_Object              => 'File_Properties_Object',              
  1.1656 +            getid3_asf::File_Transfer_Media                 => 'File_Transfer_Media',                 
  1.1657 +            getid3_asf::Old_RTP_Extension_Data              => 'Old_RTP_Extension_Data',              
  1.1658 +            getid3_asf::Advanced_Mutual_Exclusion_Object    => 'Advanced_Mutual_Exclusion_Object',    
  1.1659 +            getid3_asf::Bandwidth_Sharing_Object            => 'Bandwidth_Sharing_Object',            
  1.1660 +            getid3_asf::Reserved_1                          => 'Reserved_1',                          
  1.1661 +            getid3_asf::Bandwidth_Sharing_Exclusive         => 'Bandwidth_Sharing_Exclusive',         
  1.1662 +            getid3_asf::Bandwidth_Sharing_Partial           => 'Bandwidth_Sharing_Partial',           
  1.1663 +            getid3_asf::JFIF_Media                          => 'JFIF_Media',                          
  1.1664 +            getid3_asf::Stream_Properties_Object            => 'Stream_Properties_Object',            
  1.1665 +            getid3_asf::Video_Media                         => 'Video_Media',                         
  1.1666 +            getid3_asf::Audio_Spread                        => 'Audio_Spread',                        
  1.1667 +            getid3_asf::Metadata_Object                     => 'Metadata_Object',                     
  1.1668 +            getid3_asf::Payload_Ext_Syst_Sample_Duration    => 'Payload_Ext_Syst_Sample_Duration',    
  1.1669 +            getid3_asf::Group_Mutual_Exclusion_Object       => 'Group_Mutual_Exclusion_Object',       
  1.1670 +            getid3_asf::Extended_Content_Description_Object => 'Extended_Content_Description_Object', 
  1.1671 +            getid3_asf::Stream_Prioritization_Object        => 'Stream_Prioritization_Object',        
  1.1672 +            getid3_asf::Payload_Ext_System_Content_Type     => 'Payload_Ext_System_Content_Type',     
  1.1673 +            getid3_asf::Old_File_Properties_Object          => 'Old_File_Properties_Object',          
  1.1674 +            getid3_asf::Old_ASF_Header_Object               => 'Old_ASF_Header_Object',               
  1.1675 +            getid3_asf::Old_ASF_Data_Object                 => 'Old_ASF_Data_Object',                 
  1.1676 +            getid3_asf::Index_Object                        => 'Index_Object',                        
  1.1677 +            getid3_asf::Old_Stream_Properties_Object        => 'Old_Stream_Properties_Object',        
  1.1678 +            getid3_asf::Old_Content_Description_Object      => 'Old_Content_Description_Object',      
  1.1679 +            getid3_asf::Old_Script_Command_Object           => 'Old_Script_Command_Object',           
  1.1680 +            getid3_asf::Old_Marker_Object                   => 'Old_Marker_Object',                   
  1.1681 +            getid3_asf::Old_Component_Download_Object       => 'Old_Component_Download_Object',       
  1.1682 +            getid3_asf::Old_Stream_Group_Object             => 'Old_Stream_Group_Object',             
  1.1683 +            getid3_asf::Old_Scalable_Object                 => 'Old_Scalable_Object',                 
  1.1684 +            getid3_asf::Old_Prioritization_Object           => 'Old_Prioritization_Object',           
  1.1685 +            getid3_asf::Bitrate_Mutual_Exclusion_Object     => 'Bitrate_Mutual_Exclusion_Object',     
  1.1686 +            getid3_asf::Old_Inter_Media_Dependency_Object   => 'Old_Inter_Media_Dependency_Object',   
  1.1687 +            getid3_asf::Old_Rating_Object                   => 'Old_Rating_Object',                   
  1.1688 +            getid3_asf::Index_Parameters_Object             => 'Index_Parameters_Object',             
  1.1689 +            getid3_asf::Old_Color_Table_Object              => 'Old_Color_Table_Object',              
  1.1690 +            getid3_asf::Old_Language_List_Object            => 'Old_Language_List_Object',            
  1.1691 +            getid3_asf::Old_Audio_Media                     => 'Old_Audio_Media',                     
  1.1692 +            getid3_asf::Old_Video_Media                     => 'Old_Video_Media',                     
  1.1693 +            getid3_asf::Old_Image_Media                     => 'Old_Image_Media',                     
  1.1694 +            getid3_asf::Old_Timecode_Media                  => 'Old_Timecode_Media',                  
  1.1695 +            getid3_asf::Old_Text_Media                      => 'Old_Text_Media',                      
  1.1696 +            getid3_asf::Old_MIDI_Media                      => 'Old_MIDI_Media',                      
  1.1697 +            getid3_asf::Old_Command_Media                   => 'Old_Command_Media',                   
  1.1698 +            getid3_asf::Old_No_Error_Concealment            => 'Old_No_Error_Concealment',            
  1.1699 +            getid3_asf::Old_Scrambled_Audio                 => 'Old_Scrambled_Audio',                 
  1.1700 +            getid3_asf::Old_No_Color_Table                  => 'Old_No_Color_Table',                  
  1.1701 +            getid3_asf::Old_SMPTE_Time                      => 'Old_SMPTE_Time',                      
  1.1702 +            getid3_asf::Old_ASCII_Text                      => 'Old_ASCII_Text',                      
  1.1703 +            getid3_asf::Old_Unicode_Text                    => 'Old_Unicode_Text',                    
  1.1704 +            getid3_asf::Old_HTML_Text                       => 'Old_HTML_Text',                       
  1.1705 +            getid3_asf::Old_URL_Command                     => 'Old_URL_Command',                     
  1.1706 +            getid3_asf::Old_Filename_Command                => 'Old_Filename_Command',                
  1.1707 +            getid3_asf::Old_ACM_Codec                       => 'Old_ACM_Codec',                       
  1.1708 +            getid3_asf::Old_VCM_Codec                       => 'Old_VCM_Codec',                       
  1.1709 +            getid3_asf::Old_QuickTime_Codec                 => 'Old_QuickTime_Codec',                 
  1.1710 +            getid3_asf::Old_DirectShow_Transform_Filter     => 'Old_DirectShow_Transform_Filter',     
  1.1711 +            getid3_asf::Old_DirectShow_Rendering_Filter     => 'Old_DirectShow_Rendering_Filter',     
  1.1712 +            getid3_asf::Old_No_Enhancement                  => 'Old_No_Enhancement',                  
  1.1713 +            getid3_asf::Old_Unknown_Enhancement_Type        => 'Old_Unknown_Enhancement_Type',        
  1.1714 +            getid3_asf::Old_Temporal_Enhancement            => 'Old_Temporal_Enhancement',            
  1.1715 +            getid3_asf::Old_Spatial_Enhancement             => 'Old_Spatial_Enhancement',             
  1.1716 +            getid3_asf::Old_Quality_Enhancement             => 'Old_Quality_Enhancement',             
  1.1717 +            getid3_asf::Old_Number_of_Channels_Enhancement  => 'Old_Number_of_Channels_Enhancement',  
  1.1718 +            getid3_asf::Old_Frequency_Response_Enhancement  => 'Old_Frequency_Response_Enhancement',  
  1.1719 +            getid3_asf::Old_Media_Object                    => 'Old_Media_Object',                    
  1.1720 +            getid3_asf::Mutex_Language                      => 'Mutex_Language',                      
  1.1721 +            getid3_asf::Mutex_Bitrate                       => 'Mutex_Bitrate',                       
  1.1722 +            getid3_asf::Mutex_Unknown                       => 'Mutex_Unknown',                       
  1.1723 +            getid3_asf::Old_ASF_Placeholder_Object          => 'Old_ASF_Placeholder_Object',          
  1.1724 +            getid3_asf::Old_Data_Unit_Extension_Object      => 'Old_Data_Unit_Extension_Object',      
  1.1725 +            getid3_asf::Web_Stream_Format                   => 'Web_Stream_Format',                   
  1.1726 +            getid3_asf::Payload_Ext_System_File_Name        => 'Payload_Ext_System_File_Name',        
  1.1727 +            getid3_asf::Marker_Object                       => 'Marker_Object',                       
  1.1728 +            getid3_asf::Timecode_Index_Parameters_Object    => 'Timecode_Index_Parameters_Object',    
  1.1729 +            getid3_asf::Audio_Media                         => 'Audio_Media',                         
  1.1730 +            getid3_asf::Media_Object_Index_Object           => 'Media_Object_Index_Object',           
  1.1731 +            getid3_asf::Alt_Extended_Content_Encryption_Obj => 'Alt_Extended_Content_Encryption_Obj'  
  1.1732 +        );
  1.1733 +        
  1.1734 +        return @$lookup[$guid_string];
  1.1735 +    }
  1.1736 +
  1.1737 +
  1.1738 +
  1.1739 +    public static function ASFIndexObjectIndexTypeLookup($id) {
  1.1740 +        
  1.1741 +        static $lookup = array (
  1.1742 +            1 => 'Nearest Past Data Packet',
  1.1743 +            2 => 'Nearest Past Media Object',
  1.1744 +            3 => 'Nearest Past Cleanpoint'
  1.1745 +        );
  1.1746 +
  1.1747 +        return (isset($lookup[$id]) ? $lookup[$id] : 'invalid');
  1.1748 +    }
  1.1749 +
  1.1750 +
  1.1751 +
  1.1752 +    public static function GUIDtoBytestring($guid_string) {
  1.1753 +        
  1.1754 +        // Microsoft defines these 16-byte (128-bit) GUIDs in the strangest way:
  1.1755 +        // first 4 bytes are in little-endian order
  1.1756 +        // next 2 bytes are appended in little-endian order
  1.1757 +        // next 2 bytes are appended in little-endian order
  1.1758 +        // next 2 bytes are appended in big-endian order
  1.1759 +        // next 6 bytes are appended in big-endian order
  1.1760 +
  1.1761 +        // AaBbCcDd-EeFf-GgHh-IiJj-KkLlMmNnOoPp is stored as this 16-byte string:
  1.1762 +        // $Dd $Cc $Bb $Aa $Ff $Ee $Hh $Gg $Ii $Jj $Kk $Ll $Mm $Nn $Oo $Pp
  1.1763 +
  1.1764 +        $hex_byte_char_string  = chr(hexdec(substr($guid_string,  6, 2)));
  1.1765 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string,  4, 2)));
  1.1766 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string,  2, 2)));
  1.1767 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string,  0, 2)));
  1.1768 +
  1.1769 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 11, 2)));
  1.1770 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string,  9, 2)));
  1.1771 +
  1.1772 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 16, 2)));
  1.1773 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 14, 2)));
  1.1774 +
  1.1775 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 19, 2)));
  1.1776 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 21, 2)));
  1.1777 +
  1.1778 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 24, 2)));
  1.1779 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 26, 2)));
  1.1780 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 28, 2)));
  1.1781 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 30, 2)));
  1.1782 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 32, 2)));
  1.1783 +        $hex_byte_char_string .= chr(hexdec(substr($guid_string, 34, 2)));
  1.1784 +
  1.1785 +        return $hex_byte_char_string;
  1.1786 +    }
  1.1787 +
  1.1788 +
  1.1789 +
  1.1790 +    public static function BytestringToGUID($byte_string) {
  1.1791 +        
  1.1792 +        $guid_string  = str_pad(dechex(ord($byte_string{3})),  2, '0', STR_PAD_LEFT);
  1.1793 +        $guid_string .= str_pad(dechex(ord($byte_string{2})),  2, '0', STR_PAD_LEFT);
  1.1794 +        $guid_string .= str_pad(dechex(ord($byte_string{1})),  2, '0', STR_PAD_LEFT);
  1.1795 +        $guid_string .= str_pad(dechex(ord($byte_string{0})),  2, '0', STR_PAD_LEFT);
  1.1796 +        $guid_string .= '-';
  1.1797 +        $guid_string .= str_pad(dechex(ord($byte_string{5})),  2, '0', STR_PAD_LEFT);
  1.1798 +        $guid_string .= str_pad(dechex(ord($byte_string{4})),  2, '0', STR_PAD_LEFT);
  1.1799 +        $guid_string .= '-';
  1.1800 +        $guid_string .= str_pad(dechex(ord($byte_string{7})),  2, '0', STR_PAD_LEFT);
  1.1801 +        $guid_string .= str_pad(dechex(ord($byte_string{6})),  2, '0', STR_PAD_LEFT);
  1.1802 +        $guid_string .= '-';
  1.1803 +        $guid_string .= str_pad(dechex(ord($byte_string{8})),  2, '0', STR_PAD_LEFT);
  1.1804 +        $guid_string .= str_pad(dechex(ord($byte_string{9})),  2, '0', STR_PAD_LEFT);
  1.1805 +        $guid_string .= '-';
  1.1806 +        $guid_string .= str_pad(dechex(ord($byte_string{10})), 2, '0', STR_PAD_LEFT);
  1.1807 +        $guid_string .= str_pad(dechex(ord($byte_string{11})), 2, '0', STR_PAD_LEFT);
  1.1808 +        $guid_string .= str_pad(dechex(ord($byte_string{12})), 2, '0', STR_PAD_LEFT);
  1.1809 +        $guid_string .= str_pad(dechex(ord($byte_string{13})), 2, '0', STR_PAD_LEFT);
  1.1810 +        $guid_string .= str_pad(dechex(ord($byte_string{14})), 2, '0', STR_PAD_LEFT);
  1.1811 +        $guid_string .= str_pad(dechex(ord($byte_string{15})), 2, '0', STR_PAD_LEFT);
  1.1812 +
  1.1813 +        return strtoupper($guid_string);
  1.1814 +    }
  1.1815 +
  1.1816 +
  1.1817 +
  1.1818 +    public static function FiletimeToUNIXtime($file_time, $round=true) {
  1.1819 +        
  1.1820 +        // FILETIME is a 64-bit unsigned integer representing
  1.1821 +        // the number of 100-nanosecond intervals since January 1, 1601
  1.1822 +        // UNIX timestamp is number of seconds since January 1, 1970
  1.1823 +        // 116444736000000000 = 10000000 * 60 * 60 * 24 * 365 * 369 + 89 leap days
  1.1824 +        
  1.1825 +        $time = ($file_time - 116444736000000000) / 10000000;
  1.1826 +        
  1.1827 +        if ($round) {
  1.1828 +            return intval(round($time));
  1.1829 +        }
  1.1830 +        
  1.1831 +        return $time;
  1.1832 +    }
  1.1833 +
  1.1834 +
  1.1835 +
  1.1836 +    public static function TrimTerm($string) {
  1.1837 +
  1.1838 +        // remove terminator, only if present (it should be, but...)
  1.1839 +        if (substr($string, -2) == "\x00\x00") {
  1.1840 +            $string = substr($string, 0, -2);
  1.1841 +        }
  1.1842 +        return $string;
  1.1843 +    }
  1.1844 +
  1.1845 +
  1.1846 +}
  1.1847 +
  1.1848 +
  1.1849 +?>
  1.1850 \ No newline at end of file