#include struct asf_guid_s { uint32_t v1; uint32_t v2; uint16_t v3; uint8_t v4[8]; }; typedef struct asf_guid_s asf_guid_t; typedef struct { uint16_t type; char *codec_name; char *codec_description; uint16_t codec_information_length; uint8_t *codec_information; } asf_codec_entry_t; typedef struct { uint32_t presentation_time; uint16_t type_index; char *command_name; } asf_command_t; typedef struct { uint64_t offset; uint64_t presentation_time; uint16_t entry_length; uint32_t send_time; uint32_t flags; char *marker_description; } asf_marker_t; typedef union { char *string; uint8_t *byte_array; uint8_t bool; uint32_t dword; uint64_t qword; uint16_t word; asf_guid_t guid; } asf_value_t; typedef struct { char *descriptor_name; uint16_t descriptor_value_type; asf_value_t descriptor_value; } asf_content_descriptor_t; typedef struct { uint16_t flags; uint16_t average_bitrate; } asf_bitrate_record_t; typedef struct { uint16_t language_id_index; char *stream_name; } asf_stream_name_t; typedef struct { asf_guid_t extension_system_id; uint16_t extension_data_size; uint32_t extension_system_info_length; uint8_t *extension_system_info; } asf_payload_extension_system_t; typedef struct { uint16_t stream_count; uint16_t stream_numbers; } asf_record_t; typedef struct { uint16_t stream_number; uint16_t priority_flags; } asf_priority_record_t; typedef struct { uint16_t language_list_index; uint16_t stream_number; uint16_t data_type; uint16_t data_length; char *name; asf_value_t data; } asf_description_record_t; typedef struct { uint16_t stream_number; uint16_t index_type; } asf_index_specifier_t; typedef struct { uint16_t encrypted_object_id_type; uint16_t encrypted_object_id_length; uint8_t *encrypted_object_id; } asf_encrypted_object_record_t; typedef struct { asf_guid_t system_id; uint32_t system_version; uint16_t encrypted_object_record_count; asf_encrypted_object_record_t *encrypted_object_records; uint32_t data_size; uint8_t *data; } asf_content_encryption_record_t; typedef enum { ASF_OBJECT_NULL = 0, ASF_OBJECT_HEADER, /* objects inside header */ ASF_OBJECT_FILE_PROPERTIES, ASF_OBJECT_STREAM_PROPERTIES, ASF_OBJECT_HEADER_EXTENSION, ASF_OBJECT_CODEC_LIST, ASF_OBJECT_SCRIPT_COMMAND, ASF_OBJECT_MARKER, ASF_OBJECT_BITRATE_MUTUAL_EXCLUSION, ASF_OBJECT_ERROR_CORRECTION, ASF_OBJECT_CONTENT_DESCRIPTION, ASF_OBJECT_EXTENDED_CONTENT_DESCRIPTION, ASF_OBJECT_STREAM_BITRATE_PROPERTIES, ASF_OBJECT_CONTENT_BRANDING, ASF_OBJECT_CONTENT_ENCRYPTION, ASF_OBJECT_EXTENDED_CONTENT_ENCRYPTION, ASF_OBJECT_DIGITAL_SIGNATURE, ASF_OBJECT_PADDING, /* objects inside header extension */ ASF_OBJECT_EXTENDED_STREAM_PROPERTIES, ASF_OBJECT_ADVANCED_MUTUAL_EXCLUSION, ASF_OBJECT_GROUP_MUTUAL_EXCLUSION, ASF_OBJECT_STREAM_PRIORITIZATION, ASF_OBJECT_BANDWIDTH_SHARING, ASF_OBJECT_LANGUAGE_LIST, ASF_OBJECT_METADATA, ASF_OBJECT_METADATA_LIBRARY, ASF_OBJECT_INDEX_PARAMETERS, ASF_OBJECT_MEDIA_OBJECT_INDEX_PARAMETERS, ASF_OBJECT_TIMECODE_INDEX_PARAMETERS, ASF_OBJECT_COMPATIBILITY, ASF_OBJECT_ADVANCED_CONTENT_ENCRYPTION, /* unknown */ ASF_OBJECT_OTHER } asf_object_type_t; typedef union asf_object_u asf_object_t; #define ASF_OBJECT_COMMON \ asf_object_type_t type; \ asf_guid_t object_id; \ uint64_t object_size; \ uint64_t position; \ asf_object_t *parent; \ asf_object_t *first; \ asf_object_t *last; \ asf_object_t *next; \ typedef struct { ASF_OBJECT_COMMON } asf_object_common_t; typedef struct { ASF_OBJECT_COMMON uint32_t header_object_count; uint8_t reserved1; uint8_t reserved2; } asf_object_header_t; typedef struct { ASF_OBJECT_COMMON uint32_t header_object_count; asf_guid_t file_id; uint64_t file_size; uint64_t creation_date; uint64_t data_packets_count; uint64_t play_duration; uint64_t send_duration; uint64_t preroll; uint32_t flags; uint32_t min_data_packet_size; uint32_t max_data_packet_size; uint32_t max_bitrate; } asf_object_file_properties_t; typedef struct { ASF_OBJECT_COMMON asf_guid_t stream_type; asf_guid_t error_correction_type; uint64_t time_offset; uint32_t type_specific_data_length; uint32_t error_correction_data_length; uint16_t flags; uint32_t reserved; uint8_t *type_specific_data; uint8_t *error_correction_data; } asf_object_stream_properties_t; typedef struct { ASF_OBJECT_COMMON asf_guid_t reserved1; uint16_t reserved2; uint32_t header_extension_data_size; uint8_t *header_extension_data; } asf_object_header_extension_t; typedef struct { ASF_OBJECT_COMMON asf_guid_t reserved; uint32_t codec_entries_count; asf_codec_entry_t *codec_entries; } asf_object_codec_list_t; typedef struct { ASF_OBJECT_COMMON asf_guid_t reserved; uint16_t commands_count; uint16_t command_types_count; char **command_types; asf_command_t *commands; } asf_object_script_command_t; typedef struct { ASF_OBJECT_COMMON asf_guid_t reserved1; uint32_t markers_count; uint16_t reserved2; char *name; asf_marker_t *markers; } asf_object_marker_t; typedef struct { ASF_OBJECT_COMMON asf_guid_t exclusion_type; uint16_t stream_numbers_count; uint16_t *stream_numbers; } asf_object_bitrate_mutual_exclusion_t; typedef struct { ASF_OBJECT_COMMON asf_guid_t error_correction_type; uint32_t error_correction_data_length; uint8_t *error_correction_data; } asf_object_error_correction_t; typedef struct { ASF_OBJECT_COMMON char *title; char *author; char *copyright; char *description; char *rating; } asf_object_content_description_t; typedef struct { ASF_OBJECT_COMMON uint16_t content_descriptors_count; asf_content_descriptor_t content_descriptors; } asf_object_extended_content_description_t; typedef struct { ASF_OBJECT_COMMON uint16_t bitrate_records_count; asf_bitrate_record_t *bitrate_records; } asf_object_stream_bitrate_properties_t; typedef struct { ASF_OBJECT_COMMON uint32_t banner_image_type; uint32_t banner_image_data_size; uint8_t *banner_image_data; char *banner_image_url; char *copyright_url; } asf_object_content_branding_t; typedef struct { ASF_OBJECT_COMMON uint32_t secret_data_length; uint8_t *secret_data; char *protection_type; char *key_id; char *license_url; } asf_object_content_encryption_t; typedef struct { ASF_OBJECT_COMMON uint32_t data_size; uint8_t *data; } asf_object_extended_content_encryption_t; typedef struct { ASF_OBJECT_COMMON uint32_t signature_type; uint32_t signature_data_length; uint8_t signature_data; } asf_object_digital_signature_t; typedef struct { uint8_t *padding_data; } asf_object_padding_t; typedef struct { uint64_t start_time; uint64_t end_time; uint32_t data_bitrate; uint32_t buffer_size; uint32_t initial_buffer_fullness; uint32_t alt_data_bitrate; uint32_t alt_buffer_size; uint32_t alt_initial_buffer_fullness; uint32_t max_object_size; uint32_t flags; uint16_t stream_number; uint16_t stream_language_id_index; uint64_t average_time_per_frame; uint16_t stream_name_count; uint16_t payload_extension_system_count; asf_stream_name_t *stream_names; asf_payload_extension_system_t *payload_extension_systems; asf_object_stream_properties_t *stream_properties_object; } asf_object_extended_stream_properties_t; typedef struct { asf_guid_t exclusion_type; uint16_t stream_numbers_count; uint16_t *stream_numbers; } asf_object_advanced_mutual_exclusion_t; typedef struct { asf_guid_t exclusion_type; uint16_t record_count; asf_record_t *records; } asf_object_group_mutual_exclusion_t; typedef struct { uint16_t priority_records_count; asf_priority_record_t *priority_records; } asf_object_stream_prioritization_t; typedef struct { asf_guid_t sharing_type; uint32_t data_bitrate; uint32_t buffer_size; uint16_t stream_numbers_count; uint16_t *stream_numbers; } asf_object_bandwidth_sharing_t; typedef struct { uint16_t language_id_records_count; char **language_id_records; } asf_object_language_list_t; typedef struct { uint16_t description_records_count; asf_description_record_t *description_records; } asf_object_metadata_t; typedef struct { uint16_t description_records_count; asf_description_record_t *description_records; } asf_object_metadata_library_t; typedef struct { uint32_t index_entry_interval; uint16_t index_specifiers_count; asf_index_specifier_t *index_specifiers; } asf_object_index_parameters_t; typedef struct { uint8_t profile; uint8_t mode; } asf_object_compatibility_t; typedef struct { uint16_t content_encryption_records_count; asf_content_encryption_record_t *content_encryption_records; } asf_object_advanced_content_encryption_t; union asf_object_u { asf_object_header_t header; asf_object_file_properties_t file_properties; asf_object_stream_properties_t stream_properties; asf_object_header_extension_t header_extension; asf_object_codec_list_t codec_list; asf_object_script_command_t script_command; asf_object_marker_t marker; asf_object_bitrate_mutual_exclusion_t bitrate_mutual_exclusion; asf_object_error_correction_t error_correction; asf_object_content_description_t content_description; asf_object_extended_content_description_t extended_content_description; asf_object_stream_bitrate_properties_t stream_bitrate_properties; asf_object_content_branding_t content_branding; asf_object_content_encryption_t content_encryption; asf_object_extended_content_encryption_t extended_content_encryption; asf_object_digital_signature_t digital_signature; asf_object_padding_t padding; asf_object_extended_stream_properties_t extended_stream_properties; asf_object_advanced_mutual_exclusion_t advanced_mutual_exclusion; asf_object_group_mutual_exclusion_t group_mutual_exclusion; asf_object_stream_prioritization_t stream_prioritization; asf_object_bandwidth_sharing_t bandwidth_sharing; asf_object_language_list_t language_list; asf_object_metadata_t metadata; asf_object_metadata_library_t metadata_library; asf_object_index_parameters_t index_parameters; asf_object_index_parameters_t media_object_index_parameters; asf_object_index_parameters_t timecode_index_parameters; asf_object_compatibility_t compatibility; asf_object_advanced_content_encryption_t advanced_content_encryption; };