aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/avio.c
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-02-29 16:50:39 +0000
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2016-02-29 16:51:10 +0000
commit9c75148e6ebc88a0501e3d0242defb6dbdc3c23d (patch)
treee24939addbed549191606f8b6927b29b42c18394 /libavformat/avio.c
parente3461197b1ffa0b4ebb80ee3d8567d3b286d7fc3 (diff)
parent2758cdedfb7ac61f8b5e4861f99218b6fd43491d (diff)
downloadffmpeg-9c75148e6ebc88a0501e3d0242defb6dbdc3c23d.tar.gz
Merge commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d'
This commit also disables the async fate test, because it used internal APIs in a non-kosher way, which no longer exists. * commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d': lavf: reorganize URLProtocols Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat/avio.c')
-rw-r--r--libavformat/avio.c66
1 files changed, 26 insertions, 40 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 362099dd82..bd276f64d6 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -31,13 +31,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)
@@ -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;
}
@@ -92,27 +88,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)
{
@@ -280,11 +269,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 +290,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 +305,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 +470,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;
}