From: Tim-Philipp Müller Date: Thu, 19 Jun 2014 17:31:05 +0000 (+0100) Subject: multiudpsink: keep count of number of unique and non-unique IPv4 and IPv6 clients X-Git-Tag: 1.6.0~707 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=675384a8cb43277643ac7302c9fa5878f1893887;p=platform%2Fupstream%2Fgst-plugins-good.git multiudpsink: keep count of number of unique and non-unique IPv4 and IPv6 clients This will come in handy later. --- diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c index c38a16a..be2b964 100644 --- a/gst/udp/gstmultiudpsink.c +++ b/gst/udp/gstmultiudpsink.c @@ -378,6 +378,12 @@ gst_multiudpsink_init (GstMultiUDPSink * sink) guint max_mem; g_mutex_init (&sink->client_lock); + sink->clients = NULL; + sink->num_v4_unique = 0; + sink->num_v4_all = 0; + sink->num_v6_unique = 0; + sink->num_v6_all = 0; + sink->socket = DEFAULT_SOCKET; sink->socket_v6 = DEFAULT_SOCKET; sink->used_socket = DEFAULT_USED_SOCKET; @@ -1238,6 +1244,7 @@ static void gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host, gint port, gboolean lock) { + GSocketFamily family; GstUDPClient *client; GstUDPClient udpclient; GTimeVal now; @@ -1253,9 +1260,12 @@ gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host, find = g_list_find_custom (sink->clients, &udpclient, (GCompareFunc) client_compare); + if (find) { client = (GstUDPClient *) find->data; + family = g_socket_address_get_family (client->addr); + GST_DEBUG_OBJECT (sink, "found %d existing clients with host %s, port %d", client->refcount, host, port); client->refcount++; @@ -1264,6 +1274,8 @@ gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host, if (!client) goto error; + family = g_socket_address_get_family (client->addr); + g_get_current_time (&now); client->connect_time = GST_TIMEVAL_TO_TIME (now); @@ -1272,8 +1284,18 @@ gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host, GST_DEBUG_OBJECT (sink, "add client with host %s, port %d", host, port); sink->clients = g_list_prepend (sink->clients, client); + + if (family == G_SOCKET_FAMILY_IPV4) + ++sink->num_v4_unique; + else + ++sink->num_v6_unique; } + if (family == G_SOCKET_FAMILY_IPV4) + ++sink->num_v4_all; + else + ++sink->num_v6_all; + if (lock) g_mutex_unlock (&sink->client_lock); @@ -1387,6 +1409,10 @@ gst_multiudpsink_clear_internal (GstMultiUDPSink * sink, gboolean lock) g_list_foreach (sink->clients, (GFunc) free_client, sink); g_list_free (sink->clients); sink->clients = NULL; + sink->num_v4_unique = 0; + sink->num_v4_all = 0; + sink->num_v6_unique = 0; + sink->num_v6_all = 0; if (lock) g_mutex_unlock (&sink->client_lock); } diff --git a/gst/udp/gstmultiudpsink.h b/gst/udp/gstmultiudpsink.h index 9b126bb..60af958 100644 --- a/gst/udp/gstmultiudpsink.h +++ b/gst/udp/gstmultiudpsink.h @@ -62,6 +62,10 @@ struct _GstMultiUDPSink { GMutex client_lock; GList *clients; + guint num_v4_unique; /* number IPv4 clients (excluding duplicates) */ + guint num_v4_all; /* number IPv4 clients (including duplicates) */ + guint num_v6_unique; /* number IPv6 clients (excluding duplicates) */ + guint num_v6_all; /* number IPv6 clients (including duplicates) */ GOutputVector *vec; GstMapInfo *map;