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 E876F441A2 for ; Wed, 31 Aug 2022 07:15:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 626A368BB24; Wed, 31 Aug 2022 10:15:56 +0300 (EEST) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB4CD68B45F for ; Wed, 31 Aug 2022 10:15:49 +0300 (EEST) Received: by mail-pf1-f178.google.com with SMTP id z187so13571045pfb.12 for ; Wed, 31 Aug 2022 00:15:49 -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=WOQ9vbcCUJQcKinzM61OBCQy1orPXhavzJN+edDIyMU=; b=UXsZTa9DWOkd50boDoXhMQp8gBA+UGQzG5LZiTbm87xPA8J2YWNUluVBh/8yCr2zDF LHikvNPR8O/+QmgDu1Y9EwT2xm3BP2U5N1C7EFj1UwO/f1CdgUFBcEn8ypmaVDwTt4M3 eRpvER5rz5Do/njb1qCTLJcTj43Kw4XpTBLX7FW15wNJHsCHzIOg96F4a+1RZRH/VVwz udM7BukG2tuY1jWifvslpZF8ephhlrQ7hUW6bBPPBkGd8B9WItJKbcxv3miN3xlROGlO 1VELPUwZu80JYwm2gdoOSxgGxiNQJt1L5Hl+uJWKGbwqek4hIYVOKaPYU6zdNd7qYr83 GHZg== 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=WOQ9vbcCUJQcKinzM61OBCQy1orPXhavzJN+edDIyMU=; b=MiItNE7+mHySzL1WWIssKHDPCClBxyFrWmJafTJox+7JACl8VgSNCYAtizDDOgjERq 4hMLu9lQey00sAuYySALX3R02wVBah2j8lQmm+8ngozO+FPl8xk3v/FVIrRWG11+b+Su A/pFI0AcJoBVV6fcMEbWlpifHo45NhrSYm9GSW0E0hRoD3CQBo/7cQEaKs5cKhF3KOsO 5sFhz7SmNLunXwQxkNKmOa9RLX2Nh4Bxg8Rn0EQ9Y5O+oM8sFZ4CQS5Z3jrbFEaqynqZ 9qZkCGoyGM9ZA8YAISlRSN3fALcfOsBPYWYl3egmYlG7+lOL1lJy/iK+tyTs7vO6N+T5 1xlA== X-Gm-Message-State: ACgBeo34FuxXF6H0h4rUziXPzzQ5iwK56uLl5aA7DlQGzou9T/QqX94E k4a/QveGbfw4N3gEmPBYnsuBTlYg5c/b49SF X-Google-Smtp-Source: AA6agR43uPSVznbcf2wIcrGIBDgYUK8jESPQgHFMttbbPayHDARYyP+kDrN6rZQcmizrS5Rkgqx2Wg== X-Received: by 2002:a63:f44:0:b0:42c:5a16:dfa1 with SMTP id 4-20020a630f44000000b0042c5a16dfa1mr8415839pgp.305.1661930147488; Wed, 31 Aug 2022 00:15:47 -0700 (PDT) Received: from localhost.localdomain ([220.203.232.198]) by smtp.gmail.com with ESMTPSA id m20-20020a17090ade1400b001fad1f975casm691367pjv.12.2022.08.31.00.15.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 31 Aug 2022 00:15:47 -0700 (PDT) From: mirsfang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 Aug 2022 15:13:09 +0800 Message-Id: <20220831071308.85780-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 add option for hls when client reqeust segment url maybe use get parameters for user authenticatio --- libavformat/hls.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 3dc7bd3930..06d0a89a95 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,25 @@ static void free_rendition_list(HLSContext *c) c->n_renditions = 0; } +static void hls_make_url(const HLSContext * c,char *buf, int size, const char *base, + const char *rel) +{ + ff_make_absolute_url(buf, size, base, 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) { @@ -318,7 +338,7 @@ static struct playlist *new_playlist(HLSContext *c, const char *url, av_free(pls); return NULL; } - ff_make_absolute_url(pls->url, sizeof(pls->url), base, url); + hls_make_url(c,pls->url, sizeof(pls->url), base, url); if (!pls->url[0]) { av_packet_free(&pls->pkt); av_free(pls); @@ -411,7 +431,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) { @@ -428,7 +448,7 @@ static struct segment *new_init_section(struct playlist *pls, if (!av_strncasecmp(info->uri, "data:", 5)) { ptr = info->uri; } else { - ff_make_absolute_url(tmp_str, sizeof(tmp_str), url_base, info->uri); + hls_make_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; @@ -876,7 +896,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_make_url(c,tmp_str, sizeof(tmp_str), url, key); if (!tmp_str[0]) { av_free(cur_init_section); ret = AVERROR_INVALIDDATA; @@ -948,7 +968,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_make_url(c,tmp_str, sizeof(tmp_str), url, key); if (!tmp_str[0]) { ret = AVERROR_INVALIDDATA; av_free(seg); @@ -964,7 +984,7 @@ static int parse_playlist(HLSContext *c, const char *url, seg->key = NULL; } - ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, line); + hls_make_url(c,tmp_str, sizeof(tmp_str), url, line); if (!tmp_str[0]) { ret = AVERROR_INVALIDDATA; if (seg->key) @@ -2548,6 +2568,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".