1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2001-2003 VideoLAN
5 * $Id: libasf.h,v 1.8 2004/01/25 20:05:28 hartman Exp $
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_EXTENTION_HEADER 0x0007
43 #define ASF_OBJECT_TYPE_CODEC_LIST 0x0008
44 #define ASF_OBJECT_TYPE_MARKER 0x0009
45 #define ASF_OBJECT_TYPE_CONTENT_DESCRIPTION 0x000a
47 static const guid_t asf_object_null_guid =
52 { 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00 }
55 static const guid_t asf_object_header_guid =
60 { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
63 static const guid_t asf_object_data_guid =
68 { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
73 static const guid_t asf_object_index_guid =
78 { 0x89,0xF4, 0x00,0xA0,0xC9,0x03,0x49,0xCB }
81 static const guid_t asf_object_file_properties_guid =
86 { 0x8e,0xe4, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
89 static const guid_t asf_object_stream_properties_guid =
94 { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
98 static const guid_t asf_object_content_description_guid =
103 { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }
106 static const guid_t asf_object_header_extention_guid =
111 { 0x8E,0xE3, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
114 static const guid_t asf_object_codec_list_guid =
119 { 0xA3,0xA4, 0x00,0xA0,0xC9,0x03,0x48,0xF6 }
122 static const guid_t asf_object_marker_guid =
127 { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
131 static const guid_t asf_object_stream_type_audio =
136 { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B }
139 static const guid_t asf_object_stream_type_video =
144 { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B }
147 static const guid_t asf_object_stream_type_command =
152 { 0xA3,0xAC, 0x00,0xA0,0xC9,0x03,0x48,0xF6 }
155 #define ASF_OBJECT_COMMON \
157 guid_t i_object_id; \
158 uint64_t i_object_size; \
159 uint64_t i_object_pos; \
160 union asf_object_u *p_father; \
161 union asf_object_u *p_first; \
162 union asf_object_u *p_last; \
163 union asf_object_u *p_next;
165 typedef struct asf_object_common_s
169 } asf_object_common_t;
171 typedef struct asf_index_entry_s
173 uint32_t i_packet_number;
174 uint16_t i_packet_count;
178 /****************************************************************************
179 * High level asf object
180 ****************************************************************************/
181 /* This is the first header find in a asf file
182 * It's the only object that have subobject */
183 typedef struct asf_object_header_s
186 uint32_t i_sub_object_count;
187 uint8_t i_reserved1; /* 0x01, but could be safely ignored */
188 uint8_t i_reserved2; /* 0x02, if not must failed to source the contain */
190 } asf_object_header_t;
192 typedef struct asf_object_data_s
196 uint64_t i_total_data_packets;
202 typedef struct asf_object_index_s
206 uint64_t i_index_entry_time_interval;
207 uint32_t i_max_packet_count;
208 uint32_t i_index_entry_count;
210 asf_index_entry_t *index_entry;
212 } asf_object_index_t;
214 /****************************************************************************
215 * Sub level asf object
216 ****************************************************************************/
217 #define ASF_FILE_PROPERTIES_BROADCAST 0x01
218 #define ASF_FILE_PROPERTIES_SEEKABLE 0x02
220 typedef struct asf_object_file_properties_s
225 uint64_t i_file_size;
226 uint64_t i_creation_date;
227 uint64_t i_data_packets_count;
228 uint64_t i_play_duration;
229 uint64_t i_send_duration;
232 uint32_t i_min_data_packet_size;
233 uint32_t i_max_data_packet_size;
234 uint32_t i_max_bitrate;
236 } asf_object_file_properties_t;
238 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
239 typedef struct asf_object_stream_properties_s
243 guid_t i_stream_type;
244 guid_t i_error_correction_type;
245 uint64_t i_time_offset;
246 uint32_t i_type_specific_data_length;
247 uint32_t i_error_correction_data_length;
249 /* extrated from flags */
250 uint8_t i_stream_number;
252 uint8_t *p_type_specific_data;
253 uint8_t *p_error_correction_data;
254 } asf_object_stream_properties_t;
256 typedef struct asf_object_header_extention_s
261 uint16_t i_reserved2;
262 uint32_t i_header_extention_size;
263 uint8_t *p_header_extention_data;
265 } asf_object_header_extention_t;
267 typedef struct asf_objec_content_description_s
274 char *psz_description;
277 } asf_object_content_description_t;
279 typedef struct string16_s
285 #define ASF_CODEC_TYPE_VIDEO 0x0001
286 #define ASF_CODEC_TYPE_AUDIO 0x0002
287 #define ASF_CODEC_TYPE_UNKNOW 0xffff
289 typedef struct asf_codec_entry_s
293 char *psz_description;
295 uint16_t i_information_length;
296 uint8_t *p_information;
299 typedef struct asf_object_codec_list_s
303 uint32_t i_codec_entries_count;
304 asf_codec_entry_t *codec;
306 } asf_object_codec_list_t;
308 typedef struct asf_marker_s
311 uint64_t i_presentation_time;
312 uint16_t i_entry_length;
313 uint32_t i_send_time;
315 uint32_t i_marker_description_length;
316 uint8_t *i_marker_description;
320 typedef struct asf_object_marker_s
325 uint16_t i_reserved2;
327 asf_marker_t *marker;
329 } asf_object_marker_t;
331 /****************************************************************************
332 * Special Root Object
333 ****************************************************************************/
334 typedef struct asf_object_root_s
338 asf_object_header_t *p_hdr;
339 asf_object_data_t *p_data;
340 /* could be NULL if !b_seekable or not-present */
341 asf_object_index_t *p_index;
343 /* from asf_object_header_t */
344 asf_object_file_properties_t *p_fp;
348 /****************************************************************************
349 * asf_object_t: union of all objects.
350 ****************************************************************************/
351 typedef union asf_object_u
353 asf_object_common_t common;
354 asf_object_header_t header;
355 asf_object_data_t data;
356 asf_object_index_t index;
357 asf_object_root_t root;
358 asf_object_file_properties_t file_properties;
359 asf_object_stream_properties_t stream_properties;
360 asf_object_header_extention_t header_extention;
361 asf_object_codec_list_t codec_list;
362 asf_object_marker_t marker;
368 void ASF_GetGUID ( guid_t *p_guid, uint8_t *p_data );
369 int ASF_CmpGUID ( const guid_t *p_guid1, const guid_t *p_guid2 );
371 asf_object_root_t *ASF_ReadObjectRoot( stream_t *, int b_seekable );
372 void ASF_FreeObjectRoot ( stream_t *, asf_object_root_t *p_root );
374 #define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b )
375 int __ASF_CountObject ( asf_object_t *p_obj, const guid_t *p_guid );
377 #define ASF_FindObject( a, b, c ) __ASF_FindObject( (asf_object_t*)(a), b, c )
378 void *__ASF_FindObject ( asf_object_t *p_obj, const guid_t *p_guid, int i_number );