00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 typedef struct guid_s
00028 {
00029 uint32_t v1;
00030 uint16_t v2;
00031 uint16_t v3;
00032 uint8_t v4[8];
00033 } guid_t;
00034
00035 enum
00036 {
00037 ASF_OBJECT_NULL = 0,
00038 ASF_OBJECT_ROOT,
00039 ASF_OBJECT_HEADER,
00040 ASF_OBJECT_DATA,
00041 ASF_OBJECT_INDEX,
00042 ASF_OBJECT_FILE_PROPERTIES,
00043 ASF_OBJECT_STREAM_PROPERTIES,
00044 ASF_OBJECT_HEADER_EXTENSION,
00045 ASF_OBJECT_CODEC_LIST,
00046 ASF_OBJECT_MARKER,
00047 ASF_OBJECT_CONTENT_DESCRIPTION,
00048 ASF_OBJECT_METADATA,
00049 ASF_OBJECT_PADDING,
00050 ASF_OBJECT_OTHER,
00051 };
00052
00053 static const guid_t asf_object_null_guid =
00054 {
00055 0x00000000,
00056 0x0000,
00057 0x0000,
00058 { 0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00 }
00059 };
00060
00061 static const guid_t asf_object_header_guid =
00062 {0x75B22630, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}};
00063
00064 static const guid_t asf_object_data_guid =
00065 {0x75B22636, 0x668E, 0x11CF, {0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C}};
00066
00067 static const guid_t asf_object_index_guid =
00068 {0x33000890, 0xE5B1, 0x11CF, {0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB}};
00069
00070 static const guid_t asf_object_file_properties_guid =
00071 {0x8cabdca1, 0xa947, 0x11cf, {0x8e, 0xe4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
00072
00073 static const guid_t asf_object_stream_properties_guid =
00074 {0xB7DC0791, 0xA9B7, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
00075
00076 static const guid_t asf_object_content_description_guid =
00077 {0x75B22633, 0x668E, 0x11CF, {0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}};
00078
00079 static const guid_t asf_object_header_extension_guid =
00080 {0x5FBF03B5, 0xA92E, 0x11CF, {0x8E, 0xE3, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
00081
00082 static const guid_t asf_object_metadata_guid =
00083 {0xC5F8CBEA, 0x5BAF, 0x4877, {0x84, 0x67, 0xAA, 0x8C, 0x44, 0xFA, 0x4C, 0xCA}};
00084
00085 static const guid_t asf_object_codec_list_guid =
00086 {0x86D15240, 0x311D, 0x11D0, {0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}};
00087
00088 static const guid_t asf_object_marker_guid =
00089 {0xF487CD01, 0xA951, 0x11CF, {0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65}};
00090
00091 static const guid_t asf_object_stream_type_audio =
00092 {0xF8699E40, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
00093
00094 static const guid_t asf_object_stream_type_video =
00095 {0xbc19efc0, 0x5B4D, 0x11CF, {0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B}};
00096
00097 static const guid_t asf_object_stream_type_command =
00098 {0x59DACFC0, 0x59E6, 0x11D0, {0xA3, 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}};
00099
00100
00101 static const guid_t asf_object_stream_bitrate_properties =
00102 {0x7BF875CE, 0x468D, 0x11D1, {0x8D, 0x82, 0x00, 0x60, 0x97, 0xC9, 0xA2, 0xB2}};
00103
00104 static const guid_t asf_object_language_list =
00105 {0x7C4346A9, 0xEFE0, 0x4BFC, {0xB2, 0x29, 0x39, 0x3E, 0xDE, 0x41, 0x5C, 0x85}};
00106
00107 static const guid_t asf_object_extended_stream_properties =
00108 {0x14E6A5CB, 0xC672, 0x4332, {0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A}};
00109
00110 static const guid_t asf_object_advanced_mutual_exclusion =
00111 {0xA08649CF, 0x4775, 0x4670, {0x8A, 0x16, 0x6E, 0x35, 0x35, 0x75, 0x66, 0xCD}};
00112
00113 static const guid_t asf_object_padding =
00114 {0x1806D474, 0xCADF, 0x4509, {0xA4, 0xBA, 0x9A, 0xAB, 0xCB, 0x96, 0xAA, 0xE8}};
00115
00116 static const guid_t asf_object_stream_prioritization =
00117 {0xD4FED15B, 0x88D3, 0x454F, {0x81, 0xF0, 0xED, 0x5C, 0x45, 0x99, 0x9E, 0x24}};
00118
00119 static const guid_t asf_object_extended_content_description =
00120 {0xD2D0A440, 0xE307, 0x11D2, {0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50}};
00121
00122 #define ASF_OBJECT_COMMON \
00123 int i_type; \
00124 guid_t i_object_id; \
00125 uint64_t i_object_size; \
00126 uint64_t i_object_pos; \
00127 union asf_object_u *p_father; \
00128 union asf_object_u *p_first; \
00129 union asf_object_u *p_last; \
00130 union asf_object_u *p_next;
00131
00132 typedef struct
00133 {
00134 ASF_OBJECT_COMMON
00135
00136 } asf_object_common_t;
00137
00138 typedef struct
00139 {
00140 uint32_t i_packet_number;
00141 uint16_t i_packet_count;
00142
00143 } asf_index_entry_t;
00144
00145
00146
00147
00148
00149
00150 typedef struct
00151 {
00152 ASF_OBJECT_COMMON
00153 uint32_t i_sub_object_count;
00154 uint8_t i_reserved1;
00155 uint8_t i_reserved2;
00156
00157 } asf_object_header_t;
00158
00159 typedef struct
00160 {
00161 ASF_OBJECT_COMMON
00162 guid_t i_file_id;
00163 uint64_t i_total_data_packets;
00164 uint16_t i_reserved;
00165
00166 } asf_object_data_t;
00167
00168
00169 typedef struct
00170 {
00171 ASF_OBJECT_COMMON
00172 guid_t i_file_id;
00173 uint64_t i_index_entry_time_interval;
00174 uint32_t i_max_packet_count;
00175 uint32_t i_index_entry_count;
00176
00177 asf_index_entry_t *index_entry;
00178
00179 } asf_object_index_t;
00180
00181
00182
00183
00184 #define ASF_FILE_PROPERTIES_BROADCAST 0x01
00185 #define ASF_FILE_PROPERTIES_SEEKABLE 0x02
00186
00187 typedef struct
00188 {
00189 ASF_OBJECT_COMMON
00190
00191 guid_t i_file_id;
00192 uint64_t i_file_size;
00193 uint64_t i_creation_date;
00194 uint64_t i_data_packets_count;
00195 uint64_t i_play_duration;
00196 uint64_t i_send_duration;
00197 uint64_t i_preroll;
00198 uint32_t i_flags;
00199 uint32_t i_min_data_packet_size;
00200 uint32_t i_max_data_packet_size;
00201 uint32_t i_max_bitrate;
00202
00203 } asf_object_file_properties_t;
00204
00205 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
00206 typedef struct
00207 {
00208 ASF_OBJECT_COMMON
00209
00210 guid_t i_stream_type;
00211 guid_t i_error_correction_type;
00212 uint64_t i_time_offset;
00213 uint32_t i_type_specific_data_length;
00214 uint32_t i_error_correction_data_length;
00215 uint16_t i_flags;
00216
00217 uint8_t i_stream_number;
00218 uint32_t i_reserved;
00219 uint8_t *p_type_specific_data;
00220 uint8_t *p_error_correction_data;
00221 } asf_object_stream_properties_t;
00222
00223 typedef struct
00224 {
00225 ASF_OBJECT_COMMON
00226
00227 guid_t i_reserved1;
00228 uint16_t i_reserved2;
00229 uint32_t i_header_extension_size;
00230 uint8_t *p_header_extension_data;
00231
00232 } asf_object_header_extension_t;
00233
00234 #define ASF_METADATA_TYPE_STRING 0x0000
00235 #define ASF_METADATA_TYPE_BYTE 0x0001
00236 #define ASF_METADATA_TYPE_BOOL 0x0002
00237 #define ASF_METADATA_TYPE_DWORD 0x0003
00238 #define ASF_METADATA_TYPE_QWORD 0x0004
00239 #define ASF_METADATA_TYPE_WORD 0x0005
00240
00241 typedef struct
00242 {
00243 uint16_t i_stream;
00244 uint16_t i_type;
00245 char *psz_name;
00246
00247 int64_t i_val;
00248 int i_data;
00249 uint8_t *p_data;
00250
00251 } asf_metadata_record_t;
00252
00253 typedef struct
00254 {
00255 ASF_OBJECT_COMMON
00256
00257 uint32_t i_record_entries_count;
00258 asf_metadata_record_t *record;
00259
00260 } asf_object_metadata_t;
00261
00262 typedef struct
00263 {
00264 ASF_OBJECT_COMMON
00265
00266 char *psz_title;
00267 char *psz_author;
00268 char *psz_copyright;
00269 char *psz_description;
00270 char *psz_rating;
00271
00272 } asf_object_content_description_t;
00273
00274 typedef struct
00275 {
00276 uint16_t i_length;
00277 uint16_t *i_char;
00278
00279 } string16_t;
00280
00281 #define ASF_CODEC_TYPE_VIDEO 0x0001
00282 #define ASF_CODEC_TYPE_AUDIO 0x0002
00283 #define ASF_CODEC_TYPE_UNKNOW 0xffff
00284
00285 typedef struct
00286 {
00287 uint16_t i_type;
00288 char *psz_name;
00289 char *psz_description;
00290
00291 uint16_t i_information_length;
00292 uint8_t *p_information;
00293 } asf_codec_entry_t;
00294
00295 typedef struct
00296 {
00297 ASF_OBJECT_COMMON
00298 guid_t i_reserved;
00299 uint32_t i_codec_entries_count;
00300 asf_codec_entry_t *codec;
00301
00302 } asf_object_codec_list_t;
00303
00304 typedef struct
00305 {
00306 uint64_t i_offset;
00307 uint64_t i_presentation_time;
00308 uint16_t i_entry_length;
00309 uint32_t i_send_time;
00310 uint32_t i_flags;
00311 uint32_t i_marker_description_length;
00312 uint8_t *i_marker_description;
00313
00314 } asf_marker_t;
00315
00316 typedef struct
00317 {
00318 ASF_OBJECT_COMMON
00319 guid_t i_reserved1;
00320 uint32_t i_count;
00321 uint16_t i_reserved2;
00322 string16_t name;
00323 asf_marker_t *marker;
00324
00325 } asf_object_marker_t;
00326
00327 typedef struct
00328 {
00329 ASF_OBJECT_COMMON
00330 int i_language;
00331 char **ppsz_language;
00332
00333 } asf_object_language_list_t;
00334
00335 typedef struct
00336 {
00337 ASF_OBJECT_COMMON
00338
00339 int i_bitrate;
00340 struct
00341 {
00342 int i_stream_number;
00343 uint32_t i_avg_bitrate;
00344 } bitrate[128];
00345 } asf_object_stream_bitrate_properties_t;
00346
00347 typedef struct
00348 {
00349 ASF_OBJECT_COMMON
00350
00351 int64_t i_start_time;
00352 int64_t i_end_time;
00353 int32_t i_data_bitrate;
00354 int32_t i_buffer_size;
00355 int32_t i_initial_buffer_fullness;
00356 int32_t i_alternate_data_bitrate;
00357 int32_t i_alternate_buffer_size;
00358 int32_t i_alternate_initial_buffer_fullness;
00359 int32_t i_maximum_object_size;
00360
00361 int32_t i_flags;
00362 int16_t i_stream_number;
00363 int16_t i_language_index;
00364 int64_t i_average_time_per_frame;
00365
00366 int i_stream_name_count;
00367 int i_payload_extention_system_count;
00368
00369 int *pi_stream_name_language;
00370 char **ppsz_stream_name;
00371
00372 asf_object_stream_properties_t *p_sp;
00373 } asf_object_extended_stream_properties_t;
00374
00375 typedef struct
00376 {
00377 ASF_OBJECT_COMMON
00378
00379 guid_t type;
00380 int16_t i_stream_number_count;
00381 int16_t *pi_stream_number;
00382
00383 } asf_object_advanced_mutual_exclusion_t;
00384
00385 typedef struct
00386 {
00387 ASF_OBJECT_COMMON
00388
00389 int i_priority_count;
00390 int *pi_priority_flag;
00391 int *pi_priority_stream_number;
00392 } asf_object_stream_prioritization_t;
00393
00394 typedef struct
00395 {
00396 ASF_OBJECT_COMMON
00397
00398 int i_count;
00399 char **ppsz_name;
00400 char **ppsz_value;
00401 } asf_object_extended_content_description_t;
00402
00403
00404
00405
00406 typedef struct
00407 {
00408 ASF_OBJECT_COMMON
00409
00410 asf_object_header_t *p_hdr;
00411 asf_object_data_t *p_data;
00412
00413 asf_object_index_t *p_index;
00414
00415
00416 asf_object_file_properties_t *p_fp;
00417
00418
00419 asf_object_metadata_t *p_metadata;
00420
00421 } asf_object_root_t;
00422
00423
00424
00425
00426 typedef union asf_object_u
00427 {
00428 asf_object_common_t common;
00429 asf_object_header_t header;
00430 asf_object_data_t data;
00431 asf_object_index_t index;
00432 asf_object_root_t root;
00433 asf_object_file_properties_t file_properties;
00434 asf_object_stream_properties_t stream_properties;
00435 asf_object_header_extension_t header_extension;
00436 asf_object_metadata_t metadata;
00437 asf_object_codec_list_t codec_list;
00438 asf_object_marker_t marker;
00439 asf_object_language_list_t lang;
00440 asf_object_stream_bitrate_properties_t stream_bitrate;
00441 asf_object_extended_stream_properties_t ext_stream;
00442
00443 } asf_object_t;
00444
00445
00446 void ASF_GetGUID( guid_t *p_guid, uint8_t *p_data );
00447 int ASF_CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
00448
00449 asf_object_root_t *ASF_ReadObjectRoot( stream_t *, int b_seekable );
00450 void ASF_FreeObjectRoot( stream_t *, asf_object_root_t *p_root );
00451
00452 #define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b )
00453 int __ASF_CountObject ( asf_object_t *p_obj, const guid_t *p_guid );
00454
00455 #define ASF_FindObject( a, b, c ) __ASF_FindObject( (asf_object_t*)(a), b, c )
00456 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number );