1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2001-2003 the VideoLAN team
6 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
24 /*****************************************************************************
25 * Structure needed for decoder
26 *****************************************************************************/
42 ASF_OBJECT_FILE_PROPERTIES
,
43 ASF_OBJECT_STREAM_PROPERTIES
,
44 ASF_OBJECT_HEADER_EXTENSION
,
45 ASF_OBJECT_CODEC_LIST
,
47 ASF_OBJECT_CONTENT_DESCRIPTION
,
53 static const guid_t asf_object_null_guid
=
58 { 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00 }
61 static const guid_t asf_object_header_guid
=
62 {0x75B22630, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}};
64 static const guid_t asf_object_data_guid
=
65 {0x75B22636, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}};
67 static const guid_t asf_object_index_guid
=
68 {0x33000890, 0xE5B1, 0x11CF, {0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB}};
70 static const guid_t asf_object_file_properties_guid
=
71 {0x8cabdca1, 0xa947, 0x11cf, {0x8e, 0xe4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
73 static const guid_t asf_object_stream_properties_guid
=
74 {0xB7DC0791, 0xA9B7, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
76 static const guid_t asf_object_content_description_guid
=
77 {0x75B22633, 0x668E, 0x11CF, {0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}};
79 static const guid_t asf_object_header_extension_guid
=
80 {0x5FBF03B5, 0xA92E, 0x11CF, {0x8E, 0xE3, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
82 static const guid_t asf_object_metadata_guid
=
83 {0xC5F8CBEA, 0x5BAF, 0x4877, {0x84, 0x67, 0xAA, 0x8C, 0x44, 0xFA, 0x4C, 0xCA}};
85 static const guid_t asf_object_codec_list_guid
=
86 {0x86D15240, 0x311D, 0x11D0, {0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}};
88 static const guid_t asf_object_marker_guid
=
89 {0xF487CD01, 0xA951, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
91 static const guid_t asf_object_stream_type_audio
=
92 {0xF8699E40, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
94 static const guid_t asf_object_stream_type_video
=
95 {0xbc19efc0, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
97 static const guid_t asf_object_stream_type_command
=
98 {0x59DACFC0, 0x59E6, 0x11D0, {0xA3, 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}};
101 static const guid_t asf_object_stream_bitrate_properties
=
102 {0x7BF875CE, 0x468D, 0x11D1, {0x8D, 0x82, 0x00, 0x60, 0x97, 0xC9, 0xA2, 0xB2}};
104 static const guid_t asf_object_language_list
=
105 {0x7C4346A9, 0xEFE0, 0x4BFC, {0xB2, 0x29, 0x39, 0x3E, 0xDE, 0x41, 0x5C, 0x85}};
107 static const guid_t asf_object_extended_stream_properties
=
108 {0x14E6A5CB, 0xC672, 0x4332, {0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A}};
110 static const guid_t asf_object_advanced_mutual_exclusion
=
111 {0xA08649CF, 0x4775, 0x4670, {0x8A, 0x16, 0x6E, 0x35, 0x35, 0x75, 0x66, 0xCD}};
113 static const guid_t asf_object_padding
=
114 {0x1806D474, 0xCADF, 0x4509, {0xA4, 0xBA, 0x9A, 0xAB, 0xCB, 0x96, 0xAA, 0xE8}};
116 static const guid_t asf_object_stream_prioritization
=
117 {0xD4FED15B, 0x88D3, 0x454F, {0x81, 0xF0, 0xED, 0x5C, 0x45, 0x99, 0x9E, 0x24}};
119 static const guid_t asf_object_extended_content_description
=
120 {0xD2D0A440, 0xE307, 0x11D2, {0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50}};
122 static const guid_t asf_object_extended_stream_header
=
123 {0x3afb65e2, 0x47ef, 0x40f2, { 0xac, 0x2c, 0x70, 0xa9, 0x0d, 0x71, 0xd3, 0x43}};
125 static const guid_t asf_object_extended_stream_type_audio
=
126 {0x31178c9d, 0x03e1, 0x4528, { 0xb5, 0x82, 0x3d, 0xf9, 0xdb, 0x22, 0xf5, 0x03}};
128 #define ASF_OBJECT_COMMON \
130 guid_t i_object_id; \
131 uint64_t i_object_size; \
132 uint64_t i_object_pos; \
133 union asf_object_u *p_father; \
134 union asf_object_u *p_first; \
135 union asf_object_u *p_last; \
136 union asf_object_u *p_next;
142 } asf_object_common_t
;
146 uint32_t i_packet_number
;
147 uint16_t i_packet_count
;
151 /****************************************************************************
152 * High level asf object
153 ****************************************************************************/
154 /* This is the first header found in an asf file
155 * It's the only object that has subobjects */
159 uint32_t i_sub_object_count
;
160 uint8_t i_reserved1
; /* 0x01, but could be safely ignored */
161 uint8_t i_reserved2
; /* 0x02, if not must failed to source the contain */
163 } asf_object_header_t
;
169 uint64_t i_total_data_packets
;
179 uint64_t i_index_entry_time_interval
;
180 uint32_t i_max_packet_count
;
181 uint32_t i_index_entry_count
;
183 asf_index_entry_t
*index_entry
;
185 } asf_object_index_t
;
187 /****************************************************************************
188 * Sub level asf object
189 ****************************************************************************/
190 #define ASF_FILE_PROPERTIES_BROADCAST 0x01
191 #define ASF_FILE_PROPERTIES_SEEKABLE 0x02
198 uint64_t i_file_size
;
199 uint64_t i_creation_date
;
200 uint64_t i_data_packets_count
;
201 uint64_t i_play_duration
;
202 uint64_t i_send_duration
;
205 uint32_t i_min_data_packet_size
;
206 uint32_t i_max_data_packet_size
;
207 uint32_t i_max_bitrate
;
209 } asf_object_file_properties_t
;
211 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
216 guid_t i_stream_type
;
217 guid_t i_error_correction_type
;
218 uint64_t i_time_offset
;
219 uint32_t i_type_specific_data_length
;
220 uint32_t i_error_correction_data_length
;
222 /* extrated from flags */
223 uint8_t i_stream_number
;
225 uint8_t *p_type_specific_data
;
226 uint8_t *p_error_correction_data
;
227 } asf_object_stream_properties_t
;
234 uint16_t i_reserved2
;
235 uint32_t i_header_extension_size
;
236 uint8_t *p_header_extension_data
;
238 } asf_object_header_extension_t
;
240 #define ASF_METADATA_TYPE_STRING 0x0000
241 #define ASF_METADATA_TYPE_BYTE 0x0001
242 #define ASF_METADATA_TYPE_BOOL 0x0002
243 #define ASF_METADATA_TYPE_DWORD 0x0003
244 #define ASF_METADATA_TYPE_QWORD 0x0004
245 #define ASF_METADATA_TYPE_WORD 0x0005
257 } asf_metadata_record_t
;
263 uint32_t i_record_entries_count
;
264 asf_metadata_record_t
*record
;
266 } asf_object_metadata_t
;
275 char *psz_description
;
278 } asf_object_content_description_t
;
287 #define ASF_CODEC_TYPE_VIDEO 0x0001
288 #define ASF_CODEC_TYPE_AUDIO 0x0002
289 #define ASF_CODEC_TYPE_UNKNOW 0xffff
295 char *psz_description
;
297 uint16_t i_information_length
;
298 uint8_t *p_information
;
305 uint32_t i_codec_entries_count
;
306 asf_codec_entry_t
*codec
;
308 } asf_object_codec_list_t
;
313 uint64_t i_presentation_time
;
314 uint16_t i_entry_length
;
315 uint32_t i_send_time
;
317 uint32_t i_marker_description_length
;
318 uint8_t *i_marker_description
;
327 uint16_t i_reserved2
;
329 asf_marker_t
*marker
;
331 } asf_object_marker_t
;
337 char **ppsz_language
;
339 } asf_object_language_list_t
;
349 uint32_t i_avg_bitrate
;
351 } asf_object_stream_bitrate_properties_t
;
357 int64_t i_start_time
;
359 int32_t i_data_bitrate
;
360 int32_t i_buffer_size
;
361 int32_t i_initial_buffer_fullness
;
362 int32_t i_alternate_data_bitrate
;
363 int32_t i_alternate_buffer_size
;
364 int32_t i_alternate_initial_buffer_fullness
;
365 int32_t i_maximum_object_size
;
368 int16_t i_stream_number
;
369 int16_t i_language_index
;
370 int64_t i_average_time_per_frame
;
372 int i_stream_name_count
;
373 int i_payload_extension_system_count
;
375 int *pi_stream_name_language
;
376 char **ppsz_stream_name
;
378 asf_object_stream_properties_t
*p_sp
;
379 } asf_object_extended_stream_properties_t
;
386 int16_t i_stream_number_count
;
387 int16_t *pi_stream_number
;
389 } asf_object_advanced_mutual_exclusion_t
;
395 int i_priority_count
;
396 int *pi_priority_flag
;
397 int *pi_priority_stream_number
;
398 } asf_object_stream_prioritization_t
;
407 } asf_object_extended_content_description_t
;
409 /****************************************************************************
410 * Special Root Object
411 ****************************************************************************/
416 asf_object_header_t
*p_hdr
;
417 asf_object_data_t
*p_data
;
418 /* could be NULL if !b_seekable or not-present */
419 asf_object_index_t
*p_index
;
421 /* from asf_object_header_t */
422 asf_object_file_properties_t
*p_fp
;
424 /* from asf_object_header_extension_t */
425 asf_object_metadata_t
*p_metadata
;
429 /****************************************************************************
430 * asf_object_t: union of all objects.
431 ****************************************************************************/
432 typedef union asf_object_u
434 asf_object_common_t common
;
435 asf_object_header_t header
;
436 asf_object_data_t data
;
437 asf_object_index_t index
;
438 asf_object_root_t root
;
439 asf_object_file_properties_t file_properties
;
440 asf_object_stream_properties_t stream_properties
;
441 asf_object_header_extension_t header_extension
;
442 asf_object_metadata_t metadata
;
443 asf_object_codec_list_t codec_list
;
444 asf_object_marker_t marker
;
445 asf_object_language_list_t language_list
;
446 asf_object_stream_bitrate_properties_t stream_bitrate
;
447 asf_object_extended_stream_properties_t ext_stream
;
448 asf_object_content_description_t content_description
;
449 asf_object_advanced_mutual_exclusion_t advanced_mutual_exclusion
;
450 asf_object_stream_prioritization_t stream_prioritization
;
451 asf_object_extended_content_description_t extended_content_description
;
456 void ASF_GetGUID( guid_t
*p_guid
, const uint8_t *p_data
);
457 bool ASF_CmpGUID( const guid_t
*p_guid1
, const guid_t
*p_guid2
);
459 asf_object_root_t
*ASF_ReadObjectRoot( stream_t
*, int b_seekable
);
460 void ASF_FreeObjectRoot( stream_t
*, asf_object_root_t
*p_root
);
462 #define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b )
463 int __ASF_CountObject ( asf_object_t
*p_obj
, const guid_t
*p_guid
);
465 #define ASF_FindObject( a, b, c ) __ASF_FindObject( (asf_object_t*)(a), b, c )
466 void *__ASF_FindObject( asf_object_t
*p_obj
, const guid_t
*p_guid
, int i_number
);