From patchwork Tue Sep 13 20:12:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Venkat X-Patchwork-Id: 564 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp2317033vsd; Tue, 13 Sep 2016 13:13:08 -0700 (PDT) X-Received: by 10.28.46.204 with SMTP id u195mr6497630wmu.57.1473797588289; Tue, 13 Sep 2016 13:13:08 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bc3si382236wjb.53.2016.09.13.13.13.01; Tue, 13 Sep 2016 13:13:08 -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; dkim=neutral (body hash did not verify) header.i=@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 EECD6689E49; Tue, 13 Sep 2016 23:12:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f177.google.com (mail-pf0-f177.google.com [209.85.192.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E07C1689CBD for ; Tue, 13 Sep 2016 23:12:39 +0300 (EEST) Received: by mail-pf0-f177.google.com with SMTP id 128so66631684pfb.3 for ; Tue, 13 Sep 2016 13:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=NxGaAKYIjLm+pRCE2YQq+KeZpnU3Tpnxqbkkngu36+A=; b=GSVQD12Xa1NkXz7R1hyw++FfMtDkA51nnpZQpJtHYPi7lcbY+vFOJw0MER3t8BQjji yJOFPFcrGcLT/A4MGA54yYRuwFIl4d0Uj6kiyI3thnVNIMKJ8XzSYCCe1KDGRWTVYq1J +OB8xHsWdyJIWDIEgkGlXLH5DML32sD7aAFez13EwdBb0E9S7QzXdMFL2wD36CnLm5XO oUW/LUGIMj1nhKSqV2aJ2n41oASiVh2ARWO7QM2kuJ0gKyUOVNDN1g6BGegFn8mHzast EoiYDl8INklDwZ2+oTd7tnt3dKiyAFbfXYXIqaRSEoQT2uMVE3xhkPud1dyYjgSusEcX nQQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NxGaAKYIjLm+pRCE2YQq+KeZpnU3Tpnxqbkkngu36+A=; b=hfylZ/1Aj4OJA+Rg62fO6C753b0/PKjnhdK31MuRF8EJMKAqO/QZWeZE9rzOXPQ8Rx 01bsnurVluFmJ1S6g92JewpJAGlCgt4j3hCh9etCgZDC6gl4XH0aRBSBkvDDIkvmpAxT e1/3UYx/HpN+LpZUnBr+fR7YDGXMMwuO2zjn+Px93z/+nuslk1foecnQ/1tpbKloPKn+ CMOIxylSyQJ8rjYgjA0aLLvlT2+ddoNn6bYxM6SPn220V7oAAPJdz/URS/KdCaQywDjy 8THjBS27aWhkAB35fTVPGzHSpR9gzokfT5DSA16/oKjaRPI82dvPWwo8cK2/Z0Q/ZlHS JlCA== X-Gm-Message-State: AE9vXwOoqKVsEjSl25Jvi4dtEROSfI5inatQpHz8RyVHSwtVfvBirsYncgs5sEl319GxXGVv X-Received: by 10.98.64.193 with SMTP id f62mr4430924pfd.141.1473797570403; Tue, 13 Sep 2016 13:12:50 -0700 (PDT) Received: from vigneshv2.mtv.corp.google.com ([172.22.114.23]) by smtp.gmail.com with ESMTPSA id d26sm23382753pfe.37.2016.09.13.13.12.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Sep 2016 13:12:49 -0700 (PDT) From: Vignesh Venkatasubramanian To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Sep 2016 13:12:46 -0700 Message-Id: <1473797566-623-1-git-send-email-vigneshv@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 Subject: [FFmpeg-devel] [PATCH] libavformat/webm_chunk: Option to specify HTTP header 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 Cc: Vignesh Venkatasubramanian MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Add an option to specify HTTP header in the WebM Chunk Muxer (this works the same way as the 'method' parameter in the HLS muxer). Signed-off-by: Vignesh Venkatasubramanian --- libavformat/webm_chunk.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index bfcde78..4c22c45 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -50,6 +50,7 @@ typedef struct WebMChunkContext { char *header_filename; int chunk_duration; int chunk_index; + char *http_method; uint64_t duration_written; int prev_pts; AVOutputFormat *oformat; @@ -112,6 +113,7 @@ static int webm_chunk_write_header(AVFormatContext *s) AVFormatContext *oc = NULL; int ret; int i; + AVDictionary *options = NULL; // DASH Streams can only have either one track per file. if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; } @@ -128,7 +130,10 @@ static int webm_chunk_write_header(AVFormatContext *s) ret = get_chunk_filename(s, 1, oc->filename); if (ret < 0) return ret; - ret = s->io_open(s, &oc->pb, oc->filename, AVIO_FLAG_WRITE, NULL); + if (wc->http_method) + av_dict_set(&options, "method", wc->http_method, 0); + ret = s->io_open(s, &oc->pb, oc->filename, AVIO_FLAG_WRITE, &options); + av_dict_free(&options); if (ret < 0) return ret; @@ -166,6 +171,7 @@ static int chunk_end(AVFormatContext *s) uint8_t *buffer; AVIOContext *pb; char filename[MAX_FILENAME_SIZE]; + AVDictionary *options = NULL; if (wc->chunk_start_index == wc->chunk_index) return 0; @@ -175,13 +181,16 @@ static int chunk_end(AVFormatContext *s) ret = get_chunk_filename(s, 0, filename); if (ret < 0) goto fail; - ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, NULL); + if (wc->http_method) + av_dict_set(&options, "method", wc->http_method, 0); + ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, &options); if (ret < 0) goto fail; avio_write(pb, buffer, buffer_size); ff_format_io_close(s, &pb); oc->pb = NULL; fail: + av_dict_free(&options); av_free(buffer); return (ret < 0) ? ret : 0; } @@ -243,6 +252,7 @@ static const AVOption options[] = { { "chunk_start_index", "start index of the chunk", OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "header", "filename of the header where the initialization data will be written", OFFSET(header_filename), AV_OPT_TYPE_STRING, { 0 }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "audio_chunk_duration", "duration of each chunk in milliseconds", OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 5000}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, + { "http_method", "set the HTTP method", OFFSET(http_method), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, };