summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2021-10-18 00:35:48 +0300
committerJan Ekström <jeebjp@gmail.com>2021-10-24 13:04:39 +0300
commit682bafdb12507ec8b049ecbbe2e48bf814927002 (patch)
treec2e7df981e2c02d9f5013d8f2d2242f131bfad77 /libavformat/aviobuf.c
parenta5622ed16f8e22a80cecd8936799e61f61a74cd5 (diff)
avformat/avio{,buf}: introduce public AVIOContext::bytes_{read,written}
Such fields can be seen as generally useful in cases where the API user is not implementing custom AVIO callbacks, but still would like to know if data is being read or written out, such as in case data is being read from input but no AVPacket has been received yet.
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index f21f1c89df..5da4dea7b6 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -169,6 +169,9 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len)
if (ret < 0) {
s->error = ret;
} else {
+ ctx->bytes_written += len;
+ s->bytes_written = ctx->bytes_written;
+
if (s->pos + len > ctx->written_output_size) {
ctx->written_output_size = s->pos + len;
#if FF_API_AVIOCONTEXT_WRITTEN
@@ -584,6 +587,7 @@ static void fill_buffer(AVIOContext *s)
s->buf_ptr = dst;
s->buf_end = dst + len;
ffiocontext(s)->bytes_read += len;
+ s->bytes_read = ffiocontext(s)->bytes_read;
}
}
@@ -657,6 +661,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
} else {
s->pos += len;
ffiocontext(s)->bytes_read += len;
+ s->bytes_read = ffiocontext(s)->bytes_read;
size -= len;
buf += len;
// reset the buffer
@@ -1236,8 +1241,9 @@ int avio_close(AVIOContext *s)
av_freep(&s->buffer);
if (s->write_flag)
- av_log(s, AV_LOG_VERBOSE, "Statistics: %d seeks, %d writeouts\n",
- ctx->seek_count, ctx->writeout_count);
+ av_log(s, AV_LOG_VERBOSE,
+ "Statistics: %"PRId64" bytes written, %d seeks, %d writeouts\n",
+ ctx->bytes_written, ctx->seek_count, ctx->writeout_count);
else
av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n",
ctx->bytes_read, ctx->seek_count);