From a676c1725993c2aaf37b856b60f82a0d7b9d8091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 15 Mar 2019 09:18:00 +0100 Subject: [PATCH] rtspsrc: Don't remove udpsrc/sink from rtspsrc if they were not added to it This can happen in various error cases that could happen between the creation of the element in question and the adding to the rtspsrc. It causes an ugly critical warning right now but is otherwise harmless. --- gst/rtsp/gstrtspsrc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index 85875f1247..7ee4736056 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -2281,7 +2281,9 @@ gst_rtspsrc_stream_free (GstRTSPSrc * src, GstRTSPStream * stream) for (i = 0; i < 2; i++) { if (stream->udpsrc[i]) { gst_element_set_state (stream->udpsrc[i], GST_STATE_NULL); - gst_bin_remove (GST_BIN_CAST (src), stream->udpsrc[i]); + if (gst_object_has_as_parent (GST_OBJECT (stream->udpsrc[i]), + GST_OBJECT (src))) + gst_bin_remove (GST_BIN_CAST (src), stream->udpsrc[i]); gst_object_unref (stream->udpsrc[i]); } if (stream->channelpad[i]) @@ -2289,7 +2291,9 @@ gst_rtspsrc_stream_free (GstRTSPSrc * src, GstRTSPStream * stream) if (stream->udpsink[i]) { gst_element_set_state (stream->udpsink[i], GST_STATE_NULL); - gst_bin_remove (GST_BIN_CAST (src), stream->udpsink[i]); + if (gst_object_has_as_parent (GST_OBJECT (stream->udpsink[i]), + GST_OBJECT (src))) + gst_bin_remove (GST_BIN_CAST (src), stream->udpsink[i]); gst_object_unref (stream->udpsink[i]); } }