]> git.sesse.net Git - vlc/blob - modules/demux/asf/libasf.h
asf/* : Convert all u* into uint*_t
[vlc] / modules / demux / asf / libasf.h
1 /*****************************************************************************
2  * libasf.h : 
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: libasf.h,v 1.4 2002/11/14 16:17:47 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 #include "codecs.h"                        /* BITMAPINFOHEADER, WAVEFORMATEX */
24
25 /*****************************************************************************
26  * Structure needed for decoder
27  *****************************************************************************/
28 typedef struct guid_s
29 {
30     uint32_t v1; /* le */
31     uint16_t v2; /* le */
32     uint16_t v3; /* le */
33     uint8_t  v4[8];
34 } guid_t;
35
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
47
48 static const guid_t asf_object_null_guid =
49 {
50     0x00000000,
51     0x0000,
52     0x0000,
53     { 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00 }
54 };
55
56 static const guid_t asf_object_header_guid = 
57 {
58     0x75B22630,
59     0x668E,
60     0x11CF,
61     { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
62 };
63
64 static const guid_t asf_object_data_guid = 
65 {
66     0x75B22636,
67     0x668E,
68     0x11CF,
69     { 0xA6,0xD9, 0x00,0xAA,0x00,0x62,0xCE,0x6C }
70 };
71
72
73
74 static const guid_t asf_object_index_guid =
75 {
76     0x33000890,
77     0xE5B1,
78     0x11CF,
79     { 0x89,0xF4, 0x00,0xA0,0xC9,0x03,0x49,0xCB }
80 };
81
82 static const guid_t asf_object_file_properties_guid =
83 {
84     0x8cabdca1,
85     0xa947,
86     0x11cf,
87     { 0x8e,0xe4, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
88
89 };
90 static const guid_t asf_object_stream_properties_guid =
91 {
92     0xB7DC0791,
93     0xA9B7,
94     0x11CF,
95     { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
96
97 };
98
99 static const guid_t asf_object_content_description_guid =
100 {
101     0x75B22633,
102     0x668E,
103     0x11CF,
104     { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }
105 };
106
107 static const guid_t asf_object_header_extention_guid = 
108 {
109    0x5FBF03B5,
110    0xA92E,
111    0x11CF,
112    { 0x8E,0xE3, 0x00,0xC0,0x0C,0x20,0x53,0x65 } 
113 };
114
115 static const guid_t asf_object_codec_list_guid =
116 {
117     0x86D15240,
118     0x311D,
119     0x11D0,
120     { 0xA3,0xA4, 0x00,0xA0,0xC9,0x03,0x48,0xF6 }
121 };
122
123 static const guid_t asf_object_marker_guid =
124 {
125     0xF487CD01,
126     0xA951,
127     0x11CF,
128     { 0x8E,0xE6, 0x00,0xC0,0x0C,0x20,0x53,0x65 }
129
130 };
131
132 static const guid_t asf_object_stream_type_audio =
133 {
134     0xF8699E40,
135     0x5B4D,
136     0x11CF,
137     { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B }
138 };
139
140 static const guid_t asf_object_stream_type_video =
141 {
142     0xbc19efc0,
143     0x5B4D,
144     0x11CF,
145     { 0xA8,0xFD, 0x00,0x80,0x5F,0x5C,0x44,0x2B }
146 };
147
148 static const guid_t asf_object_stream_type_command =
149 {
150     0x59DACFC0,
151     0x59E6,
152     0x11D0,
153     { 0xA3,0xAC, 0x00,0xA0,0xC9,0x03,0x48,0xF6 }
154 };
155
156 #if 0
157 static const guid_t asf_object_
158 {
159
160
161 };
162 #endif
163 #if 0
164 typedef struct asf_packet_s
165 {
166     int i_stream_number;
167
168     int i_payload_size;
169     u8  *p_payload_data;
170     
171 } asf_packet_t;
172 #endif
173
174 #define ASF_OBJECT_COMMON           \
175     int          i_type;            \
176     guid_t       i_object_id;       \
177     u64          i_object_size;     \
178     u64          i_object_pos;      \
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;
183
184 typedef struct asf_object_common_s
185 {
186     ASF_OBJECT_COMMON
187
188 } asf_object_common_t;
189
190 typedef struct asf_index_entry_s
191 {
192     uint32_t i_packet_number;
193     uint16_t i_packet_count;
194
195 } asf_index_entry_t;
196
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
203 {
204     ASF_OBJECT_COMMON
205     uint32_t i_sub_object_count;
206     uint8_t  i_reserved1; /* 0x01, but could be safely ignored */
207     uint8_t  i_reserved2; /* 0x02, if not must failed to source the contain */
208    
209 } asf_object_header_t;
210
211 typedef struct asf_object_data_s
212 {
213     ASF_OBJECT_COMMON
214     guid_t      i_file_id;
215     uint64_t    i_total_data_packets;
216     uint16_t    i_reserved;
217     
218 } asf_object_data_t;
219
220
221 typedef struct asf_object_index_s
222 {
223     ASF_OBJECT_COMMON
224     guid_t      i_file_id;
225     uint64_t    i_index_entry_time_interval;
226     uint32_t    i_max_packet_count;
227     uint32_t    i_index_entry_count;
228     
229     asf_index_entry_t *index_entry;
230
231 } asf_object_index_t;
232
233 typedef struct asf_object_root_s
234 {
235     ASF_OBJECT_COMMON
236     
237     asf_object_header_t *p_hdr;
238     asf_object_data_t   *p_data;
239     asf_object_index_t  *p_index;
240
241 } asf_object_root_t;
242
243 /****************************************************************************
244  * Sub level asf object
245  ****************************************************************************/
246 #define ASF_FILE_PROPERTIES_BROADCAST   0x01
247 #define ASF_FILE_PROPERTIES_SEEKABLE    0x02
248
249 typedef struct asf_object_file_properties_s
250 {
251     ASF_OBJECT_COMMON
252     
253     guid_t  i_file_id;
254     uint64_t     i_file_size;
255     uint64_t     i_creation_date;
256     uint64_t     i_data_packets_count;
257     uint64_t     i_play_duration;
258     uint64_t     i_send_duration;
259     uint64_t     i_preroll;
260     uint32_t     i_flags;
261     uint32_t     i_min_data_packet_size;
262     uint32_t     i_max_data_packet_size;
263     uint32_t     i_max_bitrate;
264     
265 } asf_object_file_properties_t;
266
267 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
268 typedef struct asf_object_stream_properties_s
269 {
270     ASF_OBJECT_COMMON
271
272     guid_t  i_stream_type;
273     guid_t  i_error_correction_type;
274     uint64_t     i_time_offset;
275     uint32_t     i_type_specific_data_length;
276     uint32_t     i_error_correction_data_length;
277     uint16_t     i_flags;
278         /* extrated from flags */
279         uint8_t i_stream_number;
280     uint32_t    i_reserved;
281     uint8_t     *p_type_specific_data;
282     uint8_t     *p_error_correction_data;
283 } asf_object_stream_properties_t;
284
285 typedef struct asf_object_header_extention_s
286 {
287     ASF_OBJECT_COMMON
288
289     guid_t      i_reserved1;
290     uint16_t    i_reserved2;
291     uint32_t    i_header_extention_size;
292     uint8_t     *p_header_extention_data;
293
294 } asf_object_header_extention_t;
295
296 typedef struct asf_objec_content_description_s
297 {
298     ASF_OBJECT_COMMON
299
300     char *psz_title;
301     char *psz_author;
302     char *psz_copyright;
303     char *psz_description;
304     char *psz_rating;
305
306 } asf_object_content_description_t;
307
308 typedef struct string16_s
309 {
310     uint16_t i_length;
311     uint16_t *i_char;
312 } string16_t;
313
314 #define ASF_CODEC_TYPE_VIDEO    0x0001
315 #define ASF_CODEC_TYPE_AUDIO    0x0002
316 #define ASF_CODEC_TYPE_UNKNOW   0xffff
317
318 typedef struct asf_codec_entry_s
319 {
320     uint16_t    i_type;
321     char        *psz_name;
322     char        *psz_description;
323     
324     uint16_t    i_information_length;
325     uint8_t     *p_information;
326 } asf_codec_entry_t;
327
328 typedef struct asf_object_codec_list_s
329 {
330     ASF_OBJECT_COMMON
331     guid_t      i_reserved;
332     uint32_t    i_codec_entries_count;
333     asf_codec_entry_t *codec; 
334
335 } asf_object_codec_list_t;
336
337 #if 0
338 typedef struct asf_object_script_command_s
339 {
340     ASF_OBJECT_COMMON
341
342     
343 } asf_object_script_command_t;
344 #endif
345 typedef struct asf_marker_s
346 {
347     uint64_t     i_offset;
348     uint64_t     i_presentation_time;
349     uint16_t     i_entry_length;
350     uint32_t     i_send_time;
351     uint32_t     i_flags;
352     uint32_t     i_marker_description_length;
353     uint8_t      *i_marker_description;
354     /* u8 padding */
355             
356 } asf_marker_t;
357
358 typedef struct asf_object_marker_s
359 {
360     ASF_OBJECT_COMMON
361     guid_t      i_reserved1;
362     uint32_t    i_count;
363     uint16_t    i_reserved2;
364     string16_t name;
365     asf_marker_t *marker;
366
367 } asf_object_marker_t;
368
369 #if 0
370 typedef struct asf_object__s
371 {
372     ASF_OBJECT_COMMON
373
374 } asf_object__t;
375 #endif
376
377 typedef union asf_object_u
378 {
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;
389     
390 } asf_object_t;
391
392
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, uint8_t *p_buff, int i_size );
396 int     ASF_SkipBytes( input_thread_t *p_input, int i_count );
397
398 void GetGUID( guid_t *p_guid, uint8_t *p_data );
399 int  CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
400     
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 );
407
408 int  ASF_ReadObject( input_thread_t *p_input,
409                      asf_object_t *p_obj,
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,
415                          int b_seekable );
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 );
420
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 );
423
424