From patchwork Fri Dec 15 16:06:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jeyapal, Karthick" X-Patchwork-Id: 6794 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp681597jah; Fri, 15 Dec 2017 08:06:41 -0800 (PST) X-Google-Smtp-Source: ACJfBos7hqG9ANxmXSLEC6doARTGJd/lfV68QiD7G5WyyLLKMRKWAS5TtsPiK0tX3jwTh7vJTb9l X-Received: by 10.223.164.81 with SMTP id e17mr9601479wra.16.1513354001172; Fri, 15 Dec 2017 08:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513354001; cv=none; d=google.com; s=arc-20160816; b=EzlG9HNzOu+0k4FerZ3+P2Vm3K/47ORHp7eZVnoBa3LwHTKKaF1+4HaxdmXmC+dudQ l4h0R62j35fneWpJfOiQz8tTA7PvrQRhUi/HdWINWMWNV9HNS22r553ioJ3pJ6T4xdkR /k/9Z+s5UilSIZrFsP5jxOELWUS+mDGj7XtkKN3TvHYuBSoRtY0YvcWl0B0mWXOgiAam 4XqEDgIh90ydab6Fsa3dAFCBs598/xRWm9FD1yXlcjHInJQAO2w+/pKeDIEFrr/3KDtr wxfM61M8YxdTItr2mv0qGpMVGa1NGfG1Kj++2ymoOwo+m7npjBy6jAeYi+RhBnMqUrEH KAfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=LINCCDlqVA/rhADEmrErPyZ7vxFkuM4ojGfbW6ysODI=; b=ugd4Bj0xaT+SrSymDtT+d3yIrbAEwF7KT/FwsnQlwatZxWoNYF9SDhoXImYY+2nQbu 69fDHalFJvj8p6coBv1Bk5zaAYB4arkEVvYqtjGOJ8MzzDjKYqhsoSToBz1PUbVROMBW eWeuqsSEIkNyBdJGQkf/Q4kVEq5yH9exv3H+EJub9D7o7lm1Kq/Psun59UJvmCAe4OE3 XCLTJnq0sGhccH0LYodHcSkiy8DqGO+yHaJniCx7WfP2a3UJYgYB29CF3N4vNPQ0fZBi RIXz+rO49toy5anzTx7virAnaMTE/LQOlXgfXzqhhS6E/g1LUVzHZCGFQl/qWdGjFicX H2ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=qIcmRqw+; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n6si4939912wmd.173.2017.12.15.08.06.39; Fri, 15 Dec 2017 08:06:41 -0800 (PST) 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=@smtpservice.net header.s=m78bu0.a1-4.dyn header.b=qIcmRqw+; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AD6196899B4; Fri, 15 Dec 2017 18:06:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from a2i831.smtp2go.com (a2i831.smtp2go.com [103.47.207.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 542366805FD for ; Fri, 15 Dec 2017 18:06:23 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpservice.net; s=m78bu0.a1-4.dyn; x=1513354897; h=Feedback-ID: X-Smtpcorp-Track:Message-Id:Date:Subject:To:From:Reply-To:Sender: List-Unsubscribe; bh=rp6hShat+H4DDl7fArpijqcl9rQNUIhCqe8eM2Rq8oY=; b=qIcmRqw+ LH+jw+iGalsnUJKgbaAR4gpXjX+1bD5ATc2m28kVvMKwcrSZasVxvKprxaV0TGDych+AwxhyUGCi9 G2vU2Y+7ODl2LB1Kvh7jxcnxenzq+4eGGC3G+dx4S3pNzoJvSGy5qhFmL/CpKGURfnAbQsXHvBsvC u9PZkxL0XEZZIdu3m2RFcqicburLczWSgOanc9W80s0azUVrLg9cHUNs2THhCXKk75hmxuueAooXD 3xemkzleZ43o5uz10rx3pucIZOhcVpmxPNe60CUbh0LHQ1J81XkPAh+mqynLZo/wZ/Tn89eoR4xBk saC0trKo6RA5dAk+piDbKnxfAw==; From: Karthick J To: ffmpeg-devel@ffmpeg.org Date: Fri, 15 Dec 2017 21:36:11 +0530 Message-Id: <1513353972-19261-1-git-send-email-kjeyapal@akamai.com> X-Mailer: git-send-email 1.9.1 X-Smtpcorp-Track: 1-esVGRyIug9Ez.u7uDHFyAe Feedback-ID: 337386m:337386asVRLGB:337386sqb1KR1WK0:SMTPCORP X-Report-Abuse: Please forward a copy of this message, including all headers, to Subject: [FFmpeg-devel] [PATCH 1/2] avformat/hlsenc, utils: Moved is_http_proto from hlsenc to utils for re-use 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: Karthick Jeyapal MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Karthick Jeyapal --- libavformat/hlsenc.c | 12 +++--------- libavformat/internal.h | 8 ++++++++ libavformat/utils.c | 5 +++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e3442c3..03d54c7 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -240,15 +240,10 @@ static int mkdir_p(const char *path) { return ret; } -static int is_http_proto(char *filename) { - const char *proto = avio_find_protocol_name(filename); - return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0; -} - static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, AVDictionary **options) { HLSContext *hls = s->priv_data; - int http_base_proto = filename ? is_http_proto(filename) : 0; + int http_base_proto = filename ? ff_is_http_proto(filename) : 0; int err = AVERROR_MUXER_NOT_FOUND; if (!*pb || !http_base_proto || !hls->http_persistent) { err = s->io_open(s, pb, filename, AVIO_FLAG_WRITE, options); @@ -264,8 +259,7 @@ static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) { HLSContext *hls = s->priv_data; - int http_base_proto = filename ? is_http_proto(filename) : 0; - + int http_base_proto = filename ? ff_is_http_proto(filename) : 0; if (!http_base_proto || !hls->http_persistent || hls->key_info_file || hls->encrypt) { ff_format_io_close(s, pb); } else { @@ -275,7 +269,7 @@ static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSContext *c) { - int http_base_proto = is_http_proto(s->filename); + int http_base_proto = ff_is_http_proto(s->filename); if (c->method) { av_dict_set(options, "method", c->method, 0); diff --git a/libavformat/internal.h b/libavformat/internal.h index 36a5721..8f168c9 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -619,6 +619,14 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op void ff_format_io_close(AVFormatContext *s, AVIOContext **pb); /** + * Utility function to check if the file uses http or https protocol + * + * @param s AVFormatContext + * @param filename URL or file name to open for writing + */ +int ff_is_http_proto(char *filename); + +/** * Parse creation_time in AVFormatContext metadata if exists and warn if the * parsing fails. * diff --git a/libavformat/utils.c b/libavformat/utils.c index 84e4920..f18a7c8 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -5459,6 +5459,11 @@ void ff_format_io_close(AVFormatContext *s, AVIOContext **pb) *pb = NULL; } +int ff_is_http_proto(char *filename) { + const char *proto = avio_find_protocol_name(filename); + return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0; +} + int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds) { AVDictionaryEntry *entry;