[FFmpeg-devel] [PATCH 2/2] Update demuxers and protocols for protocol whitelist support
Andreas Cadhalpun
andreas.cadhalpun at googlemail.com
Tue Feb 2 00:45:32 CET 2016
On 30.01.2016 02:17, Michael Niedermayer wrote:
> From: Michael Niedermayer <michael at niedermayer.cc>
>
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
> libavdevice/lavfi.c | 7 ++++++-
> libavformat/async.c | 2 +-
> libavformat/cache.c | 3 ++-
> libavformat/concat.c | 6 ++++--
> libavformat/crypto.c | 5 +++--
> libavformat/dashenc.c | 9 +++++----
> libavformat/file.c | 2 ++
> libavformat/ftp.c | 11 +++++++----
> libavformat/gopher.c | 4 ++--
> libavformat/hdsenc.c | 13 +++++++------
> libavformat/hls.c | 8 +++++---
> libavformat/hlsenc.c | 29 +++++++++++++++--------------
> libavformat/hlsproto.c | 11 +++++++----
> libavformat/http.c | 18 ++++++++++++------
> libavformat/icecast.c | 3 ++-
> libavformat/md5proto.c | 5 +++--
> libavformat/mmst.c | 5 +++--
> libavformat/movenc.c | 2 +-
> libavformat/rtmpcrypt.c | 5 +++--
> libavformat/rtmpproto.c | 10 ++++++----
> libavformat/rtpproto.c | 10 +++++++---
> libavformat/rtsp.c | 20 ++++++++++----------
> libavformat/rtspdec.c | 10 ++++++----
> libavformat/sapdec.c | 5 +++--
> libavformat/sapenc.c | 9 ++++++---
> libavformat/segment.c | 17 +++++++++--------
> libavformat/smoothstreamingenc.c | 19 +++++++++++--------
> libavformat/srtpproto.c | 3 ++-
> libavformat/subfile.c | 4 +++-
> libavformat/tee.c | 5 ++++-
> libavformat/tls.c | 5 +++--
> libavformat/tls_securetransport.c | 5 +++--
> libavformat/webm_chunk.c | 8 +++++---
> 33 files changed, 168 insertions(+), 110 deletions(-)
Should be fine.
On 30.01.2016 01:58, Michael Niedermayer wrote:
> On Sat, Jan 30, 2016 at 12:03:48AM +0100, Andreas Cadhalpun wrote:
>> This looks mostly fine. I tested a few protocols and it worked as intended.
>> However, it doesn't forward the whitelist when ffurl_connect is called directly, which
>> happens in the hls demuxer and the mmsh, rtmphttp and rtsp protocols.
>> I think that should be done, too.
>
> fixed hls, others left to volunteers, i have no testcases for them
I don't see how hls is fixed, but don't have testcases either.
Anyway, the following should work:
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 0883cb5..a87bf2e 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1131,6 +1131,12 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg)
av_opt_set(pls->input->priv_data, "key", key, 0);
av_opt_set(pls->input->priv_data, "iv", iv, 0);
+ if (c->avfmt->protocol_whitelist) {
+ ret = av_dict_set(&opts, "protocol_whitelist", c->avfmt->protocol_whitelist, 0);
+ if (ret < 0)
+ goto cleanup;
+ }
+
if ((ret = url_connect(pls, c->avio_opts, opts)) < 0) {
goto cleanup;
}
diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c
index 16f07fe..7412c3a 100644
--- a/libavformat/mmsh.c
+++ b/libavformat/mmsh.c
@@ -246,6 +246,14 @@ static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int tim
host, port, mmsh->request_seq++);
av_opt_set(mms->mms_hd->priv_data, "headers", headers, 0);
+ if (!mms->mms_hd->protocol_whitelist && h->protocol_whitelist) {
+ mms->mms_hd->protocol_whitelist = av_strdup(h->protocol_whitelist);
+ if (!mms->mms_hd->protocol_whitelist) {
+ err = AVERROR(ENOMEM);
+ goto fail;
+ }
+ }
+
err = ffurl_connect(mms->mms_hd, NULL);
if (err) {
goto fail;
diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
index 8ed5eb1..3bacf84 100644
--- a/libavformat/rtmphttp.c
+++ b/libavformat/rtmphttp.c
@@ -220,6 +220,14 @@ static int rtmp_http_open(URLContext *h, const char *uri, int flags)
av_opt_set(rt->stream->priv_data, "multiple_requests", "1", 0);
av_opt_set_bin(rt->stream->priv_data, "post_data", "", 1, 0);
+ if (!rt->stream->protocol_whitelist && h->protocol_whitelist) {
+ rt->stream->protocol_whitelist = av_strdup(h->protocol_whitelist);
+ if (!rt->stream->protocol_whitelist) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+ }
+
/* open the http context */
if ((ret = ffurl_connect(rt->stream, NULL)) < 0)
goto fail;
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index d710469..c26ce75 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1746,6 +1746,14 @@ redirect:
sessioncookie);
av_opt_set(rt->rtsp_hd->priv_data, "headers", headers, 0);
+ if (!rt->rtsp_hd && s->protocol_whitelist) {
+ rt->rtsp_hd->protocol_whitelist = av_strdup(s->protocol_whitelist);
+ if (!rt->rtsp_hd->protocol_whitelist) {
+ err = AVERROR(ENOMEM);
+ goto fail;
+ }
+ }
+
/* complete the connection */
if (ffurl_connect(rt->rtsp_hd, NULL)) {
err = AVERROR(EIO);
Best regards,
Andreas
More information about the ffmpeg-devel
mailing list