xine-lib: xine-lib-1.2.13/src/demuxers/asfheader.h Source File

xine-lib 1.2.13-20230125hg15249

asfheader.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2000-2018 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 typedef enum {
39 GUID_ERROR = 0,
40 /* base ASF objects */
41 GUID_ASF_HEADER,
42 GUID_ASF_DATA,
43 GUID_ASF_SIMPLE_INDEX,
44 GUID_INDEX,
45 GUID_MEDIA_OBJECT_INDEX,
46 GUID_TIMECODE_INDEX,
47 /* header ASF objects */
48 GUID_ASF_FILE_PROPERTIES,
49 GUID_ASF_STREAM_PROPERTIES,
50 GUID_ASF_HEADER_EXTENSION,
51 GUID_ASF_CODEC_LIST,
52 GUID_ASF_SCRIPT_COMMAND,
53 GUID_ASF_MARKER,
54 GUID_ASF_BITRATE_MUTUAL_EXCLUSION,
55 GUID_ASF_ERROR_CORRECTION,
56 GUID_ASF_CONTENT_DESCRIPTION,
57 GUID_ASF_EXTENDED_CONTENT_DESCRIPTION,
58 GUID_ASF_STREAM_BITRATE_PROPERTIES,
59 GUID_ASF_EXTENDED_CONTENT_ENCRYPTION,
60 GUID_ASF_PADDING,
61 /* stream properties object stream type */
62 GUID_ASF_AUDIO_MEDIA,
63 GUID_ASF_VIDEO_MEDIA,
64 GUID_ASF_COMMAND_MEDIA,
65 GUID_ASF_JFIF_MEDIA,
66 GUID_ASF_DEGRADABLE_JPEG_MEDIA,
67 GUID_ASF_FILE_TRANSFER_MEDIA,
68 GUID_ASF_BINARY_MEDIA,
69 /* stream properties object error correction type */
70 GUID_ASF_NO_ERROR_CORRECTION,
71 GUID_ASF_AUDIO_SPREAD,
72 /* mutual exclusion object exlusion type */
73 GUID_ASF_MUTEX_BITRATE,
74 GUID_ASF_MUTEX_UKNOWN,
75 /* header extension */
76 GUID_ASF_RESERVED_1,
77 /* script command */
78 GUID_ASF_RESERVED_SCRIPT_COMMNAND,
79 /* marker object */
80 GUID_ASF_RESERVED_MARKER,
81 /* various */
82 GUID_ASF_AUDIO_CONCEAL_NONE,
83 GUID_ASF_CODEC_COMMENT1_HEADER,
84 GUID_ASF_2_0_HEADER,
85
86 GUID_EXTENDED_STREAM_PROPERTIES,
87 GUID_ADVANCED_MUTUAL_EXCLUSION,
88 GUID_GROUP_MUTUAL_EXCLUSION,
89 GUID_STREAM_PRIORITIZATION,
90 GUID_BANDWIDTH_SHARING,
91 GUID_LANGUAGE_LIST,
92 GUID_METADATA,
93 GUID_METADATA_LIBRARY,
94 GUID_INDEX_PARAMETERS,
95 GUID_MEDIA_OBJECT_INDEX_PARAMETERS,
96 GUID_TIMECODE_INDEX_PARAMETERS,
97 GUID_ADVANCED_CONTENT_ENCRYPTION,
98 GUID_COMPATIBILITY,
99 GUID_END
100} asf_guid_t;
101
102#if 0
103/* asf stream types. currently using asf_guid_t instead. */
104typedef enum {
105 ASF_STREAM_TYPE_UNKNOWN = 0,
106 ASF_STREAM_TYPE_AUDIO,
107 ASF_STREAM_TYPE_VIDEO,
108 ASF_STREAM_TYPE_CONTROL,
109 ASF_STREAM_TYPE_JFIF,
110 ASF_STREAM_TYPE_DEGRADABLE_JPEG,
111 ASF_STREAM_TYPE_FILE_TRANSFER,
112 ASF_STREAM_TYPE_BINARY
113} asf_stream_type_t;
114#endif
115
116#define ASF_MAX_NUM_STREAMS 23
117
118/* TJ. Globally Unique IDentifiction (GUID) is originally defined as
119 * uint32_t Data1; uint16_t Data2; uint16_t Data3; uint8_t Data4[8];
120 * stored in little endian byte order.
121 * This is fine with x86 but inefficient at big endian machines.
122 * We only compare GUIDs against hard-coded constants here,
123 * so lets use plain uint8_t[16] instead.
124 */
125
126 typedef struct asf_header_s asf_header_t;
127 typedef struct asf_file_s asf_file_t;
128 typedef struct asf_content_s asf_content_t;
129 typedef struct asf_stream_s asf_stream_t;
130 typedef struct asf_stream_extension_s asf_stream_extension_t;
131
132 struct asf_header_s {
133 asf_file_t *file;
134 asf_content_t *content;
135 int stream_count;
136
137 asf_stream_t *streams[ASF_MAX_NUM_STREAMS];
138 asf_stream_extension_t *stream_extensions[ASF_MAX_NUM_STREAMS];
139 uint32_t bitrates[ASF_MAX_NUM_STREAMS];
140 struct { uint32_t x, y; } aspect_ratios[ASF_MAX_NUM_STREAMS];
141};
142
143 struct asf_file_s {
144 uint8_t file_id[16];
145 uint64_t file_size; /* in bytes */
146 uint64_t data_packet_count;
147 uint64_t play_duration; /* in 100 nanoseconds unit */
148 uint64_t send_duration; /* in 100 nanoseconds unit */
149 uint64_t preroll; /* in 100 nanoseconds unit */
150
151 uint32_t packet_size;
152 uint32_t max_bitrate;
153
154 uint8_t broadcast_flag;
155 uint8_t seekable_flag;
156};
157
158/* ms unicode strings */
159 struct asf_content_s {
160 char *title;
161 char *author;
162 char *copyright;
163 char *description;
164 char *rating;
165};
166
167 struct asf_stream_s {
168 uint16_t stream_number;
169 asf_guid_t stream_type;
170 asf_guid_t error_correction_type;
171 uint64_t time_offset;
172
173 uint32_t private_data_length;
174 uint8_t *private_data;
175
176 uint32_t error_correction_data_length;
177 uint8_t *error_correction_data;
178
179 uint8_t encrypted_flag;
180};
181
182 struct asf_stream_extension_s {
183 uint64_t start_time;
184 uint64_t end_time;
185 uint32_t data_bitrate;
186 uint32_t buffer_size;
187 uint32_t initial_buffer_fullness;
188 uint32_t alternate_data_bitrate;
189 uint32_t alternate_buffer_size;
190 uint32_t alternate_initial_buffer_fullness;
191 uint32_t max_object_size;
192
193 uint8_t reliable_flag;
194 uint8_t seekable_flag;
195 uint8_t no_cleanpoints_flag;
196 uint8_t resend_live_cleanpoints_flag;
197
198 uint16_t language_id;
199 uint64_t average_time_per_frame;
200
201 uint16_t stream_name_count;
202 uint16_t payload_extension_system_count;
203
204 char **stream_names;
205};
206
207 asf_guid_t asf_guid_2_num (const uint8_t *guid);
208void asf_guid_2_str (uint8_t *str, const uint8_t *guid);
209const char *asf_guid_name (asf_guid_t num);
210
211 asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) XINE_MALLOC;
212void asf_header_choose_streams (asf_header_t *header, uint32_t bandwidth,
213 int *video_id, int *audio_id);
214void asf_header_disable_streams (asf_header_t *header,
215 int video_id, int audio_id);
216void asf_header_delete (asf_header_t *header);
217
218
219#endif
asf_guid_t
asf_guid_t
Definition asfheader.h:38
GUID_INDEX
@ GUID_INDEX
Definition asfheader.h:44
GUID_GROUP_MUTUAL_EXCLUSION
@ GUID_GROUP_MUTUAL_EXCLUSION
Definition asfheader.h:88
GUID_ASF_EXTENDED_CONTENT_DESCRIPTION
@ GUID_ASF_EXTENDED_CONTENT_DESCRIPTION
Definition asfheader.h:57
GUID_COMPATIBILITY
@ GUID_COMPATIBILITY
Definition asfheader.h:98
GUID_ASF_VIDEO_MEDIA
@ GUID_ASF_VIDEO_MEDIA
Definition asfheader.h:63
GUID_ADVANCED_MUTUAL_EXCLUSION
@ GUID_ADVANCED_MUTUAL_EXCLUSION
Definition asfheader.h:87
GUID_ASF_AUDIO_CONCEAL_NONE
@ GUID_ASF_AUDIO_CONCEAL_NONE
Definition asfheader.h:82
GUID_ASF_MUTEX_UKNOWN
@ GUID_ASF_MUTEX_UKNOWN
Definition asfheader.h:74
GUID_ASF_PADDING
@ GUID_ASF_PADDING
Definition asfheader.h:60
GUID_ASF_CODEC_LIST
@ GUID_ASF_CODEC_LIST
Definition asfheader.h:51
GUID_ASF_MARKER
@ GUID_ASF_MARKER
Definition asfheader.h:53
GUID_MEDIA_OBJECT_INDEX_PARAMETERS
@ GUID_MEDIA_OBJECT_INDEX_PARAMETERS
Definition asfheader.h:95
GUID_ASF_DATA
@ GUID_ASF_DATA
Definition asfheader.h:42
GUID_ASF_FILE_PROPERTIES
@ GUID_ASF_FILE_PROPERTIES
Definition asfheader.h:48
GUID_ASF_EXTENDED_CONTENT_ENCRYPTION
@ GUID_ASF_EXTENDED_CONTENT_ENCRYPTION
Definition asfheader.h:59
GUID_MEDIA_OBJECT_INDEX
@ GUID_MEDIA_OBJECT_INDEX
Definition asfheader.h:45
GUID_ASF_BINARY_MEDIA
@ GUID_ASF_BINARY_MEDIA
Definition asfheader.h:68
GUID_ASF_MUTEX_BITRATE
@ GUID_ASF_MUTEX_BITRATE
Definition asfheader.h:73
GUID_ASF_BITRATE_MUTUAL_EXCLUSION
@ GUID_ASF_BITRATE_MUTUAL_EXCLUSION
Definition asfheader.h:54
GUID_EXTENDED_STREAM_PROPERTIES
@ GUID_EXTENDED_STREAM_PROPERTIES
Definition asfheader.h:86
GUID_ASF_RESERVED_SCRIPT_COMMNAND
@ GUID_ASF_RESERVED_SCRIPT_COMMNAND
Definition asfheader.h:78
GUID_ASF_AUDIO_MEDIA
@ GUID_ASF_AUDIO_MEDIA
Definition asfheader.h:62
GUID_TIMECODE_INDEX
@ GUID_TIMECODE_INDEX
Definition asfheader.h:46
GUID_ASF_JFIF_MEDIA
@ GUID_ASF_JFIF_MEDIA
Definition asfheader.h:65
GUID_ASF_STREAM_BITRATE_PROPERTIES
@ GUID_ASF_STREAM_BITRATE_PROPERTIES
Definition asfheader.h:58
GUID_ASF_CONTENT_DESCRIPTION
@ GUID_ASF_CONTENT_DESCRIPTION
Definition asfheader.h:56
GUID_ASF_2_0_HEADER
@ GUID_ASF_2_0_HEADER
Definition asfheader.h:84
GUID_ASF_SCRIPT_COMMAND
@ GUID_ASF_SCRIPT_COMMAND
Definition asfheader.h:52
GUID_LANGUAGE_LIST
@ GUID_LANGUAGE_LIST
Definition asfheader.h:91
GUID_STREAM_PRIORITIZATION
@ GUID_STREAM_PRIORITIZATION
Definition asfheader.h:89
GUID_ADVANCED_CONTENT_ENCRYPTION
@ GUID_ADVANCED_CONTENT_ENCRYPTION
Definition asfheader.h:97
GUID_ASF_ERROR_CORRECTION
@ GUID_ASF_ERROR_CORRECTION
Definition asfheader.h:55
GUID_ASF_CODEC_COMMENT1_HEADER
@ GUID_ASF_CODEC_COMMENT1_HEADER
Definition asfheader.h:83
GUID_ASF_HEADER_EXTENSION
@ GUID_ASF_HEADER_EXTENSION
Definition asfheader.h:50
GUID_TIMECODE_INDEX_PARAMETERS
@ GUID_TIMECODE_INDEX_PARAMETERS
Definition asfheader.h:96
GUID_ASF_RESERVED_MARKER
@ GUID_ASF_RESERVED_MARKER
Definition asfheader.h:80
GUID_ASF_STREAM_PROPERTIES
@ GUID_ASF_STREAM_PROPERTIES
Definition asfheader.h:49
GUID_ASF_NO_ERROR_CORRECTION
@ GUID_ASF_NO_ERROR_CORRECTION
Definition asfheader.h:70
GUID_METADATA
@ GUID_METADATA
Definition asfheader.h:92
GUID_END
@ GUID_END
Definition asfheader.h:99
GUID_ASF_FILE_TRANSFER_MEDIA
@ GUID_ASF_FILE_TRANSFER_MEDIA
Definition asfheader.h:67
GUID_ASF_DEGRADABLE_JPEG_MEDIA
@ GUID_ASF_DEGRADABLE_JPEG_MEDIA
Definition asfheader.h:66
GUID_INDEX_PARAMETERS
@ GUID_INDEX_PARAMETERS
Definition asfheader.h:94
GUID_ASF_HEADER
@ GUID_ASF_HEADER
Definition asfheader.h:41
GUID_ASF_COMMAND_MEDIA
@ GUID_ASF_COMMAND_MEDIA
Definition asfheader.h:64
GUID_ASF_SIMPLE_INDEX
@ GUID_ASF_SIMPLE_INDEX
Definition asfheader.h:43
GUID_ASF_RESERVED_1
@ GUID_ASF_RESERVED_1
Definition asfheader.h:76
GUID_METADATA_LIBRARY
@ GUID_METADATA_LIBRARY
Definition asfheader.h:93
GUID_BANDWIDTH_SHARING
@ GUID_BANDWIDTH_SHARING
Definition asfheader.h:90
GUID_ASF_AUDIO_SPREAD
@ GUID_ASF_AUDIO_SPREAD
Definition asfheader.h:71
GUID_ERROR
@ GUID_ERROR
Definition asfheader.h:39
asf_header_disable_streams
void asf_header_disable_streams(asf_header_t *header, int video_id, int audio_id)
Definition asfheader.c:933
asf_header_delete
void asf_header_delete(asf_header_t *header)
Definition asfheader.c:858
ASF_MAX_NUM_STREAMS
#define ASF_MAX_NUM_STREAMS
Definition asfheader.h:116
asf_header_new
asf_header_t * asf_header_new(uint8_t *buffer, int buffer_len)
Definition asfheader.c:720
asf_guid_name
const char * asf_guid_name(asf_guid_t num)
Definition asfheader.c:1188
asf_header_choose_streams
void asf_header_choose_streams(asf_header_t *header, uint32_t bandwidth, int *video_id, int *audio_id)
Definition asfheader.c:894
asf_guid_2_str
void asf_guid_2_str(uint8_t *str, const uint8_t *guid)
Definition asfheader.c:1092
asf_guid_2_num
asf_guid_t asf_guid_2_num(const uint8_t *guid)
Definition asfheader.c:1063
XINE_MALLOC
#define XINE_MALLOC
Definition attributes.h:141
asf_content_s
Definition asfheader.h:159
asf_content_s::copyright
char * copyright
Definition asfheader.h:162
asf_content_s::author
char * author
Definition asfheader.h:161
asf_content_s::rating
char * rating
Definition asfheader.h:164
asf_content_s::description
char * description
Definition asfheader.h:163
asf_content_s::title
char * title
Definition asfheader.h:160
asf_file_s
Definition asfheader.h:143
asf_file_s::max_bitrate
uint32_t max_bitrate
Definition asfheader.h:152
asf_file_s::send_duration
uint64_t send_duration
Definition asfheader.h:148
asf_file_s::file_size
uint64_t file_size
Definition asfheader.h:145
asf_file_s::seekable_flag
uint8_t seekable_flag
Definition asfheader.h:155
asf_file_s::broadcast_flag
uint8_t broadcast_flag
Definition asfheader.h:154
asf_file_s::play_duration
uint64_t play_duration
Definition asfheader.h:147
asf_file_s::preroll
uint64_t preroll
Definition asfheader.h:149
asf_file_s::file_id
uint8_t file_id[16]
Definition asfheader.h:144
asf_file_s::data_packet_count
uint64_t data_packet_count
Definition asfheader.h:146
asf_file_s::packet_size
uint32_t packet_size
Definition asfheader.h:151
asf_header_s
Definition asfheader.h:132
asf_header_s::aspect_ratios
struct asf_header_s::@14 aspect_ratios[23]
asf_header_s::stream_extensions
asf_stream_extension_t * stream_extensions[23]
Definition asfheader.h:138
asf_header_s::bitrates
uint32_t bitrates[23]
Definition asfheader.h:139
asf_header_s::y
uint32_t y
Definition asfheader.h:140
asf_header_s::stream_count
int stream_count
Definition asfheader.h:135
asf_header_s::file
asf_file_t * file
Definition asfheader.h:133
asf_header_s::x
uint32_t x
Definition asfheader.h:140
asf_header_s::content
asf_content_t * content
Definition asfheader.h:134
asf_header_s::streams
asf_stream_t * streams[23]
Definition asfheader.h:137
asf_stream_extension_s
Definition asfheader.h:182
asf_stream_extension_s::initial_buffer_fullness
uint32_t initial_buffer_fullness
Definition asfheader.h:187
asf_stream_extension_s::alternate_buffer_size
uint32_t alternate_buffer_size
Definition asfheader.h:189
asf_stream_extension_s::payload_extension_system_count
uint16_t payload_extension_system_count
Definition asfheader.h:202
asf_stream_extension_s::alternate_initial_buffer_fullness
uint32_t alternate_initial_buffer_fullness
Definition asfheader.h:190
asf_stream_extension_s::seekable_flag
uint8_t seekable_flag
Definition asfheader.h:194
asf_stream_extension_s::alternate_data_bitrate
uint32_t alternate_data_bitrate
Definition asfheader.h:188
asf_stream_extension_s::reliable_flag
uint8_t reliable_flag
Definition asfheader.h:193
asf_stream_extension_s::stream_name_count
uint16_t stream_name_count
Definition asfheader.h:201
asf_stream_extension_s::max_object_size
uint32_t max_object_size
Definition asfheader.h:191
asf_stream_extension_s::average_time_per_frame
uint64_t average_time_per_frame
Definition asfheader.h:199
asf_stream_extension_s::no_cleanpoints_flag
uint8_t no_cleanpoints_flag
Definition asfheader.h:195
asf_stream_extension_s::resend_live_cleanpoints_flag
uint8_t resend_live_cleanpoints_flag
Definition asfheader.h:196
asf_stream_extension_s::data_bitrate
uint32_t data_bitrate
Definition asfheader.h:185
asf_stream_extension_s::language_id
uint16_t language_id
Definition asfheader.h:198
asf_stream_extension_s::end_time
uint64_t end_time
Definition asfheader.h:184
asf_stream_extension_s::stream_names
char ** stream_names
Definition asfheader.h:204
asf_stream_extension_s::buffer_size
uint32_t buffer_size
Definition asfheader.h:186
asf_stream_extension_s::start_time
uint64_t start_time
Definition asfheader.h:183
asf_stream_s
Definition asfheader.h:167
asf_stream_s::error_correction_type
asf_guid_t error_correction_type
Definition asfheader.h:170
asf_stream_s::time_offset
uint64_t time_offset
Definition asfheader.h:171
asf_stream_s::stream_type
asf_guid_t stream_type
Definition asfheader.h:169
asf_stream_s::private_data
uint8_t * private_data
Definition asfheader.h:174
asf_stream_s::private_data_length
uint32_t private_data_length
Definition asfheader.h:173
asf_stream_s::error_correction_data
uint8_t * error_correction_data
Definition asfheader.h:177
asf_stream_s::encrypted_flag
uint8_t encrypted_flag
Definition asfheader.h:179
asf_stream_s::error_correction_data_length
uint32_t error_correction_data_length
Definition asfheader.h:176
asf_stream_s::stream_number
uint16_t stream_number
Definition asfheader.h:168