summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorBjörn Axelsson <gecko@acc.umu.se>2007-11-28 19:46:49 +0000
committerAndreas Öman <andreas@lonelycoder.com>2007-11-28 19:46:49 +0000
commite7e4810aaef4c11b9a2d62c5656d76917bdd5a27 (patch)
tree3b8797d6f3a426e4acbd1ff6eff55c7ca0626e3b /libavformat/aviobuf.c
parent6b493b2f2fd241f6b893f6aa549f10aee1b9ad0c (diff)
Extend ByteIOContext and add the buffered IO functions:
av_url_read_fplay(), av_url_read_fpause() and av_url_read_fseek(). patch by: Björn Axelsson, bjorn d axelsson a intinor d se Originally committed as revision 11110 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index c79f51fe65..328b53d336 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -55,6 +55,9 @@ int init_put_byte(ByteIOContext *s,
s->pos = buffer_size;
s->buf_end = s->buffer + buffer_size;
}
+ s->read_play = NULL;
+ s->read_pause = NULL;
+ s->read_seek = NULL;
return 0;
}
@@ -551,6 +554,11 @@ int url_fdopen(ByteIOContext **s, URLContext *h)
}
(*s)->is_streamed = h->is_streamed;
(*s)->max_packet_size = max_packet_size;
+ if(h->prot) {
+ (*s)->read_play = (int (*)(void *))h->prot->url_read_play;
+ (*s)->read_pause = (int (*)(void *))h->prot->url_read_pause;
+ (*s)->read_seek = (int (*)(void *, int, int64_t, int))h->prot->url_read_seek;
+ }
return 0;
}
@@ -656,6 +664,35 @@ int url_fget_max_packet_size(ByteIOContext *s)
return s->max_packet_size;
}
+int av_url_read_fplay(ByteIOContext *s)
+{
+ if (!s->read_play)
+ return AVERROR(ENOSYS);
+ return s->read_play(s->opaque);
+}
+
+int av_url_read_fpause(ByteIOContext *s)
+{
+ if (!s->read_pause)
+ return AVERROR(ENOSYS);
+ return s->read_pause(s->opaque);
+}
+
+int av_url_read_fseek(ByteIOContext *s,
+ int stream_index, int64_t timestamp, int flags)
+{
+ URLContext *h = s->opaque;
+ int ret;
+ if (!s->read_seek)
+ return AVERROR(ENOSYS);
+ ret = s->read_seek(h, stream_index, timestamp, flags);
+ if(ret >= 0) {
+ s->buf_ptr = s->buf_end; // Flush buffer
+ s->pos = s->seek(h, 0, SEEK_CUR);
+ }
+ return ret;
+}
+
/* url_open_dyn_buf and url_close_dyn_buf are used in rtp.c to send a response
* back to the server even if CONFIG_MUXERS is not set. */
#if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK)