summaryrefslogtreecommitdiff
path: root/libavformat/avio.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/avio.c')
-rw-r--r--libavformat/avio.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c
index ff740a28b7..00c111a059 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -30,13 +30,6 @@
#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)
@@ -58,17 +51,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;
}
@@ -85,27 +81,20 @@ const AVClass ffurl_context_class = {
const char *avio_enum_protocols(void **opaque, int output)
{
- URLProtocol *p;
- *opaque = ffurl_protocol_next(*opaque);
- if (!(p = *opaque))
+ const URLProtocol **p = *opaque;
+
+ p = p ? p + 1 : ff_url_protocols;
+ *opaque = p;
+ if (!*p) {
+ *opaque = NULL;
return NULL;
- if ((output && p->url_write) || (!output && p->url_read))
- return p->name;
+ }
+ 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)
{
@@ -183,9 +172,9 @@ int ffurl_connect(URLContext *uc, AVDictionary **options)
int ffurl_alloc(URLContext **puc, const char *filename, int flags,
const AVIOInterruptCB *int_cb)
{
- URLProtocol *up = NULL;
char proto_str[128], proto_nested[128], *ptr;
size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
+ int i;
if (filename[proto_len] != ':' || is_dos_path(filename))
strcpy(proto_str, "file");
@@ -197,7 +186,8 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags,
if ((ptr = strchr(proto_nested, '+')))
*ptr = '\0';
- while (up = ffurl_protocol_next(up)) {
+ for (i = 0; ff_url_protocols[i]; i++) {
+ const URLProtocol *up = ff_url_protocols[i];
if (!strcmp(proto_str, up->name))
return url_alloc_for_protocol(puc, up, filename, flags, int_cb);
if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&