summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorAndrey Utkin <andrey.krieger.utkin@gmail.com>2014-07-23 16:12:38 +0300
committerMichael Niedermayer <michaelni@gmx.at>2014-07-23 18:42:41 +0200
commit8a4c0866dc7d718b5ee3f0af60d4317cd133d83f (patch)
treecde11a6076754e2c00e5dce8b6139684e89e3b9c /libavformat/aviobuf.c
parent01b236b70438527946b0dd79894c0105bc668c91 (diff)
avio: Introduce avio_read_to_bprint(avioctx, bp, max_size)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 738459e830..463d90a0d3 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -953,6 +953,24 @@ int64_t avio_seek_time(AVIOContext *s, int stream_index,
return ret;
}
+int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
+{
+ int ret;
+ char buf[1024];
+ while (max_size) {
+ ret = avio_read(h, buf, FFMIN(max_size, sizeof(buf)));
+ if (ret == AVERROR_EOF)
+ return 0;
+ if (ret <= 0)
+ return ret;
+ av_bprint_append_data(pb, buf, ret);
+ if (!av_bprint_is_complete(pb))
+ return AVERROR(ENOMEM);
+ max_size -= ret;
+ }
+ return 0;
+}
+
/* output in a dynamic buffer */
typedef struct DynBuffer {