summaryrefslogtreecommitdiff
path: root/libavformat/img2dec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-01-16 17:53:43 +0100
committerAnton Khirnov <anton@khirnov.net>2016-01-24 16:45:32 +0100
commit9f61abc8111c7c43f49ca012e957a108b9cc7610 (patch)
tree87af58cf56a1298f4b9b6a242d9c3a9451388ec8 /libavformat/img2dec.c
parent68395f8c99393c281a08139d20a7a04398b2fd04 (diff)
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.
Diffstat (limited to 'libavformat/img2dec.c')
-rw-r--r--libavformat/img2dec.c5
1 files changed, 2 insertions, 3 deletions
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];
}