1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2001-2003 VideoLAN
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 *****************************************************************************/
35 #define ASF_OBJECT_TYPE_NULL 0x0000
36 #define ASF_OBJECT_TYPE_ROOT 0x0001
37 #define ASF_OBJECT_TYPE_HEADER 0x0002
38 #define ASF_OBJECT_TYPE_DATA 0x0003
39 #define ASF_OBJECT_TYPE_INDEX 0x0004
40 #define ASF_OBJECT_TYPE_FILE_PROPERTIES 0x0005
41 #define ASF_OBJECT_TYPE_STREAM_PROPERTIES 0x0006
42 #define ASF_OBJECT_TYPE_HEADER_EXTENSION 0x0007
43 #define ASF_OBJECT_TYPE_CODEC_LIST 0x0008
44 #define ASF_OBJECT_TYPE_MARKER 0x0009
45 #define ASF_OBJECT_TYPE_CONTENT_DESCRIPTION 0x000a
46 #define ASF_OBJECT_TYPE_METADATA 0x000b
48 static const guid_t asf_object_null_guid =
53 { 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00 }
56 static const guid_t asf_object_header_guid =
57 {0x75B22630, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}};
59 static const guid_t asf_object_data_guid =
60 {0x75B22636, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}};
62 static const guid_t asf_object_index_guid =
63 {0x33000890, 0xE5B1, 0x11CF, {0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB}};
65 static const guid_t asf_object_file_properties_guid =
66 {0x8cabdca1, 0xa947, 0x11cf, {0x8e, 0xe4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
68 static const guid_t asf_object_stream_properties_guid =
69 {0xB7DC0791, 0xA9B7, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
71 static const guid_t asf_object_content_description_guid =
72 {0x75B22633, 0x668E, 0x11CF, {0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}};
74 static const guid_t asf_object_header_extension_guid =
75 {0x5FBF03B5, 0xA92E, 0x11CF, {0x8E, 0xE3, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
77 static const guid_t asf_object_metadata_guid =
78 {0xC5F8CBEA, 0x5BAF, 0x4877, {0x84, 0x67, 0xAA, 0x8C, 0x44, 0xFA, 0x4C, 0xCA}};
80 static const guid_t asf_object_codec_list_guid =
81 {0x86D15240, 0x311D, 0x11D0, {0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}};
83 static const guid_t asf_object_marker_guid =
84 {0xF487CD01, 0xA951, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
86 static const guid_t asf_object_stream_type_audio =
87 {0xF8699E40, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
89 static const guid_t asf_object_stream_type_video =
90 {0xbc19efc0, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
92 static const guid_t asf_object_stream_type_command =
93 {0x59DACFC0, 0x59E6, 0x11D0, {0xA3, 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}};
95 #define ASF_OBJECT_COMMON \
98 uint64_t i_object_size; \
99 uint64_t i_object_pos; \
100 union asf_object_u *p_father; \
101 union asf_object_u *p_first; \
102 union asf_object_u *p_last; \
103 union asf_object_u *p_next;
105 typedef struct asf_object_common_s
109 } asf_object_common_t;
111 typedef struct asf_index_entry_s
113 uint32_t i_packet_number;
114 uint16_t i_packet_count;
118 /****************************************************************************
119 * High level asf object
120 ****************************************************************************/
121 /* This is the first header find in a asf file
122 * It's the only object that have subobject */
123 typedef struct asf_object_header_s
126 uint32_t i_sub_object_count;
127 uint8_t i_reserved1; /* 0x01, but could be safely ignored */
128 uint8_t i_reserved2; /* 0x02, if not must failed to source the contain */
130 } asf_object_header_t;
132 typedef struct asf_object_data_s
136 uint64_t i_total_data_packets;
142 typedef struct asf_object_index_s
146 uint64_t i_index_entry_time_interval;
147 uint32_t i_max_packet_count;
148 uint32_t i_index_entry_count;
150 asf_index_entry_t *index_entry;
152 } asf_object_index_t;
154 /****************************************************************************
155 * Sub level asf object
156 ****************************************************************************/
157 #define ASF_FILE_PROPERTIES_BROADCAST 0x01
158 #define ASF_FILE_PROPERTIES_SEEKABLE 0x02
160 typedef struct asf_object_file_properties_s
165 uint64_t i_file_size;
166 uint64_t i_creation_date;
167 uint64_t i_data_packets_count;
168 uint64_t i_play_duration;
169 uint64_t i_send_duration;
172 uint32_t i_min_data_packet_size;
173 uint32_t i_max_data_packet_size;
174 uint32_t i_max_bitrate;
176 } asf_object_file_properties_t;
178 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
179 typedef struct asf_object_stream_properties_s
183 guid_t i_stream_type;
184 guid_t i_error_correction_type;
185 uint64_t i_time_offset;
186 uint32_t i_type_specific_data_length;
187 uint32_t i_error_correction_data_length;
189 /* extrated from flags */
190 uint8_t i_stream_number;
192 uint8_t *p_type_specific_data;
193 uint8_t *p_error_correction_data;
194 } asf_object_stream_properties_t;
196 typedef struct asf_object_header_extension_s
201 uint16_t i_reserved2;
202 uint32_t i_header_extension_size;
203 uint8_t *p_header_extension_data;
205 } asf_object_header_extension_t;
207 #define ASF_METADATA_TYPE_STRING 0x0000
208 #define ASF_METADATA_TYPE_BYTE 0x0001
209 #define ASF_METADATA_TYPE_BOOL 0x0002
210 #define ASF_METADATA_TYPE_DWORD 0x0003
211 #define ASF_METADATA_TYPE_QWORD 0x0004
212 #define ASF_METADATA_TYPE_WORD 0x0005
214 typedef struct asf_metadata_record_s
224 } asf_metadata_record_t;
226 typedef struct asf_object_metadata_s
230 uint32_t i_record_entries_count;
231 asf_metadata_record_t *record;
233 } asf_object_metadata_t;
235 typedef struct asf_objec_content_description_s
242 char *psz_description;
245 } asf_object_content_description_t;
247 typedef struct string16_s
254 #define ASF_CODEC_TYPE_VIDEO 0x0001
255 #define ASF_CODEC_TYPE_AUDIO 0x0002
256 #define ASF_CODEC_TYPE_UNKNOW 0xffff
258 typedef struct asf_codec_entry_s
262 char *psz_description;
264 uint16_t i_information_length;
265 uint8_t *p_information;
268 typedef struct asf_object_codec_list_s
272 uint32_t i_codec_entries_count;
273 asf_codec_entry_t *codec;
275 } asf_object_codec_list_t;
277 typedef struct asf_marker_s
280 uint64_t i_presentation_time;
281 uint16_t i_entry_length;
282 uint32_t i_send_time;
284 uint32_t i_marker_description_length;
285 uint8_t *i_marker_description;
289 typedef struct asf_object_marker_s
294 uint16_t i_reserved2;
296 asf_marker_t *marker;
298 } asf_object_marker_t;
300 /****************************************************************************
301 * Special Root Object
302 ****************************************************************************/
303 typedef struct asf_object_root_s
307 asf_object_header_t *p_hdr;
308 asf_object_data_t *p_data;
309 /* could be NULL if !b_seekable or not-present */
310 asf_object_index_t *p_index;
311 asf_object_header_extension_t *p_hdr_ext;
313 /* from asf_object_header_t */
314 asf_object_file_properties_t *p_fp;
316 /* from asf_object_header_extension_t */
317 asf_object_metadata_t *p_metadata;
321 /****************************************************************************
322 * asf_object_t: union of all objects.
323 ****************************************************************************/
324 typedef union asf_object_u
326 asf_object_common_t common;
327 asf_object_header_t header;
328 asf_object_data_t data;
329 asf_object_index_t index;
330 asf_object_root_t root;
331 asf_object_file_properties_t file_properties;
332 asf_object_stream_properties_t stream_properties;
333 asf_object_header_extension_t header_extension;
334 asf_object_metadata_t metadata;
335 asf_object_codec_list_t codec_list;
336 asf_object_marker_t marker;
341 void ASF_GetGUID( guid_t *p_guid, uint8_t *p_data );
342 int ASF_CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
344 asf_object_root_t *ASF_ReadObjectRoot( stream_t *, int b_seekable );
345 void ASF_FreeObjectRoot( stream_t *, asf_object_root_t *p_root );
347 #define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b )
348 int __ASF_CountObject ( asf_object_t *p_obj, const guid_t *p_guid );
350 #define ASF_FindObject( a, b, c ) __ASF_FindObject( (asf_object_t*)(a), b, c )
351 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number );