diff mbox series

[FFmpeg-devel] avformat: deprecate AVFormatContext io_close callback

Message ID 20230213213754.15081-1-cus@passwd.hu
State New
Headers show
Series [FFmpeg-devel] avformat: deprecate AVFormatContext io_close callback | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Marton Balint Feb. 13, 2023, 9:37 p.m. UTC
io_close2 should be used instead.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 doc/APIchanges              | 4 ++++
 libavformat/avformat.c      | 6 ++++++
 libavformat/avformat.h      | 5 +++++
 libavformat/dashenc.c       | 4 ++++
 libavformat/fifo.c          | 4 ++++
 libavformat/hlsenc.c        | 4 ++++
 libavformat/imfdec.c        | 4 ++++
 libavformat/options.c       | 6 ++++++
 libavformat/segment.c       | 4 ++++
 libavformat/tee.c           | 4 ++++
 libavformat/version.h       | 2 +-
 libavformat/version_major.h | 1 +
 12 files changed, 47 insertions(+), 1 deletion(-)

Comments

Anton Khirnov Feb. 14, 2023, 1:22 p.m. UTC | #1
Quoting Marton Balint (2023-02-13 22:37:54)
> diff --git a/libavformat/version.h b/libavformat/version.h
> index 904e7f06aa..7ff1483912 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -31,7 +31,7 @@
>  
>  #include "version_major.h"
>  
> -#define LIBAVFORMAT_VERSION_MINOR   2
> +#define LIBAVFORMAT_VERSION_MINOR   3

I don't think this needs a version bump, because nothing about the API
or ABI changes with this commit, it's just an expression of intent to
change it in the future.

Otherwise LGTM.
Marton Balint Feb. 14, 2023, 8:30 p.m. UTC | #2
On Tue, 14 Feb 2023, Anton Khirnov wrote:

> Quoting Marton Balint (2023-02-13 22:37:54)
>> diff --git a/libavformat/version.h b/libavformat/version.h
>> index 904e7f06aa..7ff1483912 100644
>> --- a/libavformat/version.h
>> +++ b/libavformat/version.h
>> @@ -31,7 +31,7 @@
>>
>>  #include "version_major.h"
>>
>> -#define LIBAVFORMAT_VERSION_MINOR   2
>> +#define LIBAVFORMAT_VERSION_MINOR   3
>
> I don't think this needs a version bump, because nothing about the API
> or ABI changes with this commit, it's just an expression of intent to
> change it in the future.

My concern with not increasing the version number is that the entry in 
doc/APIChanges will not point to the version where the change happened...

Regards,
Marton
Anton Khirnov Feb. 15, 2023, 7:21 a.m. UTC | #3
Quoting Marton Balint (2023-02-14 21:30:09)
> 
> 
> On Tue, 14 Feb 2023, Anton Khirnov wrote:
> 
> > Quoting Marton Balint (2023-02-13 22:37:54)
> >> diff --git a/libavformat/version.h b/libavformat/version.h
> >> index 904e7f06aa..7ff1483912 100644
> >> --- a/libavformat/version.h
> >> +++ b/libavformat/version.h
> >> @@ -31,7 +31,7 @@
> >>
> >>  #include "version_major.h"
> >>
> >> -#define LIBAVFORMAT_VERSION_MINOR   2
> >> +#define LIBAVFORMAT_VERSION_MINOR   3
> >
> > I don't think this needs a version bump, because nothing about the API
> > or ABI changes with this commit, it's just an expression of intent to
> > change it in the future.
> 
> My concern with not increasing the version number is that the entry in 
> doc/APIChanges will not point to the version where the change happened...

I don't see that as a problem, because the relevant question from the
user perspective is "in what version was the replacement for <x> added"
rather than "in what version was <x> deprecated", since one should
always use the newer API when it is present.
Marton Balint Feb. 16, 2023, 12:31 a.m. UTC | #4
On Wed, 15 Feb 2023, Anton Khirnov wrote:

> Quoting Marton Balint (2023-02-14 21:30:09)
>>
>>
>> On Tue, 14 Feb 2023, Anton Khirnov wrote:
>>
>>> Quoting Marton Balint (2023-02-13 22:37:54)
>>>> diff --git a/libavformat/version.h b/libavformat/version.h
>>>> index 904e7f06aa..7ff1483912 100644
>>>> --- a/libavformat/version.h
>>>> +++ b/libavformat/version.h
>>>> @@ -31,7 +31,7 @@
>>>>
>>>>  #include "version_major.h"
>>>>
>>>> -#define LIBAVFORMAT_VERSION_MINOR   2
>>>> +#define LIBAVFORMAT_VERSION_MINOR   3
>>>
>>> I don't think this needs a version bump, because nothing about the API
>>> or ABI changes with this commit, it's just an expression of intent to
>>> change it in the future.
>>
>> My concern with not increasing the version number is that the entry in
>> doc/APIChanges will not point to the version where the change happened...
>
> I don't see that as a problem, because the relevant question from the
> user perspective is "in what version was the replacement for <x> added"
> rather than "in what version was <x> deprecated", since one should
> always use the newer API when it is present.

Ok, applied without the bump.

Thanks,
Marton
diff mbox series

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 3ca724724b..69116e296a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,10 @@  The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2023-02-xx - xxxxxxxxxx - lavf 60.3.100 - avformat.h
+  Deprecate AVFormatContext io_close callback.
+  The superior io_close2 callback should be used instead.
+
 2023-02-13 - xxxxxxxxxx - lavu 58.1.100 - frame.h
   Deprecate AVFrame.coded_picture_number and display_picture_number.
   Their usefulness is questionable and very few decoders set them.
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index fe7b068f4a..708d90b38c 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -854,10 +854,16 @@  int ff_format_io_close(AVFormatContext *s, AVIOContext **pb)
 {
     int ret = 0;
     if (*pb) {
+#if FF_API_AVFORMAT_IO_CLOSE
+FF_DISABLE_DEPRECATION_WARNINGS
         if (s->io_close == ff_format_io_close_default || s->io_close == NULL)
+#endif
             ret = s->io_close2(s, *pb);
+#if FF_API_AVFORMAT_IO_CLOSE
         else
             s->io_close(s, *pb);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     }
     *pb = NULL;
     return ret;
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index b986aacc78..1916aa2dc5 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1663,10 +1663,15 @@  typedef struct AVFormatContext {
     int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url,
                    int flags, AVDictionary **options);
 
+#if FF_API_AVFORMAT_IO_CLOSE
     /**
      * A callback for closing the streams opened with AVFormatContext.io_open().
+     *
+     * @deprecated use io_close2
      */
+    attribute_deprecated
     void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
+#endif
 
     /**
      * ',' separated list of disallowed protocols.
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 52865eacb5..17fe5f430c 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1551,7 +1551,11 @@  static int dash_init(AVFormatContext *s)
             return AVERROR_MUXER_NOT_FOUND;
         ctx->interrupt_callback    = s->interrupt_callback;
         ctx->opaque                = s->opaque;
+#if FF_API_AVFORMAT_IO_CLOSE
+FF_DISABLE_DEPRECATION_WARNINGS
         ctx->io_close              = s->io_close;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         ctx->io_close2             = s->io_close2;
         ctx->io_open               = s->io_open;
         ctx->strict_std_compliance = s->strict_std_compliance;
diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index ebadeef645..9a3a23729c 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -501,7 +501,11 @@  static int fifo_mux_init(AVFormatContext *avf, const AVOutputFormat *oformat,
     if (ret < 0)
         return ret;
     avf2->opaque = avf->opaque;
+#if FF_API_AVFORMAT_IO_CLOSE
+FF_DISABLE_DEPRECATION_WARNINGS
     avf2->io_close = avf->io_close;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     avf2->io_close2 = avf->io_close2;
     avf2->io_open = avf->io_open;
     avf2->flags = avf->flags;
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index dcc363b42e..e1f96feda3 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -869,7 +869,11 @@  static int hls_mux_init(AVFormatContext *s, VariantStream *vs)
     oc->max_delay                = s->max_delay;
     oc->opaque                   = s->opaque;
     oc->io_open                  = s->io_open;
+#if FF_API_AVFORMAT_IO_CLOSE
+FF_DISABLE_DEPRECATION_WARNINGS
     oc->io_close                 = s->io_close;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     oc->io_close2                = s->io_close2;
     oc->strict_std_compliance    = s->strict_std_compliance;
     av_dict_copy(&oc->metadata, s->metadata, 0);
diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 03de9ce151..4932b7ff1f 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -379,7 +379,11 @@  static int open_track_resource_context(AVFormatContext *s,
         return AVERROR(ENOMEM);
 
     track_resource->ctx->io_open = s->io_open;
+#if FF_API_AVFORMAT_IO_CLOSE
+FF_DISABLE_DEPRECATION_WARNINGS
     track_resource->ctx->io_close = s->io_close;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     track_resource->ctx->io_close2 = s->io_close2;
     track_resource->ctx->flags |= s->flags & ~AVFMT_FLAG_CUSTOM_IO;
 
diff --git a/libavformat/options.c b/libavformat/options.c
index c7681122cd..22ad523b2d 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -151,10 +151,12 @@  static int io_open_default(AVFormatContext *s, AVIOContext **pb,
     return ffio_open_whitelist(pb, url, flags, &s->interrupt_callback, options, s->protocol_whitelist, s->protocol_blacklist);
 }
 
+#if FF_API_AVFORMAT_IO_CLOSE
 void ff_format_io_close_default(AVFormatContext *s, AVIOContext *pb)
 {
     avio_close(pb);
 }
+#endif
 
 static int io_close2_default(AVFormatContext *s, AVIOContext *pb)
 {
@@ -172,7 +174,11 @@  AVFormatContext *avformat_alloc_context(void)
     s = &si->pub;
     s->av_class = &av_format_context_class;
     s->io_open  = io_open_default;
+#if FF_API_AVFORMAT_IO_CLOSE
+FF_DISABLE_DEPRECATION_WARNINGS
     s->io_close = ff_format_io_close_default;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     s->io_close2= io_close2_default;
 
     av_opt_set_defaults(s);
diff --git a/libavformat/segment.c b/libavformat/segment.c
index eb629b342c..2a82f39f31 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -160,7 +160,11 @@  static int segment_mux_init(AVFormatContext *s)
     oc->max_delay          = s->max_delay;
     av_dict_copy(&oc->metadata, s->metadata, 0);
     oc->opaque             = s->opaque;
+#if FF_API_AVFORMAT_IO_CLOSE
+FF_DISABLE_DEPRECATION_WARNINGS
     oc->io_close           = s->io_close;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     oc->io_close2          = s->io_close2;
     oc->io_open            = s->io_open;
     oc->flags              = s->flags;
diff --git a/libavformat/tee.c b/libavformat/tee.c
index 960b2ea574..cb555f52fd 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -236,7 +236,11 @@  static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
     av_dict_copy(&avf2->metadata, avf->metadata, 0);
     avf2->opaque   = avf->opaque;
     avf2->io_open  = avf->io_open;
+#if FF_API_AVFORMAT_IO_CLOSE
+FF_DISABLE_DEPRECATION_WARNINGS
     avf2->io_close = avf->io_close;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     avf2->io_close2 = avf->io_close2;
     avf2->interrupt_callback = avf->interrupt_callback;
     avf2->flags = avf->flags;
diff --git a/libavformat/version.h b/libavformat/version.h
index 904e7f06aa..7ff1483912 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@ 
 
 #include "version_major.h"
 
-#define LIBAVFORMAT_VERSION_MINOR   2
+#define LIBAVFORMAT_VERSION_MINOR   3
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
diff --git a/libavformat/version_major.h b/libavformat/version_major.h
index 9ccf40bdc1..293fbd3397 100644
--- a/libavformat/version_major.h
+++ b/libavformat/version_major.h
@@ -44,6 +44,7 @@ 
 #define FF_API_COMPUTE_PKT_FIELDS2      (LIBAVFORMAT_VERSION_MAJOR < 61)
 #define FF_API_GET_END_PTS              (LIBAVFORMAT_VERSION_MAJOR < 61)
 #define FF_API_AVIODIRCONTEXT           (LIBAVFORMAT_VERSION_MAJOR < 61)
+#define FF_API_AVFORMAT_IO_CLOSE        (LIBAVFORMAT_VERSION_MAJOR < 61)
 
 
 #define FF_API_R_FRAME_RATE            1