[farsight2/master] Make sure we stop the elements sink->source when stopping streams

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:19:55 PST 2008


---
 gst/fsrtpconference/fs-rtp-session.c   |   49 ++++++++++++++++++++++++++++++++
 gst/fsrtpconference/fs-rtp-substream.c |   16 ++++++++++
 gst/fsrtpconference/fs-rtp-substream.h |    2 +
 3 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 39e21fb..51e9100 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -267,9 +267,11 @@ _remove_transmitter (gpointer key, gpointer value, gpointer user_data)
 
   g_object_get (transmitter, "gst-sink", &sink, "gst-src", &src, NULL);
 
+  gst_element_set_state (src, GST_STATE_NULL);
   gst_bin_remove (GST_BIN (self->priv->conference), src);
   gst_element_set_state (src, GST_STATE_NULL);
 
+  gst_element_set_state (sink, GST_STATE_NULL);
   gst_bin_remove (GST_BIN (self->priv->conference), sink);
   gst_element_set_state (sink, GST_STATE_NULL);
 
@@ -280,6 +282,17 @@ _remove_transmitter (gpointer key, gpointer value, gpointer user_data)
 }
 
 static void
+_stop_transmitter_elem (gpointer key, gpointer value, gpointer elem_name)
+{
+  FsTransmitter *transmitter = FS_TRANSMITTER (value);
+  GstElement *elem = NULL;
+
+  g_object_get (transmitter, elem_name, &elem, NULL);
+
+  gst_element_set_state (elem, GST_STATE_NULL);
+}
+
+static void
 fs_rtp_session_dispose (GObject *object)
 {
   FsRtpSession *self = FS_RTP_SESSION (object);
@@ -294,6 +307,42 @@ fs_rtp_session_dispose (GObject *object)
     self->priv->blueprints = NULL;
   }
 
+  /* Lets stop all of the elements sink to source */
+
+  /* First the send pipeline */
+  if (self->priv->transmitters)
+    g_hash_table_foreach (self->priv->transmitters, _stop_transmitter_elem,
+      "gst-sink");
+  if (self->priv->rtpbin_send_rtcp_src)
+    gst_pad_set_active (self->priv->rtpbin_send_rtcp_src, FALSE);
+  if (self->priv->transmitter_rtcp_tee)
+    gst_element_set_state (self->priv->transmitter_rtcp_tee, GST_STATE_NULL);
+  if (self->priv->transmitter_rtp_tee)
+    gst_element_set_state (self->priv->transmitter_rtp_tee, GST_STATE_NULL);
+
+  if (self->priv->rtpmuxer)
+    gst_element_set_state (self->priv->rtpmuxer, GST_STATE_NULL);
+  /* TODO: Stop the codec bin */
+  if (self->priv->media_sink_valve)
+    gst_element_set_state (self->priv->media_sink_valve, GST_STATE_NULL);
+  if (self->priv->media_sink_pad)
+    gst_pad_set_active (self->priv->media_sink_pad, FALSE);
+
+
+  /* Now the recv pipeline */
+  if (self->priv->free_substreams)
+    g_list_foreach (self->priv->free_substreams, (GFunc) fs_rtp_sub_stream_stop,
+      NULL);
+  if (self->priv->transmitter_rtp_funnel)
+    gst_element_set_state (self->priv->transmitter_rtp_funnel, GST_STATE_NULL);
+  if (self->priv->transmitter_rtcp_funnel)
+    gst_element_set_state (self->priv->transmitter_rtcp_funnel, GST_STATE_NULL);
+  if (self->priv->transmitters)
+    g_hash_table_foreach (self->priv->transmitters, _stop_transmitter_elem,
+      "gst-src");
+
+  /* Now they should all be stopped, we can remove them in peace */
+
   if (self->priv->media_sink_valve) {
     gst_bin_remove (GST_BIN (self->priv->conference),
       self->priv->media_sink_valve);
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index 3a66348..e42b6da 100644
--- a/gst/fsrtpconference/fs-rtp-substream.c
+++ b/gst/fsrtpconference/fs-rtp-substream.c
@@ -198,6 +198,7 @@ fs_rtp_sub_stream_dispose (GObject *object)
 
   if (self->priv->valve) {
     gst_object_ref (self->priv->valve);
+    gst_element_set_state (self->priv->valve, GST_STATE_NULL);
     gst_bin_remove (GST_BIN (self->priv->conference), self->priv->valve);
     gst_element_set_state (self->priv->valve, GST_STATE_NULL);
     gst_object_unref (self->priv->valve);
@@ -207,6 +208,7 @@ fs_rtp_sub_stream_dispose (GObject *object)
 
   if (self->priv->codecbin) {
     gst_object_ref (self->priv->codecbin);
+    gst_element_set_state (self->priv->codecbin, GST_STATE_NULL);
     gst_bin_remove (GST_BIN (self->priv->conference), self->priv->codecbin);
     gst_element_set_state (self->priv->codecbin, GST_STATE_NULL);
     gst_object_unref (self->priv->codecbin);
@@ -312,3 +314,17 @@ fs_rtp_sub_stream_new (FsRtpConference *conference, GstPad *rtpbin_pad,
 
   return substream;
 }
+
+
+void
+fs_rtp_sub_stream_stop (FsRtpSubStream *substream)
+{
+  if (substream->priv->output_pad)
+    gst_pad_set_active (substream->priv->output_pad, FALSE);
+
+  if (substream->priv->valve)
+    gst_element_set_state (substream->priv->valve, GST_STATE_NULL);
+
+  if (substream->priv->codecbin)
+    gst_element_set_state (substream->priv->codecbin, GST_STATE_NULL);
+}
diff --git a/gst/fsrtpconference/fs-rtp-substream.h b/gst/fsrtpconference/fs-rtp-substream.h
index 252968f..235c1c7 100644
--- a/gst/fsrtpconference/fs-rtp-substream.h
+++ b/gst/fsrtpconference/fs-rtp-substream.h
@@ -76,6 +76,8 @@ FsRtpSubStream *fs_rtp_substream_new ( FsRtpConference *conference, GstPad *pad,
 
 gboolean fs_rtp_sub_stream_try_add_codecbin (FsRtpSubStream *substream);
 
+void
+fs_rtp_sub_stream_stop (FsRtpSubStream *substream);
 
 G_END_DECLS
 
-- 
1.5.6.5




More information about the farsight-commits mailing list