[FFmpeg-devel] [PATCH 2/3] lavf/avio: Introduce avio_check_if_protocol

Alexander Strasser eclipse7 at gmx.net
Thu Jan 2 20:22:14 CET 2014


Create a function that behaves identical to avio_check except
that it checks the resource only if the URL is handled by the
specified protocol.

TODO: documentation
TODO: version bump

Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 libavformat/avio.c | 10 +++++++++-
 libavformat/avio.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 225d982..8190a15 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -376,13 +376,16 @@ int ffurl_close(URLContext *h)
 }
 
 
-int avio_check(const char *url, int flags)
+int avio_check_if_protocol(const char *prot_name, const char *url, int flags)
 {
     URLContext *h;
     int ret = ffurl_alloc(&h, url, flags, NULL);
     if (ret)
         return ret;
 
+    if (prot_name && strcmp(h->prot->name, prot_name))
+        return AVERROR(EINVAL);
+
     if (h->prot->url_check) {
         ret = h->prot->url_check(h, flags);
     } else {
@@ -395,6 +398,11 @@ int avio_check(const char *url, int flags)
     return ret;
 }
 
+int avio_check(const char *url, int flags)
+{
+    return avio_check_if_protocol(NULL, url, flags);
+}
+
 int64_t ffurl_size(URLContext *h)
 {
     int64_t pos, size;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 4f4ac3c..6130fb6 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -163,6 +163,7 @@ typedef struct AVIOContext {
  * checked resource.
  */
 int avio_check(const char *url, int flags);
+int avio_check_if_protocol(const char *prot_name, const char *url, int flags);
 
 /**
  * Allocate and initialize an AVIOContext for buffered I/O. It must be later
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140102/08d58700/attachment.asc>


More information about the ffmpeg-devel mailing list