[FFmpeg-devel] [PATCH 1/2] avformat/url.h add av_find_protocol_by_name for find URLProtocol by name

Steven Liu lq at chinaffmpeg.org
Fri Nov 22 10:56:20 EET 2019


Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 doc/APIchanges          |  3 +++
 libavformat/protocols.c | 16 ++++++++++++++++
 libavformat/url.h       |  9 +++++++++
 libavformat/version.h   |  2 +-
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 401c65a753..804a57de41 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2019-11-22 - xxxxxxxxxx - lavf 58.35.101 - url.h
+  Add av_find_protocol_by_name().
+
 2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
   Add av_expr_count_vars().
 
diff --git a/libavformat/protocols.c b/libavformat/protocols.c
index face5b29b5..d4dee23a8e 100644
--- a/libavformat/protocols.c
+++ b/libavformat/protocols.c
@@ -107,6 +107,22 @@ const char *avio_enum_protocols(void **opaque, int output)
     return avio_enum_protocols(opaque, output);
 }
 
+const URLProtocol *av_find_protocol_by_name(const char *name)
+{
+    int i = 0;
+    const URLProtocol **protocols;
+    protocols = ffurl_get_protocols(NULL, NULL);
+    for (i = 0; protocols[i]; i++) {
+        const URLProtocol *proto = protocols[i];
+        if (!strcmp(proto->name, name)) {
+            av_freep(&protocols);
+            return proto;
+        }
+    }
+    av_freep(&protocols);
+    return NULL;
+}
+
 const URLProtocol **ffurl_get_protocols(const char *whitelist,
                                         const char *blacklist)
 {
diff --git a/libavformat/url.h b/libavformat/url.h
index 4750bfff82..fe0aa10b27 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -322,6 +322,15 @@ void ff_make_absolute_url(char *buf, int size, const char *base,
  */
 AVIODirEntry *ff_alloc_dir_entry(void);
 
+/**
+ * Return the URLProtocol of the protocol that will handle the passed name.
+ *
+ * NULL is returned if no protocol could be found for the name.
+ *
+ * @return URLProtocol of the protocol or NULL.
+ */
+const URLProtocol *av_find_protocol_by_name(const char *name);
+
 const AVClass *ff_urlcontext_child_class_next(const AVClass *prev);
 
 /**
diff --git a/libavformat/version.h b/libavformat/version.h
index bac54aed9d..213b66b45f 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR  35
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \
-- 
2.15.1





More information about the ffmpeg-devel mailing list