summaryrefslogtreecommitdiff
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2014-10-09 19:35:34 +0200
committerLuca Barbato <lu_zero@gentoo.org>2014-10-10 16:29:06 +0200
commit8b2e9636c57b22582143467a8a06b509b47b92f9 (patch)
tree1f6d68a794c6eac54eaa83765491dd849e0358b7 /libavformat/rtsp.c
parentc27328e749ff3be648411765cd17362fee017341 (diff)
rtsp: Support tls-encapsulated RTSP
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 646712e5ab..d574797199 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1589,10 +1589,13 @@ void ff_rtsp_close_connections(AVFormatContext *s)
int ff_rtsp_connect(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
- char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128];
+ char proto[128], host[1024], path[1024];
+ char tcpname[1024], cmd[2048], auth[128];
+ const char *lower_rtsp_proto = "tcp";
int port, err, tcp_fd;
RTSPMessageHeader reply1 = {0}, *reply = &reply1;
int lower_transport_mask = 0;
+ int default_port = RTSP_DEFAULT_PORT;
char real_challenge[64] = "";
struct sockaddr_storage peer;
socklen_t peer_len = sizeof(peer);
@@ -1619,15 +1622,23 @@ int ff_rtsp_connect(AVFormatContext *s)
rt->lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
redirect:
- lower_transport_mask = rt->lower_transport_mask;
/* extract hostname and port */
- av_url_split(NULL, 0, auth, sizeof(auth),
+ av_url_split(proto, sizeof(proto), auth, sizeof(auth),
host, sizeof(host), &port, path, sizeof(path), s->filename);
+
+ if (!strcmp(proto, "rtsps")) {
+ lower_rtsp_proto = "tls";
+ default_port = RTSPS_DEFAULT_PORT;
+ rt->lower_transport_mask = 1 << RTSP_LOWER_TRANSPORT_TCP;
+ }
+
if (*auth) {
av_strlcpy(rt->auth, auth, sizeof(rt->auth));
}
if (port < 0)
- port = RTSP_DEFAULT_PORT;
+ port = default_port;
+
+ lower_transport_mask = rt->lower_transport_mask;
if (!lower_transport_mask)
lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
@@ -1647,7 +1658,7 @@ redirect:
/* Construct the URI used in request; this is similar to s->filename,
* but with authentication credentials removed and RTSP specific options
* stripped out. */
- ff_url_join(rt->control_uri, sizeof(rt->control_uri), "rtsp", NULL,
+ ff_url_join(rt->control_uri, sizeof(rt->control_uri), proto, NULL,
host, port, "%s", path);
if (rt->control_transport == RTSP_MODE_TUNNEL) {
@@ -1726,7 +1737,8 @@ redirect:
}
} else {
/* open the tcp connection */
- ff_url_join(tcpname, sizeof(tcpname), "tcp", NULL, host, port, NULL);
+ ff_url_join(tcpname, sizeof(tcpname), lower_rtsp_proto, NULL,
+ host, port, NULL);
if (ffurl_open(&rt->rtsp_hd, tcpname, AVIO_FLAG_READ_WRITE,
&s->interrupt_callback, NULL) < 0) {
err = AVERROR(EIO);