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 static const guid_t asf_object_extended_stream_header =
00123 {0x3afb65e2, 0x47ef, 0x40f2, { 0xac, 0x2c, 0x70, 0xa9, 0x0d, 0x71, 0xd3, 0x43}};
00124
00125 static const guid_t asf_object_extended_stream_type_audio =
00126 {0x31178c9d, 0x03e1, 0x4528, { 0xb5, 0x82, 0x3d, 0xf9, 0xdb, 0x22, 0xf5, 0x03}};
00127
00128 #define ASF_OBJECT_COMMON \
00129 int i_type; \
00130 guid_t i_object_id; \
00131 uint64_t i_object_size; \
00132 uint64_t i_object_pos; \
00133 union asf_object_u *p_father; \
00134 union asf_object_u *p_first; \
00135 union asf_object_u *p_last; \
00136 union asf_object_u *p_next;
00137
00138 typedef struct
00139 {
00140 ASF_OBJECT_COMMON
00141
00142 } asf_object_common_t;
00143
00144 typedef struct
00145 {
00146 uint32_t i_packet_number;
00147 uint16_t i_packet_count;
00148
00149 } asf_index_entry_t;
00150
00151
00152
00153
00154
00155
00156 typedef struct
00157 {
00158 ASF_OBJECT_COMMON
00159 uint32_t i_sub_object_count;
00160 uint8_t i_reserved1;
00161 uint8_t i_reserved2;
00162
00163 } asf_object_header_t;
00164
00165 typedef struct
00166 {
00167 ASF_OBJECT_COMMON
00168 guid_t i_file_id;
00169 uint64_t i_total_data_packets;
00170 uint16_t i_reserved;
00171
00172 } asf_object_data_t;
00173
00174
00175 typedef struct
00176 {
00177 ASF_OBJECT_COMMON
00178 guid_t i_file_id;
00179 uint64_t i_index_entry_time_interval;
00180 uint32_t i_max_packet_count;
00181 uint32_t i_index_entry_count;
00182
00183 asf_index_entry_t *index_entry;
00184
00185 } asf_object_index_t;
00186
00187
00188
00189
00190 #define ASF_FILE_PROPERTIES_BROADCAST 0x01
00191 #define ASF_FILE_PROPERTIES_SEEKABLE 0x02
00192
00193 typedef struct
00194 {
00195 ASF_OBJECT_COMMON
00196
00197 guid_t i_file_id;
00198 uint64_t i_file_size;
00199 uint64_t i_creation_date;
00200 uint64_t i_data_packets_count;
00201 uint64_t i_play_duration;
00202 uint64_t i_send_duration;
00203 uint64_t i_preroll;
00204 uint32_t i_flags;
00205 uint32_t i_min_data_packet_size;
00206 uint32_t i_max_data_packet_size;
00207 uint32_t i_max_bitrate;
00208
00209 } asf_object_file_properties_t;
00210
00211 #define ASF_STREAM_PROPERTIES_ENCRYPTED 0x8000
00212 typedef struct
00213 {
00214 ASF_OBJECT_COMMON
00215
00216 guid_t i_stream_type;
00217 guid_t i_error_correction_type;
00218 uint64_t i_time_offset;
00219 uint32_t i_type_specific_data_length;
00220 uint32_t i_error_correction_data_length;
00221 uint16_t i_flags;
00222
00223 uint8_t i_stream_number;
00224 uint32_t i_reserved;
00225 uint8_t *p_type_specific_data;
00226 uint8_t *p_error_correction_data;
00227 } asf_object_stream_properties_t;
00228
00229 typedef struct
00230 {
00231 ASF_OBJECT_COMMON
00232
00233 guid_t i_reserved1;
00234 uint16_t i_reserved2;
00235 uint32_t i_header_extension_size;
00236 uint8_t *p_header_extension_data;
00237
00238 } asf_object_header_extension_t;
00239
00240 #define ASF_METADATA_TYPE_STRING 0x0000
00241 #define ASF_METADATA_TYPE_BYTE 0x0001
00242 #define ASF_METADATA_TYPE_BOOL 0x0002
00243 #define ASF_METADATA_TYPE_DWORD 0x0003
00244 #define ASF_METADATA_TYPE_QWORD 0x0004
00245 #define ASF_METADATA_TYPE_WORD 0x0005
00246
00247 typedef struct
00248 {
00249 uint16_t i_stream;
00250 uint16_t i_type;
00251 char *psz_name;
00252
00253 int64_t i_val;
00254 int i_data;
00255 uint8_t *p_data;
00256
00257 } asf_metadata_record_t;
00258
00259 typedef struct
00260 {
00261 ASF_OBJECT_COMMON
00262
00263 uint32_t i_record_entries_count;
00264 asf_metadata_record_t *record;
00265
00266 } asf_object_metadata_t;
00267
00268 typedef struct
00269 {
00270 ASF_OBJECT_COMMON
00271
00272 char *psz_title;
00273 char *psz_artist;
00274 char *psz_copyright;
00275 char *psz_description;
00276 char *psz_rating;
00277
00278 } asf_object_content_description_t;
00279
00280 typedef struct
00281 {
00282 uint16_t i_length;
00283 uint16_t *i_char;
00284
00285 } string16_t;
00286
00287 #define ASF_CODEC_TYPE_VIDEO 0x0001
00288 #define ASF_CODEC_TYPE_AUDIO 0x0002
00289 #define ASF_CODEC_TYPE_UNKNOW 0xffff
00290
00291 typedef struct
00292 {
00293 uint16_t i_type;
00294 char *psz_name;
00295 char *psz_description;
00296
00297 uint16_t i_information_length;
00298 uint8_t *p_information;
00299 } asf_codec_entry_t;
00300
00301 typedef struct
00302 {
00303 ASF_OBJECT_COMMON
00304 guid_t i_reserved;
00305 uint32_t i_codec_entries_count;
00306 asf_codec_entry_t *codec;
00307
00308 } asf_object_codec_list_t;
00309
00310 typedef struct
00311 {
00312 uint64_t i_offset;
00313 uint64_t i_presentation_time;
00314 uint16_t i_entry_length;
00315 uint32_t i_send_time;
00316 uint32_t i_flags;
00317 uint32_t i_marker_description_length;
00318 uint8_t *i_marker_description;
00319
00320 } asf_marker_t;
00321
00322 typedef struct
00323 {
00324 ASF_OBJECT_COMMON
00325 guid_t i_reserved1;
00326 uint32_t i_count;
00327 uint16_t i_reserved2;
00328 string16_t name;
00329 asf_marker_t *marker;
00330
00331 } asf_object_marker_t;
00332
00333 typedef struct
00334 {
00335 ASF_OBJECT_COMMON
00336 int i_language;
00337 char **ppsz_language;
00338
00339 } asf_object_language_list_t;
00340
00341 typedef struct
00342 {
00343 ASF_OBJECT_COMMON
00344
00345 int i_bitrate;
00346 struct
00347 {
00348 int i_stream_number;
00349 uint32_t i_avg_bitrate;
00350 } bitrate[128];
00351 } asf_object_stream_bitrate_properties_t;
00352
00353 typedef struct
00354 {
00355 ASF_OBJECT_COMMON
00356
00357 int64_t i_start_time;
00358 int64_t i_end_time;
00359 int32_t i_data_bitrate;
00360 int32_t i_buffer_size;
00361 int32_t i_initial_buffer_fullness;
00362 int32_t i_alternate_data_bitrate;
00363 int32_t i_alternate_buffer_size;
00364 int32_t i_alternate_initial_buffer_fullness;
00365 int32_t i_maximum_object_size;
00366
00367 int32_t i_flags;
00368 int16_t i_stream_number;
00369 int16_t i_language_index;
00370 int64_t i_average_time_per_frame;
00371
00372 int i_stream_name_count;
00373 int i_payload_extension_system_count;
00374
00375 int *pi_stream_name_language;
00376 char **ppsz_stream_name;
00377
00378 asf_object_stream_properties_t *p_sp;
00379 } asf_object_extended_stream_properties_t;
00380
00381 typedef struct
00382 {
00383 ASF_OBJECT_COMMON
00384
00385 guid_t type;
00386 int16_t i_stream_number_count;
00387 int16_t *pi_stream_number;
00388
00389 } asf_object_advanced_mutual_exclusion_t;
00390
00391 typedef struct
00392 {
00393 ASF_OBJECT_COMMON
00394
00395 int i_priority_count;
00396 int *pi_priority_flag;
00397 int *pi_priority_stream_number;
00398 } asf_object_stream_prioritization_t;
00399
00400 typedef struct
00401 {
00402 ASF_OBJECT_COMMON
00403
00404 int i_count;
00405 char **ppsz_name;
00406 char **ppsz_value;
00407 } asf_object_extended_content_description_t;
00408
00409
00410
00411
00412 typedef struct
00413 {
00414 ASF_OBJECT_COMMON
00415
00416 asf_object_header_t *p_hdr;
00417 asf_object_data_t *p_data;
00418
00419 asf_object_index_t *p_index;
00420
00421
00422 asf_object_file_properties_t *p_fp;
00423
00424
00425 asf_object_metadata_t *p_metadata;
00426
00427 } asf_object_root_t;
00428
00429
00430
00431
00432 typedef union asf_object_u
00433 {
00434 asf_object_common_t common;
00435 asf_object_header_t header;
00436 asf_object_data_t data;
00437 asf_object_index_t index;
00438 asf_object_root_t root;
00439 asf_object_file_properties_t file_properties;
00440 asf_object_stream_properties_t stream_properties;
00441 asf_object_header_extension_t header_extension;
00442 asf_object_metadata_t metadata;
00443 asf_object_codec_list_t codec_list;
00444 asf_object_marker_t marker;
00445 asf_object_language_list_t language_list;
00446 asf_object_stream_bitrate_properties_t stream_bitrate;
00447 asf_object_extended_stream_properties_t ext_stream;
00448 asf_object_content_description_t content_description;
00449 asf_object_advanced_mutual_exclusion_t advanced_mutual_exclusion;
00450 asf_object_stream_prioritization_t stream_prioritization;
00451 asf_object_extended_content_description_t extended_content_description;
00452
00453 } asf_object_t;
00454
00455
00456 void ASF_GetGUID( guid_t *p_guid, const uint8_t *p_data );
00457 bool ASF_CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
00458
00459 asf_object_root_t *ASF_ReadObjectRoot( stream_t *, int b_seekable );
00460 void ASF_FreeObjectRoot( stream_t *, asf_object_root_t *p_root );
00461
00462 #define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b )
00463 int __ASF_CountObject ( asf_object_t *p_obj, const guid_t *p_guid );
00464
00465 #define ASF_FindObject( a, b, c ) __ASF_FindObject( (asf_object_t*)(a), b, c )
00466 void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number );