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. */ 104 typedef 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); 208 void asf_guid_2_str (uint8_t *str, const uint8_t *guid); 209 const char *asf_guid_name (asf_guid_t num); 210 211 asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) XINE_MALLOC; 212 void asf_header_choose_streams (asf_header_t *header, uint32_t bandwidth, 213 int *video_id, int *audio_id); 214 void asf_header_disable_streams (asf_header_t *header, 215 int video_id, int audio_id); 216 void asf_header_delete (asf_header_t *header); 217 218 219 #endif 220