summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-04-13 19:49:20 -0300
committerJames Almer <jamrial@gmail.com>2017-04-13 19:49:20 -0300
commit34d7f337c1608c72be8c36355018dc894f0560ce (patch)
treed9546d39b216ab49903f3208d316837451411a9c /libavformat
parentc5fd47fa8a300fc51489a47da94041609545803c (diff)
parent3f75e5116b900f1428aa13041fc7d6301bf1988a (diff)
downloadffmpeg-34d7f337c1608c72be8c36355018dc894f0560ce.tar.gz
Merge commit '3f75e5116b900f1428aa13041fc7d6301bf1988a'
* commit '3f75e5116b900f1428aa13041fc7d6301bf1988a': avio: Keep track of the amount of data written Merged-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avio.h2
-rw-r--r--libavformat/aviobuf.c7
-rw-r--r--libavformat/version.h2
3 files changed, 10 insertions, 1 deletions
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 6f4ed8440d..525eb7129e 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -327,6 +327,8 @@ typedef struct AVIOContext {
* This is current internal only, do not use from outside.
*/
int (*short_seek_get)(void *opaque);
+
+ int64_t written;
} AVIOContext;
/**
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index ef6a0d4e9b..0a7c39eacd 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -120,6 +120,7 @@ int ffio_init_context(AVIOContext *s,
s->current_type = AVIO_DATA_MARKER_UNKNOWN;
s->last_time = AV_NOPTS_VALUE;
s->short_seek_get = NULL;
+ s->written = 0;
return 0;
}
@@ -154,6 +155,9 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len)
ret = s->write_packet(s->opaque, (uint8_t *)data, len);
if (ret < 0) {
s->error = ret;
+ } else {
+ if (s->pos + len > s->written)
+ s->written = s->pos + len;
}
}
if (s->current_type == AVIO_DATA_MARKER_SYNC_POINT ||
@@ -323,6 +327,9 @@ int64_t avio_size(AVIOContext *s)
if (!s)
return AVERROR(EINVAL);
+ if (s->written)
+ return s->written;
+
if (!s->seek)
return AVERROR(ENOSYS);
size = s->seek(s->opaque, 0, AVSEEK_SIZE);
diff --git a/libavformat/version.h b/libavformat/version.h
index 0920b48145..411fd6613d 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 57
#define LIBAVFORMAT_VERSION_MINOR 72
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \