Libav
avformat.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVFORMAT_AVFORMAT_H
22 #define AVFORMAT_AVFORMAT_H
23 
253 #include <time.h>
254 #include <stdio.h> /* FILE */
255 #include "libavcodec/avcodec.h"
256 #include "libavutil/dict.h"
257 #include "libavutil/log.h"
258 
259 #include "avio.h"
260 #include "libavformat/version.h"
261 
262 struct AVFormatContext;
263 
264 
338 /* packet functions */
339 
340 
350 int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
351 
352 
367 int av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
368 
369 /*************************************************/
370 /* fractional numbers for exact pts handling */
371 
376 typedef struct AVFrac {
377  int64_t val, num, den;
378 } AVFrac;
379 
380 /*************************************************/
381 /* input/output formats */
382 
383 struct AVCodecTag;
384 
388 typedef struct AVProbeData {
389  const char *filename;
390  unsigned char *buf;
391  int buf_size;
392 } AVProbeData;
393 
394 #define AVPROBE_SCORE_EXTENSION 50
395 #define AVPROBE_SCORE_MAX 100
396 
397 #define AVPROBE_PADDING_SIZE 32
398 
399 
400 #define AVFMT_NOFILE 0x0001
401 #define AVFMT_NEEDNUMBER 0x0002
402 #define AVFMT_SHOW_IDS 0x0008
403 #define AVFMT_RAWPICTURE 0x0020
405 #define AVFMT_GLOBALHEADER 0x0040
406 #define AVFMT_NOTIMESTAMPS 0x0080
407 #define AVFMT_GENERIC_INDEX 0x0100
408 #define AVFMT_TS_DISCONT 0x0200
409 #define AVFMT_VARIABLE_FPS 0x0400
410 #define AVFMT_NODIMENSIONS 0x0800
411 #define AVFMT_NOSTREAMS 0x1000
412 #define AVFMT_NOBINSEARCH 0x2000
413 #define AVFMT_NOGENSEARCH 0x4000
414 #define AVFMT_NO_BYTE_SEEK 0x8000
415 #define AVFMT_ALLOW_FLUSH 0x10000
416 #define AVFMT_TS_NONSTRICT 0x20000
419 #define AVFMT_TS_NEGATIVE 0x40000
429 typedef struct AVOutputFormat {
430  const char *name;
436  const char *long_name;
437  const char *mime_type;
438  const char *extensions;
439  /* output support */
449  int flags;
450 
455  const struct AVCodecTag * const *codec_tag;
456 
457 
459 
460  /*****************************************************************
461  * No fields below this line are part of the public API. They
462  * may not be used outside of libavformat and can be changed and
463  * removed at will.
464  * New public fields should be added right above.
465  *****************************************************************
466  */
472 
473  int (*write_header)(struct AVFormatContext *);
481  int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
482  int (*write_trailer)(struct AVFormatContext *);
487  AVPacket *in, int flush);
494  int (*query_codec)(enum AVCodecID id, int std_compliance);
504 typedef struct AVInputFormat {
509  const char *name;
510 
516  const char *long_name;
517 
523  int flags;
524 
530  const char *extensions;
531 
532  const struct AVCodecTag * const *codec_tag;
533 
535 
536  /*****************************************************************
537  * No fields below this line are part of the public API. They
538  * may not be used outside of libavformat and can be changed and
539  * removed at will.
540  * New public fields should be added right above.
541  *****************************************************************
542  */
544 
549 
554 
561 
567  int (*read_header)(struct AVFormatContext *);
568 
578  int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
579 
584  int (*read_close)(struct AVFormatContext *);
585 
594  int (*read_seek)(struct AVFormatContext *,
595  int stream_index, int64_t timestamp, int flags);
596 
601  int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
602  int64_t *pos, int64_t pos_limit);
603 
608  int (*read_play)(struct AVFormatContext *);
609 
614  int (*read_pause)(struct AVFormatContext *);
615 
622  int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
623 } AVInputFormat;
634 };
635 
636 typedef struct AVIndexEntry {
637  int64_t pos;
638  int64_t timestamp;
639 #define AVINDEX_KEYFRAME 0x0001
640  int flags:2;
641  int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment).
643 } AVIndexEntry;
644 
645 #define AV_DISPOSITION_DEFAULT 0x0001
646 #define AV_DISPOSITION_DUB 0x0002
647 #define AV_DISPOSITION_ORIGINAL 0x0004
648 #define AV_DISPOSITION_COMMENT 0x0008
649 #define AV_DISPOSITION_LYRICS 0x0010
650 #define AV_DISPOSITION_KARAOKE 0x0020
651 
657 #define AV_DISPOSITION_FORCED 0x0040
658 #define AV_DISPOSITION_HEARING_IMPAIRED 0x0080
659 #define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100
660 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200
667 #define AV_DISPOSITION_ATTACHED_PIC 0x0400
668 
676 typedef struct AVStream {
677  int index;
683  int id;
696  void *priv_data;
697 
701  struct AVFrac pts;
702 
713 
720  int64_t start_time;
721 
727  int64_t duration;
728 
729  int64_t nb_frames;
730 
734 
741 
743 
748 
757 
758  /*****************************************************************
759  * All fields below this line are not part of the public API. They
760  * may not be used outside of libavformat and can be changed and
761  * removed at will.
762  * New public fields should be added right above.
763  *****************************************************************
764  */
765 
769 #define MAX_STD_TIMEBASES (60*12+5)
770  struct {
773 
777  int64_t fps_first_dts;
779  int64_t fps_last_dts;
781 
782  } *info;
783 
786 #if FF_API_REFERENCE_DTS
787  /* a hack to keep ABI compatibility for avconv, which accesses parser even
788  * though it should not */
789  int64_t do_not_use;
790 #endif
791  // Timestamp generation support:
792  int64_t first_dts;
793  int64_t cur_dts;
794  int64_t last_IP_pts;
796 
800 #define MAX_PROBE_PACKETS 2500
802 
807 
808  /* av_read_frame() support */
811 
817 #define MAX_REORDER_DELAY 16
819 
824 } AVStream;
825 
826 #define AV_PROGRAM_RUNNING 1
827 
834 typedef struct AVProgram {
835  int id;
836  int flags;
838  unsigned int *stream_index;
839  unsigned int nb_stream_indexes;
841 } AVProgram;
842 
843 #define AVFMTCTX_NOHEADER 0x0001
846 typedef struct AVChapter {
847  int id;
849  int64_t start, end;
851 } AVChapter;
852 
853 typedef struct AVFormatInternal AVFormatInternal;
854 
863 typedef struct AVFormatContext {
869 
876 
883 
891  void *priv_data;
892 
906 
907  /* stream info */
908  int ctx_flags;
915  unsigned int nb_streams;
928 
935  char filename[1024];
936 
944  int64_t start_time;
945 
954  int64_t duration;
955 
961  int bit_rate;
962 
963  unsigned int packet_size;
965 
966  int flags;
967 #define AVFMT_FLAG_GENPTS 0x0001
968 #define AVFMT_FLAG_IGNIDX 0x0002
969 #define AVFMT_FLAG_NONBLOCK 0x0004
970 #define AVFMT_FLAG_IGNDTS 0x0008
971 #define AVFMT_FLAG_NOFILLIN 0x0010
972 #define AVFMT_FLAG_NOPARSE 0x0020
973 #define AVFMT_FLAG_NOBUFFER 0x0040
974 #define AVFMT_FLAG_CUSTOM_IO 0x0080
975 #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100
976 #define AVFMT_FLAG_FLUSH_PACKETS 0x0200
977 
978 
983  unsigned int probesize;
984 
991 
992  const uint8_t *key;
993  int keylen;
994 
995  unsigned int nb_programs;
997 
1003 
1009 
1015 
1026  unsigned int max_index_size;
1027 
1032  unsigned int max_picture_buffer;
1033 
1045  unsigned int nb_chapters;
1047 
1057 
1065 
1072 
1079 
1090 
1094  int debug;
1095 #define FF_FDEBUG_TS 0x0001
1096 
1114 
1115  /*****************************************************************
1116  * All fields below this line are not part of the public API. They
1117  * may not be used outside of libavformat and can be changed and
1118  * removed at will.
1119  * New public fields should be added right above.
1120  *****************************************************************
1121  */
1122 
1130 
1131  /* av_seek_frame() support */
1132  int64_t data_offset;
1150 #define RAW_PACKET_BUFFER_SIZE 2500000
1152 
1157  int64_t offset;
1158 
1163 
1168  AVFormatInternal *internal;
1169 } AVFormatContext;
1170 
1171 typedef struct AVPacketList {
1174 } AVPacketList;
1175 
1176 
1189 unsigned avformat_version(void);
1190 
1194 const char *avformat_configuration(void);
1195 
1199 const char *avformat_license(void);
1200 
1210 void av_register_all(void);
1211 
1214 
1223 int avformat_network_init(void);
1224 
1228 int avformat_network_deinit(void);
1229 
1236 
1243 
1250 
1256 
1263 const AVClass *avformat_get_class(void);
1264 
1282 
1284 
1298 AVInputFormat *av_find_input_format(const char *short_name);
1299 
1307 AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
1308 
1321 AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max);
1322 
1339  const char *filename, void *logctx,
1340  unsigned int offset, unsigned int max_probe_size);
1341 
1361 int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
1362 
1385 
1411  enum AVMediaType type,
1412  int wanted_stream_nb,
1413  int related_stream,
1414  AVCodec **decoder_ret,
1415  int flags);
1416 
1442 
1456 int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
1457  int flags);
1458 
1486 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
1487 
1493 
1500 
1510 #define AVSEEK_FLAG_BACKWARD 1
1511 #define AVSEEK_FLAG_BYTE 2
1512 #define AVSEEK_FLAG_ANY 4
1513 #define AVSEEK_FLAG_FRAME 8
1514 
1515 
1535 
1567 
1602 
1613 
1626 AVOutputFormat *av_guess_format(const char *short_name,
1627  const char *filename,
1628  const char *mime_type);
1629 
1633 enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
1634  const char *filename, const char *mime_type,
1635  enum AVMediaType type);
1636 
1660 void av_hex_dump(FILE *f, const uint8_t *buf, int size);
1661 
1674 void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);
1675 
1684 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
1685 
1686 
1698 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
1699  AVStream *st);
1700 
1709 enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
1710 
1719 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
1720 
1722 
1734 int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
1735 
1742 int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
1743  int size, int distance, int flags);
1744 
1745 
1765 void av_url_split(char *proto, int proto_size,
1766  char *authorization, int authorization_size,
1767  char *hostname, int hostname_size,
1768  int *port_ptr,
1769  char *path, int path_size,
1770  const char *url);
1771 
1772 
1774  int index,
1775  const char *url,
1776  int is_output);
1777 
1790 int av_get_frame_filename(char *buf, int buf_size,
1791  const char *path, int number);
1792 
1799 int av_filename_number_test(const char *filename);
1800 
1818 int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
1819 
1827 int av_match_ext(const char *filename, const char *extensions);
1828 
1839 int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance);
1840 
1856 const struct AVCodecTag *avformat_get_riff_video_tags(void);
1860 const struct AVCodecTag *avformat_get_riff_audio_tags(void);
1869 #endif /* AVFORMAT_AVFORMAT_H */