From patchwork Sat Jun 13 22:31:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 20341 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 14F6D44A932 for ; Sun, 14 Jun 2020 01:32:19 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E242B68B67A; Sun, 14 Jun 2020 01:32:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A5B6568B31C for ; Sun, 14 Jun 2020 01:32:12 +0300 (EEST) Received: by mail-wr1-f43.google.com with SMTP id l10so13458216wrr.10 for ; Sat, 13 Jun 2020 15:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wJUj23PQlDMQTUtNTnTBrZTHALDC2KnRrijZ6hMVci4=; b=keZy+LK9Wmtb6SnM238KuSHqYmKB1WmKVEnsOlSyVWYyZ75JRXg+H6xirtpOJUyzBh 6FNMqC/nsn7TjIYyZYtNeZ9389J0/ZpYBw4dOQtFNkURlx4neLmT3rf5VLH3Z6UtT7lN yAGtncgrVohbfpR/D/tAIx5nGb5eFLO4opxOFPkMWBGz/RByob6ATrtvfhUleVUfnc8Z b9C4mJwcy02+WELbjqPwymcSMbtaXgpz/EdFXBsXGaFB7F/gwIpw71NbZFvH7o3Hep+X 2lRU/HjtKAsFiyer1csnFOfeh1RQrq81WXSWCv17hHusfSsC04Amd2N3Zq5AKqUHbodD ETeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wJUj23PQlDMQTUtNTnTBrZTHALDC2KnRrijZ6hMVci4=; b=ssLSHPoGJeAKWJIsS43cWRUzjBGqs/McN3eoUXBIOT7tTLO11YxDglugigmLAHtWQa GjT7iXXz/7+2biauwOZ9XhcxxxTPj1eIlpTUjKzRlld6vgzu73VmIdjltL6kg+zzTUd3 M3/B+9zaU0FOfEkphzZHxoTx9n0VhrKFakuOKiiW1QTgBn9sWR0hVVobZPUgr9Z7lpPc 9Yh4Xjvm094yFcBcWVUHngkgmHPFSVYclAQ0LJPWMDOblhSil3zuawJON4WchXs0y+xb ST5j3W2VqeWX+TYOodxw8TJBaq0J6hU+Ksl/SsVrI/EfAy+eZZijmPwyX38EpjD5Nm8M ZScA== X-Gm-Message-State: AOAM532HxmN+WFmay3a4S6Oz4wltYEmbzGzq2mKBZVrcZOc659dfs2rU vT8mPmV/aCchrOg4PHg2hLZCkC8xniQ= X-Google-Smtp-Source: ABdhPJzg9L9eYTAu3487LRb6wI+DuJZeXYuOKgDCveg5ynt0O+V/T+BR2hPxZ6r3/+XHCVh4NYE+Gw== X-Received: by 2002:adf:e604:: with SMTP id p4mr21035068wrm.212.1592087531884; Sat, 13 Jun 2020 15:32:11 -0700 (PDT) Received: from localhost.localdomain (h082218239149.host.wavenet.at. [82.218.239.149]) by smtp.gmail.com with ESMTPSA id k14sm16228724wrq.97.2020.06.13.15.32.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jun 2020 15:32:11 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Jun 2020 00:31:58 +0200 Message-Id: <20200613223158.63585-1-epirat07@gmail.com> X-Mailer: git-send-email 2.24.1 (Apple Git-126) In-Reply-To: <20200613215808.62675-1-epirat07@gmail.com> References: <20200613215808.62675-1-epirat07@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avformat/icecast: Add option to use TLS connection 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: Marvin Scholz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- doc/protocols.texi | 3 +++ libavformat/icecast.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 7aa758541c..32c829d2a3 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -520,6 +520,9 @@ audio/mpeg. This enables support for Icecast versions < 2.4.0, that do not support the HTTP PUT method but the SOURCE method. +@item tls +Establish a TLS (HTTPS) connection to Icecast. + @end table @example diff --git a/libavformat/icecast.c b/libavformat/icecast.c index 38af16b99e..cd70d3d337 100644 --- a/libavformat/icecast.c +++ b/libavformat/icecast.c @@ -43,6 +43,7 @@ typedef struct IcecastContext { int public; char *url; char *user_agent; + int tls; } IcecastContext; #define DEFAULT_ICE_USER "source" @@ -62,6 +63,7 @@ static const AVOption options[] = { { "password", "set password", OFFSET(pass), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E }, { "content_type", "set content-type, MUST be set if not audio/mpeg", OFFSET(content_type), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E }, { "legacy_icecast", "use legacy SOURCE method, for Icecast < v2.4", OFFSET(legacy_icecast), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E }, + { "tls", "use a TLS connection", OFFSET(tls), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E }, { NULL } }; @@ -89,6 +91,7 @@ static int icecast_open(URLContext *h, const char *uri, int flags) // URI part variables char h_url[1024], host[1024], auth[1024], path[1024]; char *headers, *user = NULL; + const char *real_proto; int port, ret; AVBPrint bp; @@ -161,8 +164,11 @@ static int icecast_open(URLContext *h, const char *uri, int flags) goto cleanup; } + // Check which underlying protocol should be used + real_proto = (s->tls) ? "https" : "http"; + // Build new URI for passing to http protocol - ff_url_join(h_url, sizeof(h_url), "http", auth, host, port, "%s", path); + ff_url_join(h_url, sizeof(h_url), real_proto, auth, host, port, "%s", path); // Finally open http proto handler ret = ffurl_open_whitelist(&s->hd, h_url, AVIO_FLAG_READ_WRITE, NULL, &opt_dict, h->protocol_whitelist, h->protocol_blacklist, h);