]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/avio.c
Merge commit '0fa00d05911aa8043ecad8dead4a73cab7faadf6'
[ffmpeg] / libavformat / avio.c
index 362099dd825083eb417c0216eed562294c2c7179..ef4253cbb9dd3cb18e04130fdad9496fab3fc7ff 100644 (file)
 #endif
 #include "url.h"
 
-static URLProtocol *first_protocol = NULL;
-
-URLProtocol *ffurl_protocol_next(const URLProtocol *prev)
-{
-    return prev ? prev->next : first_protocol;
-}
-
 /** @name Logging context. */
 /*@{*/
 static const char *urlcontext_to_name(void *ptr)
@@ -59,17 +52,20 @@ static void *urlcontext_child_next(void *obj, void *prev)
 
 static const AVClass *urlcontext_child_class_next(const AVClass *prev)
 {
-    URLProtocol *p = NULL;
+    int i;
 
     /* find the protocol that corresponds to prev */
-    while (prev && (p = ffurl_protocol_next(p)))
-        if (p->priv_data_class == prev)
+    for (i = 0; ff_url_protocols[i]; i++) {
+        if (ff_url_protocols[i]->priv_data_class == prev) {
+            i++;
             break;
+        }
+    }
 
     /* find next protocol with priv options */
-    while (p = ffurl_protocol_next(p))
-        if (p->priv_data_class)
-            return p->priv_data_class;
+    for (; ff_url_protocols[i]; i++)
+        if (ff_url_protocols[i]->priv_data_class)
+            return ff_url_protocols[i]->priv_data_class;
     return NULL;
 }
 
@@ -90,29 +86,7 @@ const AVClass ffurl_context_class = {
 };
 /*@}*/
 
-const char *avio_enum_protocols(void **opaque, int output)
-{
-    URLProtocol *p;
-    *opaque = ffurl_protocol_next(*opaque);
-    if (!(p = *opaque))
-        return NULL;
-    if ((output && p->url_write) || (!output && p->url_read))
-        return p->name;
-    return avio_enum_protocols(opaque, output);
-}
-
-int ffurl_register_protocol(URLProtocol *protocol)
-{
-    URLProtocol **p;
-    p = &first_protocol;
-    while (*p)
-        p = &(*p)->next;
-    *p             = protocol;
-    protocol->next = NULL;
-    return 0;
-}
-
-static int url_alloc_for_protocol(URLContext **puc, struct URLProtocol *up,
+static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
                                   const char *filename, int flags,
                                   const AVIOInterruptCB *int_cb)
 {
@@ -280,11 +254,12 @@ int ffurl_handshake(URLContext *c)
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                \
     "0123456789+-."
 
-static struct URLProtocol *url_find_protocol(const char *filename)
+static const struct URLProtocol *url_find_protocol(const char *filename)
 {
-    URLProtocol *up = NULL;
+    const URLProtocol *up;
     char proto_str[128], proto_nested[128], *ptr;
     size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
+    int i;
 
     if (filename[proto_len] != ':' &&
         (strncmp(filename, "subfile,", 8) || !strchr(filename + proto_len + 1, ':')) ||
@@ -300,7 +275,8 @@ static struct URLProtocol *url_find_protocol(const char *filename)
     if ((ptr = strchr(proto_nested, '+')))
         *ptr = '\0';
 
-    while (up = ffurl_protocol_next(up)) {
+    for (i = 0; ff_url_protocols[i]; i++) {
+        up = ff_url_protocols[i];
         if (!strcmp(proto_str, up->name))
             break;
         if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&
@@ -314,12 +290,7 @@ static struct URLProtocol *url_find_protocol(const char *filename)
 int ffurl_alloc(URLContext **puc, const char *filename, int flags,
                 const AVIOInterruptCB *int_cb)
 {
-    URLProtocol *p = NULL;
-
-    if (!first_protocol) {
-        av_log(NULL, AV_LOG_WARNING, "No URL Protocols are registered. "
-                                     "Missing call to av_register_all()?\n");
-    }
+    const URLProtocol *p = NULL;
 
     p = url_find_protocol(filename);
     if (p)
@@ -484,7 +455,7 @@ int ffurl_close(URLContext *h)
 
 const char *avio_find_protocol_name(const char *url)
 {
-    URLProtocol *p = url_find_protocol(url);
+    const URLProtocol *p = url_find_protocol(url);
 
     return p ? p->name : NULL;
 }