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/smoothstreamingenc.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'libavformat/smoothstreamingenc.c') diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index e1b0a63949..cfb1f8f1c9 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -64,6 +64,8 @@ typedef struct OutputStream { char *private_str; int packet_size; int audio_tag; + + const URLProtocol **protocols; } OutputStream; typedef struct SmoothStreamingContext { @@ -76,6 +78,8 @@ typedef struct SmoothStreamingContext { OutputStream *streams; int has_video, has_audio; int nb_fragments; + + const URLProtocol **protocols; } SmoothStreamingContext; static int ism_write(void *opaque, uint8_t *buf, int buf_size) @@ -121,7 +125,8 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) AVDictionary *opts = NULL; os->tail_out = os->out; av_dict_set(&opts, "truncate", "0", 0); - ret = ffurl_open(&os->out, frag->file, AVIO_FLAG_WRITE, &os->ctx->interrupt_callback, &opts); + ret = ffurl_open(&os->out, frag->file, AVIO_FLAG_WRITE, &os->ctx->interrupt_callback, &opts, + os->protocols); av_dict_free(&opts); if (ret < 0) { os->out = os->tail_out; @@ -129,7 +134,8 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) return ret; } av_dict_set(&opts, "truncate", "0", 0); - ffurl_open(&os->out2, frag->infofile, AVIO_FLAG_WRITE, &os->ctx->interrupt_callback, &opts); + ffurl_open(&os->out2, frag->infofile, AVIO_FLAG_WRITE, &os->ctx->interrupt_callback, &opts, + os->protocols); av_dict_free(&opts); ffurl_seek(os->out, offset - frag->start_pos, SEEK_SET); if (os->out2) @@ -168,6 +174,9 @@ static void ism_free(AVFormatContext *s) { SmoothStreamingContext *c = s->priv_data; int i, j; + + av_freep(&c->protocols); + if (!c->streams) return; for (i = 0; i < s->nb_streams; i++) { @@ -303,6 +312,12 @@ static int ism_write_header(AVFormatContext *s) goto fail; } + c->protocols = ffurl_get_protocols(NULL, NULL); + if (!c->protocols) { + ret = AVERROR(ENOMEM); + goto fail; + } + c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams); if (!c->streams) { ret = AVERROR(ENOMEM); @@ -327,6 +342,8 @@ static int ism_write_header(AVFormatContext *s) goto fail; } + os->protocols = c->protocols; + ctx = avformat_alloc_context(); if (!ctx) { ret = AVERROR(ENOMEM); @@ -523,7 +540,8 @@ static int ism_flush(AVFormatContext *s, int final) continue; snprintf(filename, sizeof(filename), "%s/temp", os->dirname); - ret = ffurl_open(&os->out, filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL); + ret = ffurl_open(&os->out, filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL, + c->protocols); if (ret < 0) break; os->cur_start_pos = os->tail_pos; -- cgit v1.2.3