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., 59 Temple Place - Suite 330, Boston, MA 02111, 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 #define ASF_OBJECT_COMMON \
124 guid_t i_object_id; \
125 uint64_t i_object_size; \
126 uint64_t i_object_pos; \
127 union asf_object_u *p_father; \
128 union asf_object_u *p_first; \
129 union asf_object_u *p_last; \
130 union asf_object_u *p_next;
136 } asf_object_common_t;
140 uint32_t i_packet_number;
141 uint16_t i_packet_count;
145 /****************************************************************************
146 * High level asf object
147 ****************************************************************************/
148 /* This is the first header find in a asf file
149 * It's the only object that have subobject */
153 uint32_t i_sub_object_count;
154 uint8_t i_reserved1; /* 0x01, but could be safely ignored */
155 uint8_t i_reserved2; /* 0x02, if not must failed to source the contain */
157 } asf_object_header_t;
163 uint64_t i_total_data_packets;
173 uint64_t i_index_entry_time_interval;
174 uint32_t i_max_packet_count;
175 uint32_t i_index_entry_count;
177 asf_index_entry_t *index_entry;
179 } asf_object_index_t;
181 /****************************************************************************
182 * Sub level asf object
183 ****************************************************************************/
184 #define ASF_FILE_PROPERTIES_BROADCAST 0x01
185 #define ASF_FILE_PROPERTIES_SEEKABLE 0x02
192 uint64_t i_file_size;
193 uint64_t i_creation_date;
194 uint64_t i_data_packets_count;
195 uint64_t i_play_duration;
196 uint64_t i_send_duration;
199 uint32_t i_min_data_packet_size;
200 uint32_t i_max_data_packet_size;
201 uint32_t i_max_bitrate;
203 } asf_object_file_properties_t;
205 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
210 guid_t i_stream_type;
211 guid_t i_error_correction_type;
212 uint64_t i_time_offset;
213 uint32_t i_type_specific_data_length;
214 uint32_t i_error_correction_data_length;
216 /* extrated from flags */
217 uint8_t i_stream_number;
219 uint8_t *p_type_specific_data;
220 uint8_t *p_error_correction_data;
221 } asf_object_stream_properties_t;
228 uint16_t i_reserved2;
229 uint32_t i_header_extension_size;
230 uint8_t *p_header_extension_data;
232 } asf_object_header_extension_t;
234 #define ASF_METADATA_TYPE_STRING 0x0000
235 #define ASF_METADATA_TYPE_BYTE 0x0001
236 #define ASF_METADATA_TYPE_BOOL 0x0002
237 #define ASF_METADATA_TYPE_DWORD 0x0003
238 #define ASF_METADATA_TYPE_QWORD 0x0004
239 #define ASF_METADATA_TYPE_WORD 0x0005
251 } asf_metadata_record_t;
257 uint32_t i_record_entries_count;
258 asf_metadata_record_t *record;
260 } asf_object_metadata_t;
269 char *psz_description;
272 } asf_object_content_description_t;
281 #define ASF_CODEC_TYPE_VIDEO 0x0001
282 #define ASF_CODEC_TYPE_AUDIO 0x0002
283 #define ASF_CODEC_TYPE_UNKNOW 0xffff
289 char *psz_description;
291 uint16_t i_information_length;
292 uint8_t *p_information;
299 uint32_t i_codec_entries_count;
300 asf_codec_entry_t *codec;
302 } asf_object_codec_list_t;
307 uint64_t i_presentation_time;
308 uint16_t i_entry_length;
309 uint32_t i_send_time;
311 uint32_t i_marker_description_length;
312 uint8_t *i_marker_description;
321 uint16_t i_reserved2;
323 asf_marker_t *marker;
325 } asf_object_marker_t;
331 char **ppsz_language;
333 } asf_object_language_list_t;
343 uint32_t i_avg_bitrate;
345 } asf_object_stream_bitrate_properties_t;
351 int64_t i_start_time;
353 int32_t i_data_bitrate;
354 int32_t i_buffer_size;
355 int32_t i_initial_buffer_fullness;
356 int32_t i_alternate_data_bitrate;
357 int32_t i_alternate_buffer_size;
358 int32_t i_alternate_initial_buffer_fullness;
359 int32_t i_maximum_object_size;
362 int16_t i_stream_number;
363 int16_t i_language_index;
364 int64_t i_average_time_per_frame;
366 int i_stream_name_count;
367 int i_payload_extention_system_count;
369 int *pi_stream_name_language;
370 char **ppsz_stream_name;
372 asf_object_stream_properties_t *p_sp;
373 } asf_object_extended_stream_properties_t;
380 int16_t i_stream_number_count;
381 int16_t *pi_stream_number;
383 } asf_object_advanced_mutual_exclusion_t;
389 int i_priority_count;
390 int *pi_priority_flag;
391 int *pi_priority_stream_number;
392 } asf_object_stream_prioritization_t;
401 } asf_object_extended_content_description_t;
403 /****************************************************************************
404 * Special Root Object
405 ****************************************************************************/
410 asf_object_header_t *p_hdr;
411 asf_object_data_t *p_data;
412 /* could be NULL if !b_seekable or not-present */
413 asf_object_index_t *p_index;
415 /* from asf_object_header_t */
416 asf_object_file_properties_t *p_fp;
418 /* from asf_object_header_extension_t */
419 asf_object_metadata_t *p_metadata;
423 /****************************************************************************
424 * asf_object_t: union of all objects.
425 ****************************************************************************/
426 typedef union asf_object_u
428 asf_object_common_t common;
429 asf_object_header_t header;
430 asf_object_data_t data;
431 asf_object_index_t index;
432 asf_object_root_t root;
433 asf_object_file_properties_t file_properties;
434 asf_object_stream_properties_t stream_properties;
435 asf_object_header_extension_t header_extension;
436 asf_object_metadata_t metadata;
437 asf_object_codec_list_t codec_list;
438 asf_object_marker_t marker;
439 asf_object_language_list_t lang;
440 asf_object_stream_bitrate_properties_t stream_bitrate;
441 asf_object_extended_stream_properties_t ext_stream;
446 void ASF_GetGUID( guid_t *p_guid, uint8_t *p_data );
447 int ASF_CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
449 asf_object_root_t *ASF_ReadObjectRoot( stream_t *, int b_seekable );
450 void ASF_FreeObjectRoot( stream_t *, asf_object_root_t *p_root );
452 #define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b )
453 int __ASF_CountObject ( asf_object_t *p_obj, const guid_t *p_guid );
455 #define ASF_FindObject( a, b, c ) __ASF_FindObject( (asf_object_t*)(a), b, c )
456 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number );