mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 05:12:09 +00:00
media: Make media_prepare() fail if port allocation fails
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=727376
This commit is contained in:
parent
6916875a0b
commit
9c0ef4d9f8
2 changed files with 54 additions and 4 deletions
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue