[FFmpeg-cvslog] aviobuf: Partial support for reading in read/write contexts
Martin Storsjö
git at videolan.org
Fri Jan 4 13:11:51 CET 2013
ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Tue Jan 1 22:57:36 2013 +0200| [a0b7e289075dccf223b7f407790d8a86fc5d77e8] | committer: Martin Storsjö
aviobuf: Partial support for reading in read/write contexts
So far, aviocontexts are used either in pure-read or pure-write
mode - full read/write mode doesn't work well (and implementing it
is a much larger, not totally trivial change).
This patch allows using avio_read and ffio_read_partial on
read/write aviocontexts, where the read operations are passed
through directly unbuffered, while writes are buffered as usual.
This is enough to support the operations needed by packet based
data transfer like in udp/rtp, where aviocontext is the only
public API for hooking up custom IO.
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0b7e289075dccf223b7f407790d8a86fc5d77e8
---
libavformat/aviobuf.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 0da1e05..8f3e511 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -452,7 +452,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
len = s->buf_end - s->buf_ptr;
if (len > size)
len = size;
- if (len == 0) {
+ if (len == 0 || s->write_flag) {
if(size > s->buffer_size && !s->update_checksum){
if(s->read_packet)
len = s->read_packet(s->opaque, buf, size);
@@ -497,6 +497,13 @@ int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size)
if (size < 0)
return -1;
+ if (s->read_packet && s->write_flag) {
+ len = s->read_packet(s->opaque, buf, size);
+ if (len > 0)
+ s->pos += len;
+ return len;
+ }
+
len = s->buf_end - s->buf_ptr;
if (len == 0) {
fill_buffer(s);
More information about the ffmpeg-cvslog
mailing list