From patchwork Sat Jun 13 21:58:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 20340 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 BE17E44BB34 for ; Sun, 14 Jun 2020 01:06:41 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9635468B66B; Sun, 14 Jun 2020 01:06:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5BEB768B56C for ; Sun, 14 Jun 2020 01:06:35 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id b82so2609001wmb.1 for ; Sat, 13 Jun 2020 15:06:35 -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:mime-version :content-transfer-encoding; bh=CdFVCPTXsx8j9ZUXT5utd2DCIjGqMd/qs8h8hxntE/w=; b=en+RpY1ARPLqsGemQuzJZB4ITfZhjbROfBQ1vn+yROYQz2dmy+uZSZtrsuFmpvpqt8 lCGnPHMz9JxZOt2RfWMJaUbT8KsmYISLqsjd14kk4scj153fEGB0A9hSTKneYA6Nxm2a rd5xP8uqGB8JFgjb9VeKBjz7JIwKjHgtrQ6pvBnkpmNgiTTynGeFq6ExDuDtwSzbVKEq Jpqf3zVOH4wrTbT1aYnGBYLECXwuZblbRfDmoFs4+V2H+mWVc3SEvV4Ll/1cxzl7F1MR 6AXFDM3X81IHDn1cQ8Hz7/ygQkp6L6Vceo5IpI3kVUSx1Tk5T3//uSOHwX49Fy0AeYeA 6N9w== 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:mime-version :content-transfer-encoding; bh=CdFVCPTXsx8j9ZUXT5utd2DCIjGqMd/qs8h8hxntE/w=; b=oLRekRrFmxnS/7Jpri7KI9kVCDeopWokwEM41B2Z2ORbaFI1WkHcXHm/AsZ+BRSQcT neaU38qrmmhRHoAjZQkbJg+eSlP0vaNW+DaDRbAj+dOQk/sqSR3ShM5+q0/2eyscvQhS jzPkraUSjEnq53vC2fP/Wek2kfbuzUbP0W3Lh5ObPqMGPpOvVrzBowq6/eQjL5FWcuN7 XY8KOZn//OCw2zQtUMhCymkJgbgA/9LQJxVA5o0BaqRfujIUGfGRClowHwiVEuMriYkn 8ZEl9GX6WPaPKYUzFaiR5v8QOREKFTxNEvJUmWZQLRrCvDw5zUco6mjlum9Gzj9xURbx 9dQg== X-Gm-Message-State: AOAM530sxfz5P8h1QDpOPYTydUPymf+PIAzR4o5pb29T1b3bh2LyihJA /P9T54asjljVLPILmze9G79VpT5CLKI= X-Google-Smtp-Source: ABdhPJyWym8AqjmKr7JM+cE/PCqAZAtYloodlOqh7sSvmHDTAhcloOi8IwI+FaZxyfWOBcRQfi7uHw== X-Received: by 2002:a1c:e057:: with SMTP id x84mr5708460wmg.160.1592085502006; Sat, 13 Jun 2020 14:58:22 -0700 (PDT) Received: from localhost.localdomain (h082218239149.host.wavenet.at. [82.218.239.149]) by smtp.gmail.com with ESMTPSA id i10sm16459206wrw.51.2020.06.13.14.58.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jun 2020 14:58:21 -0700 (PDT) From: Marvin Scholz To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Jun 2020 23:58:08 +0200 Message-Id: <20200613215808.62675-1-epirat07@gmail.com> X-Mailer: git-send-email 2.24.1 (Apple Git-126) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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 | 7 ++++++- 2 files changed, 9 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..5073367fd4 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 } }; @@ -161,8 +163,11 @@ static int icecast_open(URLContext *h, const char *uri, int flags) goto cleanup; } + // Check which underlying protocol should be used + const char *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);