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.
This commit is contained in:
Wim Taymans 2009-01-13 17:49:07 +00:00
parent 4b227159cb
commit 89060e8696
2 changed files with 59 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2009-01-13 Wim Taymans <wim.taymans@collabora.co.uk>
* tests/examples/rtp/server-alsasrc-PCMA.c: (print_source_stats),
(print_stats), (main):
Add some example code for printing the RTP manager stats.
2009-01-13 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/audiofx/audiochebband.c: (gst_audio_cheb_band_class_init),

View file

@ -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);