From 2f17369e9d110e1a437124a3e116fd2e092363bd Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 28 Nov 2013 14:10:19 +0100 Subject: media: add suspend modes Add support for different suspend modes. The stream is suspended right after producing the SDP and after PAUSE. Different suspend modes are available that affect the state of the pipeline. NONE leaves the pipeline state unchanged and is the current and old behaviour, PAUSE will set the pipeline to the PAUSED state and RESET will bring the pipeline to the NULL state. A stream is also unsuspended when it goes back to PLAYING, for RESET streams, this means that the pipeline needs to be prerolled again. Base on patches by Ognyan Tonchev See https://bugzilla.gnome.org/show_bug.cgi?id=711257 --- tests/check/gst/media.c | 45 ++++++++++++++++++++++++++++++++++++++++++ tests/check/gst/mediafactory.c | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) (limited to 'tests/check/gst') diff --git a/tests/check/gst/media.c b/tests/check/gst/media.c index ca2c324..23e8586 100644 --- a/tests/check/gst/media.c +++ b/tests/check/gst/media.c @@ -300,6 +300,50 @@ GST_START_TEST (test_media_take_pipeline) GST_END_TEST; +GST_START_TEST (test_media_reset) +{ + GstRTSPMediaFactory *factory; + GstRTSPMedia *media; + GstRTSPUrl *url; + GstRTSPThreadPool *pool; + GstRTSPThread *thread; + + pool = gst_rtsp_thread_pool_new (); + + factory = gst_rtsp_media_factory_new (); + fail_if (gst_rtsp_media_factory_is_shared (factory)); + gst_rtsp_url_parse ("rtsp://localhost:8554/test", &url); + + gst_rtsp_media_factory_set_launch (factory, + "( videotestsrc ! rtpvrawpay pt=96 name=pay0 )"); + + media = gst_rtsp_media_factory_construct (factory, url); + fail_unless (GST_IS_RTSP_MEDIA (media)); + + thread = gst_rtsp_thread_pool_get_thread (pool, + GST_RTSP_THREAD_TYPE_MEDIA, NULL); + fail_unless (gst_rtsp_media_prepare (media, thread)); + fail_unless (gst_rtsp_media_suspend (media)); + fail_unless (gst_rtsp_media_unprepare (media)); + g_object_unref (media); + + media = gst_rtsp_media_factory_construct (factory, url); + fail_unless (GST_IS_RTSP_MEDIA (media)); + + thread = gst_rtsp_thread_pool_get_thread (pool, + GST_RTSP_THREAD_TYPE_MEDIA, NULL); + gst_rtsp_media_set_suspend_mode (media, GST_RTSP_SUSPEND_MODE_RESET); + fail_unless (gst_rtsp_media_prepare (media, thread)); + fail_unless (gst_rtsp_media_suspend (media)); + fail_unless (gst_rtsp_media_unprepare (media)); + g_object_unref (media); + + gst_rtsp_url_free (url); + g_object_unref (factory); +} + +GST_END_TEST; + static Suite * rtspmedia_suite (void) { @@ -313,6 +357,7 @@ rtspmedia_suite (void) tcase_add_test (tc, test_media_prepare); tcase_add_test (tc, test_media_dyn_prepare); tcase_add_test (tc, test_media_take_pipeline); + tcase_add_test (tc, test_media_reset); return s; } diff --git a/tests/check/gst/mediafactory.c b/tests/check/gst/mediafactory.c index 73e4883..b6b250b 100644 --- a/tests/check/gst/mediafactory.c +++ b/tests/check/gst/mediafactory.c @@ -280,6 +280,40 @@ GST_START_TEST (test_permissions) GST_END_TEST; +GST_START_TEST (test_reset) +{ + GstRTSPMediaFactory *factory; + GstRTSPMedia *media; + GstRTSPUrl *url; + + factory = gst_rtsp_media_factory_new (); + fail_if (gst_rtsp_media_factory_is_shared (factory)); + gst_rtsp_url_parse ("rtsp://localhost:8554/test", &url); + + gst_rtsp_media_factory_set_launch (factory, + "( videotestsrc ! rtpvrawpay pt=96 name=pay0 )"); + + media = gst_rtsp_media_factory_construct (factory, url); + fail_unless (GST_IS_RTSP_MEDIA (media)); + fail_if (gst_rtsp_media_get_suspend_mode (media) != + GST_RTSP_SUSPEND_MODE_NONE); + g_object_unref (media); + + gst_rtsp_media_factory_set_suspend_mode (factory, + GST_RTSP_SUSPEND_MODE_RESET); + + media = gst_rtsp_media_factory_construct (factory, url); + fail_unless (GST_IS_RTSP_MEDIA (media)); + fail_if (gst_rtsp_media_get_suspend_mode (media) != + GST_RTSP_SUSPEND_MODE_RESET); + g_object_unref (media); + + gst_rtsp_url_free (url); + g_object_unref (factory); +} + +GST_END_TEST; + static Suite * rtspmediafactory_suite (void) { @@ -294,6 +328,7 @@ rtspmediafactory_suite (void) tcase_add_test (tc, test_shared); tcase_add_test (tc, test_addresspool); tcase_add_test (tc, test_permissions); + tcase_add_test (tc, test_reset); return s; } -- cgit v1.2.3