From 8c0ceafb0f25da077ff23e394667119f031574fd Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 19 Feb 2016 18:02:45 +0100 Subject: urlprotocol: receive a list of protocols from the caller This way, the decisions about which protocols are available for use in any given situations can be delegated to the caller. --- libavformat/aviobuf.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'libavformat/aviobuf.c') diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 18c3945c30..20bef66029 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -42,6 +42,7 @@ typedef struct AVIOInternal { URLContext *h; + const URLProtocol **protocols; } AVIOInternal; static void *ff_avio_child_next(void *obj, void *prev) @@ -846,17 +847,31 @@ int avio_open(AVIOContext **s, const char *filename, int flags) int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options) { + AVIOInternal *internal; + const URLProtocol **protocols; URLContext *h; int err; - err = ffurl_open(&h, filename, flags, int_cb, options); - if (err < 0) + protocols = ffurl_get_protocols(NULL, NULL); + if (!protocols) + return AVERROR(ENOMEM); + + err = ffurl_open(&h, filename, flags, int_cb, options, protocols); + if (err < 0) { + av_freep(&protocols); return err; + } + err = ffio_fdopen(s, h); if (err < 0) { ffurl_close(h); + av_freep(&protocols); return err; } + + internal = (*s)->opaque; + internal->protocols = protocols; + return 0; } @@ -872,6 +887,7 @@ int avio_close(AVIOContext *s) internal = s->opaque; h = internal->h; + av_freep(&internal->protocols); av_freep(&s->opaque); av_freep(&s->buffer); av_free(s); -- cgit v1.2.3