From patchwork Sun Oct 16 16:24:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jay X-Patchwork-Id: 1020 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.133 with SMTP id o127csp44274vsd; Sun, 16 Oct 2016 09:24:48 -0700 (PDT) X-Received: by 10.194.242.1 with SMTP id wm1mr9056641wjc.145.1476635088833; Sun, 16 Oct 2016 09:24:48 -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 le9si30671509wjc.142.2016.10.16.09.24.48; Sun, 16 Oct 2016 09:24:48 -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=@gmail.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; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4265B68988D; Sun, 16 Oct 2016 19:24:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1984E68974E for ; Sun, 16 Oct 2016 19:24:38 +0300 (EEST) Received: by mail-qk0-f193.google.com with SMTP id v138so12114993qka.2 for ; Sun, 16 Oct 2016 09:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=hrJcNuRUQEzYVrbLSZ8/pvST5lBbduKCo0VCHqEEUao=; b=f/Q/2OUeOzhjtJ8JBbZJUqo7DXpR7JULeow4BbxTJHZgYWL3zhiBjFqz5V1meweE/5 T8jLJjvou+Xfu/ZlDAAcLNNxwN+EBoRL5Dyv76H4J3S3LR2v74f1Wtz/MIA+t8VWKxJY /hE5FuNDRagqewzAQduwhMol9sLB47vKT1cbEEjwMbabJwqHdvM1B4I08xXQKMx9wkcq QMjLKRsU9w6nC0qUy8eqXsRAkEk5ebt0P1Z/eDGCjNKxEm/mJNj2+0jxnYWgy3ostb4B AoFeVBhbHvOEiO+SpmWhnzwuGygTPXmz97N7v7deUfBn7O1zZu6C6iwhCnamDr6aIj7O ZKwg== 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=hrJcNuRUQEzYVrbLSZ8/pvST5lBbduKCo0VCHqEEUao=; b=Mt2lZo1N9tR15hf1EU0qojS7Awq6md/fZejSiEpZquHeJytGh4VCFiZPj6ru+M7/fA QKUIqlSTr0fuwAP10tjBSynJzVRLNF08+i3FHpQrUp4jHloWOKD4CoY5syouVxbZIiWZ lu9Q8cNlNsRgSL0n9QvLPiLthWDIVpNFfoN3+F0cdjylm+cJAJdO/q86zpCEXLvA0ija rSb0zSCr6fOzEvrh8ckLGFJM1ixojaet3jCKGBKWur4YHdK/+m9F4nY9Wszz1pRPmtAK ev1SZMGHc9Ji3pS8wyWvHeP9bLaZ82TNMzcZB4h/AruSOuJ7e+bFAFNh7Ak7YQBX83As H+0A== X-Gm-Message-State: AA6/9RmK8mlgEfMyf6X44gV9fq2Fc/kme0jc3hI7S0aCHiogIpmtBsxdsnSG58LhtZdseg== X-Received: by 10.55.111.68 with SMTP id k65mr9092875qkc.9.1476635078838; Sun, 16 Oct 2016 09:24:38 -0700 (PDT) Received: from localhost.localdomain (pool-96-255-15-101.washdc.fios.verizon.net. [96.255.15.101]) by smtp.gmail.com with ESMTPSA id p58sm12774235qte.49.2016.10.16.09.24.38 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 16 Oct 2016 09:24:38 -0700 (PDT) From: jayridge@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Oct 2016 12:24:37 -0400 Message-Id: <1476635077-47726-1-git-send-email-jayridge@gmail.com> X-Mailer: git-send-email 2.6.3 Subject: [FFmpeg-devel] [PATCH] avformat/rtsp: support rtsps 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: Jay Ridgeway MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Jay Ridgeway Pass TLS args to support RTSPS. This patch requires TLS patch. --- libavformat/rtsp.c | 19 ++++++++++++++++--- libavformat/rtsp.h | 8 ++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index c6292c5..53ecb6c 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -78,6 +78,7 @@ { "reorder_queue_size", "set number of packets to buffer for handling of reordered packets", OFFSET(reordering_queue_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC }, \ { "buffer_size", "Underlying protocol send/receive buffer size", OFFSET(buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC|ENC } \ +#define NONNULLSTR(s) (s ? s : "") const AVOption ff_rtsp_options[] = { { "initial_pause", "do not start playing the stream immediately", OFFSET(initial_pause), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC }, @@ -97,6 +98,10 @@ const AVOption ff_rtsp_options[] = { { "stimeout", "set timeout (in microseconds) of socket TCP I/O operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC }, COMMON_OPTS(), { "user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC }, + { "ca_file", "Certificate Authority database file", OFFSET(ca_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC|ENC }, + { "tls_verify", "verify the peer certificate", OFFSET(verify), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC|ENC}, + { "cert_file", "certificate file", OFFSET(cert_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC|ENC }, + { "key_file", "private key file", OFFSET(key_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC|ENC }, { NULL }, }; @@ -1812,9 +1817,17 @@ redirect: } else { int ret; /* open the tcp connection */ - ff_url_join(tcpname, sizeof(tcpname), lower_rtsp_proto, NULL, - host, port, - "?timeout=%d", rt->stimeout); + if (strcmp("tls", lower_rtsp_proto) == 0) { + ff_url_join(tcpname, sizeof(tcpname), lower_rtsp_proto, NULL, + host, port, + "?timeout=%d&verify=%d&cafile=%s&cert_file=%s&key_file=%s", + rt->stimeout, rt->verify, NONNULLSTR(rt->ca_file), + NONNULLSTR(rt->cert_file), NONNULLSTR(rt->key_file)); + } else { + ff_url_join(tcpname, sizeof(tcpname), lower_rtsp_proto, NULL, + host, port, + "?timeout=%d", rt->stimeout); + } if ((ret = ffurl_open_whitelist(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE, &s->interrupt_callback, NULL, s->protocol_whitelist, s->protocol_blacklist, NULL)) < 0) { err = ret; diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h index 852fd67..fa872a8 100644 --- a/libavformat/rtsp.h +++ b/libavformat/rtsp.h @@ -408,6 +408,14 @@ typedef struct RTSPState { char default_lang[4]; int buffer_size; + + /** The following are used for RTSPS streams */ + //@{ + char *ca_file; + int verify; + char *cert_file; + char *key_file; + //@} } RTSPState; #define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets -