struct _GstRTSPConnection
{
/*< private > */
- /* URL for the connection */
+ /* URL for the remote connection */
GstRTSPUrl *url;
/* connection state */
gboolean tunneled;
GstRTSPTunnelState tstate;
- gchar *ip;
+ /* the remote and local ip */
+ gchar *remote_ip;
+ gchar *local_ip;
gint read_ahead;
GstRTSPResult res;
GSocketAddress *addr;
GError *err = NULL;
- gchar *localip;
+ gchar *local_ip;
g_return_val_if_fail (G_IS_SOCKET (socket), GST_RTSP_EINVAL);
g_return_val_if_fail (ip != NULL, GST_RTSP_EINVAL);
if (!addr)
goto getnameinfo_failed;
- localip = g_inet_address_to_string (g_inet_socket_address_get_address
+ local_ip = g_inet_address_to_string (g_inet_socket_address_get_address
(G_INET_SOCKET_ADDRESS (addr)));
g_object_unref (addr);
newconn->socket0 = G_SOCKET (g_object_ref (socket));
newconn->socket1 = G_SOCKET (g_object_ref (socket));
newconn->write_socket = newconn->read_socket = newconn->socket0;
- newconn->ip = localip;
+ newconn->remote_ip = g_strdup (ip);
+ newconn->local_ip = local_ip;
newconn->initial_buffer = g_strdup (initial_buffer);
*conn = newconn;
newconn_failed:
{
GST_ERROR ("failed to make connection");
- g_free (localip);
+ g_free (local_ip);
gst_rtsp_url_free (url);
return res;
}
if (!addr)
goto getnameinfo_failed;
+ /* get the remote ip address and port */
ip = g_inet_address_to_string (g_inet_socket_address_get_address
(G_INET_SOCKET_ADDRESS (addr)));
port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr));
uri = g_strdup_printf ("%s%s%s", url->abspath, url->query ? "?" : "",
url->query ? url->query : "");
hostparam = NULL;
- ip = conn->ip;
+ ip = conn->remote_ip;
port = url_port;
}
/* and resolve the new ip address */
if (!(ip = do_resolve (value, conn->cancellable)))
goto not_resolved;
- g_free (conn->ip);
- conn->ip = ip;
+ g_free (conn->remote_ip);
+ conn->remote_ip = ip;
}
}
}
not_resolved:
{
- GST_ERROR ("could not resolve %s", conn->ip);
+ GST_ERROR ("could not resolve %s", conn->remote_ip);
res = GST_RTSP_ENET;
goto exit;
}
/* get the port from the url */
gst_rtsp_url_get_port (url, &port);
- g_free (conn->ip);
- conn->ip = ip;
+ g_free (conn->remote_ip);
+ conn->remote_ip = ip;
}
/* connect to the host/port */
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_PRAGMA, "no-cache");
if (code == GST_RTSP_STS_OK) {
- if (conn->ip)
+ /* add the local ip address to the tunnel reply, this is where the client
+ * should send the POST request to */
+ if (conn->local_ip)
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_X_SERVER_IP_ADDRESS,
- conn->ip);
+ conn->local_ip);
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CONTENT_TYPE,
"application/x-rtsp-tunnelled");
}
conn->socket1 = NULL;
}
- g_free (conn->ip);
- conn->ip = NULL;
+ g_free (conn->remote_ip);
+ conn->remote_ip = NULL;
+ g_free (conn->local_ip);
+ conn->local_ip = NULL;
conn->read_ahead = 0;
{
g_return_val_if_fail (conn != NULL, NULL);
- return conn->ip;
+ return conn->remote_ip;
}
/**
{
g_return_if_fail (conn != NULL);
- g_free (conn->ip);
- conn->ip = g_strdup (ip);
+ g_free (conn->remote_ip);
+ conn->remote_ip = g_strdup (ip);
}
/**