00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FFMPEG_AVFORMAT_H
00022 #define FFMPEG_AVFORMAT_H
00023
00024 #define LIBAVFORMAT_VERSION_INT ((52<<16)+(7<<8)+0)
00025 #define LIBAVFORMAT_VERSION 52.7.0
00026 #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
00027
00028 #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
00029
00030 #include <time.h>
00031 #include <stdio.h>
00032 #include "avcodec.h"
00033
00034 #include "avio.h"
00035
00036
00037
00038 typedef struct AVPacket {
00039 int64_t pts;
00040 int64_t dts;
00041 uint8_t *data;
00042 int size;
00043 int stream_index;
00044 int flags;
00045 int duration;
00046 void (*destruct)(struct AVPacket *);
00047 void *priv;
00048 int64_t pos;
00049 } AVPacket;
00050 #define PKT_FLAG_KEY 0x0001
00051
00052 void av_destruct_packet_nofree(AVPacket *pkt);
00053
00057 void av_destruct_packet(AVPacket *pkt);
00058
00064 void av_init_packet(AVPacket *pkt);
00065
00073 int av_new_packet(AVPacket *pkt, int size);
00074
00082 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
00083
00088 int av_dup_packet(AVPacket *pkt);
00089
00095 static inline void av_free_packet(AVPacket *pkt)
00096 {
00097 if (pkt && pkt->destruct) {
00098 pkt->destruct(pkt);
00099 }
00100 }
00101
00102
00103
00104
00110 typedef struct AVFrac {
00111 int64_t val, num, den;
00112 } AVFrac attribute_deprecated;
00113
00114
00115
00116
00117 struct AVCodecTag;
00118
00119 struct AVFormatContext;
00120
00122 typedef struct AVProbeData {
00123 const char *filename;
00124 unsigned char *buf;
00125 int buf_size;
00126 } AVProbeData;
00127
00128 #define AVPROBE_SCORE_MAX 100
00129 #define AVPROBE_PADDING_SIZE 32
00130
00131 typedef struct AVFormatParameters {
00132 AVRational time_base;
00133 int sample_rate;
00134 int channels;
00135 int width;
00136 int height;
00137 enum PixelFormat pix_fmt;
00138 int channel;
00139 const char *standard;
00140 int mpeg2ts_raw:1;
00141 int mpeg2ts_compute_pcr:1;
00144 int initial_pause:1;
00146 int prealloced_context:1;
00147 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00148 enum CodecID video_codec_id;
00149 enum CodecID audio_codec_id;
00150 #endif
00151 } AVFormatParameters;
00152
00154 #define AVFMT_NOFILE 0x0001
00155 #define AVFMT_NEEDNUMBER 0x0002
00156 #define AVFMT_SHOW_IDS 0x0008
00157 #define AVFMT_RAWPICTURE 0x0020
00159 #define AVFMT_GLOBALHEADER 0x0040
00160 #define AVFMT_NOTIMESTAMPS 0x0080
00161 #define AVFMT_GENERIC_INDEX 0x0100
00163 typedef struct AVOutputFormat {
00164 const char *name;
00165 const char *long_name;
00166 const char *mime_type;
00167 const char *extensions;
00169 int priv_data_size;
00170
00171 enum CodecID audio_codec;
00172 enum CodecID video_codec;
00173 int (*write_header)(struct AVFormatContext *);
00174 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
00175 int (*write_trailer)(struct AVFormatContext *);
00177 int flags;
00179 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
00180 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
00181
00186 const struct AVCodecTag **codec_tag;
00187
00188 enum CodecID subtitle_codec;
00190
00191 struct AVOutputFormat *next;
00192 } AVOutputFormat;
00193
00194 typedef struct AVInputFormat {
00195 const char *name;
00196 const char *long_name;
00198 int priv_data_size;
00204 int (*read_probe)(AVProbeData *);
00209 int (*read_header)(struct AVFormatContext *,
00210 AVFormatParameters *ap);
00214 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
00217 int (*read_close)(struct AVFormatContext *);
00226 int (*read_seek)(struct AVFormatContext *,
00227 int stream_index, int64_t timestamp, int flags);
00232 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
00233 int64_t *pos, int64_t pos_limit);
00235 int flags;
00239 const char *extensions;
00241 int value;
00242
00245 int (*read_play)(struct AVFormatContext *);
00246
00249 int (*read_pause)(struct AVFormatContext *);
00250
00251 const struct AVCodecTag **codec_tag;
00252
00253
00254 struct AVInputFormat *next;
00255 } AVInputFormat;
00256
00257 enum AVStreamParseType {
00258 AVSTREAM_PARSE_NONE,
00259 AVSTREAM_PARSE_FULL,
00260 AVSTREAM_PARSE_HEADERS,
00261 AVSTREAM_PARSE_TIMESTAMPS,
00262 };
00263
00264 typedef struct AVIndexEntry {
00265 int64_t pos;
00266 int64_t timestamp;
00267 #define AVINDEX_KEYFRAME 0x0001
00268 int flags:2;
00269 int size:30;
00270 int min_distance;
00271 } AVIndexEntry;
00272
00280 typedef struct AVStream {
00281 int index;
00282 int id;
00283 AVCodecContext *codec;
00292 AVRational r_frame_rate;
00293 void *priv_data;
00294
00295
00296 int64_t first_dts;
00298 struct AVFrac pts;
00299
00306 AVRational time_base;
00307 int pts_wrap_bits;
00308
00309 int stream_copy;
00310 enum AVDiscard discard;
00311
00314 float quality;
00323 int64_t start_time;
00329 int64_t duration;
00330
00331 char language[4];
00333
00334 enum AVStreamParseType need_parsing;
00335 struct AVCodecParserContext *parser;
00336
00337 int64_t cur_dts;
00338 int last_IP_duration;
00339 int64_t last_IP_pts;
00340
00341 AVIndexEntry *index_entries;
00343 int nb_index_entries;
00344 unsigned int index_entries_allocated_size;
00345
00346 int64_t nb_frames;
00347
00348 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00349 int64_t unused[4+1];
00350 #endif
00351
00352 char *filename;
00353 #define MAX_REORDER_DELAY 16
00354 int64_t pts_buffer[MAX_REORDER_DELAY+1];
00355 } AVStream;
00356
00357 #define AV_PROGRAM_RUNNING 1
00358
00365 typedef struct AVProgram {
00366 int id;
00367 char *provider_name;
00368 char *name;
00369 int flags;
00370 enum AVDiscard discard;
00371 unsigned int *stream_index;
00372 unsigned int nb_stream_indexes;
00373 } AVProgram;
00374
00375 #define AVFMTCTX_NOHEADER 0x0001
00378 #define MAX_STREAMS 20
00379
00387 typedef struct AVFormatContext {
00388 const AVClass *av_class;
00389
00390 struct AVInputFormat *iformat;
00391 struct AVOutputFormat *oformat;
00392 void *priv_data;
00393 ByteIOContext *pb;
00394 unsigned int nb_streams;
00395 AVStream *streams[MAX_STREAMS];
00396 char filename[1024];
00397
00398 int64_t timestamp;
00399 char title[512];
00400 char author[512];
00401 char copyright[512];
00402 char comment[512];
00403 char album[512];
00404 int year;
00405 int track;
00406 char genre[32];
00408 int ctx_flags;
00409
00413 struct AVPacketList *packet_buffer;
00414
00418 int64_t start_time;
00422 int64_t duration;
00424 int64_t file_size;
00428 int bit_rate;
00429
00430
00431 AVStream *cur_st;
00432 const uint8_t *cur_ptr;
00433 int cur_len;
00434 AVPacket cur_pkt;
00435
00436
00437 int64_t data_offset;
00438 int index_built;
00439
00440 int mux_rate;
00441 int packet_size;
00442 int preload;
00443 int max_delay;
00444
00445 #define AVFMT_NOOUTPUTLOOP -1
00446 #define AVFMT_INFINITEOUTPUTLOOP 0
00447
00448 int loop_output;
00449
00450 int flags;
00451 #define AVFMT_FLAG_GENPTS 0x0001
00452 #define AVFMT_FLAG_IGNIDX 0x0002
00453 #define AVFMT_FLAG_NONBLOCK 0x0004
00454
00455 int loop_input;
00457 unsigned int probesize;
00458
00462 int max_analyze_duration;
00463
00464 const uint8_t *key;
00465 int keylen;
00466
00467 unsigned int nb_programs;
00468 AVProgram **programs;
00469
00474 enum CodecID video_codec_id;
00479 enum CodecID audio_codec_id;
00484 enum CodecID subtitle_codec_id;
00485
00496 unsigned int max_index_size;
00497 } AVFormatContext;
00498
00499 typedef struct AVPacketList {
00500 AVPacket pkt;
00501 struct AVPacketList *next;
00502 } AVPacketList;
00503
00504 #if LIBAVFORMAT_VERSION_INT < (53<<16)
00505 extern AVInputFormat *first_iformat;
00506 extern AVOutputFormat *first_oformat;
00507 #endif
00508
00509 AVInputFormat *av_iformat_next(AVInputFormat *f);
00510 AVOutputFormat *av_oformat_next(AVOutputFormat *f);
00511
00512 enum CodecID av_guess_image2_codec(const char *filename);
00513
00514
00515
00516
00517
00518 void av_register_input_format(AVInputFormat *format);
00519 void av_register_output_format(AVOutputFormat *format);
00520 AVOutputFormat *guess_stream_format(const char *short_name,
00521 const char *filename, const char *mime_type);
00522 AVOutputFormat *guess_format(const char *short_name,
00523 const char *filename, const char *mime_type);
00524
00528 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
00529 const char *filename, const char *mime_type, enum CodecType type);
00530
00540 void av_hex_dump(FILE *f, uint8_t *buf, int size);
00541
00554 void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
00555
00563 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
00564
00575 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
00576
00577 void av_register_all(void);
00578
00580 enum CodecID av_codec_get_id(const struct AVCodecTag **tags, unsigned int tag);
00581 unsigned int av_codec_get_tag(const struct AVCodecTag **tags, enum CodecID id);
00582
00583
00584
00588 AVInputFormat *av_find_input_format(const char *short_name);
00589
00596 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
00597
00602 int av_open_input_stream(AVFormatContext **ic_ptr,
00603 ByteIOContext *pb, const char *filename,
00604 AVInputFormat *fmt, AVFormatParameters *ap);
00605
00617 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
00618 AVInputFormat *fmt,
00619 int buf_size,
00620 AVFormatParameters *ap);
00626 AVFormatContext *av_alloc_format_context(void);
00627
00640 int av_find_stream_info(AVFormatContext *ic);
00641
00652 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
00653
00673 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
00674
00686 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
00687
00692 int av_read_play(AVFormatContext *s);
00693
00699 int av_read_pause(AVFormatContext *s);
00700
00705 void av_close_input_stream(AVFormatContext *s);
00706
00712 void av_close_input_file(AVFormatContext *s);
00713
00724 AVStream *av_new_stream(AVFormatContext *s, int id);
00725 AVProgram *av_new_program(AVFormatContext *s, int id);
00726
00736 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
00737 int pts_num, int pts_den);
00738
00739 #define AVSEEK_FLAG_BACKWARD 1
00740 #define AVSEEK_FLAG_BYTE 2
00741 #define AVSEEK_FLAG_ANY 4
00742
00743 int av_find_default_stream_index(AVFormatContext *s);
00744
00753 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
00754
00762 void ff_reduce_index(AVFormatContext *s, int stream_index);
00763
00769 int av_add_index_entry(AVStream *st,
00770 int64_t pos, int64_t timestamp, int size, int distance, int flags);
00771
00778 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
00779
00788 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
00789
00796 int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
00797
00799 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
00800
00808 int av_write_header(AVFormatContext *s);
00809
00821 int av_write_frame(AVFormatContext *s, AVPacket *pkt);
00822
00837 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
00838
00853 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush);
00854
00862 int av_write_trailer(AVFormatContext *s);
00863
00864 void dump_format(AVFormatContext *ic,
00865 int index,
00866 const char *url,
00867 int is_output);
00868
00873 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
00874
00879 attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
00880
00907 int64_t parse_date(const char *datestr, int duration);
00908
00909 int64_t av_gettime(void);
00910
00911
00912 #define FFM_PACKET_SIZE 4096
00913 offset_t ffm_read_write_index(int fd);
00914 void ffm_write_write_index(int fd, offset_t pos);
00915 void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
00916
00923 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
00924
00937 int av_get_frame_filename(char *buf, int buf_size,
00938 const char *path, int number);
00939
00946 int av_filename_number_test(const char *filename);
00947
00962 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
00963
00964 #ifdef HAVE_AV_CONFIG_H
00965
00966 void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
00967
00968 #ifdef __GNUC__
00969 #define dynarray_add(tab, nb_ptr, elem)\
00970 do {\
00971 typeof(tab) _tab = (tab);\
00972 typeof(elem) _elem = (elem);\
00973 (void)sizeof(**_tab == _elem); \
00974 __dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
00975 } while(0)
00976 #else
00977 #define dynarray_add(tab, nb_ptr, elem)\
00978 do {\
00979 __dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
00980 } while(0)
00981 #endif
00982
00983 time_t mktimegm(struct tm *tm);
00984 struct tm *brktimegm(time_t secs, struct tm *tm);
00985 const char *small_strptime(const char *p, const char *fmt,
00986 struct tm *dt);
00987
00988 struct in_addr;
00989 int resolve_host(struct in_addr *sin_addr, const char *hostname);
00990
00991 void url_split(char *proto, int proto_size,
00992 char *authorization, int authorization_size,
00993 char *hostname, int hostname_size,
00994 int *port_ptr,
00995 char *path, int path_size,
00996 const char *url);
00997
00998 int match_ext(const char *filename, const char *extensions);
00999
01000 #endif
01001
01002 #endif