From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 6D488420EA for ; Thu, 16 Dec 2021 08:09:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 38B8968AE33; Thu, 16 Dec 2021 10:09:52 +0200 (EET) Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE8256806F5 for ; Thu, 16 Dec 2021 10:09:45 +0200 (EET) Message-ID: <0d2a0b34-3680-394a-e5ed-c18b69ea4330@zanevaniperen.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=key1; t=1639642184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mt4Qz64WT/QxDoerBjnxY58KUtVbu5eh3NKTxLlw5sE=; b=L+FRPjm5few0R0zi2p36Rtpj87TdDOGYVHDr4AC1hT4Ot9rIi3x7/xoN+HpPjfzT69aAIY Y8LmaKb2TKF4LC5xlxH/+2KMng+/wF/FjbyLbdnq4tEQYLR/TQOM4TPux3hBB7T7idvKI2 BnxHSGqi0hj4XQmRDZODLDQOlISMUrdjXlmrw8agCuhkZu0hrxj3RY95v5yOBIPvbRWkGz 02viPT9/W1KKwNdd1jMdESBFQrSVY8OtGTpkFfeOGq5tlMWbiRtaYoGHAFG3ObJzovoTy5 /uCZNPPkl8ApR/Sy6n1LtaKYYl8aqFxOSe+TSem9ci9gGhhWcCNGuIop00uB/A== Date: Thu, 16 Dec 2021 18:09:40 +1000 MIME-Version: 1.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20211215003514.23851-1-pal@sandflow.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zane van Iperen In-Reply-To: <20211215003514.23851-1-pal@sandflow.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: zanevaniperen.com Subject: Re: [FFmpeg-devel] [PATCH v1] avformat/aviobuf: ffio_copy_url_options X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Dedup is always good, lgtm. On 15/12/21 10:35, pal@sandflow.com wrote: > From: Pierre-Anthony Lemieux > > Signed-off-by: Pierre-Anthony Lemieux > --- > > Notes: > Refactors save_avio_options() from dashdec.c and hls.c > into a common ffio_copy_url_options() in libavformat/aviobuf.c. > > Co-authored: Nicholas Vanderzwet > > libavformat/avio_internal.h | 6 ++++++ > libavformat/aviobuf.c | 24 ++++++++++++++++++++++++ > libavformat/dashdec.c | 27 +-------------------------- > libavformat/hls.c | 24 +----------------------- > 4 files changed, 32 insertions(+), 49 deletions(-) > > diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h > index 187433f283..1f5e3d474b 100644 > --- a/libavformat/avio_internal.h > +++ b/libavformat/avio_internal.h > @@ -206,6 +206,12 @@ int ffio_fdopen(AVIOContext **s, URLContext *h); > */ > URLContext *ffio_geturlcontext(AVIOContext *s); > > + > +/** > + * Read url related dictionary options from the AVIOContext and write to the given dictionary > + */ > +int ffio_copy_url_options(AVIOContext* pb, AVDictionary** avio_opts); > + > /** > * Open a write-only fake memory stream. The written data is not stored > * anywhere - this is only used for measuring the amount of data > diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c > index 969c127b23..096f37ae23 100644 > --- a/libavformat/aviobuf.c > +++ b/libavformat/aviobuf.c > @@ -1022,6 +1022,30 @@ URLContext* ffio_geturlcontext(AVIOContext *s) > return NULL; > } > > +int ffio_copy_url_options(AVIOContext* pb, AVDictionary** avio_opts) > +{ > + const char *opts[] = { > + "headers", "user_agent", "cookies", "http_proxy", "referer", "rw_timeout", "icy", NULL }; > + const char **opt = opts; > + uint8_t *buf = NULL; > + int ret = 0; > + > + while (*opt) { > + if (av_opt_get(pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) { > + if (buf[0] != '\0') { > + ret = av_dict_set(avio_opts, *opt, buf, AV_DICT_DONT_STRDUP_VAL); > + if (ret < 0) > + return ret; > + } else { > + av_freep(&buf); > + } > + } > + opt++; > + } > + > + return ret; > +} > + > static void update_checksum(AVIOContext *s) > { > if (s->update_checksum && s->buf_ptr > s->checksum_ptr) { > diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c > index 983dc85d65..797fe74157 100644 > --- a/libavformat/dashdec.c > +++ b/libavformat/dashdec.c > @@ -1833,31 +1833,6 @@ end: > return ret; > } > > -static int save_avio_options(AVFormatContext *s) > -{ > - DASHContext *c = s->priv_data; > - const char *opts[] = { > - "headers", "user_agent", "cookies", "http_proxy", "referer", "rw_timeout", "icy", NULL }; > - const char **opt = opts; > - uint8_t *buf = NULL; > - int ret = 0; > - > - while (*opt) { > - if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN, &buf) >= 0) { > - if (buf[0] != '\0') { > - ret = av_dict_set(&c->avio_opts, *opt, buf, AV_DICT_DONT_STRDUP_VAL); > - if (ret < 0) > - return ret; > - } else { > - av_freep(&buf); > - } > - } > - opt++; > - } > - > - return ret; > -} > - > static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, > int flags, AVDictionary **opts) > { > @@ -2057,7 +2032,7 @@ static int dash_read_header(AVFormatContext *s) > > c->interrupt_callback = &s->interrupt_callback; > > - if ((ret = save_avio_options(s)) < 0) > + if ((ret = ffio_copy_url_options(s->pb, &c->avio_opts)) < 0) > return ret; > > if ((ret = parse_manifest(s, s->url, s->pb)) < 0) > diff --git a/libavformat/hls.c b/libavformat/hls.c > index 557faf8e8d..8c526f748f 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -1717,28 +1717,6 @@ static int64_t select_cur_seq_no(HLSContext *c, struct playlist *pls) > return pls->start_seq_no; > } > > -static int save_avio_options(AVFormatContext *s) > -{ > - HLSContext *c = s->priv_data; > - static const char * const opts[] = { > - "headers", "http_proxy", "user_agent", "cookies", "referer", "rw_timeout", "icy", NULL }; > - const char * const * opt = opts; > - uint8_t *buf; > - int ret = 0; > - > - while (*opt) { > - if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN | AV_OPT_ALLOW_NULL, &buf) >= 0) { > - ret = av_dict_set(&c->avio_opts, *opt, buf, > - AV_DICT_DONT_STRDUP_VAL); > - if (ret < 0) > - return ret; > - } > - opt++; > - } > - > - return ret; > -} > - > static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, > int flags, AVDictionary **opts) > { > @@ -1884,7 +1862,7 @@ static int hls_read_header(AVFormatContext *s) > c->first_timestamp = AV_NOPTS_VALUE; > c->cur_timestamp = AV_NOPTS_VALUE; > > - if ((ret = save_avio_options(s)) < 0) > + if ((ret = ffio_copy_url_options(s->pb, &c->avio_opts)) < 0) > return ret; > > /* XXX: Some HLS servers don't like being sent the range header, > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".