summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-11-12 14:50:00 +0100
committerAnton Khirnov <anton@khirnov.net>2021-11-16 10:51:32 +0100
commited75a08d36c011db152d89e2c23b2dab55331d93 (patch)
treeb0bbebd307b88e4d7db7f4c7f5f8111c2fe2fe29 /libavformat
parent85433fb937f8ef69077a05a03c347ada46281282 (diff)
lavf: add an AVClass to AVStream on next major bump
Also add a function to retrieve that class, analogously to avformat_get_class(). This will be useful for adding an AVOption for dispositions.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avformat.h15
-rw-r--r--libavformat/utils.c15
-rw-r--r--libavformat/version.h3
3 files changed, 32 insertions, 1 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index c38fac5a37..da92a3847a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -909,6 +909,13 @@ typedef struct AVIndexEntry {
* sizeof(AVStream) must not be used outside libav*.
*/
typedef struct AVStream {
+#if FF_API_AVSTREAM_CLASS
+ /**
+ * A class for @ref avoptions. Set on stream creation.
+ */
+ const AVClass *av_class;
+#endif
+
int index; /**< stream index in AVFormatContext */
/**
* Format-specific stream ID.
@@ -1865,6 +1872,14 @@ void avformat_free_context(AVFormatContext *s);
const AVClass *avformat_get_class(void);
/**
+ * Get the AVClass for AVStream. It can be used in combination with
+ * AV_OPT_SEARCH_FAKE_OBJ for examining options.
+ *
+ * @see av_opt_find().
+ */
+const AVClass *av_stream_get_class(void);
+
+/**
* Add a new stream to a media file.
*
* When demuxing, it is called by the demuxer in read_header(). If the
diff --git a/libavformat/utils.c b/libavformat/utils.c
index bbc61dccbb..dcfbae7d7e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -721,6 +721,17 @@ void avformat_free_context(AVFormatContext *s)
av_free(s);
}
+static const AVClass stream_class = {
+ .class_name = "AVStream",
+ .item_name = av_default_item_name,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+const AVClass *av_stream_get_class(void)
+{
+ return &stream_class;
+}
+
AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
{
FFFormatContext *const si = ffformatcontext(s);
@@ -745,6 +756,10 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
return NULL;
st = &sti->pub;
+#if FF_API_AVSTREAM_CLASS
+ st->av_class = &stream_class;
+#endif
+
st->codecpar = avcodec_parameters_alloc();
if (!st->codecpar)
goto fail;
diff --git a/libavformat/version.h b/libavformat/version.h
index 2e860b8d76..1d10481734 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 59
-#define LIBAVFORMAT_VERSION_MINOR 8
+#define LIBAVFORMAT_VERSION_MINOR 9
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -58,6 +58,7 @@
#define FF_API_LAVF_PRIV_OPT (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 60)
#define FF_API_AVIOCONTEXT_WRITTEN (LIBAVFORMAT_VERSION_MAJOR < 60)
+#define FF_API_AVSTREAM_CLASS (LIBAVFORMAT_VERSION_MAJOR > 59)
#define FF_API_R_FRAME_RATE 1