[FFmpeg-devel] avformat/utils: use AVIOContext.read_seek for seeks if available

Submitted by Aman Gupta on April 3, 2019, 10:55 a.m.

Details

Message ID 20190403105529.88874-1-ffmpeg@tmm1.net
State New
Headers show

Commit Message

Aman Gupta April 3, 2019, 10:55 a.m.
From: Aman Gupta <aman@tmm1.net>

Currently only flv and asf decoders attempt to use pb->read_seek,
by calling avio_read_seek() expliclity.

This change allows avformat users to specify a custom AVIOContext
with a read_seek callback, and have it be used with any format
whenever av_seek_frame() is invoked.

Signed-off-by: Aman Gupta <aman@tmm1.net>
---
 libavformat/utils.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9b3f0d28e6..b38727b3ed 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2487,6 +2487,9 @@  static int seek_frame_internal(AVFormatContext *s, int stream_index,
     if (s->iformat->read_seek) {
         ff_read_frame_flush(s);
         ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
+    } else if (s->pb->read_seek) {
+        ff_read_frame_flush(s);
+        ret = s->pb->read_seek(s->pb->opaque, stream_index, timestamp, flags);
     } else
         ret = -1;
     if (ret >= 0)