00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVFORMAT_AVFORMAT_H
00022 #define AVFORMAT_AVFORMAT_H
00023
00024
00029 unsigned avformat_version(void);
00030
00034 const char *avformat_configuration(void);
00035
00039 const char *avformat_license(void);
00040
00041 #include <time.h>
00042 #include <stdio.h>
00043 #include "libavcodec/avcodec.h"
00044
00045 #include "avio.h"
00046 #include "libavformat/version.h"
00047
00048 struct AVFormatContext;
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 #define AV_METADATA_MATCH_CASE 1
00110 #define AV_METADATA_IGNORE_SUFFIX 2
00111 #define AV_METADATA_DONT_STRDUP_KEY 4
00112 #define AV_METADATA_DONT_STRDUP_VAL 8
00113 #define AV_METADATA_DONT_OVERWRITE 16
00114
00115 typedef struct {
00116 char *key;
00117 char *value;
00118 }AVMetadataTag;
00119
00120 typedef struct AVMetadata AVMetadata;
00121 #if FF_API_OLD_METADATA
00122 typedef struct AVMetadataConv AVMetadataConv;
00123 #endif
00124
00133 AVMetadataTag *
00134 av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags);
00135
00136 #if FF_API_OLD_METADATA
00137
00147 attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
00148 #endif
00149
00160 int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
00161
00162 #if FF_API_OLD_METADATA
00163
00166 attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
00167 const AVMetadataConv *s_conv);
00168 #endif
00169
00178 void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags);
00179
00183 void av_metadata_free(AVMetadata **m);
00184
00185
00186
00187
00188
00197 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
00198
00199
00213 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
00214
00215
00216
00217
00222 typedef struct AVFrac {
00223 int64_t val, num, den;
00224 } AVFrac;
00225
00226
00227
00228
00229 struct AVCodecTag;
00230
00234 typedef struct AVProbeData {
00235 const char *filename;
00236 unsigned char *buf;
00237 int buf_size;
00238 } AVProbeData;
00239
00240 #define AVPROBE_SCORE_MAX 100
00241 #define AVPROBE_PADDING_SIZE 32
00242
00243 typedef struct AVFormatParameters {
00244 AVRational time_base;
00245 int sample_rate;
00246 int channels;
00247 int width;
00248 int height;
00249 enum PixelFormat pix_fmt;
00250 int channel;
00251 const char *standard;
00252 unsigned int mpeg2ts_raw:1;
00253 unsigned int mpeg2ts_compute_pcr:1;
00256 unsigned int initial_pause:1;
00258 unsigned int prealloced_context:1;
00259 #if FF_API_PARAMETERS_CODEC_ID
00260 attribute_deprecated enum CodecID video_codec_id;
00261 attribute_deprecated enum CodecID audio_codec_id;
00262 #endif
00263 } AVFormatParameters;
00264
00266 #define AVFMT_NOFILE 0x0001
00267 #define AVFMT_NEEDNUMBER 0x0002
00268 #define AVFMT_SHOW_IDS 0x0008
00269 #define AVFMT_RAWPICTURE 0x0020
00271 #define AVFMT_GLOBALHEADER 0x0040
00272 #define AVFMT_NOTIMESTAMPS 0x0080
00273 #define AVFMT_GENERIC_INDEX 0x0100
00274 #define AVFMT_TS_DISCONT 0x0200
00275 #define AVFMT_VARIABLE_FPS 0x0400
00276 #define AVFMT_NODIMENSIONS 0x0800
00277 #define AVFMT_NOSTREAMS 0x1000
00279 typedef struct AVOutputFormat {
00280 const char *name;
00286 const char *long_name;
00287 const char *mime_type;
00288 const char *extensions;
00292 int priv_data_size;
00293
00294 enum CodecID audio_codec;
00295 enum CodecID video_codec;
00296 int (*write_header)(struct AVFormatContext *);
00297 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
00298 int (*write_trailer)(struct AVFormatContext *);
00304 int flags;
00308 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
00309 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out,
00310 AVPacket *in, int flush);
00311
00316 const struct AVCodecTag * const *codec_tag;
00317
00318 enum CodecID subtitle_codec;
00320 #if FF_API_OLD_METADATA
00321 const AVMetadataConv *metadata_conv;
00322 #endif
00323
00324 const AVClass *priv_class;
00325
00326
00327 struct AVOutputFormat *next;
00328 } AVOutputFormat;
00329
00330 typedef struct AVInputFormat {
00335 const char *name;
00336
00342 const char *long_name;
00343
00347 int priv_data_size;
00348
00354 int (*read_probe)(AVProbeData *);
00355
00362 int (*read_header)(struct AVFormatContext *,
00363 AVFormatParameters *ap);
00364
00374 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
00375
00380 int (*read_close)(struct AVFormatContext *);
00381
00382 #if FF_API_READ_SEEK
00383
00391 attribute_deprecated int (*read_seek)(struct AVFormatContext *,
00392 int stream_index, int64_t timestamp, int flags);
00393 #endif
00394
00398 int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
00399 int64_t *pos, int64_t pos_limit);
00400
00404 int flags;
00405
00411 const char *extensions;
00412
00416 int value;
00417
00422 int (*read_play)(struct AVFormatContext *);
00423
00428 int (*read_pause)(struct AVFormatContext *);
00429
00430 const struct AVCodecTag * const *codec_tag;
00431
00438 int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
00439
00440 #if FF_API_OLD_METADATA
00441 const AVMetadataConv *metadata_conv;
00442 #endif
00443
00444
00445 struct AVInputFormat *next;
00446 } AVInputFormat;
00447
00448 enum AVStreamParseType {
00449 AVSTREAM_PARSE_NONE,
00450 AVSTREAM_PARSE_FULL,
00451 AVSTREAM_PARSE_HEADERS,
00452 AVSTREAM_PARSE_TIMESTAMPS,
00453 AVSTREAM_PARSE_FULL_ONCE,
00454 };
00455
00456 typedef struct AVIndexEntry {
00457 int64_t pos;
00458 int64_t timestamp;
00459 #define AVINDEX_KEYFRAME 0x0001
00460 int flags:2;
00461 int size:30;
00462 int min_distance;
00463 } AVIndexEntry;
00464
00465 #define AV_DISPOSITION_DEFAULT 0x0001
00466 #define AV_DISPOSITION_DUB 0x0002
00467 #define AV_DISPOSITION_ORIGINAL 0x0004
00468 #define AV_DISPOSITION_COMMENT 0x0008
00469 #define AV_DISPOSITION_LYRICS 0x0010
00470 #define AV_DISPOSITION_KARAOKE 0x0020
00471
00477 #define AV_DISPOSITION_FORCED 0x0040
00478 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080
00479 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100
00480 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200
00489 typedef struct AVStream {
00490 int index;
00491 int id;
00492 AVCodecContext *codec;
00501 AVRational r_frame_rate;
00502 void *priv_data;
00503
00504
00505 int64_t first_dts;
00506
00510 struct AVFrac pts;
00511
00519 AVRational time_base;
00520 int pts_wrap_bits;
00521
00522 int stream_copy;
00523 enum AVDiscard discard;
00524
00525
00530 float quality;
00531
00540 int64_t start_time;
00541
00547 int64_t duration;
00548
00549 #if FF_API_OLD_METADATA
00550 attribute_deprecated char language[4];
00551 #endif
00552
00553
00554 enum AVStreamParseType need_parsing;
00555 struct AVCodecParserContext *parser;
00556
00557 int64_t cur_dts;
00558 int last_IP_duration;
00559 int64_t last_IP_pts;
00560
00561 AVIndexEntry *index_entries;
00563 int nb_index_entries;
00564 unsigned int index_entries_allocated_size;
00565
00566 int64_t nb_frames;
00567
00568 #if FF_API_LAVF_UNUSED
00569 attribute_deprecated int64_t unused[4+1];
00570 #endif
00571
00572 #if FF_API_OLD_METADATA
00573 attribute_deprecated char *filename;
00574 #endif
00575
00576 int disposition;
00578 AVProbeData probe_data;
00579 #define MAX_REORDER_DELAY 16
00580 int64_t pts_buffer[MAX_REORDER_DELAY+1];
00581
00587 AVRational sample_aspect_ratio;
00588
00589 AVMetadata *metadata;
00590
00591
00592
00593 const uint8_t *cur_ptr;
00594 int cur_len;
00595 AVPacket cur_pkt;
00596
00597
00605 int64_t reference_dts;
00606
00611 #define MAX_PROBE_PACKETS 2500
00612 int probe_packets;
00613
00618 struct AVPacketList *last_in_packet_buffer;
00619
00623 AVRational avg_frame_rate;
00624
00628 int codec_info_nb_frames;
00629
00633 #define MAX_STD_TIMEBASES (60*12+5)
00634 struct {
00635 int64_t last_dts;
00636 int64_t duration_gcd;
00637 int duration_count;
00638 double duration_error[MAX_STD_TIMEBASES];
00639 int64_t codec_info_duration;
00640 } *info;
00641 } AVStream;
00642
00643 #define AV_PROGRAM_RUNNING 1
00644
00651 typedef struct AVProgram {
00652 int id;
00653 #if FF_API_OLD_METADATA
00654 attribute_deprecated char *provider_name;
00655 attribute_deprecated char *name;
00656 #endif
00657 int flags;
00658 enum AVDiscard discard;
00659 unsigned int *stream_index;
00660 unsigned int nb_stream_indexes;
00661 AVMetadata *metadata;
00662 } AVProgram;
00663
00664 #define AVFMTCTX_NOHEADER 0x0001
00667 typedef struct AVChapter {
00668 int id;
00669 AVRational time_base;
00670 int64_t start, end;
00671 #if FF_API_OLD_METADATA
00672 attribute_deprecated char *title;
00673 #endif
00674 AVMetadata *metadata;
00675 } AVChapter;
00676
00677 #if FF_API_MAX_STREAMS
00678 #define MAX_STREAMS 20
00679 #endif
00680
00688 typedef struct AVFormatContext {
00689 const AVClass *av_class;
00690
00691 struct AVInputFormat *iformat;
00692 struct AVOutputFormat *oformat;
00693 void *priv_data;
00694 AVIOContext *pb;
00695 unsigned int nb_streams;
00696 #if FF_API_MAX_STREAMS
00697 AVStream *streams[MAX_STREAMS];
00698 #else
00699 AVStream **streams;
00700 #endif
00701 char filename[1024];
00702
00703 int64_t timestamp;
00704 #if FF_API_OLD_METADATA
00705 attribute_deprecated char title[512];
00706 attribute_deprecated char author[512];
00707 attribute_deprecated char copyright[512];
00708 attribute_deprecated char comment[512];
00709 attribute_deprecated char album[512];
00710 attribute_deprecated int year;
00711 attribute_deprecated int track;
00712 attribute_deprecated char genre[32];
00713 #endif
00714
00715 int ctx_flags;
00716
00722 struct AVPacketList *packet_buffer;
00723
00729 int64_t start_time;
00730
00737 int64_t duration;
00738
00742 int64_t file_size;
00743
00749 int bit_rate;
00750
00751
00752 AVStream *cur_st;
00753 #if FF_API_LAVF_UNUSED
00754 const uint8_t *cur_ptr_deprecated;
00755 int cur_len_deprecated;
00756 AVPacket cur_pkt_deprecated;
00757 #endif
00758
00759
00760 int64_t data_offset;
00761 #if FF_API_INDEX_BUILT
00762 attribute_deprecated int index_built;
00763 #endif
00764
00765 int mux_rate;
00766 unsigned int packet_size;
00767 int preload;
00768 int max_delay;
00769
00770 #define AVFMT_NOOUTPUTLOOP -1
00771 #define AVFMT_INFINITEOUTPUTLOOP 0
00772
00775 int loop_output;
00776
00777 int flags;
00778 #define AVFMT_FLAG_GENPTS 0x0001
00779 #define AVFMT_FLAG_IGNIDX 0x0002
00780 #define AVFMT_FLAG_NONBLOCK 0x0004
00781 #define AVFMT_FLAG_IGNDTS 0x0008
00782 #define AVFMT_FLAG_NOFILLIN 0x0010
00783 #define AVFMT_FLAG_NOPARSE 0x0020
00784 #define AVFMT_FLAG_RTP_HINT 0x0040
00785
00786 int loop_input;
00787
00791 unsigned int probesize;
00792
00797 int max_analyze_duration;
00798
00799 const uint8_t *key;
00800 int keylen;
00801
00802 unsigned int nb_programs;
00803 AVProgram **programs;
00804
00809 enum CodecID video_codec_id;
00810
00815 enum CodecID audio_codec_id;
00816
00821 enum CodecID subtitle_codec_id;
00822
00833 unsigned int max_index_size;
00834
00839 unsigned int max_picture_buffer;
00840
00841 unsigned int nb_chapters;
00842 AVChapter **chapters;
00843
00847 int debug;
00848 #define FF_FDEBUG_TS 0x0001
00849
00856 struct AVPacketList *raw_packet_buffer;
00857 struct AVPacketList *raw_packet_buffer_end;
00858
00859 struct AVPacketList *packet_buffer_end;
00860
00861 AVMetadata *metadata;
00862
00867 #define RAW_PACKET_BUFFER_SIZE 2500000
00868 int raw_packet_buffer_remaining_size;
00869
00877 int64_t start_time_realtime;
00878 } AVFormatContext;
00879
00880 typedef struct AVPacketList {
00881 AVPacket pkt;
00882 struct AVPacketList *next;
00883 } AVPacketList;
00884
00885 #if FF_API_FIRST_FORMAT
00886 attribute_deprecated extern AVInputFormat *first_iformat;
00887 attribute_deprecated extern AVOutputFormat *first_oformat;
00888 #endif
00889
00895 AVInputFormat *av_iformat_next(AVInputFormat *f);
00896
00902 AVOutputFormat *av_oformat_next(AVOutputFormat *f);
00903
00904 enum CodecID av_guess_image2_codec(const char *filename);
00905
00906
00907
00908
00909
00910 void av_register_input_format(AVInputFormat *format);
00911 void av_register_output_format(AVOutputFormat *format);
00912 #if FF_API_GUESS_FORMAT
00913 attribute_deprecated AVOutputFormat *guess_stream_format(const char *short_name,
00914 const char *filename,
00915 const char *mime_type);
00916
00920 attribute_deprecated AVOutputFormat *guess_format(const char *short_name,
00921 const char *filename,
00922 const char *mime_type);
00923 #endif
00924
00937 AVOutputFormat *av_guess_format(const char *short_name,
00938 const char *filename,
00939 const char *mime_type);
00940
00944 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
00945 const char *filename, const char *mime_type,
00946 enum AVMediaType type);
00947
00957 void av_hex_dump(FILE *f, uint8_t *buf, int size);
00958
00971 void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
00972
00981 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
00982
00983 attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
00984
00996 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
00997 AVStream *st);
00998
00999 attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt,
01000 int dump_payload);
01001
01011 void av_register_all(void);
01012
01020 enum CodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
01021
01029 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum CodecID id);
01030
01031
01032
01036 AVInputFormat *av_find_input_format(const char *short_name);
01037
01044 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
01045
01057 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
01058
01074 int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
01075 const char *filename, void *logctx,
01076 unsigned int offset, unsigned int max_probe_size);
01077
01082 int av_open_input_stream(AVFormatContext **ic_ptr,
01083 AVIOContext *pb, const char *filename,
01084 AVInputFormat *fmt, AVFormatParameters *ap);
01085
01098 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
01099 AVInputFormat *fmt,
01100 int buf_size,
01101 AVFormatParameters *ap);
01102
01103 #if FF_API_ALLOC_FORMAT_CONTEXT
01104
01107 attribute_deprecated AVFormatContext *av_alloc_format_context(void);
01108 #endif
01109
01115 AVFormatContext *avformat_alloc_context(void);
01116
01130 int av_find_stream_info(AVFormatContext *ic);
01131
01156 int av_find_best_stream(AVFormatContext *ic,
01157 enum AVMediaType type,
01158 int wanted_stream_nb,
01159 int related_stream,
01160 AVCodec **decoder_ret,
01161 int flags);
01162
01173 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
01174
01199 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
01200
01212 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
01213 int flags);
01214
01241 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
01242
01247 int av_read_play(AVFormatContext *s);
01248
01254 int av_read_pause(AVFormatContext *s);
01255
01260 void av_close_input_stream(AVFormatContext *s);
01261
01267 void av_close_input_file(AVFormatContext *s);
01268
01273 void avformat_free_context(AVFormatContext *s);
01274
01285 AVStream *av_new_stream(AVFormatContext *s, int id);
01286 AVProgram *av_new_program(AVFormatContext *s, int id);
01287
01298 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
01299 unsigned int pts_num, unsigned int pts_den);
01300
01301 #define AVSEEK_FLAG_BACKWARD 1
01302 #define AVSEEK_FLAG_BYTE 2
01303 #define AVSEEK_FLAG_ANY 4
01304 #define AVSEEK_FLAG_FRAME 8
01305
01306 int av_find_default_stream_index(AVFormatContext *s);
01307
01316 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
01317
01324 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
01325 int size, int distance, int flags);
01326
01335 int av_seek_frame_binary(AVFormatContext *s, int stream_index,
01336 int64_t target_ts, int flags);
01337
01346 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
01347
01355 int64_t av_gen_search(AVFormatContext *s, int stream_index,
01356 int64_t target_ts, int64_t pos_min,
01357 int64_t pos_max, int64_t pos_limit,
01358 int64_t ts_min, int64_t ts_max,
01359 int flags, int64_t *ts_ret,
01360 int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ));
01361
01365 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
01366
01386 void av_url_split(char *proto, int proto_size,
01387 char *authorization, int authorization_size,
01388 char *hostname, int hostname_size,
01389 int *port_ptr,
01390 char *path, int path_size,
01391 const char *url);
01392
01402 int av_write_header(AVFormatContext *s);
01403
01416 int av_write_frame(AVFormatContext *s, AVPacket *pkt);
01417
01433 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
01434
01450 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
01451 AVPacket *pkt, int flush);
01452
01462 int av_write_trailer(AVFormatContext *s);
01463
01464 #if FF_API_DUMP_FORMAT
01465 attribute_deprecated void dump_format(AVFormatContext *ic,
01466 int index,
01467 const char *url,
01468 int is_output);
01469 #endif
01470
01471 void av_dump_format(AVFormatContext *ic,
01472 int index,
01473 const char *url,
01474 int is_output);
01475
01476 #if FF_API_PARSE_FRAME_PARAM
01477
01481 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr,
01482 const char *str);
01483
01488 attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base,
01489 const char *arg);
01490 #endif
01491
01492 #if FF_API_PARSE_DATE
01493
01500 attribute_deprecated
01501 int64_t parse_date(const char *datestr, int duration);
01502 #endif
01503
01507 int64_t av_gettime(void);
01508
01509
01510 #define FFM_PACKET_SIZE 4096
01511 int64_t ffm_read_write_index(int fd);
01512 int ffm_write_write_index(int fd, int64_t pos);
01513 void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
01514
01515 #if FF_API_FIND_INFO_TAG
01516
01519 attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
01520 #endif
01521
01534 int av_get_frame_filename(char *buf, int buf_size,
01535 const char *path, int number);
01536
01543 int av_filename_number_test(const char *filename);
01544
01559 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
01560
01567 int av_match_ext(const char *filename, const char *extensions);
01568
01569 #endif