diff options
author | Ognyan Tonchev <ognyan@axis.com> | 2014-03-31 11:00:11 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2014-04-08 15:11:25 +0200 |
commit | 9c0ef4d9f884200764400715ee7813c3f9e768ca (patch) | |
tree | 2831db94fe81ef0160ecbbd5ff951d9380b99e56 | |
parent | 6916875a0b31bc2484cb16613813974348ba068c (diff) |
media: Make media_prepare() fail if port allocation fails
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=727376
-rw-r--r-- | gst/rtsp-server/rtsp-media.c | 18 | ||||
-rw-r--r-- | tests/check/gst/media.c | 40 |
2 files changed, 54 insertions, 4 deletions
diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 9848171..de47c68 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -1935,8 +1935,10 @@ pad_added_cb (GstElement * element, GstPad * pad, GstRTSPMedia * media) /* join the element in the PAUSED state because this callback is * called from the streaming thread and it is PAUSED */ - gst_rtsp_stream_join_bin (stream, GST_BIN (priv->pipeline), - priv->rtpbin, GST_STATE_PAUSED); + if (!gst_rtsp_stream_join_bin (stream, GST_BIN (priv->pipeline), + priv->rtpbin, GST_STATE_PAUSED)) { + GST_WARNING ("failed to join bin element"); + } priv->adding = FALSE; g_rec_mutex_unlock (&priv->state_lock); @@ -2089,8 +2091,10 @@ start_prepare (GstRTSPMedia * media) stream = g_ptr_array_index (priv->streams, i); - gst_rtsp_stream_join_bin (stream, GST_BIN (priv->pipeline), - priv->rtpbin, GST_STATE_NULL); + if (!gst_rtsp_stream_join_bin (stream, GST_BIN (priv->pipeline), + priv->rtpbin, GST_STATE_NULL)) { + goto join_bin_failed; + } } for (walk = priv->dynamic; walk; walk = g_list_next (walk)) { @@ -2119,6 +2123,12 @@ start_prepare (GstRTSPMedia * media) return FALSE; +join_bin_failed: + { + GST_WARNING ("failed to join bin element"); + gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_ERROR); + return FALSE; + } preroll_failed: { GST_WARNING ("failed to preroll pipeline"); diff --git a/tests/check/gst/media.c b/tests/check/gst/media.c index e23fa37..307c9e1 100644 --- a/tests/check/gst/media.c +++ b/tests/check/gst/media.c @@ -294,6 +294,45 @@ GST_START_TEST (test_media_dyn_prepare) GST_END_TEST; +GST_START_TEST (test_media_prepare_port_alloc_fail) +{ + GstRTSPMediaFactory *factory; + GstRTSPMedia *media; + GstRTSPUrl *url; + GstRTSPThreadPool *pool; + GstRTSPThread *thread; + GstRTSPAddressPool *addrpool; + + pool = gst_rtsp_thread_pool_new (); + + factory = gst_rtsp_media_factory_new (); + fail_unless (gst_rtsp_url_parse ("rtsp://localhost:8554/test", + &url) == GST_RTSP_OK); + + gst_rtsp_media_factory_set_launch (factory, + "( fakesrc is-live=true ! text/plain ! rtpgstpay name=pay0 )"); + + media = gst_rtsp_media_factory_construct (factory, url); + fail_unless (GST_IS_RTSP_MEDIA (media)); + + addrpool = gst_rtsp_address_pool_new (); + fail_unless (gst_rtsp_address_pool_add_range (addrpool, "192.168.1.1", + "192.168.1.1", 6000, 6001, 0)); + gst_rtsp_media_set_address_pool (media, addrpool); + + thread = gst_rtsp_thread_pool_get_thread (pool, + GST_RTSP_THREAD_TYPE_MEDIA, NULL); + fail_if (gst_rtsp_media_prepare (media, thread)); + + g_object_unref (media); + g_object_unref (addrpool); + gst_rtsp_url_free (url); + g_object_unref (factory); + g_object_unref (pool); +} + +GST_END_TEST; + GST_START_TEST (test_media_take_pipeline) { GstRTSPMediaFactory *factory; @@ -379,6 +418,7 @@ rtspmedia_suite (void) tcase_add_test (tc, test_media); tcase_add_test (tc, test_media_prepare); tcase_add_test (tc, test_media_dyn_prepare); + tcase_add_test (tc, test_media_prepare_port_alloc_fail); tcase_add_test (tc, test_media_take_pipeline); tcase_add_test (tc, test_media_reset); |