aboutsummaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorsoftworkz2017-01-05 01:33:26 +0100
committerMichael Niedermayer2017-01-07 13:04:05 +0100
commit9488032e10b744335059b48e7a134efd5d9359c3 (patch)
tree765159ddabd70f2bb20dac7658a50a8088e4ac6b /libavformat/aviobuf.c
parent90ac9f4094afc2aa7ee64a7b02df8fb05cbd7d8a (diff)
libavformat/avio: Add avio_get_dyn_buf function
This commit adds the avio_get_dyn_buf function which allows accessing the content of a DynBuffer without destroying it. This is required in matroskaenc for preliminary writing (correct) mkv headers. Context for this change is fixing regression bug #5977. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 134d627a6e..bf7e5f85a0 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1277,6 +1277,23 @@ int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
return url_open_dyn_buf_internal(s, max_packet_size);
}
+int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
+{
+ DynBuffer *d;
+
+ if (!s) {
+ *pbuffer = NULL;
+ return 0;
+ }
+
+ avio_flush(s);
+
+ d = s->opaque;
+ *pbuffer = d->buffer;
+
+ return d->size;
+}
+
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
{
DynBuffer *d;