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.
This commit is contained in:
Anton Khirnov
2021-11-12 14:50:00 +01:00
parent 85433fb937
commit ed75a08d36
4 changed files with 36 additions and 1 deletions

View File

@@ -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;