diff options
author | Martin Storsjö <martin@martin.st> | 2015-02-28 02:00:50 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2016-03-24 10:34:19 +0200 |
commit | fab8156b2f30666adabe227b3d7712fd193873b1 (patch) | |
tree | 025734e80fdf8862c1769bb039d1d895e1bf82c8 /libavformat | |
parent | 564b4591bbe223bdc5f36a1131eaef103f23f5d0 (diff) | |
download | ffmpeg-fab8156b2f30666adabe227b3d7712fd193873b1.tar.gz |
avio: Copy URLContext generic options into child URLContexts
Since all URLContexts have the same AVOptions, such AVOptions
will be applied on the outermost context only and removed from the
dict, while they probably make sense on all contexts.
This makes sure that rw_timeout gets propagated to the innermost
URLContext (to make sure it gets passed to the tcp protocol, when
opening a http connection for instance).
Alternatively, such matching options would be kept in the dict
and only removed after the ffurl_connect call.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avio.c | 5 | ||||
-rw-r--r-- | libavformat/aviobuf.c | 2 | ||||
-rw-r--r-- | libavformat/concat.c | 2 | ||||
-rw-r--r-- | libavformat/crypto.c | 2 | ||||
-rw-r--r-- | libavformat/gopher.c | 2 | ||||
-rw-r--r-- | libavformat/hlsproto.c | 2 | ||||
-rw-r--r-- | libavformat/http.c | 4 | ||||
-rw-r--r-- | libavformat/icecast.c | 2 | ||||
-rw-r--r-- | libavformat/md5proto.c | 2 | ||||
-rw-r--r-- | libavformat/mmst.c | 2 | ||||
-rw-r--r-- | libavformat/rtmpcrypt.c | 2 | ||||
-rw-r--r-- | libavformat/rtmpproto.c | 4 | ||||
-rw-r--r-- | libavformat/rtpproto.c | 4 | ||||
-rw-r--r-- | libavformat/rtsp.c | 10 | ||||
-rw-r--r-- | libavformat/rtspdec.c | 4 | ||||
-rw-r--r-- | libavformat/sapdec.c | 2 | ||||
-rw-r--r-- | libavformat/sapenc.c | 4 | ||||
-rw-r--r-- | libavformat/smoothstreamingenc.c | 6 | ||||
-rw-r--r-- | libavformat/srtpproto.c | 2 | ||||
-rw-r--r-- | libavformat/tls.c | 2 | ||||
-rw-r--r-- | libavformat/url.h | 4 |
21 files changed, 37 insertions, 32 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c index 6039990990..1692f1ba47 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -174,11 +174,14 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags, int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, - const URLProtocol **protocols) + const URLProtocol **protocols, + URLContext *parent) { int ret = ffurl_alloc(puc, filename, flags, int_cb, protocols); if (ret) return ret; + if (parent) + av_opt_copy(*puc, parent); if (options && (ret = av_opt_set_dict(*puc, options)) < 0) goto fail; diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index a2edb74974..29fccbea83 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -905,7 +905,7 @@ int avio_open2(AVIOContext **s, const char *filename, int flags, if (!protocols) return AVERROR(ENOMEM); - err = ffurl_open(&h, filename, flags, int_cb, options, protocols); + err = ffurl_open(&h, filename, flags, int_cb, options, protocols, NULL); if (err < 0) { av_freep(&protocols); return err; diff --git a/libavformat/concat.c b/libavformat/concat.c index ecdf5dfeb7..a338df61ce 100644 --- a/libavformat/concat.c +++ b/libavformat/concat.c @@ -95,7 +95,7 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) /* creating URLContext */ if ((err = ffurl_open(&uc, node_uri, flags, - &h->interrupt_callback, NULL, h->protocols)) < 0) + &h->interrupt_callback, NULL, h->protocols, h)) < 0) break; /* creating size */ diff --git a/libavformat/crypto.c b/libavformat/crypto.c index a364dc0af5..55430c48e5 100644 --- a/libavformat/crypto.c +++ b/libavformat/crypto.c @@ -83,7 +83,7 @@ static int crypto_open(URLContext *h, const char *uri, int flags) goto err; } if ((ret = ffurl_open(&c->hd, nested_url, AVIO_FLAG_READ, - &h->interrupt_callback, NULL, h->protocols)) < 0) { + &h->interrupt_callback, NULL, h->protocols, h)) < 0) { av_log(h, AV_LOG_ERROR, "Unable to open input\n"); goto err; } diff --git a/libavformat/gopher.c b/libavformat/gopher.c index afa2b7d68b..6d9fc38d8c 100644 --- a/libavformat/gopher.c +++ b/libavformat/gopher.c @@ -94,7 +94,7 @@ static int gopher_open(URLContext *h, const char *uri, int flags) s->hd = NULL; err = ffurl_open(&s->hd, buf, AVIO_FLAG_READ_WRITE, - &h->interrupt_callback, NULL, h->protocols); + &h->interrupt_callback, NULL, h->protocols, h); if (err < 0) goto fail; diff --git a/libavformat/hlsproto.c b/libavformat/hlsproto.c index b01cef0008..4c3048a790 100644 --- a/libavformat/hlsproto.c +++ b/libavformat/hlsproto.c @@ -304,7 +304,7 @@ retry: url = s->segments[s->cur_seq_no - s->start_seq_no]->url, av_log(h, AV_LOG_DEBUG, "opening %s\n", url); ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ, - &h->interrupt_callback, NULL, h->protocols); + &h->interrupt_callback, NULL, h->protocols, h); if (ret < 0) { if (ff_check_interrupt(&h->interrupt_callback)) return AVERROR_EXIT; diff --git a/libavformat/http.c b/libavformat/http.c index 48303908b5..8fe8d11e1e 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -181,7 +181,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) if (!s->hd) { err = ffurl_open(&s->hd, buf, AVIO_FLAG_READ_WRITE, - &h->interrupt_callback, options, h->protocols); + &h->interrupt_callback, options, h->protocols, h); if (err < 0) return err; } @@ -1079,7 +1079,7 @@ static int http_proxy_open(URLContext *h, const char *uri, int flags) NULL); redo: ret = ffurl_open(&s->hd, lower_url, AVIO_FLAG_READ_WRITE, - &h->interrupt_callback, NULL, h->protocols); + &h->interrupt_callback, NULL, h->protocols, h); if (ret < 0) return ret; diff --git a/libavformat/icecast.c b/libavformat/icecast.c index 78238378b7..820681b953 100644 --- a/libavformat/icecast.c +++ b/libavformat/icecast.c @@ -177,7 +177,7 @@ static int icecast_open(URLContext *h, const char *uri, int flags) ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, "%s", path); // Finally open http proto handler ret = ffurl_open(&s->hd, h_url, AVIO_FLAG_READ_WRITE, NULL, &opt_dict, - h->protocols); + h->protocols, h); cleanup: // Free variables diff --git a/libavformat/md5proto.c b/libavformat/md5proto.c index 07c085a561..08cdd71ea1 100644 --- a/libavformat/md5proto.c +++ b/libavformat/md5proto.c @@ -71,7 +71,7 @@ static int md5_close(URLContext *h) if (*filename) { err = ffurl_open(&out, filename, AVIO_FLAG_WRITE, &h->interrupt_callback, NULL, - h->protocols); + h->protocols, h); if (err) return err; err = ffurl_write(out, buf, i*2+1); diff --git a/libavformat/mmst.c b/libavformat/mmst.c index aeddf0fd1d..1489076ad3 100644 --- a/libavformat/mmst.c +++ b/libavformat/mmst.c @@ -520,7 +520,7 @@ static int mms_open(URLContext *h, const char *uri, int flags) // establish tcp connection. ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, mmst->host, port, NULL); err = ffurl_open(&mms->mms_hd, tcpname, AVIO_FLAG_READ_WRITE, - &h->interrupt_callback, NULL, h->protocols); + &h->interrupt_callback, NULL, h->protocols, h); if (err) goto fail; diff --git a/libavformat/rtmpcrypt.c b/libavformat/rtmpcrypt.c index 75fc1283c5..cf121c635a 100644 --- a/libavformat/rtmpcrypt.c +++ b/libavformat/rtmpcrypt.c @@ -265,7 +265,7 @@ static int rtmpe_open(URLContext *h, const char *uri, int flags) /* open the tcp or ffrtmphttp connection */ if ((ret = ffurl_open(&rt->stream, url, AVIO_FLAG_READ_WRITE, - &h->interrupt_callback, NULL, h->protocols)) < 0) { + &h->interrupt_callback, NULL, h->protocols, h)) < 0) { rtmpe_close(h); return ret; } diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 9ed3d0f436..d4f35f6b19 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -1119,7 +1119,7 @@ static int rtmp_calc_swfhash(URLContext *s) /* Get the SWF player file. */ if ((ret = ffurl_open(&stream, rt->swfverify, AVIO_FLAG_READ, - &s->interrupt_callback, NULL, s->protocols)) < 0) { + &s->interrupt_callback, NULL, s->protocols, s)) < 0) { av_log(s, AV_LOG_ERROR, "Cannot open connection %s.\n", rt->swfverify); goto fail; } @@ -2641,7 +2641,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) reconnect: if ((ret = ffurl_open(&rt->stream, buf, AVIO_FLAG_READ_WRITE, - &s->interrupt_callback, &opts, s->protocols)) < 0) { + &s->interrupt_callback, &opts, s->protocols, s)) < 0) { av_log(s , AV_LOG_ERROR, "Cannot open connection %s\n", buf); goto fail; } diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 50b8d249ce..6582e4ad76 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -369,7 +369,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) build_udp_url(s, buf, sizeof(buf), hostname, rtp_port, s->local_rtpport, sources, block); if (ffurl_open(&s->rtp_hd, buf, flags, &h->interrupt_callback, NULL, - h->protocols) < 0) + h->protocols, h) < 0) goto fail; if (s->local_rtpport >= 0 && s->local_rtcpport < 0) s->local_rtcpport = ff_udp_get_local_port(s->rtp_hd) + 1; @@ -377,7 +377,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) build_udp_url(s, buf, sizeof(buf), hostname, s->rtcp_port, s->local_rtcpport, sources, block); if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback, NULL, - h->protocols) < 0) + h->protocols, h) < 0) goto fail; /* just to ease handle access. XXX: need to suppress direct handle diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index dc07422349..7e430e838b 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1466,7 +1466,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, /* we will use two ports per rtp stream (rtp and rtcp) */ j += 2; err = ffurl_open(&rtsp_st->rtp_handle, buf, AVIO_FLAG_READ_WRITE, - &s->interrupt_callback, &opts, rt->protocols); + &s->interrupt_callback, &opts, rt->protocols, NULL); av_dict_free(&opts); @@ -1610,7 +1610,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, ff_url_join(url, sizeof(url), "rtp", NULL, namebuf, port, "%s", optbuf); if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE, - &s->interrupt_callback, NULL, rt->protocols) < 0) { + &s->interrupt_callback, NULL, rt->protocols, NULL) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1804,7 +1804,7 @@ redirect: ff_url_join(tcpname, sizeof(tcpname), lower_rtsp_proto, NULL, host, port, NULL); if (ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE, - &s->interrupt_callback, NULL, rt->protocols) < 0) { + &s->interrupt_callback, NULL, rt->protocols, NULL) < 0) { err = AVERROR(EIO); goto fail; } @@ -2311,7 +2311,7 @@ static int sdp_read_header(AVFormatContext *s) rtsp_st->nb_exclude_source_addrs, rtsp_st->exclude_source_addrs); err = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE, - &s->interrupt_callback, &opts, rt->protocols); + &s->interrupt_callback, &opts, rt->protocols, NULL); av_dict_free(&opts); @@ -2388,7 +2388,7 @@ static int rtp_read_header(AVFormatContext *s) } ret = ffurl_open(&in, s->filename, AVIO_FLAG_READ, - &s->interrupt_callback, NULL, rt->protocols); + &s->interrupt_callback, NULL, rt->protocols, NULL); if (ret) goto fail; diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index 7b6a0258c8..03374dc0e6 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -295,7 +295,7 @@ static int rtsp_read_setup(AVFormatContext *s, char* host, char *controlurl) ff_url_join(url, sizeof(url), "rtp", NULL, host, localport, NULL); av_log(s, AV_LOG_TRACE, "Opening: %s", url); ret = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE, - &s->interrupt_callback, &opts, rt->protocols); + &s->interrupt_callback, &opts, rt->protocols, NULL); av_dict_free(&opts); if (ret) localport += 2; @@ -667,7 +667,7 @@ static int rtsp_listen(AVFormatContext *s) "?listen&listen_timeout=%d", rt->initial_timeout * 1000); if (ret = ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE, - &s->interrupt_callback, NULL, rt->protocols)) { + &s->interrupt_callback, NULL, rt->protocols, NULL)) { av_log(s, AV_LOG_ERROR, "Unable to open RTSP for listening\n"); return ret; } diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 0e99ace614..ce0ceaa81d 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -95,7 +95,7 @@ static int sap_read_header(AVFormatContext *s) ff_url_join(url, sizeof(url), "udp", NULL, host, port, "?localport=%d", port); ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_READ, - &s->interrupt_callback, NULL, sap->protocols); + &s->interrupt_callback, NULL, sap->protocols, NULL); if (ret) goto fail; diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 5786644056..ed3a0245af 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -160,7 +160,7 @@ static int sap_write_header(AVFormatContext *s) if (!same_port) base_port += 2; ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL, - sap->protocols); + sap->protocols, NULL); if (ret) { ret = AVERROR(EIO); goto fail; @@ -179,7 +179,7 @@ static int sap_write_header(AVFormatContext *s) ff_url_join(url, sizeof(url), "udp", NULL, announce_addr, port, "?ttl=%d&connect=1", ttl); ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_WRITE, - &s->interrupt_callback, NULL, sap->protocols); + &s->interrupt_callback, NULL, sap->protocols, NULL); if (ret) { ret = AVERROR(EIO); goto fail; diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index 8eba9c9a45..bf1f8d49d6 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -126,7 +126,7 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) 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, - os->protocols); + os->protocols, NULL); av_dict_free(&opts); if (ret < 0) { os->out = os->tail_out; @@ -135,7 +135,7 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) } av_dict_set(&opts, "truncate", "0", 0); ffurl_open(&os->out2, frag->infofile, AVIO_FLAG_WRITE, &os->ctx->interrupt_callback, &opts, - os->protocols); + os->protocols, NULL); av_dict_free(&opts); ffurl_seek(os->out, offset - frag->start_pos, SEEK_SET); if (os->out2) @@ -541,7 +541,7 @@ static int ism_flush(AVFormatContext *s, int final) snprintf(filename, sizeof(filename), "%s/temp", os->dirname); ret = ffurl_open(&os->out, filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL, - c->protocols); + c->protocols, NULL); if (ret < 0) break; os->cur_start_pos = os->tail_pos; diff --git a/libavformat/srtpproto.c b/libavformat/srtpproto.c index 2c64f451aa..e6e035aa3e 100644 --- a/libavformat/srtpproto.c +++ b/libavformat/srtpproto.c @@ -81,7 +81,7 @@ static int srtp_open(URLContext *h, const char *uri, int flags) path, sizeof(path), uri); ff_url_join(buf, sizeof(buf), "rtp", NULL, hostname, rtp_port, "%s", path); if ((ret = ffurl_open(&s->rtp_hd, buf, flags, &h->interrupt_callback, NULL, - h->protocols)) < 0) + h->protocols, h)) < 0) goto fail; h->max_packet_size = FFMIN(s->rtp_hd->max_packet_size, diff --git a/libavformat/tls.c b/libavformat/tls.c index a2a1ffe36d..fab243e93e 100644 --- a/libavformat/tls.c +++ b/libavformat/tls.c @@ -76,5 +76,5 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV } return ffurl_open(&c->tcp, buf, AVIO_FLAG_READ_WRITE, - &parent->interrupt_callback, options, parent->protocols); + &parent->interrupt_callback, options, parent->protocols, parent); } diff --git a/libavformat/url.h b/libavformat/url.h index 408c674ddf..5cbfd1a942 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -137,12 +137,14 @@ int ffurl_connect(URLContext *uc, AVDictionary **options); * @param protocols a NULL-terminate list of protocols available for use by * this context and its children. The caller must ensure this * list remains valid until the context is closed. + * @param parent An enclosing URLContext, whose generic options should + * be applied to this URLContext as well. * @return 0 in case of success, a negative value corresponding to an * AVERROR code in case of failure */ int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, - const URLProtocol **protocols); + const URLProtocol **protocols, URLContext *parent); /** * Read up to size bytes from the resource accessed by h, and store |