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 ((51<<16)+(19<<8)+0)
00025 #define LIBAVFORMAT_VERSION 51.19.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 #if LIBAVFORMAT_VERSION_INT < (52<<16)
00140 const char *device;
00141 #endif
00142 const char *standard;
00143 int mpeg2ts_raw:1;
00144 int mpeg2ts_compute_pcr:1;
00147 int initial_pause:1;
00149 int prealloced_context:1;
00150 enum CodecID video_codec_id;
00151 enum CodecID audio_codec_id;
00152 } AVFormatParameters;
00153
00155 #define AVFMT_NOFILE 0x0001
00156 #define AVFMT_NEEDNUMBER 0x0002
00157 #define AVFMT_SHOW_IDS 0x0008
00158 #define AVFMT_RAWPICTURE 0x0020
00160 #define AVFMT_GLOBALHEADER 0x0040
00161 #define AVFMT_NOTIMESTAMPS 0x0080
00162 #define AVFMT_GENERIC_INDEX 0x0100
00164 typedef struct AVOutputFormat {
00165 const char *name;
00166 const char *long_name;
00167 const char *mime_type;
00168 const char *extensions;
00170 int priv_data_size;
00171
00172 enum CodecID audio_codec;
00173 enum CodecID video_codec;
00174 int (*write_header)(struct AVFormatContext *);
00175 int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
00176 int (*write_trailer)(struct AVFormatContext *);
00178 int flags;
00180 int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
00181 int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
00182
00187 const struct AVCodecTag **codec_tag;
00188
00189 enum CodecID subtitle_codec;
00191
00192 struct AVOutputFormat *next;
00193 } AVOutputFormat;
00194
00195 typedef struct AVInputFormat {
00196 const char *name;
00197 const char *long_name;
00199 int priv_data_size;
00205 int (*read_probe)(AVProbeData *);
00210 int (*read_header)(struct AVFormatContext *,
00211 AVFormatParameters *ap);
00215 int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
00218 int (*read_close)(struct AVFormatContext *);
00227 int (*read_seek)(struct AVFormatContext *,
00228 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
00273 typedef struct AVStream {
00274 int index;
00275 int id;
00276 AVCodecContext *codec;
00285 AVRational r_frame_rate;
00286 void *priv_data;
00287
00288
00289 int64_t first_dts;
00290 #if LIBAVFORMAT_VERSION_INT < (52<<16)
00291 int codec_info_nb_frames;
00292 #endif
00293
00294 struct AVFrac pts;
00295
00302 AVRational time_base;
00303 int pts_wrap_bits;
00304
00305 int stream_copy;
00306 enum AVDiscard discard;
00307
00310 float quality;
00319 int64_t start_time;
00325 int64_t duration;
00326
00327 char language[4];
00329
00330 enum AVStreamParseType need_parsing;
00331 struct AVCodecParserContext *parser;
00332
00333 int64_t cur_dts;
00334 int last_IP_duration;
00335 int64_t last_IP_pts;
00336
00337 AVIndexEntry *index_entries;
00339 int nb_index_entries;
00340 unsigned int index_entries_allocated_size;
00341
00342 int64_t nb_frames;
00343
00344 #define MAX_REORDER_DELAY 4
00345 int64_t pts_buffer[MAX_REORDER_DELAY+1];
00346
00347 int got_frame;
00348 int64_t cur_frame_startpos;
00349
00350 int component_tag;
00351 } AVStream;
00352
00353 #define AV_PROGRAM_RUNNING 1
00354
00355 typedef struct AVProgram {
00356 int id;
00357 char *provider_name;
00358 char *name;
00359 int flags;
00360 enum AVDiscard discard;
00361 unsigned int *stream_index;
00362 unsigned int nb_stream_indexes;
00363 } AVProgram;
00364
00365 #define AVFMTCTX_NOHEADER 0x0001
00368 #define MAX_STREAMS 40
00369
00370
00371 typedef struct AVFormatContext {
00372 const AVClass *av_class;
00373
00374 struct AVInputFormat *iformat;
00375 struct AVOutputFormat *oformat;
00376 void *priv_data;
00377 ByteIOContext pb;
00378 unsigned int nb_streams;
00379 AVStream *streams[MAX_STREAMS];
00380 char filename[1024];
00381
00382 int64_t timestamp;
00383 char title[512];
00384 char author[512];
00385 char copyright[512];
00386 char comment[512];
00387 char album[512];
00388 int year;
00389 int track;
00390 char genre[32];
00392 int ctx_flags;
00393
00397 struct AVPacketList *packet_buffer;
00398
00402 int64_t start_time;
00406 int64_t duration;
00408 int64_t file_size;
00412 int bit_rate;
00413
00414
00415 AVStream *cur_st;
00416 const uint8_t *cur_ptr;
00417 int cur_len;
00418 AVPacket cur_pkt;
00419
00420
00421 int64_t data_offset;
00422 int index_built;
00423
00424 int mux_rate;
00425 int packet_size;
00426 int preload;
00427 int max_delay;
00428
00429 int build_index;
00430
00431
00432 void (*streams_changed)(void*);
00433 void *stream_change_data;
00434 const uint8_t *cur_pmt_sect;
00435 int cur_pmt_sect_len;
00436
00437 #define AVFMT_NOOUTPUTLOOP -1
00438 #define AVFMT_INFINITEOUTPUTLOOP 0
00439
00440 int loop_output;
00441
00442 int flags;
00443 #define AVFMT_FLAG_GENPTS 0x0001
00444 #define AVFMT_FLAG_IGNIDX 0x0002
00445 #define AVFMT_FLAG_NONBLOCK 0x0004
00446
00447 int loop_input;
00449 unsigned int probesize;
00450
00454 int max_analyze_duration;
00455
00456 const uint8_t *key;
00457 int keylen;
00458
00459 unsigned int nb_programs;
00460 AVProgram **programs;
00461 } AVFormatContext;
00462
00463 typedef struct AVPacketList {
00464 AVPacket pkt;
00465 struct AVPacketList *next;
00466 } AVPacketList;
00467
00468 extern AVInputFormat *first_iformat;
00469 extern AVOutputFormat *first_oformat;
00470
00471 enum CodecID av_guess_image2_codec(const char *filename);
00472
00473
00474
00475
00476
00477 void av_register_input_format(AVInputFormat *format);
00478 void av_register_output_format(AVOutputFormat *format);
00479 AVOutputFormat *guess_stream_format(const char *short_name,
00480 const char *filename, const char *mime_type);
00481 AVOutputFormat *guess_format(const char *short_name,
00482 const char *filename, const char *mime_type);
00483
00487 enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
00488 const char *filename, const char *mime_type, enum CodecType type);
00489
00499 void av_hex_dump(FILE *f, uint8_t *buf, int size);
00500
00513 void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
00514
00522 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
00523
00534 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
00535
00536 void av_register_all(void);
00537
00539 enum CodecID av_codec_get_id(const struct AVCodecTag **tags, unsigned int tag);
00540 unsigned int av_codec_get_tag(const struct AVCodecTag **tags, enum CodecID id);
00541
00542
00543
00547 AVInputFormat *av_find_input_format(const char *short_name);
00548
00555 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
00556
00561 int av_open_input_stream(AVFormatContext **ic_ptr,
00562 ByteIOContext *pb, const char *filename,
00563 AVInputFormat *fmt, AVFormatParameters *ap);
00564
00576 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
00577 AVInputFormat *fmt,
00578 int buf_size,
00579 AVFormatParameters *ap);
00581 AVFormatContext *av_alloc_format_context(void);
00582
00595 int av_find_stream_info(AVFormatContext *ic);
00596
00607 int av_read_packet(AVFormatContext *s, AVPacket *pkt);
00608
00628 int av_read_frame(AVFormatContext *s, AVPacket *pkt);
00629
00641 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags);
00642
00647 int av_read_play(AVFormatContext *s);
00648
00654 int av_read_pause(AVFormatContext *s);
00655
00661 void av_close_input_file(AVFormatContext *s);
00662
00673 AVStream *av_new_stream(AVFormatContext *s, int id);
00674 AVProgram *av_new_program(AVFormatContext *s, int id);
00675
00685 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
00686 int pts_num, int pts_den);
00687
00688 void av_estimate_timings(AVFormatContext *ic, offset_t old_offset);
00689 void av_read_frame_flush(AVFormatContext *s);
00690 AVStream *av_add_stream(AVFormatContext *s, AVStream *st, int id);
00691 void av_remove_stream(AVFormatContext *s, int id, int remove_ts);
00692
00693 #define AVSEEK_FLAG_BACKWARD 1
00694 #define AVSEEK_FLAG_BYTE 2
00695 #define AVSEEK_FLAG_ANY 4
00696
00697 int av_find_default_stream_index(AVFormatContext *s);
00698
00707 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
00708
00714 int av_add_index_entry(AVStream *st,
00715 int64_t pos, int64_t timestamp, int size, int distance, int flags);
00716
00723 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags);
00724
00733 void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
00734
00741 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 ));
00742
00744 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
00745
00753 int av_write_header(AVFormatContext *s);
00754
00766 int av_write_frame(AVFormatContext *s, AVPacket *pkt);
00767
00782 int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
00783
00798 int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush);
00799
00807 int av_write_trailer(AVFormatContext *s);
00808
00809 void dump_format(AVFormatContext *ic,
00810 int index,
00811 const char *url,
00812 int is_output);
00813
00818 attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
00819
00824 attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
00825
00852 int64_t parse_date(const char *datestr, int duration);
00853
00854 int64_t av_gettime(void);
00855
00856
00857 #define FFM_PACKET_SIZE 4096
00858 offset_t ffm_read_write_index(int fd);
00859 void ffm_write_write_index(int fd, offset_t pos);
00860 void ffm_set_write_index(AVFormatContext *s, offset_t pos, offset_t file_size);
00861
00868 int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
00869
00882 int av_get_frame_filename(char *buf, int buf_size,
00883 const char *path, int number);
00884
00891 int av_filename_number_test(const char *filename);
00892
00907 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
00908
00909 #ifdef HAVE_AV_CONFIG_H
00910
00911 #include "os_support.h"
00912
00913 void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
00914
00915 #ifdef __GNUC__
00916 #define dynarray_add(tab, nb_ptr, elem)\
00917 do {\
00918 typeof(tab) _tab = (tab);\
00919 typeof(elem) _elem = (elem);\
00920 (void)sizeof(**_tab == _elem); \
00921 __dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
00922 } while(0)
00923 #else
00924 #define dynarray_add(tab, nb_ptr, elem)\
00925 do {\
00926 __dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
00927 } while(0)
00928 #endif
00929
00930 time_t mktimegm(struct tm *tm);
00931 struct tm *brktimegm(time_t secs, struct tm *tm);
00932 const char *small_strptime(const char *p, const char *fmt,
00933 struct tm *dt);
00934
00935 struct in_addr;
00936 int resolve_host(struct in_addr *sin_addr, const char *hostname);
00937
00938 void url_split(char *proto, int proto_size,
00939 char *authorization, int authorization_size,
00940 char *hostname, int hostname_size,
00941 int *port_ptr,
00942 char *path, int path_size,
00943 const char *url);
00944
00945 int match_ext(const char *filename, const char *extensions);
00946
00947 #endif
00948
00949 #endif