From 2541ddf123997b8a278be7a3563e2eef1fe2e864 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 11 Apr 2013 14:04:45 +0100 Subject: [PATCH] nettimeprovider: notify of changed bound address Notify when the bound address is known, just like the port. --- libs/gst/net/gstnettimeprovider.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libs/gst/net/gstnettimeprovider.c b/libs/gst/net/gstnettimeprovider.c index 5ad1b83..c4b4ef2 100644 --- a/libs/gst/net/gstnettimeprovider.c +++ b/libs/gst/net/gstnettimeprovider.c @@ -280,6 +280,7 @@ gst_net_time_provider_start (GstNetTimeProvider * self) GSocket *socket; GError *err = NULL; int port; + gchar *address; if (self->priv->address) { inet_addr = g_inet_address_new_from_string (self->priv->address); @@ -307,14 +308,25 @@ gst_net_time_provider_start (GstNetTimeProvider * self) bound_addr = g_socket_get_local_address (socket, NULL); port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (bound_addr)); - GST_DEBUG_OBJECT (self, "bound on UDP port %d", port); - g_object_unref (bound_addr); - + inet_addr = + g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (bound_addr)); + address = g_inet_address_to_string (inet_addr); + + if (g_strcmp0 (address, self->priv->address)) { + g_free (self->priv->address); + self->priv->address = address; + GST_DEBUG_OBJECT (self, "notifying address %s", address); + g_object_notify (G_OBJECT (self), "address"); + } else { + g_free (address); + } if (port != self->priv->port) { self->priv->port = port; GST_DEBUG_OBJECT (self, "notifying port %d", port); g_object_notify (G_OBJECT (self), "port"); } + GST_DEBUG_OBJECT (self, "bound on UDP address %s, port %d", address, port); + g_object_unref (bound_addr); self->priv->socket = socket; self->priv->cancel = g_cancellable_new (); -- 2.7.4