summaryrefslogtreecommitdiff
path: root/libavformat/options.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/options.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/options.c')
-rw-r--r--libavformat/options.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libavformat/options.c b/libavformat/options.c
index a6fbbd2623..c7fa51f41f 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -90,12 +90,26 @@ static const AVClass av_format_context_class = {
.child_class_next = format_child_class_next,
};
+static int io_open_default(AVFormatContext *s, AVIOContext **pb,
+ const char *url, int flags, AVDictionary **options)
+{
+ return avio_open2(pb, url, flags, &s->interrupt_callback, options);
+}
+
+static void io_close_default(AVFormatContext *s, AVIOContext *pb)
+{
+ avio_close(pb);
+}
+
static void avformat_get_context_defaults(AVFormatContext *s)
{
memset(s, 0, sizeof(AVFormatContext));
s->av_class = &av_format_context_class;
+ s->io_open = io_open_default;
+ s->io_close = io_close_default;
+
av_opt_set_defaults(s);
}