[FFmpeg-cvslog] avio: Introduce avio_read_to_bprint(avioctx, bp, max_size)
Andrey Utkin
git at videolan.org
Wed Jul 23 18:56:56 CEST 2014
ffmpeg | branch: master | Andrey Utkin <andrey.krieger.utkin at gmail.com> | Wed Jul 23 16:12:38 2014 +0300| [8a4c0866dc7d718b5ee3f0af60d4317cd133d83f] | committer: Michael Niedermayer
avio: Introduce avio_read_to_bprint(avioctx, bp, max_size)
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a4c0866dc7d718b5ee3f0af60d4317cd133d83f
---
doc/APIchanges | 3 +++
libavformat/avio.h | 9 +++++++++
libavformat/aviobuf.c | 18 ++++++++++++++++++
libavformat/version.h | 4 ++--
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 1a9d103..22a6be8 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2012-10-22
API changes, most recent first:
+2014-07-23 - XXXXXXX - lavf 55.49.100 - avio.h
+ Add avio_read_to_bprint()
+
2014-07-14 - 62227a7 - lavf 55.47.100 - avformat.h
Add av_stream_get_parser()
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 4004b6f..9b16843 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -31,6 +31,7 @@
#include "libavutil/common.h"
#include "libavutil/dict.h"
#include "libavutil/log.h"
+#include "libavutil/bprint.h"
#include "libavformat/version.h"
@@ -500,4 +501,12 @@ int avio_pause(AVIOContext *h, int pause);
int64_t avio_seek_time(AVIOContext *h, int stream_index,
int64_t timestamp, int flags);
+/**
+ * Read contents of h into print buffer, up to max_size bytes, or up to EOF.
+ *
+ * @return 0 for success (max_size bytes read or EOF reached), negative error
+ * code otherwise
+ */
+int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size);
+
#endif /* AVFORMAT_AVIO_H */
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 738459e..463d90a 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 {
diff --git a/libavformat/version.h b/libavformat/version.h
index 4e28112..5ad2338 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,8 +30,8 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
-#define LIBAVFORMAT_VERSION_MINOR 48
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MINOR 49
+#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list