diff mbox series

[FFmpeg-devel,2/6] lavf: add an AVClass to AVStream on next major bump

Message ID 20211112163255.20522-2-anton@khirnov.net
State Accepted
Commit ed75a08d36c011db152d89e2c23b2dab55331d93
Headers show
Series [FFmpeg-devel,1/6] lavf: improve AV_DISPOSITION_* doxy
Related show

Checks

Context Check Description
andriy/configurex86 warning Failed to apply patch
andriy/configureppc warning Failed to apply patch

Commit Message

Anton Khirnov Nov. 12, 2021, 4:32 p.m. UTC
Also add a function to retrieve that class, analogously to
avformat_get_class().

This will be useful for adding an AVOption for dispositions.
---
 doc/APIchanges         |  4 ++++
 libavformat/avformat.h | 15 +++++++++++++++
 libavformat/utils.c    | 15 +++++++++++++++
 libavformat/version.h  |  3 ++-
 4 files changed, 36 insertions(+), 1 deletion(-)

Comments

Anton Khirnov Nov. 12, 2021, 4:47 p.m. UTC | #1
Quoting James Almer (2021-11-12 17:36:58)
> On 11/12/2021 1:32 PM, Anton Khirnov wrote:
> > Also add a function to retrieve that class, analogously to
> > avformat_get_class().
> > 
> > This will be useful for adding an AVOption for dispositions.
> 
> While it's true that quite a few months have passed since the bump, we 
> haven't made a release just yet that would effectively freeze in practice.
> If this change brings some immediate benefits, we could consider just 
> adding it now instead.

It has been over half a year and the instability periods is supposed to
be brief. I would prefer to maintain the convention that git master is
kept stable for most of the time.
James Almer Nov. 12, 2021, 4:49 p.m. UTC | #2
On 11/12/2021 1:47 PM, Anton Khirnov wrote:
> Quoting James Almer (2021-11-12 17:36:58)
>> On 11/12/2021 1:32 PM, Anton Khirnov wrote:
>>> Also add a function to retrieve that class, analogously to
>>> avformat_get_class().
>>>
>>> This will be useful for adding an AVOption for dispositions.
>>
>> While it's true that quite a few months have passed since the bump, we
>> haven't made a release just yet that would effectively freeze in practice.
>> If this change brings some immediate benefits, we could consider just
>> adding it now instead.
> 
> It has been over half a year and the instability periods is supposed to
> be brief. I would prefer to maintain the convention that git master is
> kept stable for most of the time.

Alright.
Hendrik Leppkes Nov. 12, 2021, 7 p.m. UTC | #3
On Fri, Nov 12, 2021 at 5:47 PM Anton Khirnov <anton@khirnov.net> wrote:
>
> Quoting James Almer (2021-11-12 17:36:58)
> > On 11/12/2021 1:32 PM, Anton Khirnov wrote:
> > > Also add a function to retrieve that class, analogously to
> > > avformat_get_class().
> > >
> > > This will be useful for adding an AVOption for dispositions.
> >
> > While it's true that quite a few months have passed since the bump, we
> > haven't made a release just yet that would effectively freeze in practice.
> > If this change brings some immediate benefits, we could consider just
> > adding it now instead.
>
> It has been over half a year and the instability periods is supposed to
> be brief. I would prefer to maintain the convention that git master is
> kept stable for most of the time.
>

I agree with that. The supposed "instability period" after this bump
was ridiculous. IMO that period should be a day or so. Prepare patches
before, in a branch or another repo, push after bump, all done.

- Hendrik
Lynne Nov. 12, 2021, 8:41 p.m. UTC | #4
12 Nov 2021, 20:00 by h.leppkes@gmail.com:

> On Fri, Nov 12, 2021 at 5:47 PM Anton Khirnov <anton@khirnov.net> wrote:
>
>>
>> Quoting James Almer (2021-11-12 17:36:58)
>> > On 11/12/2021 1:32 PM, Anton Khirnov wrote:
>> > > Also add a function to retrieve that class, analogously to
>> > > avformat_get_class().
>> > >
>> > > This will be useful for adding an AVOption for dispositions.
>> >
>> > While it's true that quite a few months have passed since the bump, we
>> > haven't made a release just yet that would effectively freeze in practice.
>> > If this change brings some immediate benefits, we could consider just
>> > adding it now instead.
>>
>> It has been over half a year and the instability periods is supposed to
>> be brief. I would prefer to maintain the convention that git master is
>> kept stable for most of the time.
>>
>
> I agree with that. The supposed "instability period" after this bump
> was ridiculous. IMO that period should be a day or so. Prepare patches
> before, in a branch or another repo, push after bump, all done.
>

Once every 2 years is really pushing it IMO. Multimedia moves faster
than that.
I'd prefer once a year with a period of 2 months or so.
Marton Balint Nov. 13, 2021, 1:14 p.m. UTC | #5
On Fri, 12 Nov 2021, Lynne wrote:

> 12 Nov 2021, 20:00 by h.leppkes@gmail.com:
>
>> On Fri, Nov 12, 2021 at 5:47 PM Anton Khirnov <anton@khirnov.net> wrote:
>>
>>>
>>> Quoting James Almer (2021-11-12 17:36:58)
>>>> On 11/12/2021 1:32 PM, Anton Khirnov wrote:
>>>>> Also add a function to retrieve that class, analogously to
>>>>> avformat_get_class().
>>>>>
>>>>> This will be useful for adding an AVOption for dispositions.
>>>>
>>>> While it's true that quite a few months have passed since the bump, we
>>>> haven't made a release just yet that would effectively freeze in practice.
>>>> If this change brings some immediate benefits, we could consider just
>>>> adding it now instead.
>>>
>>> It has been over half a year and the instability periods is supposed to
>>> be brief. I would prefer to maintain the convention that git master is
>>> kept stable for most of the time.
>>>
>>
>> I agree with that. The supposed "instability period" after this bump
>> was ridiculous. IMO that period should be a day or so. Prepare patches
>> before, in a branch or another repo, push after bump, all done.
>>
>
> Once every 2 years is really pushing it IMO. Multimedia moves faster
> than that.

I would not bump yearly just because we can. If some development is 
actually blocked by limited ABI or it would be too much work to maintain 
something, then OK, but in general IMHO it is better to keep the number of 
ABI versions small. (less stuff to maintain, less number of versions of 
libraries for distros to ship, etc). So the current 1-2-3 years as it 
fits us looks fine by me.

Regards,
Marton
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 10bad1d21e..a86f4b936e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,10 @@  libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2021-11-xx - xxxxxxxxxx - lavf 59.9.100 - avformat.h
+  Add av_stream_get_class(). Schedule adding AVStream.av_class at libavformat
+  major version 60.
+
 2021-11-12 - xxxxxxxxxx - lavu 57.8.100 - hwcontext_vulkan.h
   Added AVFrame.sem_value, AVVulkanDeviceContext.queue_family_encode_index,
   nb_encode_queues, queue_family_decode_index, and nb_decode_queues.
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 7d8ad08f07..4dabc90f24 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.
@@ -1864,6 +1871,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.
  *
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 509c0ecdce..d889134a1a 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