aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Strasser <eclipse7@gmx.net>2014-01-05 02:11:18 +0100
committerAlexander Strasser <eclipse7@gmx.net>2014-02-16 22:34:21 +0100
commitdb3c9701f46d20fd7e94c3222cf4fd4524a16414 (patch)
treebb13ace709cbc881905c0ba211da30c36436ae6e
parenta392bf657015c9a79a5a13adfbfb15086c1943b9 (diff)
downloadffmpeg-db3c9701f46d20fd7e94c3222cf4fd4524a16414.tar.gz
lavf/avio: Introduce avio_find_protocol_name
Make it possible to find out what protocol will be chosen for a given URL. Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
-rw-r--r--libavformat/avio.c39
-rw-r--r--libavformat/avio.h9
-rw-r--r--libavformat/version.h4
3 files changed, 40 insertions, 12 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 225d9821a0..a76f9db3b8 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -215,18 +215,12 @@ int ffurl_connect(URLContext *uc, AVDictionary **options)
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
"0123456789+-."
-int ffurl_alloc(URLContext **puc, const char *filename, int flags,
- const AVIOInterruptCB *int_cb)
+static struct URLProtocol *url_find_protocol(const char *filename)
{
URLProtocol *up = NULL;
char proto_str[128], proto_nested[128], *ptr;
size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
- if (!first_protocol) {
- av_log(NULL, AV_LOG_WARNING, "No URL Protocols are registered. "
- "Missing call to av_register_all()?\n");
- }
-
if (filename[proto_len] != ':' &&
(filename[proto_len] != ',' || !strchr(filename + proto_len + 1, ':')) ||
is_dos_path(filename))
@@ -243,13 +237,31 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags,
while (up = ffurl_protocol_next(up)) {
if (!strcmp(proto_str, up->name))
- return url_alloc_for_protocol(puc, up, filename, flags, int_cb);
+ break;
if (up->flags & URL_PROTOCOL_FLAG_NESTED_SCHEME &&
!strcmp(proto_nested, up->name))
- return url_alloc_for_protocol(puc, up, filename, flags, int_cb);
+ break;
}
+
+ return up;
+}
+
+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");
+ }
+
+ p = url_find_protocol(filename);
+ if (p)
+ return url_alloc_for_protocol(puc, p, filename, flags, int_cb);
+
*puc = NULL;
- if (!strcmp("https", proto_str))
+ if (av_strstart("https:", filename, NULL))
av_log(NULL, AV_LOG_WARNING, "https protocol not found, recompile with openssl or gnutls enabled.\n");
return AVERROR_PROTOCOL_NOT_FOUND;
}
@@ -376,6 +388,13 @@ int ffurl_close(URLContext *h)
}
+const char *avio_find_protocol_name(const char *url)
+{
+ URLProtocol *p = url_find_protocol(url);
+
+ return p ? p->name : NULL;
+}
+
int avio_check(const char *url, int flags)
{
URLContext *h;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 4f4ac3cbaf..bf23171502 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -151,6 +151,15 @@ typedef struct AVIOContext {
/* unbuffered I/O */
/**
+ * Return the name of the protocol that will handle the passed URL.
+ *
+ * NULL is returned if no protocol could be found for the given URL.
+ *
+ * @return Name of the protocol or NULL.
+ */
+const char *avio_find_protocol_name(const char *url);
+
+/**
* Return AVIO_FLAG_* access flags corresponding to the access permissions
* of the resource in url, or a negative value corresponding to an
* AVERROR code in case of failure. The returned access flags are
diff --git a/libavformat/version.h b/libavformat/version.h
index 9e7bcf798f..9f0695c86d 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,8 +30,8 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
-#define LIBAVFORMAT_VERSION_MINOR 32
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MINOR 33
+#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \