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 6D49642C44 for ; Wed, 31 Aug 2022 13:13:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DDC6368BB20; Wed, 31 Aug 2022 16:13:05 +0300 (EEST) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 34A3468B823 for ; Wed, 31 Aug 2022 16:13:00 +0300 (EEST) Received: by mail-pg1-f174.google.com with SMTP id v4so13466606pgi.10 for ; Wed, 31 Aug 2022 06:13:00 -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=aZlFhoMDvIi6e3zaUVNWekiBfe8rRdr9FAcsuOZOxbk=; b=e6sqOTBVRqBLa1qr8iCXqMNp9RDdw/8GAzJ9PBCR8IcwNJRRQ6c6s/gKIM2N5G2s/y NdDNRzNBbTTjhFr0At3w8qa1IRD4dKXjqTHBNJMkzBSrI1cj6+wO+CziZq4yZSPA1ski lS0pXWD8hf43D2avZnytdQtFKQbVdMWBFKnFvtEyhnKVdjv4/Yc3HIRXeJN/rUJJqVY2 etPPn3pTWdXuFW5JTDmxyg79JJoFzaV/xcwp7E6c7Cje03/Vk5wgyVbf+bIAKsX+Nke/ Qd6ymrSdetazYWsOlmfJVnZp8fMmZxxyO3cEHM0mRv5yKhn5h+BG//KwhM7PU0eJw3wr Fxhg== 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=aZlFhoMDvIi6e3zaUVNWekiBfe8rRdr9FAcsuOZOxbk=; b=i77Gv6a+cEKeuJlGXIsyHQU9Rpeluj+BeO6y1XF7VFQ9T+1ObfxBLnizIBMthkdJsV UVsN8J6COlHlo3DHrbj0Aw7jFDN5qOB2EMYTjPAFYYWKyZn+D088g47lB4LysLbD9SR0 /DQUjOcoRwoGbGSRJaHMqfkWrSttVeMe56vc6i4X7OLM1J6Lfe6kX9Z/W2C9eTe9tLlL cLT09FBhD1pIMqNTckqA7g7egmqWYX4zUhaVMhPeMZd1dlBl3U4MJ+8pnRBuyYpCmAy8 /TQHiOzElUEpCrfz3nQYtRQFOxnorrTlbuycFI72ggf7w7g2zn9oV3lKmZETGx+Upc4J jXag== X-Gm-Message-State: ACgBeo0D/dJoOaUwZICW9EGxmZuEJOA7o7JgutP5LeMulUnIpA3MvYXa SIJFaOFkSSDKHVORog2qN0O+5gHVjmcFh0R3 X-Google-Smtp-Source: AA6agR6/xPUe2hn5pcPPYlqEjAS1/Yzn8Q47+rN75rZtWyW86gar6s9UXaZgI7uqPiPhP+/8D6nong== X-Received: by 2002:a05:6a00:b43:b0:52f:59dc:93 with SMTP id p3-20020a056a000b4300b0052f59dc0093mr26016600pfo.26.1661951578063; Wed, 31 Aug 2022 06:12:58 -0700 (PDT) Received: from localhost ([220.203.232.198]) by smtp.gmail.com with ESMTPSA id e6-20020a170902784600b0016dcbdf9492sm11610301pln.92.2022.08.31.06.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 06:12:57 -0700 (PDT) From: mirsfang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 Aug 2022 21:12:54 +0800 Message-Id: <20220831131254.21788-1-mirsfang@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1] 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 --- libavformat/hls.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 3dc7bd3930..3a1cc855c4 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 = 1}, 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".