From c41a4d0df48ab3a6f04b3d5750d456fe0c6484a2 Mon Sep 17 00:00:00 2001 From: Andoni Morales Alastruey Date: Wed, 13 Oct 2010 17:09:13 +0200 Subject: [PATCH] multifdsink: add first and last buffer's timestamp to the stats --- gst/tcp/gstmultifdsink.c | 20 +++++++++++++++++++- gst/tcp/gstmultifdsink.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gst/tcp/gstmultifdsink.c b/gst/tcp/gstmultifdsink.c index dcc1879b12..f72bfff4dd 100644 --- a/gst/tcp/gstmultifdsink.c +++ b/gst/tcp/gstmultifdsink.c @@ -846,6 +846,8 @@ gst_multi_fd_sink_add_full (GstMultiFdSink * sink, int fd, client->bytes_sent = 0; client->dropped_buffers = 0; client->avg_queue_size = 0; + client->first_buffer_ts = GST_CLOCK_TIME_NONE; + client->last_buffer_ts = GST_CLOCK_TIME_NONE; client->new_connection = TRUE; client->burst_min_unit = min_unit; client->burst_min_value = min_value; @@ -1036,6 +1038,8 @@ restart: * guint64 : time the client is/was connected (in nanoseconds) * guint64 : last activity time (in nanoseconds, since Epoch) * guint64 : buffers dropped due to recovery + * guint64 : timestamp of the first buffer sent (in nanoseconds) + * guint64 : timestamp of the last buffer sent (in nanoseconds) */ GValueArray * gst_multi_fd_sink_get_stats (GstMultiFdSink * sink, int fd) @@ -1054,7 +1058,7 @@ gst_multi_fd_sink_get_stats (GstMultiFdSink * sink, int fd) GValue value = { 0 }; guint64 interval; - result = g_value_array_new (5); + result = g_value_array_new (7); g_value_init (&value, G_TYPE_UINT64); g_value_set_uint64 (&value, client->bytes_sent); @@ -1088,6 +1092,14 @@ gst_multi_fd_sink_get_stats (GstMultiFdSink * sink, int fd) g_value_init (&value, G_TYPE_UINT64); g_value_set_uint64 (&value, client->dropped_buffers); result = g_value_array_append (result, &value); + g_value_unset (&value); + g_value_init (&value, G_TYPE_UINT64); + g_value_set_uint64 (&value, client->first_buffer_ts); + result = g_value_array_append (result, &value); + g_value_unset (&value); + g_value_init (&value, G_TYPE_UINT64); + g_value_set_uint64 (&value, client->last_buffer_ts); + result = g_value_array_append (result, &value); } noclient: @@ -2065,6 +2077,12 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink, buf = g_array_index (sink->bufqueue, GstBuffer *, client->bufpos); client->bufpos--; + /* update stats */ + if (client->first_buffer_ts == GST_CLOCK_TIME_NONE) + client->first_buffer_ts = GST_BUFFER_TIMESTAMP (buf); + client->last_buffer_ts = GST_BUFFER_TIMESTAMP (buf); + + /* decrease flushcount */ if (client->flushcount != -1) client->flushcount--; diff --git a/gst/tcp/gstmultifdsink.h b/gst/tcp/gstmultifdsink.h index d2d9ce4e5b..0ee7888527 100644 --- a/gst/tcp/gstmultifdsink.h +++ b/gst/tcp/gstmultifdsink.h @@ -176,6 +176,8 @@ typedef struct { guint64 last_activity_time; guint64 dropped_buffers; guint64 avg_queue_size; + guint64 first_buffer_ts; + guint64 last_buffer_ts; } GstTCPClient; #define CLIENTS_LOCK_INIT(fdsink) (g_static_rec_mutex_init(&fdsink->clientslock))