summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Förlin <perfn@axis.com>2021-04-23 18:03:20 +0200
committerTim-Philipp Müller <tim@centricular.com>2021-06-24 19:44:55 +0100
commitb26b8ae6f860770b91f8553db6ecdc066c95cde6 (patch)
tree50c22efa7c009aa0a6952d253a7253ccd576cc0d
parent01c7106aa9d2734daa2521bcf17ac3ef8e8c1aba (diff)
downloadgstreamer-plugins-base-b26b8ae6f860770b91f8553db6ecdc066c95cde6.tar.gz
gstrtspconnection: Add IPv6 support for tunneled mode
An IPv6 address must be specified within [] brackets. Add brackets for IPv6 address used for tunneled mode, for non-tunneled this is already supported. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1214>
-rw-r--r--gst-libs/gst/rtsp/gstrtspconnection.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c
index 574b967ce..2bdc229cd 100644
--- a/gst-libs/gst/rtsp/gstrtspconnection.c
+++ b/gst-libs/gst/rtsp/gstrtspconnection.c
@@ -774,6 +774,22 @@ gst_rtsp_connection_set_accept_certificate_func (GstRTSPConnection * conn,
conn->accept_certificate_destroy_notify = destroy_notify;
}
+static gchar *
+get_tunneled_connection_uri_strdup (GstRTSPUrl * url, guint16 port)
+{
+ const gchar *pre_host = "";
+ const gchar *post_host = "";
+
+ if (url->family == GST_RTSP_FAM_INET6) {
+ pre_host = "[";
+ post_host = "]";
+ }
+
+ return g_strdup_printf ("http://%s%s%s:%d%s%s%s", pre_host, url->host,
+ post_host, port, url->abspath, url->query ? "?" : "",
+ url->query ? url->query : "");
+}
+
static GstRTSPResult
setup_tunneling (GstRTSPConnection * conn, gint64 timeout, gchar * uri,
GstRTSPMessage * response)
@@ -845,8 +861,7 @@ setup_tunneling (GstRTSPConnection * conn, gint64 timeout, gchar * uri,
conn->remote_ip = g_strdup (value);
}
- connection_uri = g_strdup_printf ("http://%s:%d%s%s%s", url->host, url_port,
- url->abspath, url->query ? "?" : "", url->query ? url->query : "");
+ connection_uri = get_tunneled_connection_uri_strdup (url, url_port);
/* connect to the host/port */
if (conn->proxy_host) {
@@ -998,8 +1013,7 @@ gst_rtsp_connection_connect_with_response_usec (GstRTSPConnection * conn,
gst_rtsp_url_get_port (url, &url_port);
if (conn->tunneled) {
- connection_uri = g_strdup_printf ("http://%s:%d%s%s%s", url->host, url_port,
- url->abspath, url->query ? "?" : "", url->query ? url->query : "");
+ connection_uri = get_tunneled_connection_uri_strdup (url, url_port);
} else {
connection_uri = gst_rtsp_url_get_request_uri (url);
}