From 89060e8696a1b3daa576449095b12f9ab2e8e34a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 13 Jan 2009 17:49:07 +0000 Subject: tests/examples/rtp/server-alsasrc-PCMA.c: Add some example code for printing the RTP manager stats. Original commit message from CVS: * tests/examples/rtp/server-alsasrc-PCMA.c: (print_source_stats), (print_stats), (main): Add some example code for printing the RTP manager stats. --- tests/examples/rtp/server-alsasrc-PCMA.c | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'tests') diff --git a/tests/examples/rtp/server-alsasrc-PCMA.c b/tests/examples/rtp/server-alsasrc-PCMA.c index 3af888a0..c237d7e5 100755 --- a/tests/examples/rtp/server-alsasrc-PCMA.c +++ b/tests/examples/rtp/server-alsasrc-PCMA.c @@ -52,6 +52,56 @@ #define AUDIO_ENC "alawenc" #define AUDIO_PAY "rtppcmapay" +/* print the stats of a source */ +static void +print_source_stats (GObject * source) +{ + GstStructure *stats; + gchar *str; + + /* get the source stats */ + g_object_get (source, "stats", &stats, NULL); + + /* simply dump the stats structure */ + str = gst_structure_to_string (stats); + g_print ("source stats: %s\n", str); + + gst_structure_free (stats); + g_free (str); +} + +/* this function is called every second and dumps the RTP manager stats */ +static gboolean +print_stats (GstElement * rtpbin) +{ + GObject *session; + GValueArray *arr; + GValue *val; + guint i; + + g_print ("***********************************\n"); + + /* get session 0 */ + g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session); + + /* print all the sources in the session, this includes the internal source */ + g_object_get (session, "sources", &arr, NULL); + + for (i = 0; i < arr->n_values; i++) { + GObject *source; + + val = g_value_array_get_nth (arr, i); + source = g_value_get_object (val); + + print_source_stats (source); + } + g_value_array_free (arr); + + g_object_unref (session); + + return TRUE; +} + /* build a pipeline equivalent to: * * gst-launch -v gstrtpbin name=rtpbin \ @@ -157,6 +207,9 @@ main (int argc, char *argv[]) g_print ("starting sender pipeline\n"); gst_element_set_state (pipeline, GST_STATE_PLAYING); + /* print stats every second */ + g_timeout_add (1000, (GSourceFunc) print_stats, rtpbin); + /* we need to run a GLib main loop to get the messages */ loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); -- cgit