From patchwork Sat May 29 10:02:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 27981 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp1267411iof; Sat, 29 May 2021 03:02:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8tXdVLrQ8N7Er8wBmy09P0yllCK5M28y0Hgh2Pb18kkpMs4sgfDG0nv5MhQyK0pGjt2V6 X-Received: by 2002:a05:6402:152:: with SMTP id s18mr14462720edu.221.1622282578938; Sat, 29 May 2021 03:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622282578; cv=none; d=google.com; s=arc-20160816; b=svHZKZ4Ua82oymH5WvUqIV7qDMHgycMA7M/02Ub0BArnms7Z1G+HxWsbrfVQ3L7eKA Vg1JwE7OVY2XY/h5VKGs2y0xeg7Bl8tuS9KmMroZavF3d1I4lVzhtSVfIOhO7678USsy rCIhWyIcProqmDXxz3IaLop+WRGJ7zR93CLismICNyF4PDjM3QDXDspuEDLe01ECJpMc I2zl5Rq8rXNkqAd5Wbq6KpfzEBWRJ790X15aG0GV0KvOMMAv4va8QoMWOhtPKozWi6JW YVHC5QH/PTA3KOyIE4bImWHXX/RZuvYTNauWPs1GcViTcPU2AvIPst6ZGhbKmU4S6YBd j2ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=wDIMjRNxHrYDRiG2g6g14UDKxixh5kPsGb5057BPgLg=; b=deSOcjqEXzGBfTVYM4CrJNvImraNUwPlDX3gL40hJRM11NcP/x4c8CTdXs/8oKYwxk uByJH5BH0HJIbywPNtY/9G/fJSxvzubULp3vLGzDK26zkYNqayxhZ0AWH/l9bGJqPS6t iNpBMVVJEY6A/P1Lv9AYZmqepe9a2xTH4SaxXwZ2xcWpySpqqxlHhyy1mfKGzbn9y1l7 2s8M2IxIpOk0tUPZ40y+6tfC7kon14XP8vE4yuKget22mV8g6+mhx6UDCieIGdDJSw0R dm6PieqCnf3LojUtvq0k2h6lwX4cG428zL6w3qFacCi2fbv81i3EP2VO8btfljst3zPJ o2Yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d4si7272235eja.217.2021.05.29.03.02.58; Sat, 29 May 2021 03:02:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 00B79680895; Sat, 29 May 2021 13:02:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CE610687F4E for ; Sat, 29 May 2021 13:02:48 +0300 (EEST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4FscYh2tQBzQk1B for ; Sat, 29 May 2021 12:02:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id KLaVhCfKPXqB for ; Sat, 29 May 2021 12:02:44 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 29 May 2021 15:32:28 +0530 Message-Id: <20210529100228.10591-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.28 / 15.00 / 15.00 X-Rspamd-Queue-Id: 8C70E1806 X-Rspamd-UID: 36fc55 Subject: [FFmpeg-devel] [PATCH] avformat/hls: relay format options to segment demuxer 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gF32LuNuuVjO --- doc/demuxers.texi | 3 +++ libavformat/hls.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 13fe17ff4f..f79faff92b 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -347,6 +347,9 @@ Enabled by default for HTTP/1.1 servers. @item http_seekable Use HTTP partial requests for downloading HTTP segments. 0 = disable, 1 = enable, -1 = auto, Default is auto. + +@item seg_format_options +Set options for the demuxer of media segments using a list of key=value couples separated by @code{:}. @end table @section image2 diff --git a/libavformat/hls.c b/libavformat/hls.c index 8fc6924c90..c2ca23e973 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -207,6 +207,7 @@ typedef struct HLSContext { int64_t cur_timestamp; AVIOInterruptCB *interrupt_callback; AVDictionary *avio_opts; + AVDictionary *seg_format_opts; char *allowed_extensions; int max_reload; int http_persistent; @@ -1959,6 +1960,7 @@ static int hls_read_header(AVFormatContext *s) struct playlist *pls = c->playlists[i]; const AVInputFormat *in_fmt = NULL; char *url; + AVDictionary *seg_format_opts = NULL; if (!(pls->ctx = avformat_alloc_context())) { ret = AVERROR(ENOMEM); @@ -2017,7 +2019,10 @@ static int hls_read_header(AVFormatContext *s) if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0) goto fail; - ret = avformat_open_input(&pls->ctx, pls->segments[0]->url, in_fmt, NULL); + av_dict_copy(&seg_format_opts, c->seg_format_opts, 0); + + ret = avformat_open_input(&pls->ctx, pls->segments[0]->url, in_fmt, &seg_format_opts); + av_dict_free(&seg_format_opts); if (ret < 0) goto fail; @@ -2403,6 +2408,8 @@ static const AVOption hls_options[] = { OFFSET(http_multiple), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, FLAGS}, {"http_seekable", "Use HTTP partial requests, 0 = disable, 1 = enable, -1 = auto", 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}, {NULL} };