From 0da54fd0555cfe1dbeca9498e466cca62e0e72a9 Mon Sep 17 00:00:00 2001 From: Fabrice Bellet Date: Wed, 14 Jun 2017 12:22:32 +0200 Subject: [PATCH] rtp: stop the transmitter src before unlinking its funnel This patch tweaks the order the elements are stopped and unlinked to prevent the transmitter source to fail on a not-linked to any sinkpads error. The pipeline is transmitter-src -> funnel -> rtpbin -> substream. The funnel is stopped, then the transmitter-src, and thereafter the funnel is unlinked. https://bugs.freedesktop.org/show_bug.cgi?id=100586 --- gst/fsrtpconference/fs-rtp-session.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c index bcee590..a9d7c95 100644 --- a/gst/fsrtpconference/fs-rtp-session.c +++ b/gst/fsrtpconference/fs-rtp-session.c @@ -574,19 +574,27 @@ _stop_transmitter_elem (gpointer key, gpointer value, gpointer elem_name) } static void -stop_and_remove (GstBin *conf, GstElement **element, gboolean unref) +stop_element (GstElement *element) { - if (*element == NULL) + if (element == NULL) return; - gst_element_set_locked_state (*element, TRUE); - if (gst_element_set_state (*element, GST_STATE_NULL) != + gst_element_set_locked_state (element, TRUE); + if (gst_element_set_state (element, GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS) { - gchar *elemname = gst_element_get_name (*element); + gchar *elemname = gst_element_get_name (element); GST_WARNING ("Could not set %s to GST_STATE_NULL", elemname); g_free (elemname); } +} + +static void +remove_element (GstBin *conf, GstElement **element, gboolean unref) +{ + if (*element == NULL) + return; + if (!gst_bin_remove (conf, *element)) { gchar *binname = gst_element_get_name (conf); @@ -600,6 +608,12 @@ stop_and_remove (GstBin *conf, GstElement **element, gboolean unref) *element = NULL; } +static void +stop_and_remove (GstBin *conf, GstElement **element, gboolean unref) +{ + stop_element (*element); + remove_element (conf, element, unref); +} static void fs_rtp_session_dispose (GObject *obj) @@ -748,13 +762,16 @@ fs_rtp_session_dispose (GObject *obj) if (self->priv->rtpbin_recv_rtcp_sink) gst_pad_set_active (self->priv->rtpbin_recv_rtcp_sink, FALSE); - stop_and_remove (conferencebin, &self->priv->transmitter_rtp_funnel, TRUE); - stop_and_remove (conferencebin, &self->priv->transmitter_rtcp_funnel, TRUE); + stop_element (self->priv->transmitter_rtp_funnel); + stop_element (self->priv->transmitter_rtcp_funnel); if (self->priv->transmitters) g_hash_table_foreach (self->priv->transmitters, _stop_transmitter_elem, "gst-src"); + remove_element (conferencebin, &self->priv->transmitter_rtp_funnel, TRUE); + remove_element (conferencebin, &self->priv->transmitter_rtcp_funnel, TRUE); + self->priv->extra_sources = fs_rtp_special_sources_destroy (self->priv->extra_sources); -- 2.9.4