From 3e55e0e46784ed687a863064e49015918525fcb1 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 7 Sep 2012 17:14:30 +0200 Subject: [PATCH] client: use more GIO Fixes https://bugzilla.gnome.org/show_bug.cgi?id=681593 --- gst/rtsp-server/rtsp-client.c | 49 ++++++++--------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c index 89a8b64c75..81b5bd8435 100644 --- a/gst/rtsp-server/rtsp-client.c +++ b/gst/rtsp-server/rtsp-client.c @@ -18,19 +18,7 @@ */ #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "rtsp-client.h" #include "rtsp-sdp.h" @@ -73,7 +61,7 @@ static void gst_rtsp_client_set_property (GObject * object, guint propid, const GValue * value, GParamSpec * pspec); static void gst_rtsp_client_finalize (GObject * obj); -static GstSDPMessage * create_sdp (GstRTSPClient * client, GstRTSPMedia * media); +static GstSDPMessage *create_sdp (GstRTSPClient * client, GstRTSPMedia * media); static void client_session_finalized (GstRTSPClient * client, GstRTSPSession * session); static void unlink_session_streams (GstRTSPClient * client, @@ -2012,9 +2000,6 @@ attach_client (GstRTSPClient * client, GSocket * socket, GSource *source; GMainContext *context; GstRTSPUrl *url; - struct sockaddr_storage addr; - socklen_t addrlen; - gchar ip[INET6_ADDRSTRLEN]; read_socket = gst_rtsp_connection_get_read_socket (conn); client->is_ipv6 = g_socket_get_family (socket) == G_SOCKET_FAMILY_IPV6; @@ -2022,18 +2007,17 @@ attach_client (GstRTSPClient * client, GSocket * socket, if (!(addres = g_socket_get_remote_address (read_socket, error))) goto no_address; - addrlen = sizeof (addr); - if (!g_socket_address_to_native (addres, &addr, addrlen, error)) - goto native_failed; - g_object_unref (addres); - - if (getnameinfo ((struct sockaddr *) &addr, addrlen, ip, sizeof (ip), NULL, 0, - NI_NUMERICHOST) != 0) - goto getnameinfo_failed; - - /* keep the original ip that the client connected to */ g_free (client->server_ip); - client->server_ip = g_strndup (ip, sizeof (ip)); + /* keep the original ip that the client connected to */ + if (G_IS_INET_SOCKET_ADDRESS (addres)) { + GInetAddress *iaddr; + + iaddr = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (addres)); + + client->server_ip = g_inet_address_to_string (iaddr); + } else { + client->server_ip = g_strdup ("unknown"); + } GST_INFO ("client %p connected to server ip %s, ipv6 = %d", client, client->server_ip, client->is_ipv6); @@ -2066,17 +2050,6 @@ no_address: GST_ERROR ("could not get remote address %s", (*error)->message); return FALSE; } -native_failed: - { - g_object_unref (addres); - GST_ERROR ("could not get native address %s", (*error)->message); - return FALSE; - } -getnameinfo_failed: - { - GST_ERROR ("getnameinfo failed: %s", g_strerror (errno)); - return FALSE; - } } /**