[farsight2/master] rtp: Free substream if its parent is unlinked

Olivier Crête olivier.crete at collabora.co.uk
Wed May 13 14:18:32 PDT 2009


---
 gst/fsrtpconference/fs-rtp-session.c |   32 ++++++++++++++++++++++++++++++++
 gst/fsrtpconference/fs-rtp-stream.c  |   24 ++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 0da8313..2149213 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -2316,6 +2316,35 @@ _substream_error (FsRtpSubStream *substream,
   fs_session_emit_error (session, errorno, error_msg, debug_msg);
 }
 
+static void
+_substream_unlinked (FsRtpSubStream *substream, gpointer user_data)
+{
+  FsRtpSession *self = FS_RTP_SESSION (user_data);
+
+
+  if (fs_rtp_session_has_disposed_enter (self, NULL))
+    return;
+
+  FS_RTP_SESSION_LOCK (self);
+
+  if (g_list_find (self->priv->free_substreams, substream))
+  {
+    self->priv->free_substreams = g_list_remove (self->priv->free_substreams,
+        substream);
+    FS_RTP_SESSION_UNLOCK (self);
+
+    fs_rtp_sub_stream_stop (substream);
+    g_object_unref (substream);
+  }
+  else
+  {
+    FS_RTP_SESSION_UNLOCK (self);
+  }
+
+  fs_rtp_session_has_disposed_exit (self);
+}
+
+
 /**
  * fs_rtp_session_new_recv_pad:
  * @session: a #FsSession
@@ -2366,6 +2395,9 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
   g_signal_connect (substream, "blocked", G_CALLBACK (_substream_blocked),
       session);
 
+  g_signal_connect (substream, "unlinked", G_CALLBACK (_substream_unlinked),
+      session);
+
   /* Lets find the FsRtpStream for this substream, if no Stream claims it
    * then we just store it
    */
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index 2eacae8..6d0eb4c 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -879,6 +879,28 @@ _substream_error (FsRtpSubStream *substream,
   fs_stream_emit_error (stream, errorno, error_msg, debug_msg);
 }
 
+
+static void
+_substream_unlinked (FsRtpSubStream *substream, gpointer user_data)
+{
+  FsRtpStream *stream = FS_RTP_STREAM (user_data);
+  FsRtpSession *session =  fs_rtp_stream_get_session (stream, NULL);
+
+  if (!session)
+    return;
+
+  FS_RTP_SESSION_LOCK (session);
+  stream->substreams = g_list_remove (stream->substreams,
+      substream);
+  FS_RTP_SESSION_UNLOCK (session);
+
+  fs_rtp_sub_stream_stop (substream);
+
+  g_object_unref (substream);
+  g_object_unref (session);
+}
+
+
 /**
  * fs_rtp_stream_add_substream_unlock:
  * @stream: a #FsRtpStream
@@ -909,6 +931,8 @@ fs_rtp_stream_add_substream_unlock (FsRtpStream *stream,
       "receiving", ((stream->priv->direction & FS_DIRECTION_RECV) != 0),
       NULL);
 
+  g_signal_connect (substream, "unlinked",
+      G_CALLBACK (_substream_unlinked), stream);
   g_signal_connect (substream, "src-pad-added",
                     G_CALLBACK (_substream_src_pad_added), stream);
   g_signal_connect (substream, "codec-changed",
-- 
1.5.6.5



More information about the farsight-commits mailing list