From 24736736636882e2fb94d442060642851a49c7ed Mon Sep 17 00:00:00 2001
From: Ole Andre Birkedal <o.birkedal@sportradar.com>
Date: Tue, 15 Oct 2019 14:07:30 +0200
Subject: [PATCH] Feature for setting custom HTTP headers on the DASH muxer

---
 libavformat/dashenc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index a462876c13..3f040b144b 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -148,6 +148,7 @@ typedef struct DASHContext {
     int ignore_io_errors;
     int lhls;
     int master_publish_rate;
+    const char *http_headers;
     int nr_of_streams_to_flush;
     int nr_of_streams_flushed;
 } DASHContext;
@@ -444,6 +445,8 @@ static void set_http_options(AVDictionary **options, DASHContext *c)
         av_dict_set_int(options, "multiple_requests", 1, 0);
     if (c->timeout >= 0)
         av_dict_set_int(options, "timeout", c->timeout, 0);
+    if (c->http_headers)
+        av_dict_set(options, "headers", c->http_headers, 0);
 }
 
 static void get_hls_playlist_name(char *playlist_name, int string_size,
@@ -1941,6 +1944,7 @@ static const AVOption options[] = {
     { "ignore_io_errors", "Ignore IO errors during open and write. Useful for long-duration runs with network output", OFFSET(ignore_io_errors), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
     { "lhls", "Enable Low-latency HLS(Experimental). Adds #EXT-X-PREFETCH tag with current segment's URI", OFFSET(lhls), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
     { "master_m3u8_publish_rate", "Publish master playlist every after this many segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX, E},
+    { "headers", "Set custom HTTP headers, can override built in default headers", OFFSET(http_headers), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
     { NULL },
 };
 
-- 
2.19.1

