summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Förlin <perfn@axis.com>2021-06-01 15:27:31 +0200
committerNirbheek Chauhan <nirbheek@centricular.com>2021-08-16 09:06:37 +0000
commit535c02c73b62eb1d9d72e77be873e11e6c94051e (patch)
tree41009f5ec45182dcf7896c0c6df123e13a7ce06f
parent3ced923da5baf8b7f64dc3b126195aae9b835099 (diff)
downloadgstreamer-plugins-base-535c02c73b62eb1d9d72e77be873e11e6c94051e.tar.gz
gstrtspconnection: Add support to ignore x-server header reply
When connecting to an RTSP server in tunnled mode (HTTP) the server usually replies with a x-server header. This contains the address of the intended streaming server. However some servers return an "invalid" address. Here follows two examples when it might happen. 1. A server use Apache combined with a separate RTSP process to handle Https request on port 443. In this case Apache handle TLS and connects to the local RTSP server, which results in a local address 127.0.0.1 or ::1 in the x-server reply. This address is returned to the actual RTSP client in the x-server header. The client will receive this address and try to connect to it and fail. 2. The client use a ipv6 link local address with a specified scope id fe80::aaaa:bbbb:cccc:dddd%eth0 and connects via Http on port 80. The RTSP server receives the connection and returns the address in the x-server header. The client will receive this address and try to connect to it "as is" without the scope id and fail. In the case of streaming data from RTSP servers like 1. and 2. it's useful to have the option to simply ignore the x-server header reply and continue using the original address. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1192>
-rw-r--r--gst-libs/gst/rtsp/gstrtspconnection.c43
-rw-r--r--gst-libs/gst/rtsp/gstrtspconnection.h6
2 files changed, 48 insertions, 1 deletions
diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c
index b2d3f8ab5..64eb4b89a 100644
--- a/gst-libs/gst/rtsp/gstrtspconnection.c
+++ b/gst-libs/gst/rtsp/gstrtspconnection.c
@@ -173,6 +173,7 @@ struct _GstRTSPConnection
gchar tunnelid[TUNNELID_LEN];
gboolean tunneled;
+ gboolean ignore_x_server_reply;
GstRTSPTunnelState tstate;
/* the remote and local ip */
@@ -878,7 +879,8 @@ setup_tunneling (GstRTSPConnection * conn, gint64 timeout, gchar * uri,
response->type_data.response.code != GST_RTSP_STS_OK)
goto wrong_result;
- if (gst_rtsp_message_get_header (response, GST_RTSP_HDR_X_SERVER_IP_ADDRESS,
+ if (!conn->ignore_x_server_reply &&
+ gst_rtsp_message_get_header (response, GST_RTSP_HDR_X_SERVER_IP_ADDRESS,
&value, 0) == GST_RTSP_OK) {
g_free (url->host);
url->host = g_strdup (value);
@@ -3464,6 +3466,45 @@ gst_rtsp_connection_get_tunnelid (const GstRTSPConnection * conn)
}
/**
+ * gst_rtsp_connection_set_ignore_x_server_reply:
+ * @conn: a #GstRTSPConnection
+ * @ignore: %TRUE to ignore the x-server-ip-address header reply or %FALSE to
+ * comply with it (%FALSE is the default).
+ *
+ * Set whether to ignore the x-server-ip-address header reply or not. If the
+ * header is ignored, the original address will be used instead.
+ *
+ * Since: 1.20
+ */
+void
+gst_rtsp_connection_set_ignore_x_server_reply (GstRTSPConnection * conn,
+ gboolean ignore)
+{
+ g_return_if_fail (conn != NULL);
+
+ conn->ignore_x_server_reply = ignore;
+}
+
+/**
+ * gst_rtsp_connection_get_ignore_x_server_reply:
+ * @conn: a #GstRTSPConnection
+ *
+ * Get the ignore_x_server_reply value.
+ *
+ * Returns: returns %TRUE if the x-server-ip-address header reply will be
+ * ignored, else returns %FALSE
+ *
+ * Since: 1.20
+ */
+gboolean
+gst_rtsp_connection_get_ignore_x_server_reply (const GstRTSPConnection * conn)
+{
+ g_return_val_if_fail (conn != NULL, FALSE);
+
+ return conn->ignore_x_server_reply;
+}
+
+/**
* gst_rtsp_connection_do_tunnel:
* @conn: a #GstRTSPConnection
* @conn2: a #GstRTSPConnection or %NULL
diff --git a/gst-libs/gst/rtsp/gstrtspconnection.h b/gst-libs/gst/rtsp/gstrtspconnection.h
index 21eee0da2..2eeb462bd 100644
--- a/gst-libs/gst/rtsp/gstrtspconnection.h
+++ b/gst-libs/gst/rtsp/gstrtspconnection.h
@@ -235,6 +235,12 @@ void gst_rtsp_connection_set_remember_session_id (GstRTSPConnectio
GST_RTSP_API
gboolean gst_rtsp_connection_get_remember_session_id (GstRTSPConnection *conn);
+GST_RTSP_API
+void gst_rtsp_connection_set_ignore_x_server_reply (GstRTSPConnection *conn, gboolean ignore);
+
+GST_RTSP_API
+gboolean gst_rtsp_connection_get_ignore_x_server_reply (const GstRTSPConnection *conn);
+
/* async IO */
/**