From patchwork Wed Jun 26 16:58:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 13708 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id ED6D9448BD1 for ; Wed, 26 Jun 2019 20:04:26 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CBD7A689B70; Wed, 26 Jun 2019 20:04:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ACCED680C46 for ; Wed, 26 Jun 2019 20:04:20 +0300 (EEST) Received: by mail-wr1-f67.google.com with SMTP id x4so3596103wrt.6 for ; Wed, 26 Jun 2019 10:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=yhmx+jNieaguSCxCqqXrTHz1VsJCCMaJc5R//YLtEVU=; b=I0NLob8eEJE0FQY3Sv9sBoTMwHMv/3Jx3BeGe+DXAYzRalcw8L2/Uhn3Ieg68VGz3r WWiDtrZ2kC1GIFI0mmf8oqs2c3KqDBYyCyDKIJzUkUicvgLeAPl28pGgBZc1kOfQQUuO G03DPdV1avc21bus3dE/H7tGe7c3OkFvwufPnUD/Hq6ycBd3X/iVQFYkiMgtLgNOY1Oy vBdlunHNjtqQ29WrsbVASZOdAwvK/E0jbchz+Lw5jRgSmgTEt5jtKXglipgXnxreEbEK B68491/m/h6wUXPNV/j7BWrCKIXFXJS8Ndz+ECYUIxu761pI9AEOiXVqgMYKLxEkTxxi garA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=yhmx+jNieaguSCxCqqXrTHz1VsJCCMaJc5R//YLtEVU=; b=T2Z5axfMJV3laggVWgLpWWIw3FSyBqbj1NBZ+RM27dIafGqdvYwR0lCbwCH0IXyiOk 8jlVXQ5NYwoHdmS3WHUGCGUR1FIkWhFlE/xFCeBsQntYFpDAcnxgSfAJdHIz4eb5vXGb v5OU+kiHObv+cZ30ddqkueGDnASZaypX3i9t9BQoJdb9Oy3xPm58YsB46R4G821Reu/X Hke8YeZl4QkJtiBWxV1uo81K+lyJ6Z+Wt+KSGQ1TQIe7IGe7IFKF50cSPBcLMZbvGyE1 DRypeekUylrotnuSQVJQIvHzyZexYVS4TJs5mUCa1Nr2qmMa6GNAFZWA1v8ggOCN2T5s krog== X-Gm-Message-State: APjAAAUBThfiZLEINzPlCLB+kiulTqzlyr+JCBliNG2+LnUkPPuaWpNt wi8xNCLRdd7IvH1KQKijNJk24W8p X-Google-Smtp-Source: APXvYqwp2nPRvG7QKA5nWblgUU8ublGQ+/iaWDhpmHYZP8ZuAN+KRLpb4xwUXjjIcFPzBshxN941wQ== X-Received: by 2002:adf:f503:: with SMTP id q3mr4456163wro.43.1561568344608; Wed, 26 Jun 2019 09:59:04 -0700 (PDT) Received: from localhost.localdomain ([82.129.88.112]) by smtp.gmail.com with ESMTPSA id g8sm2920307wme.20.2019.06.26.09.59.03 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 09:59:03 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Wed, 26 Jun 2019 17:58:54 +0100 Message-Id: <20190626165854.94244-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] hlsenc: Add option to set custom HTTP headers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Signed-off-by: Derek Buitenhuis --- Onward and upward with the never-ending quest to manually forward all the HTTP options to the subcontexts in every meta-muxer! --- doc/muxers.texi | 3 +++ libavformat/hlsenc.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/doc/muxers.texi b/doc/muxers.texi index 6c5b4bb637..59c93bc687 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1089,6 +1089,9 @@ Set timeout for socket I/O operations. Applicable only for HTTP output. @item -ignore_io_errors Ignore IO errors during open, write and delete. Useful for long-duration runs with network output. +@item headers +Set custom HTTP headers, can override built in default headers. Applicable only for HTTP output. + @end table @anchor{ico} diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 9f5eee5491..37ae128f4f 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -237,6 +237,7 @@ typedef struct HLSContext { AVIOContext *sub_m3u8_out; int64_t timeout; int ignore_io_errors; + char *headers; int has_default_key; /* has DEFAULT field of var_stream_map */ int has_video_m3u8; /* has video stream m3u8 list */ } HLSContext; @@ -294,6 +295,8 @@ static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSCont av_dict_set_int(options, "multiple_requests", 1, 0); if (c->timeout >= 0) av_dict_set_int(options, "timeout", c->timeout, 0); + if (c->headers) + av_dict_set(options, "headers", c->headers, 0); } static void write_codec_attr(AVStream *st, VariantStream *vs) { @@ -3029,6 +3032,7 @@ static const AVOption options[] = { {"http_persistent", "Use persistent HTTP connections", OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E }, {"timeout", "set timeout for socket I/O operations", OFFSET(timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags = E }, {"ignore_io_errors", "Ignore IO errors for stable long-duration runs with network output", OFFSET(ignore_io_errors), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E }, + {"headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E }, { NULL }, };