diff options
author | Björn Axelsson <gecko@acc.umu.se> | 2007-10-11 14:57:47 +0000 |
---|---|---|
committer | Benoit Fouet <benoit.fouet@free.fr> | 2007-10-11 14:57:47 +0000 |
commit | 770d9dafa1b329a2ee2366ce5357068d6445630d (patch) | |
tree | 2c7bc78a4771d118f19a36694ddd91e933e07cf4 /libavformat/aviobuf.c | |
parent | 3ea7841120c5b4871a0d571bbab04818d72dd274 (diff) | |
download | ffmpeg-770d9dafa1b329a2ee2366ce5357068d6445630d.tar.gz |
Add functionality to set the direction of a ByteIOContext buffer.
Patch by Björn Axelsson bjorn axelsson intinor se
Original thread: [FFmpeg-devel] [PATCH] MMS protocol support patch 1
Date: 09/19/2007 05:51 PM
Originally committed as revision 10709 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 195bbae035..6370f57be6 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -38,11 +38,7 @@ int init_put_byte(ByteIOContext *s, s->buffer = buffer; s->buffer_size = buffer_size; s->buf_ptr = buffer; - s->write_flag = write_flag; - if (!s->write_flag) - s->buf_end = buffer; - else - s->buf_end = buffer + buffer_size; + url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY); s->opaque = opaque; s->write_packet = write_packet; s->read_packet = read_packet; @@ -534,10 +530,23 @@ int url_setbufsize(ByteIOContext *s, int buf_size) s->buffer = buffer; s->buffer_size = buf_size; s->buf_ptr = buffer; - if (!s->write_flag) - s->buf_end = buffer; - else - s->buf_end = buffer + buf_size; + url_resetbuf(s, s->write_flag ? URL_WRONLY : URL_RDONLY); + return 0; +} + +int url_resetbuf(ByteIOContext *s, int flags) +{ + URLContext *h = s->opaque; + if ((flags & URL_RDWR) || (h && h->flags != flags && !h->flags & URL_RDWR)) + return AVERROR(EINVAL); + + if (flags & URL_WRONLY) { + s->buf_end = s->buffer + s->buffer_size; + s->write_flag = 1; + } else { + s->buf_end = s->buffer; + s->write_flag = 0; + } return 0; } |