]> git.sesse.net Git - vlc/blob - modules/demux/asf/libasf.h
* all : add an asf file (v1.0 only) demuxer. Need a lot of work to be
[vlc] / modules / demux / asf / libasf.h
1 /*****************************************************************************
2  * libasf.h : 
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: libasf.h,v 1.1 2002/10/20 17:22:33 fenrir Exp $
6  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7  * 
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.
12  * 
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.
17  *
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  *****************************************************************************/
22
23 /*****************************************************************************
24  * Structure needed for decoder
25  *****************************************************************************/
26 typedef struct bitmapinfoheader_s
27 {
28     u32 i_size; /* size of header 40 + size of data follwoing this header */
29     u32 i_width;
30     u32 i_height;
31     u16 i_planes;
32     u16 i_bitcount;
33     u32 i_compression;
34     u32 i_sizeimage;
35     u32 i_xpelspermeter;
36     u32 i_ypelspermeter;
37     u32 i_clrused;
38     u32 i_clrimportant;
39 } bitmapinfoheader_t;
40
41 typedef struct waveformatex_s
42 {
43     u16 i_format;
44     u16 i_channels;
45     u32 i_samplepersec;
46     u32 i_avgbytespersec;
47     u16 i_blockalign;
48     u16 i_bitspersample;
49     u16 i_size;          /* This give size of data 
50                             imediatly following this header. */
51 } waveformatex_t;
52
53 typedef struct guid_s
54 {
55     u32 v1; /* le */
56     u16 v2; /* le */
57     u16 v3; /* le */
58     u8  v4[8];
59 } guid_t;
60
61 #define ASF_OBJECT_TYPE_NULL      0x0000
62 #define ASF_OBJECT_TYPE_ROOT      0x0001
63 #define ASF_OBJECT_TYPE_HEADER    0x0002
64 #define ASF_OBJECT_TYPE_DATA      0x0003
65 #define ASF_OBJECT_TYPE_INDEX     0x0004
66 #define ASF_OBJECT_TYPE_FILE_PROPERTIES     0x0005
67 #define ASF_OBJECT_TYPE_STREAM_PROPERTIES   0x0006
68 #define ASF_OBJECT_TYPE_EXTENTION_HEADER    0x0007
69 #define ASF_OBJECT_TYPE_CODEC_LIST          0x0008
70 #define ASF_OBJECT_TYPE_MARKER              0x0009
71 #define ASF_OBJECT_TYPE_CONTENT_DESCRIPTION 0x000a
72
73 static const guid_t asf_object_null_guid =
74 {
75     0x00000000,
76     0x0000,
77     0x0000,
78     { 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00 }
79 };
80
81 static const guid_t asf_object_header_guid = 
82 {
83     0x75B22630,
84     0x668E,
85     0x11CF,
86     { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
87 };
88
89 static const guid_t asf_object_data_guid = 
90 {
91     0x75B22636,
92     0x668E,
93     0x11CF,
94     { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
95 };
96
97
98
99 static const guid_t asf_object_index_guid =
100 {
101     0x33000890,
102     0xE5B1,
103     0x11CF,
104     { 0x89,0xF4, 0x00,0xA0,0xC9,0x03,0x49,0xCB }
105 };
106
107 static const guid_t asf_object_file_properties_guid =
108 {
109     0x8cabdca1,
110     0xa947,
111     0x11cf,
112     { 0x8e,0xe4, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
113
114 };
115 static const guid_t asf_object_stream_properties_guid =
116 {
117     0xB7DC0791,
118     0xA9B7,
119     0x11CF,
120     { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
121
122 };
123
124 static const guid_t asf_object_content_description_guid =
125 {
126     0x75B22633,
127     0x668E,
128     0x11CF,
129     { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }
130 };
131
132 static const guid_t asf_object_header_extention_guid = 
133 {
134    0x5FBF03B5,
135    0xA92E,
136    0x11CF,
137    { 0x8E,0xE3, 0x00,0xC0,0x0C,0x20,0x53,0x65 } 
138 };
139
140 static const guid_t asf_object_codec_list_guid =
141 {
142     0x86D15240,
143     0x311D,
144     0x11D0,
145     { 0xA3,0xA4, 0x00,0xA0,0xC9,0x03,0x48,0xF6 }
146 };
147
148 static const guid_t asf_object_marker_guid =
149 {
150     0xF487CD01,
151     0xA951,
152     0x11CF,
153     { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
154
155 };
156
157 static const guid_t asf_object_stream_type_audio =
158 {
159     0xF8699E40,
160     0x5B4D,
161     0x11CF,
162     { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B }
163 };
164
165 static const guid_t asf_object_stream_type_video =
166 {
167     0xbc19efc0,
168     0x5B4D,
169     0x11CF,
170     { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B }
171 };
172
173 static const guid_t asf_object_stream_type_command =
174 {
175     0x59DACFC0,
176     0x59E6,
177     0x11D0,
178     { 0xA3,0xAC, 0x00,0xA0,0xC9,0x03,0x48,0xF6 }
179 };
180
181 #if 0
182 static const guid_t asf_object_
183 {
184
185
186 };
187 #endif
188 #if 0
189 typedef struct asf_packet_s
190 {
191     int i_stream_number;
192
193     int i_payload_size;
194     u8  *p_payload_data;
195     
196 } asf_packet_t;
197 #endif
198
199 #define ASF_OBJECT_COMMON           \
200     int          i_type;            \
201     guid_t       i_object_id;       \
202     u64          i_object_size;     \
203     u64          i_object_pos;      \
204     union asf_object_u *p_father;  \
205     union asf_object_u *p_first;   \
206     union asf_object_u *p_last;    \
207     union asf_object_u *p_next;
208
209 typedef struct asf_object_common_s
210 {
211     ASF_OBJECT_COMMON
212
213 } asf_object_common_t;
214
215 typedef struct asf_index_entry_s
216 {
217     u32 i_packet_number;
218     u16 i_packet_count;
219
220 } asf_index_entry_t;
221
222 /****************************************************************************
223  * High level asf object 
224  ****************************************************************************/
225 /* This is the first header find in a asf file
226  * It's the only object that have subobject */
227 typedef struct asf_object_header_s
228 {
229     ASF_OBJECT_COMMON
230     u32 i_sub_object_count;
231     u8  i_reserved1; /* 0x01, but could be safely ignored */
232     u8  i_reserved2; /* 0x02, if not must failed to source the contain */
233    
234 } asf_object_header_t;
235
236 typedef struct asf_object_data_s
237 {
238     ASF_OBJECT_COMMON
239     guid_t  i_file_id;
240     u64     i_total_data_packets;
241     u16     i_reserved;
242     
243 } asf_object_data_t;
244
245
246 typedef struct asf_object_index_s
247 {
248     ASF_OBJECT_COMMON
249     guid_t  i_file_id;
250     u64     i_index_entry_time_interval;
251     u32     i_max_packet_count;
252     u32     i_index_entry_count;
253     
254     asf_index_entry_t *index_entry;
255
256 } asf_object_index_t;
257
258 typedef struct asf_object_root_s
259 {
260     ASF_OBJECT_COMMON
261     
262     asf_object_header_t *p_hdr;
263     asf_object_data_t   *p_data;
264     asf_object_index_t  *p_index;
265
266 } asf_object_root_t;
267
268 /****************************************************************************
269  * Sub level asf object
270  ****************************************************************************/
271 #define ASF_FILE_PROPERTIES_BROADCAST   0x01
272 #define ASF_FILE_PROPERTIES_SEEKABLE    0x02
273
274 typedef struct asf_object_file_properties_s
275 {
276     ASF_OBJECT_COMMON
277     
278     guid_t  i_file_id;
279     u64     i_file_size;
280     u64     i_creation_date;
281     u64     i_data_packets_count;
282     u64     i_play_duration;
283     u64     i_send_duration;
284     u64     i_preroll;
285     u32     i_flags;
286     u32     i_min_data_packet_size;
287     u32     i_max_data_packet_size;
288     u32     i_max_bitrate;
289     
290 } asf_object_file_properties_t;
291
292 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
293 typedef struct asf_object_stream_properties_s
294 {
295     ASF_OBJECT_COMMON
296
297     guid_t  i_stream_type;
298     guid_t  i_error_correction_type;
299     u64     i_time_offset;
300     u32     i_type_specific_data_length;
301     u32     i_error_correction_data_length;
302     u16     i_flags;
303         /* extrated from flags */
304         u8      i_stream_number;
305     u32     i_reserved;
306     u8      *p_type_specific_data;
307     u8      *p_error_correction_data;
308 } asf_object_stream_properties_t;
309
310 typedef struct asf_object_header_extention_s
311 {
312     ASF_OBJECT_COMMON
313
314     guid_t  i_reserved1;
315     u16     i_reserved2;
316     u32     i_header_extention_size;
317     u8      *p_header_extention_data;
318
319 } asf_object_header_extention_t;
320
321 typedef struct asf_objec_content_description_s
322 {
323     ASF_OBJECT_COMMON
324
325     char *psz_title;
326     char *psz_author;
327     char *psz_copyright;
328     char *psz_description;
329     char *psz_rating;
330
331 } asf_object_content_description_t;
332
333 typedef struct string16_s
334 {
335     u16 i_length;
336     u16 *i_char;
337 } string16_t;
338
339 #define ASF_CODEC_TYPE_VIDEO    0x0001
340 #define ASF_CODEC_TYPE_AUDIO    0x0002
341 #define ASF_CODEC_TYPE_UNKNOW   0xffff
342
343 typedef struct asf_codec_entry_s
344 {
345     u16         i_type;
346     char        *psz_name;
347     char        *psz_description;
348     
349     u16         i_information_length;
350     u8          *p_information;
351 } asf_codec_entry_t;
352
353 typedef struct asf_object_codec_list_s
354 {
355     ASF_OBJECT_COMMON
356     guid_t  i_reserved;
357     u32     i_codec_entries_count;
358     asf_codec_entry_t *codec; 
359
360 } asf_object_codec_list_t;
361
362 #if 0
363 typedef struct asf_object_script_command_s
364 {
365     ASF_OBJECT_COMMON
366
367     
368 } asf_object_script_command_t;
369 #endif
370 typedef struct asf_marker_s
371 {
372     u64     i_offset;
373     u64     i_presentation_time;
374     u16     i_entry_length;
375     u32     i_send_time;
376     u32     i_flags;
377     u32     i_marker_description_length;
378     u8      *i_marker_description;
379     /* u8 padding */
380             
381 } asf_marker_t;
382
383 typedef struct asf_object_marker_s
384 {
385     ASF_OBJECT_COMMON
386     guid_t  i_reserved1;
387     u32     i_count;
388     u16     i_reserved2;
389     string16_t name;
390     asf_marker_t *marker;
391
392 } asf_object_marker_t;
393
394 #if 0
395 typedef struct asf_object__s
396 {
397     ASF_OBJECT_COMMON
398
399 } asf_object__t;
400 #endif
401
402 typedef union asf_object_u
403 {
404     asf_object_common_t common;
405     asf_object_header_t header;
406     asf_object_data_t   data;
407     asf_object_index_t  index;
408     asf_object_root_t   root;
409     asf_object_file_properties_t    file_properties;
410     asf_object_stream_properties_t  stream_properties;
411     asf_object_header_extention_t   header_extention;   
412     asf_object_codec_list_t         codec_list;
413     asf_object_marker_t             marker;
414     
415 } asf_object_t;
416
417
418 off_t   ASF_TellAbsolute( input_thread_t *p_input );
419 int     ASF_SeekAbsolute( input_thread_t *p_input, off_t i_pos);
420 int     ASF_ReadData( input_thread_t *p_input, u8 *p_buff, int i_size );
421 int     ASF_SkipBytes( input_thread_t *p_input, int i_count );
422
423 void GetGUID( guid_t *p_guid, u8 *p_data );
424 int  CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
425     
426 int  ASF_ReadObjectCommon( input_thread_t *p_input,
427                            asf_object_t *p_obj );
428 int  ASF_NextObject( input_thread_t *p_input,
429                      asf_object_t *p_obj );
430 int  ASF_GotoObject( input_thread_t *p_input,
431                      asf_object_t *p_obj );
432
433 int  ASF_ReadObject( input_thread_t *p_input,
434                      asf_object_t *p_obj,
435                      asf_object_t *p_father );
436 void ASF_FreeObject( input_thread_t *p_input,
437                      asf_object_t *p_obj );
438 int  ASF_ReadObjectRoot( input_thread_t *p_input,
439                          asf_object_root_t *p_root,
440                          int b_seekable );
441 void ASF_FreeObjectRoot( input_thread_t *p_input,
442                          asf_object_root_t *p_root );
443
444 int  ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid );
445 asf_object_t *ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number );
446
447