summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2009-01-13 17:49:07 +0000
committerWim Taymans <wim.taymans@gmail.com>2009-01-13 17:49:07 +0000
commit89060e8696a1b3daa576449095b12f9ab2e8e34a (patch)
tree42cd4df195c4b50d6f0245f469a7e6f6a5648df7 /tests
parent4b227159cba3b5953d85dd5358cefece06e5d35f (diff)
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.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/examples/rtp/server-alsasrc-PCMA.c53
1 files changed, 53 insertions, 0 deletions
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);