diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2013-04-04 12:32:24 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2013-04-04 12:34:09 +0200 |
commit | 21837ea7d50742c69323dfcecbe0f2a07acae99d (patch) | |
tree | a2ed77f9acf89a39ff21f5b383497fe53b6ea644 | |
parent | fb8561f4caf3ad48741a1259198d3768b5060ad8 (diff) |
rtsp: make local_ip and remote_ip variables
Separate local_ip and remote_ip into separate variables for clarity.
-rw-r--r-- | gst-libs/gst/rtsp/gstrtspconnection.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index 269283e0e..0033f92e5 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -105,7 +105,7 @@ typedef enum struct _GstRTSPConnection { /*< private > */ - /* URL for the connection */ + /* URL for the remote connection */ GstRTSPUrl *url; /* connection state */ @@ -119,7 +119,9 @@ struct _GstRTSPConnection gboolean tunneled; GstRTSPTunnelState tstate; - gchar *ip; + /* the remote and local ip */ + gchar *remote_ip; + gchar *local_ip; gint read_ahead; @@ -244,7 +246,7 @@ gst_rtsp_connection_create_from_socket (GSocket * socket, const gchar * ip, 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); @@ -258,7 +260,7 @@ gst_rtsp_connection_create_from_socket (GSocket * socket, const gchar * ip, 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); @@ -275,7 +277,8 @@ gst_rtsp_connection_create_from_socket (GSocket * socket, const gchar * ip, 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; @@ -292,7 +295,7 @@ getnameinfo_failed: newconn_failed: { GST_ERROR ("failed to make connection"); - g_free (localip); + g_free (local_ip); gst_rtsp_url_free (url); return res; } @@ -331,6 +334,7 @@ gst_rtsp_connection_accept (GSocket * socket, GstRTSPConnection ** conn, 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)); @@ -532,7 +536,7 @@ setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout) 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; } @@ -586,8 +590,8 @@ setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout) /* 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; } } @@ -658,7 +662,7 @@ wrong_result: } 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; } @@ -713,8 +717,8 @@ gst_rtsp_connection_connect (GstRTSPConnection * conn, GTimeVal * timeout) /* 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 */ @@ -2012,9 +2016,11 @@ gen_tunnel_reply (GstRTSPConnection * conn, GstRTSPStatusCode code, 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"); } @@ -2180,8 +2186,10 @@ gst_rtsp_connection_close (GstRTSPConnection * conn) 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; @@ -2674,7 +2682,7 @@ gst_rtsp_connection_get_ip (const GstRTSPConnection * conn) { g_return_val_if_fail (conn != NULL, NULL); - return conn->ip; + return conn->remote_ip; } /** @@ -2689,8 +2697,8 @@ gst_rtsp_connection_set_ip (GstRTSPConnection * conn, const gchar * 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); } /** |