diff mbox series

[FFmpeg-devel,15/17] URLContext: switch to child_class_iterate()

Message ID 20200528201559.22618-15-anton@khirnov.net
State Accepted
Commit 43ed2b86d67ee493a9fd9ef90c13c4cf6ac89257
Headers show
Series [FFmpeg-devel,01/17] Remove unnecessary use of avcodec_close().
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Anton Khirnov May 28, 2020, 8:15 p.m. UTC
---
 libavformat/avio.c      |  3 +++
 libavformat/protocols.c | 16 ++++++++++++++++
 libavformat/url.h       |  4 ++++
 3 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 237966c303..3886ed7a90 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -67,7 +67,10 @@  const AVClass ffurl_context_class = {
     .option           = options,
     .version          = LIBAVUTIL_VERSION_INT,
     .child_next       = urlcontext_child_next,
+#if FF_API_CHILD_CLASS_NEXT
     .child_class_next = ff_urlcontext_child_class_next,
+#endif
+    .child_class_iterate = ff_urlcontext_child_class_iterate,
 };
 /*@}*/
 
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index f1b8eab0fd..7df18fbb3b 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -73,6 +73,7 @@  extern const URLProtocol ff_libzmq_protocol;
 
 #include "libavformat/protocol_list.c"
 
+#if FF_API_CHILD_CLASS_NEXT
 const AVClass *ff_urlcontext_child_class_next(const AVClass *prev)
 {
     int i;
@@ -91,7 +92,22 @@  const AVClass *ff_urlcontext_child_class_next(const AVClass *prev)
             return url_protocols[i]->priv_data_class;
     return NULL;
 }
+#endif
 
+const AVClass *ff_urlcontext_child_class_iterate(void **iter)
+{
+    const AVClass *ret = NULL;
+    uintptr_t i;
+
+    for (i = (uintptr_t)*iter; url_protocols[i]; i++) {
+        ret = url_protocols[i]->priv_data_class;
+        if (ret)
+            break;
+    }
+
+    *iter = (void*)(uintptr_t)(url_protocols[i] ? i + 1 : i);
+    return ret;
+}
 
 const char *avio_enum_protocols(void **opaque, int output)
 {
diff --git a/libavformat/url.h b/libavformat/url.h
index 4750bfff82..de0d30aca0 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -322,7 +322,11 @@  void ff_make_absolute_url(char *buf, int size, const char *base,
  */
 AVIODirEntry *ff_alloc_dir_entry(void);
 
+#if FF_API_CHILD_CLASS_NEXT
 const AVClass *ff_urlcontext_child_class_next(const AVClass *prev);
+#endif
+
+const AVClass *ff_urlcontext_child_class_iterate(void **iter);
 
 /**
  * Construct a list of protocols matching a given whitelist and/or blacklist.