]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avformat.h
Add FFMPEG_ prefix to all multiple inclusion guards.
[ffmpeg] / libavformat / avformat.h
index 512328a6ee32ff2e3dbee389bbfa362a635f2cc0..dbbb9b48c32b9f47ffd78205252da0e2cbea5a7b 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVFORMAT_H
-#define AVFORMAT_H
+#ifndef FFMPEG_AVFORMAT_H
+#define FFMPEG_AVFORMAT_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define LIBAVFORMAT_VERSION_INT ((51<<16)+(10<<8)+0)
-#define LIBAVFORMAT_VERSION     51.10.0
+#define LIBAVFORMAT_VERSION_INT ((51<<16)+(15<<8)+0)
+#define LIBAVFORMAT_VERSION     51.15.0
 #define LIBAVFORMAT_BUILD       LIBAVFORMAT_VERSION_INT
 
 #define LIBAVFORMAT_IDENT       "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
@@ -60,20 +56,15 @@ void av_destruct_packet_nofree(AVPacket *pkt);
  */
 void av_destruct_packet(AVPacket *pkt);
 
-/* initialize optional fields of a packet */
-static inline void av_init_packet(AVPacket *pkt)
-{
-    pkt->pts   = AV_NOPTS_VALUE;
-    pkt->dts   = AV_NOPTS_VALUE;
-    pkt->pos   = -1;
-    pkt->duration = 0;
-    pkt->flags = 0;
-    pkt->stream_index = 0;
-    pkt->destruct= av_destruct_packet_nofree;
-}
+/**
+ * Initialize optional fields of a packet to default values.
+ *
+ * @param pkt packet
+ */
+void av_init_packet(AVPacket *pkt);
 
 /**
- * Allocate the payload of a packet and intialized its fields to default values.
+ * Allocate the payload of a packet and initialize its fields to default values.
  *
  * @param pkt packet
  * @param size wanted payload size
@@ -82,7 +73,7 @@ static inline void av_init_packet(AVPacket *pkt)
 int av_new_packet(AVPacket *pkt, int size);
 
 /**
- * Allocate and read the payload of a packet and intialized its fields to default values.
+ * Allocate and read the payload of a packet and initialize its fields to default values.
  *
  * @param pkt packet
  * @param size wanted payload size
@@ -111,8 +102,11 @@ static inline void av_free_packet(AVPacket *pkt)
 /*************************************************/
 /* fractional numbers for exact pts handling */
 
-/* the exact value of the fractional number is: 'val + num / den'. num
-   is assumed to be such as 0 <= num < den */
+/**
+ * the exact value of the fractional number is: 'val + num / den'.
+ * num is assumed to be such as 0 <= num < den
+ * @deprecated Use AVRational instead
+*/
 typedef struct AVFrac {
     int64_t val, num, den;
 } AVFrac attribute_deprecated;
@@ -132,6 +126,7 @@ typedef struct AVProbeData {
 } AVProbeData;
 
 #define AVPROBE_SCORE_MAX 100               ///< max score, half of that is used for file extension based detection
+#define AVPROBE_PADDING_SIZE 32             ///< extra allocated bytes at the end of the probe buffer
 
 typedef struct AVFormatParameters {
     AVRational time_base;
@@ -148,7 +143,7 @@ typedef struct AVFormatParameters {
     int mpeg2ts_raw:1;  /**< force raw MPEG2 transport stream output, if possible */
     int mpeg2ts_compute_pcr:1; /**< compute exact PCR for each transport
                                   stream packet (only meaningful if
-                                  mpeg2ts_raw is TRUE */
+                                  mpeg2ts_raw is TRUE) */
     int initial_pause:1;       /**< do not begin to play the stream
                                   immediately (RTSP only) */
     int prealloced_context:1;
@@ -163,14 +158,14 @@ typedef struct AVFormatParameters {
 #define AVFMT_RAWPICTURE    0x0020 /**< format wants AVPicture structure for
                                       raw picture data */
 #define AVFMT_GLOBALHEADER  0x0040 /**< format wants global header */
-#define AVFMT_NOTIMESTAMPS  0x0080 /**< format doesnt need / has any timestamps */
+#define AVFMT_NOTIMESTAMPS  0x0080 /**< format does not need / have any timestamps */
 #define AVFMT_GENERIC_INDEX 0x0100 /**< use generic index building code */
 
 typedef struct AVOutputFormat {
     const char *name;
     const char *long_name;
     const char *mime_type;
-    const char *extensions; /**< comma separated extensions */
+    const char *extensions; /**< comma separated filename extensions */
     /** size of private data so that it can be allocated in the wrapper */
     int priv_data_size;
     /* output support */
@@ -191,6 +186,8 @@ typedef struct AVOutputFormat {
      */
     const struct AVCodecTag **codec_tag;
 
+    enum CodecID subtitle_codec; /**< default subtitle codec */
+
     /* private fields */
     struct AVOutputFormat *next;
 } AVOutputFormat;
@@ -200,11 +197,15 @@ typedef struct AVInputFormat {
     const char *long_name;
     /** size of private data so that it can be allocated in the wrapper */
     int priv_data_size;
-    /** tell if a given file has a chance of being parsing by this format */
+    /**
+     * tell if a given file has a chance of being parsed by this format.
+     * The buffer provided is guranteed to be AVPROBE_PADDING_SIZE bytes big
+     * so you dont have to check for that unless you need more.
+     */
     int (*read_probe)(AVProbeData *);
     /** read the format header and initialize the AVFormatContext
        structure. Return 0 if OK. 'ap' if non NULL contains
-       additionnal paramters. Only used in raw format right
+       additional paramters. Only used in raw format right
        now. 'av_new_stream' should be called to create new streams.  */
     int (*read_header)(struct AVFormatContext *,
                        AVFormatParameters *ap);
@@ -221,6 +222,7 @@ typedef struct AVInputFormat {
      * @param stream_index must not be -1
      * @param flags selects which direction should be preferred if no exact
      *              match is available
+     * @return >= 0 on success (but not necessarily the new offset)
      */
     int (*read_seek)(struct AVFormatContext *,
                      int stream_index, int64_t timestamp, int flags);
@@ -252,12 +254,19 @@ typedef struct AVInputFormat {
     struct AVInputFormat *next;
 } AVInputFormat;
 
+enum AVStreamParseType {
+    AVSTREAM_PARSE_NONE,
+    AVSTREAM_PARSE_FULL,       /**< full parsing and repack */
+    AVSTREAM_PARSE_HEADERS,    /**< only parse headers, don't repack */
+    AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on packet boundary */
+};
+
 typedef struct AVIndexEntry {
     int64_t pos;
     int64_t timestamp;
 #define AVINDEX_KEYFRAME 0x0001
     int flags:2;
-    int size:30; //yeah trying to keep the size of this small to reduce memory requirements (its 24 vs 32 byte due to possible 8byte align)
+    int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs 32 byte due to possible 8byte align).
     int min_distance;         /**< min distance between this and the previous keyframe, used to avoid unneeded searching */
 } AVIndexEntry;
 
@@ -268,18 +277,21 @@ typedef struct AVStream {
     /**
      * real base frame rate of the stream.
      * this is the lowest framerate with which all timestamps can be
-     * represented accurately (its the least common multiple of all
+     * represented accurately (it is the least common multiple of all
      * framerates in the stream), Note, this value is just a guess!
      * for example if the timebase is 1/90000 and all frames have either
      * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1
      */
     AVRational r_frame_rate;
     void *priv_data;
+
     /* internal data used in av_find_stream_info() */
-    int64_t codec_info_duration;
+    int64_t first_dts;
+#if LIBAVFORMAT_VERSION_INT < (52<<16)
     int codec_info_nb_frames;
+#endif
     /** encoding: PTS generation when outputing stream */
-    AVFrac pts;
+    struct AVFrac pts;
 
     /**
      * this is the fundamental unit of time (in seconds) in terms
@@ -290,23 +302,32 @@ typedef struct AVStream {
     AVRational time_base;
     int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
     /* ffmpeg.c private use */
-    int stream_copy; /**< if TRUE, just copy stream */
-    enum AVDiscard discard; ///< selects which packets can be discarded at will and dont need to be demuxed
+    int stream_copy; /**< if set, just copy stream */
+    enum AVDiscard discard; ///< selects which packets can be discarded at will and do not need to be demuxed
     //FIXME move stuff to a flags field?
     /** quality, as it has been removed from AVCodecContext and put in AVVideoFrame
-     * MN:dunno if thats the right place, for it */
+     * MN: dunno if that is the right place for it */
     float quality;
-    /** decoding: position of the first frame of the component, in
-       AV_TIME_BASE fractional seconds. */
+    /**
+     * decoding: pts of the first frame of the stream, in stream time base.
+     * only set this if you are absolutely 100% sure that the value you set
+     * it to really is the pts of the first frame
+     * This may be undefined (AV_NOPTS_VALUE).
+     * @note the ASF header does NOT contain a correct start_time the ASF
+     * demuxer must NOT set this
+     */
     int64_t start_time;
-    /** decoding: duration of the stream, in AV_TIME_BASE fractional
-       seconds. */
+    /**
+     * decoding: duration of the stream, in stream time base.
+     * If a source file does not specify a duration, but does specify
+     * a bitrate, this value will be estimates from bit rate and file size.
+     */
     int64_t duration;
 
     char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
 
     /* av_read_frame() support */
-    int need_parsing;                  ///< 1->full parsing needed, 2->only parse headers dont repack
+    enum AVStreamParseType need_parsing;
     struct AVCodecParserContext *parser;
 
     int64_t cur_dts;
@@ -324,6 +345,16 @@ typedef struct AVStream {
     int64_t pts_buffer[MAX_REORDER_DELAY+1];
 } AVStream;
 
+#define AV_PROGRAM_RUNNING 1
+
+typedef struct AVProgram {
+    int            id;
+    char           *provider_name; ///< Network name for DVB streams
+    char           *name;          ///< Service name for DVB streams
+    int            flags;
+    enum AVDiscard discard;        ///< selects which program to discard and which to feed to the caller
+} AVProgram;
+
 #define AVFMTCTX_NOHEADER      0x0001 /**< signal that no header is present
                                          (streams are added dynamically) */
 
@@ -396,6 +427,7 @@ typedef struct AVFormatContext {
     int flags;
 #define AVFMT_FLAG_GENPTS       0x0001 ///< generate pts if missing even if it requires parsing future frames
 #define AVFMT_FLAG_IGNIDX       0x0002 ///< ignore index
+#define AVFMT_FLAG_NONBLOCK     0x0004 ///< do not block when reading packets from input
 
     int loop_input;
     /** decoding: size of data to probe; encoding unused */
@@ -408,6 +440,9 @@ typedef struct AVFormatContext {
 
     const uint8_t *key;
     int keylen;
+
+    unsigned int nb_programs;
+    AVProgram **programs;
 } AVFormatContext;
 
 typedef struct AVPacketList {
@@ -442,21 +477,51 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
                             const char *filename, const char *mime_type, enum CodecType type);
 
 /**
- * Print  nice hexa dump of a buffer
- * @param f stream for output
+ * Send a nice hexadecimal dump of a buffer to the specified file stream.
+ *
+ * @param f The file stream pointer where the dump should be sent to.
  * @param buf buffer
  * @param size buffer size
+ *
+ * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log
  */
 void av_hex_dump(FILE *f, uint8_t *buf, int size);
 
 /**
- * Print on 'f' a nice dump of a packet
- * @param f stream for output
+ * Send a nice hexadecimal dump of a buffer to the log.
+ *
+ * @param avcl A pointer to an arbitrary struct of which the first field is a
+ * pointer to an AVClass struct.
+ * @param level The importance level of the message, lower values signifying
+ * higher importance.
+ * @param buf buffer
+ * @param size buffer size
+ *
+ * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log
+ */
+void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
+
+/**
+ * Send a nice dump of a packet to the specified file stream.
+ *
+ * @param f The file stream pointer where the dump should be sent to.
  * @param pkt packet to dump
  * @param dump_payload true if the payload must be displayed too
  */
 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
 
+/**
+ * Send a nice dump of a packet to the log.
+ *
+ * @param avcl A pointer to an arbitrary struct of which the first field is a
+ * pointer to an AVClass struct.
+ * @param level The importance level of the message, lower values signifying
+ * higher importance.
+ * @param pkt packet to dump
+ * @param dump_payload true if the payload must be displayed too
+ */
+void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
+
 void av_register_all(void);
 
 /** codec tag <-> codec id */
@@ -487,14 +552,14 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
                          AVInputFormat *fmt, AVFormatParameters *ap);
 
 /**
- * Open a media file as input. The codec are not opened. Only the file
+ * Open a media file as input. The codecs are not opened. Only the file
  * header (if present) is read.
  *
  * @param ic_ptr the opened media file handle is put here
  * @param filename filename to open.
  * @param fmt if non NULL, force the file format to use
  * @param buf_size optional buffer size (zero if default is OK)
- * @param ap additionnal parameters needed when opening the file (NULL if default)
+ * @param ap additional parameters needed when opening the file (NULL if default)
  * @return 0 if OK. AVERROR_xxx otherwise.
  */
 int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
@@ -514,14 +579,14 @@ AVFormatContext *av_alloc_format_context(void);
  *
  * @param ic media file handle
  * @return >=0 if OK. AVERROR_xxx if error.
- * @todo let user decide somehow what information is needed so we dont waste time geting stuff the user doesnt need
+ * @todo Let user decide somehow what information is needed so we do not waste time geting stuff the user does not need.
  */
 int av_find_stream_info(AVFormatContext *ic);
 
 /**
  * Read a transport packet from a media file.
  *
- * This function is absolete and should never be used.
+ * This function is obsolete and should never be used.
  * Use av_read_frame() instead.
  *
  * @param s media file handle
@@ -595,6 +660,7 @@ void av_close_input_file(AVFormatContext *s);
  * @param id file format dependent stream id
  */
 AVStream *av_new_stream(AVFormatContext *s, int id);
+AVProgram *av_new_program(AVFormatContext *s, int id);
 
 /**
  * Set the pts for a given stream.
@@ -634,7 +700,7 @@ int av_add_index_entry(AVStream *st,
 
 /**
  * Does a binary search using av_index_search_timestamp() and AVCodec.read_timestamp().
- * this isnt supposed to be called directly by a user application, but by demuxers
+ * This is not supposed to be called directly by a user application, but by demuxers.
  * @param target_ts target timestamp in the time base of the given stream
  * @param stream_index stream number
  */
@@ -644,7 +710,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts
  * Updates cur_dts of all streams based on given timestamp and AVStream.
  *
  * Stream ref_st unchanged, others set cur_dts in their native timebase
- * only needed for timestamp wrapping or if (dts not set and pts!=dts)
+ * only needed for timestamp wrapping or if (dts not set and pts!=dts).
  * @param timestamp new dts expressed in time_base of param ref_st
  * @param ref_st reference stream giving time_base of param timestamp
  */
@@ -652,7 +718,7 @@ void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp);
 
 /**
  * Does a binary search using read_timestamp().
- * this isnt supposed to be called directly by a user application, but by demuxers
+ * This is not supposed to be called directly by a user application, but by demuxers.
  * @param target_ts target timestamp in the time base of the given stream
  * @param stream_index stream number
  */
@@ -662,8 +728,8 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i
 int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
 
 /**
- * allocate the stream private data and write the stream header to an
- * output media file
+ * Allocate the stream private data and write the stream header to an
+ * output media file.
  *
  * @param s media file handle
  * @return 0 if OK. AVERROR_xxx if error.
@@ -688,10 +754,10 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  *
  * The packet must contain one audio or video frame.
  * If the packets are already correctly interleaved the application should
- * call av_write_frame() instead as its slightly faster, its also important
- * to keep in mind that completly non interleaved input will need huge amounts
- * of memory to interleave with this, so its prefereable to interleave at the
- * demuxer level
+ * call av_write_frame() instead as it is slightly faster. It is also important
+ * to keep in mind that completely non-interleaved input will need huge amounts
+ * of memory to interleave with this, so it is preferable to interleave at the
+ * demuxer level.
  *
  * @param s media file handle
  * @param pkt the packet, which contains the stream_index, buf/buf_size, dts/pts, ...
@@ -731,28 +797,41 @@ void dump_format(AVFormatContext *ic,
 
 /**
  * parses width and height out of string str.
+ * @deprecated Use av_parse_video_frame_size instead.
  */
-int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
+attribute_deprecated int parse_image_size(int *width_ptr, int *height_ptr, const char *str);
 
 /**
  * Converts frame rate from string to a fraction.
+ * @deprecated Use av_parse_video_frame_rate instead.
  */
-int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
+attribute_deprecated int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg);
 
 /**
- * Converts date string to number of seconds since Jan 1st, 1970.
- *
+ * Parses \p datestr and returns a corresponding number of microseconds.
+ * @param datestr String representing a date or a duration.
+ * - If a date the syntax is:
  * @code
- * Syntax:
- * - If not a duration:
  *  [{YYYY-MM-DD|YYYYMMDD}]{T| }{HH[:MM[:SS[.m...]]][Z]|HH[MM[SS[.m...]]][Z]}
- * Time is localtime unless Z is suffixed to the end. In this case GMT
- * Return the date in micro seconds since 1970
- *
- * - If a duration:
- *  HH[:MM[:SS[.m...]]]
- *  S+[.m...]
  * @endcode
+ * Time is localtime unless Z is appended, in which case it is
+ * interpreted as UTC.
+ * If the year-month-day part isn't specified it takes the current
+ * year-month-day.
+ * Returns the number of microseconds since 1st of January, 1970 up to
+ * the time of the parsed date or INT64_MIN if \p datestr cannot be
+ * successfully parsed.
+ * - If a duration the syntax is:
+ * @code
+ *  [-]HH[:MM[:SS[.m...]]]
+ *  [-]S+[.m...]
+ * @endcode
+ * Returns the number of microseconds contained in a time interval
+ * with the specified duration or INT64_MIN if \p datestr cannot be
+ * succesfully parsed.
+ * @param duration Flag which tells how to interpret \p datestr, if
+ * not zero \p datestr is interpreted as a duration, otherwise as a
+ * date.
  */
 int64_t parse_date(const char *datestr, int duration);
 
@@ -795,23 +874,26 @@ int av_get_frame_filename(char *buf, int buf_size,
  */
 int av_filename_number_test(const char *filename);
 
-/* grab specific */
-int video_grab_init(void);
-int audio_init(void);
-
-/* DV1394 */
-int dv1394_init(void);
-int dc1394_init(void);
+/**
+ * Generate an SDP for an RTP session.
+ *
+ * @param ac array of AVFormatContexts describing the RTP streams. If the
+ *           array is composed by only one context, such context can contain
+ *           multiple AVStreams (one AVStream per RTP stream). Otherwise,
+ *           all the contexts in the array (an AVCodecContext per RTP stream)
+ *           must contain only one AVStream
+ * @param n_files number of AVCodecContexts contained in ac
+ * @param buff buffer where the SDP will be stored (must be allocated by
+ *             the caller
+ * @param size the size of the buffer
+ * @return 0 if OK. AVERROR_xxx if error.
+ */
+int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
 
 #ifdef HAVE_AV_CONFIG_H
 
 #include "os_support.h"
 
-int strstart(const char *str, const char *val, const char **ptr);
-int stristart(const char *str, const char *val, const char **ptr);
-void pstrcpy(char *buf, int buf_size, const char *str);
-char *pstrcat(char *buf, int buf_size, const char *s);
-
 void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
 
 #ifdef __GNUC__
@@ -848,9 +930,4 @@ int match_ext(const char *filename, const char *extensions);
 
 #endif /* HAVE_AV_CONFIG_H */
 
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AVFORMAT_H */
-
+#endif /* FFMPEG_AVFORMAT_H */