00001 /* 00002 * Copyright (c) 2000, 2001 Fabrice Bellard 00003 * 00004 * This file is part of FFmpeg. 00005 * 00006 * FFmpeg is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * FFmpeg is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with FFmpeg; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #ifndef AVFORMAT_ASF_H 00022 #define AVFORMAT_ASF_H 00023 00024 #include <stdint.h> 00025 #include "avformat.h" 00026 #include "metadata.h" 00027 00028 #define PACKET_SIZE 3200 00029 00030 typedef struct { 00031 int num; 00032 unsigned char seq; 00033 /* use for reading */ 00034 AVPacket pkt; 00035 int frag_offset; 00036 int timestamp; 00037 int64_t duration; 00038 00039 int ds_span; /* descrambling */ 00040 int ds_packet_size; 00041 int ds_chunk_size; 00042 00043 int64_t packet_pos; 00044 00045 } ASFStream; 00046 00047 typedef uint8_t GUID[16]; 00048 00049 typedef struct { 00050 GUID guid; 00051 uint64_t file_size; 00053 uint64_t create_time; 00055 uint64_t play_time; 00057 uint64_t send_time; 00059 uint32_t preroll; 00061 uint32_t ignore; 00062 uint32_t flags; 00065 uint32_t min_pktsize; 00067 uint32_t max_pktsize; 00069 uint32_t max_bitrate; 00072 } ASFMainHeader; 00073 00074 00075 typedef struct { 00076 uint32_t packet_number; 00077 uint16_t packet_count; 00078 } ASFIndex; 00079 00080 00081 typedef struct { 00082 uint32_t seqno; 00083 int is_streamed; 00084 int asfid2avid[128]; 00085 ASFStream streams[128]; 00086 uint32_t stream_bitrates[128]; 00087 /* non streamed additonnal info */ 00088 uint64_t nb_packets; 00089 int64_t duration; 00090 /* packet filling */ 00091 unsigned char multi_payloads_present; 00092 int packet_size_left; 00093 int packet_timestamp_start; 00094 int packet_timestamp_end; 00095 unsigned int packet_nb_payloads; 00096 int packet_nb_frames; 00097 uint8_t packet_buf[PACKET_SIZE]; 00098 ByteIOContext pb; 00099 /* only for reading */ 00100 uint64_t data_offset; 00101 uint64_t data_object_offset; 00102 uint64_t data_object_size; 00103 int index_read; 00104 00105 ASFMainHeader hdr; 00106 00107 int packet_flags; 00108 int packet_property; 00109 int packet_timestamp; 00110 int packet_segsizetype; 00111 int packet_segments; 00112 int packet_seq; 00113 int packet_replic_size; 00114 int packet_key_frame; 00115 int packet_padsize; 00116 unsigned int packet_frag_offset; 00117 unsigned int packet_frag_size; 00118 int64_t packet_frag_timestamp; 00119 int packet_multi_size; 00120 int packet_obj_size; 00121 int packet_time_delta; 00122 int packet_time_start; 00123 int64_t packet_pos; 00124 00125 int stream_index; 00126 00127 00128 int64_t last_indexed_pts; 00129 ASFIndex* index_ptr; 00130 uint32_t nb_index_count; 00131 uint32_t nb_index_memory_alloc; 00132 uint16_t maximum_packet; 00133 00134 ASFStream* asf_st; 00135 } ASFContext; 00136 00137 extern const GUID ff_asf_header; 00138 extern const GUID ff_asf_file_header; 00139 extern const GUID ff_asf_stream_header; 00140 extern const GUID ff_asf_ext_stream_header; 00141 extern const GUID ff_asf_audio_stream; 00142 extern const GUID ff_asf_audio_conceal_none; 00143 extern const GUID ff_asf_audio_conceal_spread; 00144 extern const GUID ff_asf_video_stream; 00145 extern const GUID ff_asf_video_conceal_none; 00146 extern const GUID ff_asf_command_stream; 00147 extern const GUID ff_asf_comment_header; 00148 extern const GUID ff_asf_codec_comment_header; 00149 extern const GUID ff_asf_codec_comment1_header; 00150 extern const GUID ff_asf_data_header; 00151 extern const GUID ff_asf_head1_guid; 00152 extern const GUID ff_asf_head2_guid; 00153 extern const GUID ff_asf_extended_content_header; 00154 extern const GUID ff_asf_simple_index_header; 00155 extern const GUID ff_asf_ext_stream_embed_stream_header; 00156 extern const GUID ff_asf_ext_stream_audio_stream; 00157 extern const GUID ff_asf_metadata_header; 00158 extern const GUID ff_asf_my_guid; 00159 00160 extern const AVMetadataConv ff_asf_metadata_conv[]; 00161 00162 #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 0000 00163 00164 00165 // ASF data packet structure 00166 // ========================= 00167 // 00168 // 00169 // ----------------------------------- 00170 // | Error Correction Data | Optional 00171 // ----------------------------------- 00172 // | Payload Parsing Information (PPI) | 00173 // ----------------------------------- 00174 // | Payload Data | 00175 // ----------------------------------- 00176 // | Padding Data | 00177 // ----------------------------------- 00178 00179 00180 // PPI_FLAG - Payload parsing information flags 00181 #define ASF_PPI_FLAG_MULTIPLE_PAYLOADS_PRESENT 1 00182 00183 #define ASF_PPI_FLAG_SEQUENCE_FIELD_IS_BYTE 0x02 //0000 0010 00184 #define ASF_PPI_FLAG_SEQUENCE_FIELD_IS_WORD 0x04 //0000 0100 00185 #define ASF_PPI_FLAG_SEQUENCE_FIELD_IS_DWORD 0x06 //0000 0110 00186 #define ASF_PPI_MASK_SEQUENCE_FIELD_SIZE 0x06 //0000 0110 00187 00188 #define ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_BYTE 0x08 //0000 1000 00189 #define ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_WORD 0x10 //0001 0000 00190 #define ASF_PPI_FLAG_PADDING_LENGTH_FIELD_IS_DWORD 0x18 //0001 1000 00191 #define ASF_PPI_MASK_PADDING_LENGTH_FIELD_SIZE 0x18 //0001 1000 00192 00193 #define ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_BYTE 0x20 //0010 0000 00194 #define ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_WORD 0x40 //0100 0000 00195 #define ASF_PPI_FLAG_PACKET_LENGTH_FIELD_IS_DWORD 0x60 //0110 0000 00196 #define ASF_PPI_MASK_PACKET_LENGTH_FIELD_SIZE 0x60 //0110 0000 00197 00198 // PL_FLAG - Payload flags 00199 #define ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_BYTE 0x01 //0000 0001 00200 #define ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_WORD 0x02 //0000 0010 00201 #define ASF_PL_FLAG_REPLICATED_DATA_LENGTH_FIELD_IS_DWORD 0x03 //0000 0011 00202 #define ASF_PL_MASK_REPLICATED_DATA_LENGTH_FIELD_SIZE 0x03 //0000 0011 00203 00204 #define ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_BYTE 0x04 //0000 0100 00205 #define ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_WORD 0x08 //0000 1000 00206 #define ASF_PL_FLAG_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_IS_DWORD 0x0c //0000 1100 00207 #define ASF_PL_MASK_OFFSET_INTO_MEDIA_OBJECT_LENGTH_FIELD_SIZE 0x0c //0000 1100 00208 00209 #define ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_BYTE 0x10 //0001 0000 00210 #define ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_WORD 0x20 //0010 0000 00211 #define ASF_PL_FLAG_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_IS_DWORD 0x30 //0011 0000 00212 #define ASF_PL_MASK_MEDIA_OBJECT_NUMBER_LENGTH_FIELD_SIZE 0x30 //0011 0000 00213 00214 #define ASF_PL_FLAG_STREAM_NUMBER_LENGTH_FIELD_IS_BYTE 0x40 //0100 0000 00215 #define ASF_PL_MASK_STREAM_NUMBER_LENGTH_FIELD_SIZE 0xc0 //1100 0000 00216 00217 #define ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_BYTE 0x40 //0100 0000 00218 #define ASF_PL_FLAG_PAYLOAD_LENGTH_FIELD_IS_WORD 0x80 //1000 0000 00219 #define ASF_PL_MASK_PAYLOAD_LENGTH_FIELD_SIZE 0xc0 //1100 0000 00220 00221 #define ASF_PL_FLAG_KEY_FRAME 0x80 //1000 0000 00222 00223 extern AVInputFormat asf_demuxer; 00224 00231 int ff_asf_get_packet(AVFormatContext *s, ByteIOContext *pb); 00232 00242 int ff_asf_parse_packet(AVFormatContext *s, ByteIOContext *pb, AVPacket *pkt); 00243 00244 #endif /* AVFORMAT_ASF_H */