From: <ms...@fr...> - 2005-12-20 12:45:17
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: msmith Date: Tue Dec 20 2005 04:44:37 PST Log message: * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_render), (gst_multiudpsink_add), (gst_multiudpsink_remove), (gst_multiudpsink_get_stats): * gst/udp/gstmultiudpsink.h: Collect statistics; return them from get_stats. Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c gstmultiudpsink.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.2065&r2=1.2066 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.6&r2=1.7 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.h.diff?r1=1.2&r2=1.3 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.2065 retrieving revision 1.2066 diff -u -d -r1.2065 -r1.2066 --- ChangeLog 19 Dec 2005 15:43:29 -0000 1.2065 +++ ChangeLog 20 Dec 2005 12:44:25 -0000 1.2066 @@ -1,3 +1,11 @@ +2005-12-20 Michael Smith <ms...@fl...> + + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_render), + (gst_multiudpsink_add), (gst_multiudpsink_remove), + (gst_multiudpsink_get_stats): + * gst/udp/gstmultiudpsink.h: + Collect statistics; return them from get_stats. 2005-12-19 Edward Hervey <ed...@fl...> * gst/avi/gstavidemux.c: (gst_avi_demux_stream_scan): Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gstmultiudpsink.c 9 Sep 2005 11:09:49 -0000 1.6 +++ gstmultiudpsink.c 20 Dec 2005 12:44:25 -0000 1.7 @@ -226,8 +226,10 @@ if (errno != EINTR && errno != EAGAIN) { goto send_error; } - } else + } else { + client->bytes_sent += ret; break; + } } } g_mutex_unlock (sink->client_lock); @@ -320,6 +322,7 @@ struct in_addr addr; struct ip_mreq multi_addr; GstUDPClient *client; + GTimeVal now; GST_DEBUG_OBJECT (sink, "adding client on host %s, port %d", host, port); client = g_new0 (GstUDPClient, 1); @@ -331,6 +334,9 @@ client->theiraddr.sin_family = AF_INET; /* host byte order */ client->theiraddr.sin_port = htons (port); /* short, network byte order */ + g_get_current_time (&now); + client->connect_time = GST_TIMEVAL_TO_TIME (now); /* if its an IP address */ if (inet_aton (host, &addr)) { /* check if its a multicast address */ @@ -407,9 +413,19 @@ (GCompareFunc) client_compare); if (find) { GstUDPClient *client; + GTimeVal now; client = (GstUDPClient *) find->data; + g_get_current_time (&now); + client->disconnect_time = GST_TIMEVAL_TO_TIME (now); + /* Unlock to emit signal before we delete the actual client */ + g_mutex_unlock (sink->client_lock); + g_signal_emit (G_OBJECT (sink), + gst_multiudpsink_signals[SIGNAL_CLIENT_REMOVED], 0, host, port); + g_mutex_lock (sink->client_lock); sink->clients = g_list_delete_link (sink->clients, find); free_client (client); @@ -432,7 +448,50 @@ gst_multiudpsink_get_stats (GstMultiUDPSink * sink, const gchar * host, gint port) { - return NULL; + GstUDPClient *client; + GValueArray *result = NULL; + GstUDPClient udpclient; + GList *find; + udpclient.host = (gchar *) host; + udpclient.port = port; + g_mutex_lock (sink->client_lock); + find = g_list_find_custom (sink->clients, &udpclient, + (GCompareFunc) client_compare); + if (find) { + client = (GstUDPClient *) find->data; + GValue value = { 0 }; + /* Result is a value array of (bytes_sent, connect_time, disconnect_time) */ + result = g_value_array_new (3); + g_value_init (&value, G_TYPE_UINT64); + g_value_set_uint64 (&value, client->bytes_sent); + result = g_value_array_append (result, &value); + g_value_unset (&value); + g_value_set_uint64 (&value, client->connect_time); + g_value_set_uint64 (&value, client->disconnect_time); + } + g_mutex_unlock (sink->client_lock); + /* Apparently (see comment in gstmultifdsink.c) returning NULL from here may + * confuse/break python bindings */ + if (result == NULL) + result = g_value_array_new (0); + return result; } static GstStateChangeReturn Index: gstmultiudpsink.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gstmultiudpsink.h 6 Dec 2005 19:44:56 -0000 1.2 +++ gstmultiudpsink.h 20 Dec 2005 12:44:25 -0000 1.3 @@ -57,6 +57,11 @@ gchar *host; gint port; + /* Per-client stats */ + guint64 bytes_sent; + guint64 connect_time; + guint64 disconnect_time; } GstUDPClient; /* sends udp packets to multiple host/port pairs. |