xine-lib  1.2.9
asfheader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2000-2008 the xine project
3  *
4  * This file is part of xine, a free video player.
5  *
6  * xine is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * xine is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19  *
20  * demultiplexer for asf streams
21  *
22  * based on ffmpeg's
23  * ASF compatible encoder and decoder.
24  * Copyright (c) 2000, 2001 Gerard Lantau.
25  *
26  * GUID list from avifile
27  * some other ideas from MPlayer
28  */
29 
30 #ifndef ASFHEADER_H
31 #define ASFHEADER_H
32 
33 #include <inttypes.h>
34 
35 /*
36  * define asf GUIDs (list from avifile)
37  */
38 #define GUID_ERROR 0
39 
40  /* base ASF objects */
41 #define GUID_ASF_HEADER 1
42 #define GUID_ASF_DATA 2
43 #define GUID_ASF_SIMPLE_INDEX 3
44 #define GUID_INDEX 4
45 #define GUID_MEDIA_OBJECT_INDEX 5
46 #define GUID_TIMECODE_INDEX 6
47 
48  /* header ASF objects */
49 #define GUID_ASF_FILE_PROPERTIES 7
50 #define GUID_ASF_STREAM_PROPERTIES 8
51 #define GUID_ASF_HEADER_EXTENSION 9
52 #define GUID_ASF_CODEC_LIST 10
53 #define GUID_ASF_SCRIPT_COMMAND 11
54 #define GUID_ASF_MARKER 12
55 #define GUID_ASF_BITRATE_MUTUAL_EXCLUSION 13
56 #define GUID_ASF_ERROR_CORRECTION 14
57 #define GUID_ASF_CONTENT_DESCRIPTION 15
58 #define GUID_ASF_EXTENDED_CONTENT_DESCRIPTION 16
59 #define GUID_ASF_STREAM_BITRATE_PROPERTIES 17
60 #define GUID_ASF_EXTENDED_CONTENT_ENCRYPTION 18
61 #define GUID_ASF_PADDING 19
62 
63  /* stream properties object stream type */
64 #define GUID_ASF_AUDIO_MEDIA 20
65 #define GUID_ASF_VIDEO_MEDIA 21
66 #define GUID_ASF_COMMAND_MEDIA 22
67 #define GUID_ASF_JFIF_MEDIA 23
68 #define GUID_ASF_DEGRADABLE_JPEG_MEDIA 24
69 #define GUID_ASF_FILE_TRANSFER_MEDIA 25
70 #define GUID_ASF_BINARY_MEDIA 26
71 
72  /* stream properties object error correction type */
73 #define GUID_ASF_NO_ERROR_CORRECTION 27
74 #define GUID_ASF_AUDIO_SPREAD 28
75 
76  /* mutual exclusion object exlusion type */
77 #define GUID_ASF_MUTEX_BITRATE 29
78 #define GUID_ASF_MUTEX_UKNOWN 30
79 
80  /* header extension */
81 #define GUID_ASF_RESERVED_1 31
82 
83  /* script command */
84 #define GUID_ASF_RESERVED_SCRIPT_COMMNAND 32
85 
86  /* marker object */
87 #define GUID_ASF_RESERVED_MARKER 33
88 
89  /* various */
90 #define GUID_ASF_AUDIO_CONCEAL_NONE 34
91 #define GUID_ASF_CODEC_COMMENT1_HEADER 35
92 #define GUID_ASF_2_0_HEADER 36
93 
94 #define GUID_EXTENDED_STREAM_PROPERTIES 37
95 #define GUID_ADVANCED_MUTUAL_EXCLUSION 38
96 #define GUID_GROUP_MUTUAL_EXCLUSION 39
97 #define GUID_STREAM_PRIORITIZATION 40
98 #define GUID_BANDWIDTH_SHARING 41
99 #define GUID_LANGUAGE_LIST 42
100 #define GUID_METADATA 43
101 #define GUID_METADATA_LIBRARY 44
102 #define GUID_INDEX_PARAMETERS 45
103 #define GUID_MEDIA_OBJECT_INDEX_PARAMETERS 46
104 #define GUID_TIMECODE_INDEX_PARAMETERS 47
105 #define GUID_ADVANCED_CONTENT_ENCRYPTION 48
106 #define GUID_COMPATIBILITY 49
107 #define GUID_END 50
108 
109 
110 /* asf stream types */
111 #define ASF_STREAM_TYPE_UNKNOWN 0
112 #define ASF_STREAM_TYPE_AUDIO 1
113 #define ASF_STREAM_TYPE_VIDEO 2
114 #define ASF_STREAM_TYPE_CONTROL 3
115 #define ASF_STREAM_TYPE_JFIF 4
116 #define ASF_STREAM_TYPE_DEGRADABLE_JPEG 5
117 #define ASF_STREAM_TYPE_FILE_TRANSFER 6
118 #define ASF_STREAM_TYPE_BINARY 7
119 
120 #define ASF_MAX_NUM_STREAMS 23
121 
122 #if !defined(GUID_DEFINED) && !defined(_GUID_DEFINED)
123 #define GUID_DEFINED
124 #define _GUID_DEFINED
125 
126 typedef struct _GUID { /* size is 16 */
127  uint32_t Data1;
128  uint16_t Data2;
129  uint16_t Data3;
130  uint8_t Data4[8];
131 } GUID;
132 
133 #endif /* !GUID_DEFINED */
134 
135 static const struct
136 {
137  const char* name;
138  const GUID guid;
139 } guids[] =
140 {
141  { "error",
142  { 0x0,} },
143 
144 
145  /* base ASF objects */
146  { "header",
147  { 0x75b22630, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} },
148 
149  { "data",
150  { 0x75b22636, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} },
151 
152  { "simple index",
153  { 0x33000890, 0xe5b1, 0x11cf, { 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb }} },
154 
155  { "index",
156  { 0xd6e229d3, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} },
157 
158  { "media object index",
159  { 0xfeb103f8, 0x12ad, 0x4c64, { 0x84, 0x0f, 0x2a, 0x1d, 0x2f, 0x7a, 0xd4, 0x8c }} },
160 
161  { "timecode index",
162  { 0x3cb73fd0, 0x0c4a, 0x4803, { 0x95, 0x3d, 0xed, 0xf7, 0xb6, 0x22, 0x8f, 0x0c }} },
163 
164  /* header ASF objects */
165  { "file properties",
166  { 0x8cabdca1, 0xa947, 0x11cf, { 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} },
167 
168  { "stream header",
169  { 0xb7dc0791, 0xa9b7, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} },
170 
171  { "header extension",
172  { 0x5fbf03b5, 0xa92e, 0x11cf, { 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} },
173 
174  { "codec list",
175  { 0x86d15240, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} },
176 
177  { "script command",
178  { 0x1efb1a30, 0x0b62, 0x11d0, { 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} },
179 
180  { "marker",
181  { 0xf487cd01, 0xa951, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} },
182 
183  { "bitrate mutual exclusion",
184  { 0xd6e229dc, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} },
185 
186  { "error correction",
187  { 0x75b22635, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} },
188 
189  { "content description",
190  { 0x75b22633, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c }} },
191 
192  { "extended content description",
193  { 0xd2d0a440, 0xe307, 0x11d2, { 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50 }} },
194 
195  { "stream bitrate properties", /* (http://get.to/sdp) */
196  { 0x7bf875ce, 0x468d, 0x11d1, { 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2 }} },
197 
198  { "extended content encryption",
199  { 0x298ae614, 0x2622, 0x4c17, { 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c }} },
200 
201  { "padding",
202  { 0x1806d474, 0xcadf, 0x4509, { 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8 }} },
203 
204 
205  /* stream properties object stream type */
206  { "audio media",
207  { 0xf8699e40, 0x5b4d, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} },
208 
209  { "video media",
210  { 0xbc19efc0, 0x5b4d, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} },
211 
212  { "command media",
213  { 0x59dacfc0, 0x59e6, 0x11d0, { 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} },
214 
215  { "JFIF media (JPEG)",
216  { 0xb61be100, 0x5b4e, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} },
217 
218  { "Degradable JPEG media",
219  { 0x35907de0, 0xe415, 0x11cf, { 0xa9, 0x17, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} },
220 
221  { "File Transfer media",
222  { 0x91bd222c, 0xf21c, 0x497a, { 0x8b, 0x6d, 0x5a, 0xa8, 0x6b, 0xfc, 0x01, 0x85 }} },
223 
224  { "Binary media",
225  { 0x3afb65e2, 0x47ef, 0x40f2, { 0xac, 0x2c, 0x70, 0xa9, 0x0d, 0x71, 0xd3, 0x43 }} },
226 
227  /* stream properties object error correction */
228  { "no error correction",
229  { 0x20fb5700, 0x5b55, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b }} },
230 
231  { "audio spread",
232  { 0xbfc3cd50, 0x618f, 0x11cf, { 0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2, 0x20 }} },
233 
234 
235  /* mutual exclusion object exlusion type */
236  { "mutex bitrate",
237  { 0xd6e22a01, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} },
238 
239  { "mutex unknown",
240  { 0xd6e22a02, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} },
241 
242 
243  /* header extension */
244  { "reserved_1",
245  { 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} },
246 
247 
248  /* script command */
249  { "reserved script command",
250  { 0x4B1ACBE3, 0x100B, 0x11D0, { 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6 }} },
251 
252  /* marker object */
253  { "reserved marker",
254  { 0x4CFEDB20, 0x75F6, 0x11CF, { 0x9C, 0x0F, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB }} },
255 
256  /* various */
257  { "audio conceal none",
258  { 0x49f1a440, 0x4ece, 0x11d0, { 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} },
259 
260  { "codec comment1 header",
261  { 0x86d15241, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6 }} },
262 
263  { "asf 2.0 header",
264  { 0xd6e229d1, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} },
265 
266 
267  /* header extension GUIDs */
268  { "extended stream properties",
269  { 0x14E6A5CB, 0xC672, 0x4332, { 0x83, 0x99, 0xA9, 0x69, 0x52, 0x6, 0x5B, 0x5A }} },
270 
271  { "advanced mutual exclusion",
272  { 0xA08649CF, 0x4775, 0x4670, { 0x8a, 0x16, 0x6e, 0x35, 0x35, 0x75, 0x66, 0xcd }} },
273 
274  { "group mutual exclusion",
275  { 0xD1465A40, 0x5A79, 0x4338, { 0xb7, 0x1b, 0xe3, 0x6b, 0x8f, 0xd6, 0xc2, 0x49 }} },
276 
277  { "stream prioritization",
278  { 0xD4FED15B, 0x88D3, 0x454F, { 0x81, 0xf0, 0xed, 0x5c, 0x45, 0x99, 0x9e, 0x24 }} },
279 
280  { "bandwidth sharing",
281  { 0xA69609E6, 0x517B, 0x11D2, { 0xb6, 0xaf, 0x00, 0xc0, 0x4f, 0xd9, 0x08, 0xe9 }} },
282 
283  { "language list",
284  { 0x7C4346A9, 0xEFE0, 0x4BFC, {0xB2, 0x29, 0x39, 0x3E, 0xDE, 0x41, 0x5C, 0x85}} },
285 
286  { "metadata",
287  { 0xC5F8CBEA, 0x5BAF, 0x4877, {0x84, 0x67, 0xAA, 0x8C, 0x44, 0xFA, 0x4C, 0xCA}} },
288 
289  { "metadata library",
290  { 0x44231C94, 0x9498, 0x49D1, {0xA1, 0x41, 0x1D, 0x13, 0x4E, 0x45, 0x70, 0x54}} },
291 
292  { "index parameters",
293  { 0xD6E229DF, 0x35DA, 0x11D1, {0x90, 0x34, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xBE}} },
294 
295  { "media object index parameters",
296  { 0x6B203BAD, 0x3F11, 0x48E4, {0xAC, 0xA8, 0xD7, 0x61, 0x3D, 0xE2, 0xCF, 0xA7}} },
297 
298  { "timecode index parameters",
299  { 0xF55E496D, 0x9797, 0x4B5D, {0x8C, 0x8B, 0x60, 0x4D, 0xF9, 0x9B, 0xFB, 0x24}} },
300 
301  { "advanced content encryption",
302  { 0x43058533, 0x6981, 0x49E6, {0x9B, 0x74, 0xAD, 0x12, 0xCB, 0x86, 0xD5, 0x8C}} },
303 
304  /* exotic stuff */
305  { "compatibility",
306  { 0x26F18B5D, 0x4584, 0x47EC, {0x9F, 0x5F, 0xE,0x65, 0x1F, 0x4, 0x52, 0xC9}} }
307 };
308 
309 typedef struct asf_header_s asf_header_t;
310 typedef struct asf_file_s asf_file_t;
312 typedef struct asf_stream_s asf_stream_t;
314 
315 struct asf_header_s {
319 
323  struct { uint32_t x, y; } aspect_ratios[ASF_MAX_NUM_STREAMS];
324 };
325 
326 struct asf_file_s {
328  uint64_t file_size; /* in bytes */
330  uint64_t play_duration; /* in 100 nanoseconds unit */
331  uint64_t send_duration; /* in 100 nanoseconds unit */
332  uint64_t preroll; /* in 100 nanoseconds unit */
333 
334  uint32_t packet_size;
335  uint32_t max_bitrate;
336 
337  uint8_t broadcast_flag;
338  uint8_t seekable_flag;
339 };
340 
341 /* ms unicode strings */
343  char *title;
344  char *author;
345  char *copyright;
346  char *description;
347  char *rating;
348 };
349 
350 struct asf_stream_s {
351  uint16_t stream_number;
354  uint64_t time_offset;
355 
357  uint8_t *private_data;
358 
361 
362  uint8_t encrypted_flag;
363 };
364 
366  uint64_t start_time;
367  uint64_t end_time;
368  uint32_t data_bitrate;
369  uint32_t buffer_size;
374  uint32_t max_object_size;
375 
376  uint8_t reliable_flag;
377  uint8_t seekable_flag;
380 
381  uint16_t language_id;
383 
386 
387  char **stream_names;
388 };
389 
390 int asf_find_object_id (GUID *g);
391 void asf_get_guid (uint8_t *buffer, GUID *value);
392 
393 asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) XINE_MALLOC;
394 void asf_header_choose_streams (asf_header_t *header, uint32_t bandwidth,
395  int *video_id, int *audio_id);
397  int video_id, int audio_id);
398 void asf_header_delete (asf_header_t *header);
399 
400 
401 #endif
uint16_t language_id
Definition: asfheader.h:381
uint8_t seekable_flag
Definition: asfheader.h:338
Definition: asfheader.h:126
Definition: asfheader.h:350
#define XINE_MALLOC
Definition: attributes.h:119
Definition: asfheader.h:326
char * description
Definition: asfheader.h:346
uint32_t data_bitrate
Definition: asfheader.h:368
uint8_t * private_data
Definition: asfheader.h:357
uint32_t Data1
Definition: asfheader.h:127
uint64_t start_time
Definition: asfheader.h:366
uint32_t alternate_data_bitrate
Definition: asfheader.h:371
static const struct @9 guids[]
uint8_t Data4[8]
Definition: asfheader.h:130
uint8_t no_cleanpoints_flag
Definition: asfheader.h:378
uint16_t stream_number
Definition: asfheader.h:351
Definition: asfheader.h:342
GUID file_id
Definition: asfheader.h:327
uint8_t reliable_flag
Definition: asfheader.h:376
const GUID guid
Definition: asfheader.h:138
char * rating
Definition: asfheader.h:347
int stream_type
Definition: asfheader.h:352
uint32_t private_data_length
Definition: asfheader.h:356
uint16_t Data3
Definition: asfheader.h:129
uint32_t buffer_size
Definition: asfheader.h:369
asf_header_t * asf_header_new(uint8_t *buffer, int buffer_len)
Definition: asfheader.c:726
uint32_t bitrates[23]
Definition: asfheader.h:322
uint32_t max_bitrate
Definition: asfheader.h:335
void asf_get_guid(uint8_t *buffer, GUID *value)
Definition: asfheader.c:214
uint32_t y
Definition: asfheader.h:323
int error_correction_type
Definition: asfheader.h:353
Definition: asfheader.h:315
char * copyright
Definition: asfheader.h:345
uint32_t x
Definition: asfheader.h:323
uint8_t encrypted_flag
Definition: asfheader.h:362
struct asf_header_s::@10 aspect_ratios[23]
asf_stream_t * streams[23]
Definition: asfheader.h:320
uint64_t file_size
Definition: asfheader.h:328
uint64_t play_duration
Definition: asfheader.h:330
uint8_t resend_live_cleanpoints_flag
Definition: asfheader.h:379
const char * name
Definition: asfheader.h:137
uint8_t * error_correction_data
Definition: asfheader.h:360
uint64_t preroll
Definition: asfheader.h:332
int stream_count
Definition: asfheader.h:318
uint64_t end_time
Definition: asfheader.h:367
asf_stream_extension_t * stream_extensions[23]
Definition: asfheader.h:321
uint32_t error_correction_data_length
Definition: asfheader.h:359
uint32_t max_object_size
Definition: asfheader.h:374
asf_content_t * content
Definition: asfheader.h:317
uint32_t alternate_initial_buffer_fullness
Definition: asfheader.h:373
uint32_t alternate_buffer_size
Definition: asfheader.h:372
char * title
Definition: asfheader.h:343
void asf_header_choose_streams(asf_header_t *header, uint32_t bandwidth, int *video_id, int *audio_id)
Definition: asfheader.c:882
uint64_t average_time_per_frame
Definition: asfheader.h:382
uint64_t data_packet_count
Definition: asfheader.h:329
char * author
Definition: asfheader.h:344
int asf_find_object_id(GUID *g)
Definition: asfheader.c:225
uint64_t send_duration
Definition: asfheader.h:331
uint32_t initial_buffer_fullness
Definition: asfheader.h:370
uint64_t time_offset
Definition: asfheader.h:354
uint16_t Data2
Definition: asfheader.h:128
uint32_t packet_size
Definition: asfheader.h:334
uint8_t broadcast_flag
Definition: asfheader.h:337
#define ASF_MAX_NUM_STREAMS
Definition: asfheader.h:120
uint16_t payload_extension_system_count
Definition: asfheader.h:385
struct _GUID GUID
void asf_header_delete(asf_header_t *header)
Definition: asfheader.c:840
asf_file_t * file
Definition: asfheader.h:316
char ** stream_names
Definition: asfheader.h:387
Definition: asfheader.h:365
uint8_t seekable_flag
Definition: asfheader.h:377
void asf_header_disable_streams(asf_header_t *header, int video_id, int audio_id)
Definition: asfheader.c:921
uint16_t stream_name_count
Definition: asfheader.h:384