1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: libasf.h,v 1.6 2003/08/17 23:42:37 fenrir 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 typedef struct asf_object_root_s
218 asf_object_header_t *p_hdr;
219 asf_object_data_t *p_data;
220 asf_object_index_t *p_index;
224 /****************************************************************************
225 * Sub level asf object
226 ****************************************************************************/
227 #define ASF_FILE_PROPERTIES_BROADCAST 0x01
228 #define ASF_FILE_PROPERTIES_SEEKABLE 0x02
230 typedef struct asf_object_file_properties_s
235 uint64_t i_file_size;
236 uint64_t i_creation_date;
237 uint64_t i_data_packets_count;
238 uint64_t i_play_duration;
239 uint64_t i_send_duration;
242 uint32_t i_min_data_packet_size;
243 uint32_t i_max_data_packet_size;
244 uint32_t i_max_bitrate;
246 } asf_object_file_properties_t;
248 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
249 typedef struct asf_object_stream_properties_s
253 guid_t i_stream_type;
254 guid_t i_error_correction_type;
255 uint64_t i_time_offset;
256 uint32_t i_type_specific_data_length;
257 uint32_t i_error_correction_data_length;
259 /* extrated from flags */
260 uint8_t i_stream_number;
262 uint8_t *p_type_specific_data;
263 uint8_t *p_error_correction_data;
264 } asf_object_stream_properties_t;
266 typedef struct asf_object_header_extention_s
271 uint16_t i_reserved2;
272 uint32_t i_header_extention_size;
273 uint8_t *p_header_extention_data;
275 } asf_object_header_extention_t;
277 typedef struct asf_objec_content_description_s
284 char *psz_description;
287 } asf_object_content_description_t;
289 typedef struct string16_s
295 #define ASF_CODEC_TYPE_VIDEO 0x0001
296 #define ASF_CODEC_TYPE_AUDIO 0x0002
297 #define ASF_CODEC_TYPE_UNKNOW 0xffff
299 typedef struct asf_codec_entry_s
303 char *psz_description;
305 uint16_t i_information_length;
306 uint8_t *p_information;
309 typedef struct asf_object_codec_list_s
313 uint32_t i_codec_entries_count;
314 asf_codec_entry_t *codec;
316 } asf_object_codec_list_t;
318 typedef struct asf_marker_s
321 uint64_t i_presentation_time;
322 uint16_t i_entry_length;
323 uint32_t i_send_time;
325 uint32_t i_marker_description_length;
326 uint8_t *i_marker_description;
330 typedef struct asf_object_marker_s
335 uint16_t i_reserved2;
337 asf_marker_t *marker;
339 } asf_object_marker_t;
341 typedef union asf_object_u
343 asf_object_common_t common;
344 asf_object_header_t header;
345 asf_object_data_t data;
346 asf_object_index_t index;
347 asf_object_root_t root;
348 asf_object_file_properties_t file_properties;
349 asf_object_stream_properties_t stream_properties;
350 asf_object_header_extention_t header_extention;
351 asf_object_codec_list_t codec_list;
352 asf_object_marker_t marker;
357 off_t ASF_TellAbsolute( input_thread_t *p_input );
358 int ASF_SeekAbsolute( input_thread_t *p_input, off_t i_pos);
359 int ASF_ReadData( input_thread_t *p_input, uint8_t *p_buff, int i_size );
360 int ASF_SkipBytes( input_thread_t *p_input, int i_count );
362 void ASF_GetGUID( guid_t *p_guid, uint8_t *p_data );
363 int ASF_CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
365 int ASF_ReadObjectCommon( input_thread_t *p_input,
366 asf_object_t *p_obj );
367 int ASF_NextObject( input_thread_t *p_input,
368 asf_object_t *p_obj );
369 int ASF_GotoObject( input_thread_t *p_input,
370 asf_object_t *p_obj );
372 int ASF_ReadObject( input_thread_t *p_input,
374 asf_object_t *p_father );
375 void ASF_FreeObject( input_thread_t *p_input,
376 asf_object_t *p_obj );
377 int ASF_ReadObjectRoot( input_thread_t *p_input,
378 asf_object_root_t *p_root,
380 void ASF_FreeObjectRoot( input_thread_t *p_input,
381 asf_object_root_t *p_root );
382 #define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b )
383 int __ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid );
385 #define ASF_FindObject( a, b, c ) __ASF_FindObject( (asf_object_t*)(a), b, c )
386 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number );