diff options
author | Wim Taymans <wtaymans@redhat.com> | 2014-09-15 16:54:05 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2014-09-15 16:54:36 +0200 |
commit | 4056897111ba9030450635ab658645fa3a69b40b (patch) | |
tree | 14e7a8251dc5edcb97e778b50fc0991e42efbe70 | |
parent | 376488d8c7d0a92c56065070f9003e699533c3e5 (diff) |
test: add example of dumping RTCP reports
-rw-r--r-- | examples/test-mp4.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/examples/test-mp4.c b/examples/test-mp4.c index 52e082d..bf88abe 100644 --- a/examples/test-mp4.c +++ b/examples/test-mp4.c @@ -21,6 +21,61 @@ #include <gst/rtsp-server/rtsp-server.h> +/* called when a stream has received an RTCP packet from the client */ +static void +on_ssrc_active (GObject * session, GObject * source, GstRTSPMedia * media) +{ + GstStructure *stats; + + GST_INFO ("source %p in session %p is active", source, session); + + g_object_get (source, "stats", &stats, NULL); + if (stats) { + gchar *sstr; + + sstr = gst_structure_to_string (stats); + g_print ("structure: %s\n", sstr); + g_free (sstr); + + gst_structure_free (stats); + } +} + +/* signal callback when the media is prepared for streaming. We can get the + * session manager for each of the streams and connect to some signals. */ +static void +media_prepared_cb (GstRTSPMedia * media) +{ + guint i, n_streams; + + n_streams = gst_rtsp_media_n_streams (media); + + GST_INFO ("media %p is prepared and has %u streams", media, n_streams); + + for (i = 0; i < n_streams; i++) { + GstRTSPStream *stream; + GObject *session; + + stream = gst_rtsp_media_get_stream (media, i); + if (stream == NULL) + continue; + + session = gst_rtsp_stream_get_rtpsession (stream); + GST_INFO ("watching session %p on stream %u", session, i); + + g_signal_connect (session, "on-ssrc-active", + (GCallback) on_ssrc_active, media); + } +} + +static void +media_configure_cb (GstRTSPMediaFactory * factory, GstRTSPMedia * media) +{ + /* connect our prepared signal so that we can see when this media is + * prepared for streaming */ + g_signal_connect (media, "prepared", (GCallback) media_prepared_cb, factory); +} + int main (int argc, char *argv[]) { @@ -57,6 +112,8 @@ main (int argc, char *argv[]) * element with pay%d names will be a stream */ factory = gst_rtsp_media_factory_new (); gst_rtsp_media_factory_set_launch (factory, str); + g_signal_connect (factory, "media-configure", (GCallback) media_configure_cb, + factory); g_free (str); /* attach the test factory to the /test url */ |