1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: libasf.h,v 1.3 2002/11/05 10:07:56 gbazin 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 *****************************************************************************/
23 #include "codecs.h" /* BITMAPINFOHEADER, WAVEFORMATEX */
25 /*****************************************************************************
26 * Structure needed for decoder
27 *****************************************************************************/
36 #define ASF_OBJECT_TYPE_NULL 0x0000
37 #define ASF_OBJECT_TYPE_ROOT 0x0001
38 #define ASF_OBJECT_TYPE_HEADER 0x0002
39 #define ASF_OBJECT_TYPE_DATA 0x0003
40 #define ASF_OBJECT_TYPE_INDEX 0x0004
41 #define ASF_OBJECT_TYPE_FILE_PROPERTIES 0x0005
42 #define ASF_OBJECT_TYPE_STREAM_PROPERTIES 0x0006
43 #define ASF_OBJECT_TYPE_EXTENTION_HEADER 0x0007
44 #define ASF_OBJECT_TYPE_CODEC_LIST 0x0008
45 #define ASF_OBJECT_TYPE_MARKER 0x0009
46 #define ASF_OBJECT_TYPE_CONTENT_DESCRIPTION 0x000a
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 =
61 { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
64 static const guid_t asf_object_data_guid =
69 { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
74 static const guid_t asf_object_index_guid =
79 { 0x89,0xF4, 0x00,0xA0,0xC9,0x03,0x49,0xCB }
82 static const guid_t asf_object_file_properties_guid =
87 { 0x8e,0xe4, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
90 static const guid_t asf_object_stream_properties_guid =
95 { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
99 static const guid_t asf_object_content_description_guid =
104 { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }
107 static const guid_t asf_object_header_extention_guid =
112 { 0x8E,0xE3, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
115 static const guid_t asf_object_codec_list_guid =
120 { 0xA3,0xA4, 0x00,0xA0,0xC9,0x03,0x48,0xF6 }
123 static const guid_t asf_object_marker_guid =
128 { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
132 static const guid_t asf_object_stream_type_audio =
137 { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B }
140 static const guid_t asf_object_stream_type_video =
145 { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B }
148 static const guid_t asf_object_stream_type_command =
153 { 0xA3,0xAC, 0x00,0xA0,0xC9,0x03,0x48,0xF6 }
157 static const guid_t asf_object_
164 typedef struct asf_packet_s
174 #define ASF_OBJECT_COMMON \
176 guid_t i_object_id; \
179 union asf_object_u *p_father; \
180 union asf_object_u *p_first; \
181 union asf_object_u *p_last; \
182 union asf_object_u *p_next;
184 typedef struct asf_object_common_s
188 } asf_object_common_t;
190 typedef struct asf_index_entry_s
197 /****************************************************************************
198 * High level asf object
199 ****************************************************************************/
200 /* This is the first header find in a asf file
201 * It's the only object that have subobject */
202 typedef struct asf_object_header_s
205 u32 i_sub_object_count;
206 u8 i_reserved1; /* 0x01, but could be safely ignored */
207 u8 i_reserved2; /* 0x02, if not must failed to source the contain */
209 } asf_object_header_t;
211 typedef struct asf_object_data_s
215 u64 i_total_data_packets;
221 typedef struct asf_object_index_s
225 u64 i_index_entry_time_interval;
226 u32 i_max_packet_count;
227 u32 i_index_entry_count;
229 asf_index_entry_t *index_entry;
231 } asf_object_index_t;
233 typedef struct asf_object_root_s
237 asf_object_header_t *p_hdr;
238 asf_object_data_t *p_data;
239 asf_object_index_t *p_index;
243 /****************************************************************************
244 * Sub level asf object
245 ****************************************************************************/
246 #define ASF_FILE_PROPERTIES_BROADCAST 0x01
247 #define ASF_FILE_PROPERTIES_SEEKABLE 0x02
249 typedef struct asf_object_file_properties_s
256 u64 i_data_packets_count;
261 u32 i_min_data_packet_size;
262 u32 i_max_data_packet_size;
265 } asf_object_file_properties_t;
267 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
268 typedef struct asf_object_stream_properties_s
272 guid_t i_stream_type;
273 guid_t i_error_correction_type;
275 u32 i_type_specific_data_length;
276 u32 i_error_correction_data_length;
278 /* extrated from flags */
281 u8 *p_type_specific_data;
282 u8 *p_error_correction_data;
283 } asf_object_stream_properties_t;
285 typedef struct asf_object_header_extention_s
291 u32 i_header_extention_size;
292 u8 *p_header_extention_data;
294 } asf_object_header_extention_t;
296 typedef struct asf_objec_content_description_s
303 char *psz_description;
306 } asf_object_content_description_t;
308 typedef struct string16_s
314 #define ASF_CODEC_TYPE_VIDEO 0x0001
315 #define ASF_CODEC_TYPE_AUDIO 0x0002
316 #define ASF_CODEC_TYPE_UNKNOW 0xffff
318 typedef struct asf_codec_entry_s
322 char *psz_description;
324 u16 i_information_length;
328 typedef struct asf_object_codec_list_s
332 u32 i_codec_entries_count;
333 asf_codec_entry_t *codec;
335 } asf_object_codec_list_t;
338 typedef struct asf_object_script_command_s
343 } asf_object_script_command_t;
345 typedef struct asf_marker_s
348 u64 i_presentation_time;
352 u32 i_marker_description_length;
353 u8 *i_marker_description;
358 typedef struct asf_object_marker_s
365 asf_marker_t *marker;
367 } asf_object_marker_t;
370 typedef struct asf_object__s
377 typedef union asf_object_u
379 asf_object_common_t common;
380 asf_object_header_t header;
381 asf_object_data_t data;
382 asf_object_index_t index;
383 asf_object_root_t root;
384 asf_object_file_properties_t file_properties;
385 asf_object_stream_properties_t stream_properties;
386 asf_object_header_extention_t header_extention;
387 asf_object_codec_list_t codec_list;
388 asf_object_marker_t marker;
393 off_t ASF_TellAbsolute( input_thread_t *p_input );
394 int ASF_SeekAbsolute( input_thread_t *p_input, off_t i_pos);
395 int ASF_ReadData( input_thread_t *p_input, u8 *p_buff, int i_size );
396 int ASF_SkipBytes( input_thread_t *p_input, int i_count );
398 void GetGUID( guid_t *p_guid, u8 *p_data );
399 int CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
401 int ASF_ReadObjectCommon( input_thread_t *p_input,
402 asf_object_t *p_obj );
403 int ASF_NextObject( input_thread_t *p_input,
404 asf_object_t *p_obj );
405 int ASF_GotoObject( input_thread_t *p_input,
406 asf_object_t *p_obj );
408 int ASF_ReadObject( input_thread_t *p_input,
410 asf_object_t *p_father );
411 void ASF_FreeObject( input_thread_t *p_input,
412 asf_object_t *p_obj );
413 int ASF_ReadObjectRoot( input_thread_t *p_input,
414 asf_object_root_t *p_root,
416 void ASF_FreeObjectRoot( input_thread_t *p_input,
417 asf_object_root_t *p_root );
418 #define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b )
419 int __ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid );
421 #define ASF_FindObject( a, b, c ) __ASF_FindObject( (asf_object_t*)(a), b, c )
422 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number );