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 3293942C84 for ; Wed, 31 Aug 2022 13:22:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 01E9168BB28; Wed, 31 Aug 2022 16:22:39 +0300 (EEST) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBB1E68BAF2 for ; Wed, 31 Aug 2022 16:22:32 +0300 (EEST) Received: by mail-pg1-f170.google.com with SMTP id r22so13504423pgm.5 for ; Wed, 31 Aug 2022 06:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=yt4ijL/qVvxRVML3rU3xsRI6f0vMprcRmaGumOhp+00=; b=aANA1RzMOfZYWakTrrVJtot7LpgsqmI5TRciisNSqVfNRyP1TfX9WnDFl9z+6IEdTz q9SXeUnYkERHjX4YfzauS6jBEZkH1m/AZwfn1QDoHaMzYbFdXmhjeZ4Sgr6JqNcj6E4B Esz2nWAHyyOmoVBFi5SoGTiHWaWJ6mtPu0fYegHCGJEKSOUWOIqzlCMSf4KqPloEY+zt AX0/8pLc4LkicJXZz3XlFVGuzYvUwhH0hfKbtdv43KSiSGhYRhlQlMdNP4ilAtGEDtXN pk3ipCK1qNeBg+lmcrgxvpp30Q963lhmSrXOGkUVlin3Gt9At0w4mGxtlSHe8XiMHdKM 1KTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=yt4ijL/qVvxRVML3rU3xsRI6f0vMprcRmaGumOhp+00=; b=PwF9hZuGkxS1vQpsF4FKrMyVleZrY6bDHDej3OhuHdQMDOn05Bn4TJdn0uvb6YIEIE 2hb4bUJEnBelFaJQz9n5Ownxsd0A+KPG09B/pFaXklWzSN3AcsXBgGVWyyjR/cf4B47F dcrJc4nvFlUbyjUA7bKIsr0OuiFRJXB6yKOlKqEAh0LDMZrMwf8We0pyTFZpfznWfdMJ H6UO0nRHfVDz9iWtQqCJtcrp1eDkUcEx3c74XixRxEV6B67ELWElCC+1n0TrpM3Z4b62 l2uxvOLdteurwDdrlzW4lF7J9NLG9bnqsKx0hTlJlC430Iy3v493Ifc9I8GF1KrfphQ6 vm4A== X-Gm-Message-State: ACgBeo2DD4NXUsZQmNgErXW8aTY3mpqrMUH8Sh1uVJd0DQjuU4S3QYbw gOiIhsi4gKEsGPtSZb6nIpQ7uHt5PPE41/gY X-Google-Smtp-Source: AA6agR5/mizzbFBnwPipG+jdxDYyO1Zg0hEpIK2d3Z6rILm/2E6NEORp6Ddes3AMag7bdyBkbg9yYg== X-Received: by 2002:a05:6a00:1688:b0:517:cf7b:9293 with SMTP id k8-20020a056a00168800b00517cf7b9293mr26453761pfc.7.1661952151158; Wed, 31 Aug 2022 06:22:31 -0700 (PDT) Received: from localhost ([220.203.232.198]) by smtp.gmail.com with ESMTPSA id w13-20020a6556cd000000b0042ba1a95235sm3304300pgs.86.2022.08.31.06.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 06:22:30 -0700 (PDT) From: mirsfang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 Aug 2022 21:21:41 +0800 Message-Id: <20220831132140.24682-1-mirsfang@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 2/2] lavf/hls: add option for hls segment request append http get request parameters 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 Cc: mirs Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: mirs Signed-off-by: mirs add option for hls segment request append, default is disable --- libavformat/hls.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 3dc7bd3930..b069cde144 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -220,6 +220,7 @@ typedef struct HLSContext { AVIOInterruptCB *interrupt_callback; AVDictionary *avio_opts; AVDictionary *seg_format_opts; + int seg_append_http_get_params; char *allowed_extensions; int max_reload; int http_persistent; @@ -307,6 +308,23 @@ static void free_rendition_list(HLSContext *c) c->n_renditions = 0; } +static void hls_append_param_to_url(const HLSContext * c,char *buf, int size, const char *base, + const char *rel) +{ + if (c && c->seg_append_http_get_params && base) { + char * ch = strchr(base, '?'); + if (!ch) { + return; + } + + if (strchr(buf, '?')) { + ch++; + av_strlcat(buf, "&", size); + } + av_strlcat(buf, ch, size); + } +} + static struct playlist *new_playlist(HLSContext *c, const char *url, const char *base) { @@ -319,6 +337,7 @@ static struct playlist *new_playlist(HLSContext *c, const char *url, return NULL; } ff_make_absolute_url(pls->url, sizeof(pls->url), base, url); + hls_append_param_to_url(c,pls->url, sizeof(pls->url), base, url); if (!pls->url[0]) { av_packet_free(&pls->pkt); av_free(pls); @@ -411,7 +430,7 @@ struct init_section_info { char byterange[32]; }; -static struct segment *new_init_section(struct playlist *pls, +static struct segment *new_init_section(const HLSContext * c,struct playlist *pls, struct init_section_info *info, const char *url_base) { @@ -429,6 +448,7 @@ static struct segment *new_init_section(struct playlist *pls, ptr = info->uri; } else { ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri); + hls_append_param_to_url(c,tmp_str, sizeof(tmp_str), url_base, info->uri); if (!tmp_str[0]) { av_free(sec); return NULL; @@ -861,7 +881,7 @@ static int parse_playlist(HLSContext *c, const char *url, goto fail; ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_init_section_args, &info); - cur_init_section = new_init_section(pls, &info, url); + cur_init_section = new_init_section(c,pls, &info, url); if (!cur_init_section) { ret = AVERROR(ENOMEM); goto fail; @@ -877,6 +897,7 @@ static int parse_playlist(HLSContext *c, const char *url, if (key_type != KEY_NONE) { ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key); + hls_append_param_to_url(c,tmp_str, sizeof(tmp_str), url, key); if (!tmp_str[0]) { av_free(cur_init_section); ret = AVERROR_INVALIDDATA; @@ -949,6 +970,7 @@ static int parse_playlist(HLSContext *c, const char *url, if (key_type != KEY_NONE) { ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key); + hls_append_param_to_url(c,tmp_str, sizeof(tmp_str), url, key); if (!tmp_str[0]) { ret = AVERROR_INVALIDDATA; av_free(seg); @@ -963,8 +985,9 @@ static int parse_playlist(HLSContext *c, const char *url, } else { seg->key = NULL; } - ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, line); + hls_append_param_to_url(c,tmp_str, sizeof(tmp_str), url, line); + if (!tmp_str[0]) { ret = AVERROR_INVALIDDATA; if (seg->key) @@ -2548,6 +2571,8 @@ static const AVOption hls_options[] = { OFFSET(http_seekable), AV_OPT_TYPE_BOOL, { .i64 = -1}, -1, 1, FLAGS}, {"seg_format_options", "Set options for segment demuxer", OFFSET(seg_format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, + {"seg_append_http_get_params", "Segment request append http get parameters 0 = disable 1 = enable", + OFFSET(seg_append_http_get_params), AV_OPT_TYPE_BOOL,{.i64 = 0}, 0, 1, FLAGS}, {NULL} }; -- 2.32.1 (Apple Git-133) _______________________________________________ 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".