From: Stefano Sabatini <[email protected]>
---
libavformat/avio.c | 16 ++++++++++++++++
libavformat/avio.h | 9 +++++++++
libavformat/url.h | 1 +
3 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index ad1f1b4..ecc7f27 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -374,6 +374,22 @@ int url_exist(const char *filename)
return 1;
}
+int avio_check(const char *url, int flags)
+{
+ URLContext *h;
+ int ret = url_alloc(&h, url, flags);
+ if (ret)
+ return ret;
+
+ if (h->prot->url_check)
+ ret = h->prot->url_check(h, flags);
+ else
+ ret = (ret = url_connect(h)) < 0 ? ret : 1;
+
+ url_close(h);
+ return ret;
+}
+
int64_t ffurl_size(URLContext *h)
{
int64_t pos, size;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 7bb8d17..823aa97 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -126,6 +126,14 @@ attribute_deprecated void url_set_interrupt_cb(int
(*interrupt_cb)(void));
int url_exist(const char *url);
/**
+ * Return a positive value if the resource indicated by url can be
+ * accessed with the mode indicated by flags, 0 if the resource cannot
+ * be accessed in that way, a negative value corresponding to an
+ * AVERROR code in case of failure.
+ */
+int avio_check(const char *url, int flags);
+
+/**
* The callback is called in blocking functions to test regulary if
* asynchronous interruption is needed. AVERROR_EXIT is returned
* in this case by the interrupted function. 'NULL' means no interrupt
@@ -159,6 +167,7 @@ typedef struct URLProtocol {
int priv_data_size;
const AVClass *priv_data_class;
int flags;
+ int (*url_check)(URLContext *h, int flags);
} URLProtocol;
#endif
diff --git a/libavformat/url.h b/libavformat/url.h
index bde06d9..7a39b9c 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -59,6 +59,7 @@ typedef struct URLProtocol {
int priv_data_size;
const AVClass *priv_data_class;
int flags;
+ int (*url_check)(URLContext *h, int flags);
} URLProtocol;
#endif
--
1.7.4.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel