[FFmpeg-devel] [PATCH 3/4] avio: add url_set_nonblock
Nicolas George
nicolas.george
Fri Feb 18 18:59:22 CET 2011
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavformat/avio.c | 13 +++++++++++++
libavformat/avio.h | 7 +++++++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 4d2848a..a433ebb 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -357,3 +357,16 @@ int64_t av_url_read_seek(URLContext *h,
return AVERROR(ENOSYS);
return h->prot->url_read_seek(h, stream_index, timestamp, flags);
}
+
+int url_set_nonblock(URLContext *h, int nonblock)
+{
+ do {
+ int f = (h->flags & ~URL_FLAG_NONBLOCK) |
+ (nonblock ? URL_FLAG_NONBLOCK : 0);
+ if (h->prot->url_change_flags)
+ return h->prot->url_change_flags(h, f);
+ h->flags = f;
+ h = h->slave;
+ } while(h);
+ return 0;
+}
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 2faf5b4..1509e10 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -249,6 +249,12 @@ void url_get_filename(URLContext *h, char *buf, int buf_size);
*/
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
+/**
+ * Set the non-blocking flag
+ * @return 0 on success; no error currently possible
+ */
+int url_set_nonblock(URLContext *h, int nonblock);
+
/* not implemented */
int url_poll(URLPollEntry *poll_table, int n, int timeout);
@@ -301,6 +307,7 @@ typedef struct URLProtocol {
int (*url_get_file_handle)(URLContext *h);
int priv_data_size;
const AVClass *priv_data_class;
+ int (*url_change_flags)(URLContext *h, int new_flags);
} URLProtocol;
#if FF_API_REGISTER_PROTOCOL
--
1.7.2.3
More information about the ffmpeg-devel
mailing list