From 9f61abc8111c7c43f49ca012e957a108b9cc7610 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 16 Jan 2016 17:53:43 +0100 Subject: lavf: allow custom IO for all files Some (de)muxers open additional files beyond the main IO context. Currently, they call avio_open() directly, which prevents the caller from using custom IO for such streams. This commit adds callbacks to AVFormatContext that default to avio_open2()/avio_close(), but can be overridden by the caller. All muxers and demuxers using AVIO are switched to using those callbacks instead of calling avio_open()/avio_close() directly. (de)muxers that use the URLProtocol layer directly instead of AVIO remain unconverted for now. This should be fixed in later commits. --- libavformat/img2dec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libavformat/img2dec.c') diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index eb2508738e..ec3a829532 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -238,8 +238,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) s->img_number) < 0 && s->img_number > 1) return AVERROR(EIO); for (i = 0; i < 3; i++) { - if (avio_open2(&f[i], filename, AVIO_FLAG_READ, - &s1->interrupt_callback, NULL) < 0) { + if (s1->io_open(s1, &f[i], filename, AVIO_FLAG_READ, NULL) < 0) { if (i >= 1) break; av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n", @@ -273,7 +272,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) if (f[i]) { ret[i] = avio_read(f[i], pkt->data + pkt->size, size[i]); if (!s->is_pipe) - avio_close(f[i]); + ff_format_io_close(s1, &f[i]); if (ret[i] > 0) pkt->size += ret[i]; } -- cgit v1.2.3