diff options
author | Anton Khirnov <anton@khirnov.net> | 2016-02-19 18:02:45 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2016-02-22 11:45:31 +0100 |
commit | 8c0ceafb0f25da077ff23e394667119f031574fd (patch) | |
tree | c495ca2679de2d9c0bc436652cfb5764cee47905 /libavformat/aviobuf.c | |
parent | cae448cfbf31d492cba782bc64fc4eed556ed83d (diff) | |
download | ffmpeg-8c0ceafb0f25da077ff23e394667119f031574fd.tar.gz |
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.
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 20 |
1 files changed, 18 insertions, 2 deletions
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); |