]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avformat.h
Factor tag reading code out of wav read_header()
[ffmpeg] / libavformat / avformat.h
index 4bc8461a9a2584ab93810ab6778f95f813835c8e..919933ff688ed9d020c85e2b53d803a6b1bca76b 100644 (file)
@@ -22,7 +22,7 @@
 #define AVFORMAT_AVFORMAT_H
 
 #define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 82
+#define LIBAVFORMAT_VERSION_MINOR 93
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
  * They may change, break or disappear at any time.
  */
 #ifndef FF_API_MAX_STREAMS
-#define FF_API_MAX_STREAMS   (LIBAVFORMAT_VERSION_MAJOR < 53)
+#define FF_API_MAX_STREAMS             (LIBAVFORMAT_VERSION_MAJOR < 53)
 #endif
 #ifndef FF_API_OLD_METADATA
-#define FF_API_OLD_METADATA  (LIBAVFORMAT_VERSION_MAJOR < 53)
+#define FF_API_OLD_METADATA            (LIBAVFORMAT_VERSION_MAJOR < 53)
 #endif
 #ifndef FF_API_URL_CLASS
-#define FF_API_URL_CLASS     (LIBAVFORMAT_VERSION_MAJOR >= 53)
+#define FF_API_URL_CLASS               (LIBAVFORMAT_VERSION_MAJOR >= 53)
 #endif
 #ifndef FF_API_URL_RESETBUF
-#define FF_API_URL_RESETBUF       (LIBAVFORMAT_VERSION_MAJOR < 53)
+#define FF_API_URL_RESETBUF            (LIBAVFORMAT_VERSION_MAJOR < 53)
 #endif
 #ifndef FF_API_REGISTER_PROTOCOL
-#define FF_API_REGISTER_PROTOCOL  (LIBAVFORMAT_VERSION_MAJOR < 53)
+#define FF_API_REGISTER_PROTOCOL       (LIBAVFORMAT_VERSION_MAJOR < 53)
 #endif
 #ifndef FF_API_GUESS_FORMAT
-#define FF_API_GUESS_FORMAT       (LIBAVFORMAT_VERSION_MAJOR < 53)
+#define FF_API_GUESS_FORMAT            (LIBAVFORMAT_VERSION_MAJOR < 53)
 #endif
 #ifndef FF_API_UDP_GET_FILE
-#define FF_API_UDP_GET_FILE       (LIBAVFORMAT_VERSION_MAJOR < 53)
+#define FF_API_UDP_GET_FILE            (LIBAVFORMAT_VERSION_MAJOR < 53)
 #endif
 #ifndef FF_API_URL_SPLIT
-#define FF_API_URL_SPLIT          (LIBAVFORMAT_VERSION_MAJOR < 53)
+#define FF_API_URL_SPLIT               (LIBAVFORMAT_VERSION_MAJOR < 53)
 #endif
 #ifndef FF_API_ALLOC_FORMAT_CONTEXT
 #define FF_API_ALLOC_FORMAT_CONTEXT    (LIBAVFORMAT_VERSION_MAJOR < 53)
 #ifndef FF_API_READ_SEEK
 #define FF_API_READ_SEEK               (LIBAVFORMAT_VERSION_MAJOR < 54)
 #endif
+#ifndef FF_API_LAVF_UNUSED
+#define FF_API_LAVF_UNUSED             (LIBAVFORMAT_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_PARAMETERS_CODEC_ID
+#define FF_API_PARAMETERS_CODEC_ID     (LIBAVFORMAT_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_FIRST_FORMAT
+#define FF_API_FIRST_FORMAT            (LIBAVFORMAT_VERSION_MAJOR < 53)
+#endif
+#ifndef FF_API_SYMVER
+#define FF_API_SYMVER                  (LIBAVFORMAT_VERSION_MAJOR < 53)
+#endif
 
 /**
  * I return the LIBAVFORMAT_VERSION_INT constant.  You got
@@ -125,10 +137,9 @@ struct AVFormatContext;
  *       sorting will have '-sort' appended. E.g. artist="The Beatles",
  *       artist-sort="Beatles, The".
  *
- * 4. Tag names are normally exported exactly as stored in the container to
- *    allow lossless remuxing to the same format. For container-independent
- *    handling of metadata, av_metadata_conv() can convert it to ffmpeg generic
- *    format. Follows a list of generic tag names:
+ * 4. Demuxers attempt to export metadata in a generic format, however tags
+ *    with no generic equivalents are left as they are stored in the container.
+ *    Follows a list of generic tag names:
  *
  * album        -- name of the set this work belongs to
  * album_artist -- main creator of the set/album, if different from artist.
@@ -137,6 +148,7 @@ struct AVFormatContext;
  * comment      -- any additional description of the file.
  * composer     -- who composed the work, if different from artist.
  * copyright    -- name of copyright holder.
+ * creation_time-- date when the file was created, preferably in ISO 8601.
  * date         -- date when the work was created, preferably in ISO 8601.
  * disc         -- number of a subset, e.g. disc in a multi-disc collection.
  * encoder      -- name/settings of the software/hardware that produced the file.
@@ -165,7 +177,9 @@ typedef struct {
 }AVMetadataTag;
 
 typedef struct AVMetadata AVMetadata;
+#if FF_API_OLD_METADATA
 typedef struct AVMetadataConv AVMetadataConv;
+#endif
 
 /**
  * Get a metadata element with matching key.
@@ -204,16 +218,23 @@ attribute_deprecated int av_metadata_set(AVMetadata **pm, const char *key, const
  */
 int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags);
 
+#if FF_API_OLD_METADATA
 /**
- * Convert all the metadata sets from ctx according to the source and
- * destination conversion tables. If one of the tables is NULL, then
- * tags are converted to/from ffmpeg generic tag names.
- *
- * @param d_conv destination tags format conversion table
- * @param s_conv source tags format conversion table
+ * This function is provided for compatibility reason and currently does nothing.
+ */
+attribute_deprecated void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
+                                                                        const AVMetadataConv *s_conv);
+#endif
+
+/**
+ * Copy metadata from one AVMetadata struct into another.
+ * @param dst pointer to a pointer to a AVMetadata struct. If *dst is NULL,
+ *            this function will allocate a struct for you and put it in *dst
+ * @param src pointer to source AVMetadata struct
+ * @param flags flags to use when setting metadata in *dst
+ * @note metadata is read using the AV_METADATA_IGNORE_SUFFIX flag
  */
-void av_metadata_conv(struct AVFormatContext *ctx, const AVMetadataConv *d_conv,
-                                                   const AVMetadataConv *s_conv);
+void av_metadata_copy(AVMetadata **dst, AVMetadata *src, int flags);
 
 /**
  * Free all the memory allocated for an AVMetadata struct.
@@ -235,6 +256,21 @@ void av_metadata_free(AVMetadata **m);
 int av_get_packet(ByteIOContext *s, AVPacket *pkt, int size);
 
 
+/**
+ * Read data and append it to the current content of the AVPacket.
+ * If pkt->size is 0 this is identical to av_get_packet.
+ * Note that this uses av_grow_packet and thus involves a realloc
+ * which is inefficient. Thus this function should only be used
+ * when there is no reasonable way to know (an upper bound of)
+ * the final size.
+ *
+ * @param pkt packet
+ * @param size amount of data to read
+ * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data
+ *         will not be lost even if an error occurs.
+ */
+int av_append_packet(ByteIOContext *s, AVPacket *pkt, int size);
+
 /*************************************************/
 /* fractional numbers for exact pts handling */
 
@@ -279,7 +315,7 @@ typedef struct AVFormatParameters {
     unsigned int initial_pause:1;       /**< Do not begin to play the stream
                                             immediately (RTSP only). */
     unsigned int prealloced_context:1;
-#if LIBAVFORMAT_VERSION_INT < (53<<16)
+#if FF_API_PARAMETERS_CODEC_ID
     attribute_deprecated enum CodecID video_codec_id;
     attribute_deprecated enum CodecID audio_codec_id;
 #endif
@@ -294,9 +330,10 @@ typedef struct AVFormatParameters {
 #define AVFMT_GLOBALHEADER  0x0040 /**< Format wants global header. */
 #define AVFMT_NOTIMESTAMPS  0x0080 /**< Format does not need / have any timestamps. */
 #define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */
-#define AVFMT_TS_DISCONT    0x0200 /**< Format allows timestamp discontinuities. */
+#define AVFMT_TS_DISCONT    0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */
 #define AVFMT_VARIABLE_FPS  0x0400 /**< Format allows variable fps. */
 #define AVFMT_NODIMENSIONS  0x0800 /**< Format does not need width/height */
+#define AVFMT_NOSTREAMS     0x1000 /**< Format does not require any streams */
 
 typedef struct AVOutputFormat {
     const char *name;
@@ -337,7 +374,11 @@ typedef struct AVOutputFormat {
 
     enum CodecID subtitle_codec; /**< default subtitle codec */
 
+#if FF_API_OLD_METADATA
     const AVMetadataConv *metadata_conv;
+#endif
+
+    const AVClass *priv_class; ///< AVClass for the private context
 
     /* private fields */
     struct AVOutputFormat *next;
@@ -453,7 +494,9 @@ typedef struct AVInputFormat {
      */
     int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
 
+#if FF_API_OLD_METADATA
     const AVMetadataConv *metadata_conv;
+#endif
 
     /* private fields */
     struct AVInputFormat *next;
@@ -574,7 +617,7 @@ typedef struct AVStream {
 
     int64_t nb_frames;                 ///< number of frames in this stream if known or 0
 
-#if LIBAVFORMAT_VERSION_INT < (53<<16)
+#if FF_API_LAVF_UNUSED
     attribute_deprecated int64_t unused[4+1];
 #endif
 
@@ -759,7 +802,7 @@ typedef struct AVFormatContext {
 
     /* av_read_frame() support */
     AVStream *cur_st;
-#if LIBAVFORMAT_VERSION_INT < (53<<16)
+#if FF_API_LAVF_UNUSED
     const uint8_t *cur_ptr_deprecated;
     int cur_len_deprecated;
     AVPacket cur_pkt_deprecated;
@@ -889,7 +932,7 @@ typedef struct AVPacketList {
     struct AVPacketList *next;
 } AVPacketList;
 
-#if LIBAVFORMAT_VERSION_INT < (53<<16)
+#if FF_API_FIRST_FORMAT
 attribute_deprecated extern AVInputFormat *first_iformat;
 attribute_deprecated extern AVOutputFormat *first_oformat;
 #endif
@@ -1109,6 +1152,37 @@ AVFormatContext *avformat_alloc_context(void);
  */
 int av_find_stream_info(AVFormatContext *ic);
 
+/**
+ * Find the "best" stream in the file.
+ * The best stream is determined according to various heuristics as the most
+ * likely to be what the user expects.
+ * If the decoder parameter is non-NULL, av_find_best_stream will find the
+ * default decoder for the stream's codec; streams for which no decoder can
+ * be found are ignored.
+ *
+ * @param ic                media file handle
+ * @param type              stream type: video, audio, subtitles, etc.
+ * @param wanted_stream_nb  user-requested stream number,
+ *                          or -1 for automatic selection
+ * @param related_stream    try to find a stream related (eg. in the same
+ *                          program) to this one, or -1 if none
+ * @param decoder_ret       if non-NULL, returns the decoder for the
+ *                          selected stream
+ * @param flags             flags; none are currently defined
+ * @return  the non-negative stream number in case of success,
+ *          AVERROR_STREAM_NOT_FOUND if no stream with the requested type
+ *          could be found,
+ *          AVERROR_DECODER_NOT_FOUND if streams were found but no decoder
+ * @note  If av_find_best_stream returns successfully and decoder_ret is not
+ *        NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.
+ */
+int av_find_best_stream(AVFormatContext *ic,
+                        enum AVMediaType type,
+                        int wanted_stream_nb,
+                        int related_stream,
+                        AVCodec **decoder_ret,
+                        int flags);
+
 /**
  * Read a transport packet from a media file.
  *