[PATCH 1/3] Add url_check() function.
Stefano Sabatini
stefano.sabatini-lala
Thu Sep 30 12:45:32 CEST 2010
---
libavformat/avio.c | 16 ++++++++++++++++
libavformat/avio.h | 9 +++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 4399878..ac23d59 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -285,6 +285,22 @@ int url_exist(const char *filename)
return 1;
}
+int url_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 url_filesize(URLContext *h)
{
int64_t pos, size;
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 1e97357..db5f081 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -166,6 +166,14 @@ int url_close(URLContext *h);
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 url_check(const char *url, int flags);
+
+/**
* Return the filesize of the resource accessed by h, AVERROR(ENOSYS)
* if the operation is not supported by h, or another negative value
* corresponding to an AVERROR error code in case of failure.
@@ -259,6 +267,7 @@ typedef struct URLProtocol {
int (*url_get_file_handle)(URLContext *h);
int priv_data_size;
const AVClass *priv_data_class;
+ int (*url_check)(URLContext *h, int flags);
} URLProtocol;
#if FF_API_REGISTER_PROTOCOL
--
1.7.1
--uAKRQypu60I7Lcqm--
More information about the ffmpeg-devel
mailing list