[farsight2/master] Always verify a substream's codec after it has been added to a stream

Olivier Crête olivier.crete at collabora.co.uk
Mon Mar 16 09:21:48 PDT 2009


This fixes a subtle race where the codecs are changed between the time
when the codecbin is set on the substream and the moment the substream
is added to a stream (during this perioud the substream is "free floating", so
we need to verify that nothing nasty happened during that period).
---
 gst/fsrtpconference/fs-rtp-session.c |   26 ++++++--------------------
 gst/fsrtpconference/fs-rtp-stream.c  |    2 ++
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 89a1985..cdadefa 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -2455,24 +2455,8 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
   }
 
 
-  if (!fs_rtp_session_substream_set_codec_bin_unlock (session, substream,
-          stream, ssrc, pt, &error))
-  {
-    if (error)
-      fs_session_emit_error (FS_SESSION (session), error->code,
-          "Could not add the codec bin to the new substream", error->message);
-    else
-      fs_session_emit_error (FS_SESSION (session), FS_ERROR_CONSTRUCTION,
-          "Could not add the codec bin to the new substream",
-          "No error details returned");
-  }
-
-  g_clear_error (&error);
-
-
   if (stream)
   {
-    FS_RTP_SESSION_LOCK (session);
     if (!fs_rtp_stream_add_substream_unlock (stream, substream, &error))
       fs_session_emit_error (FS_SESSION (session), error->code,
           "Could not add the output ghostpad to the new substream",
@@ -2480,6 +2464,11 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
 
     g_clear_error (&error);
   }
+  else
+  {
+    fs_rtp_sub_stream_verify_codec (substream);
+    FS_RTP_SESSION_UNLOCK (session);
+  }
 
   if (stream)
     g_object_unref (stream);
@@ -3665,7 +3654,6 @@ fs_rtp_session_associate_free_substreams (FsRtpSession *session,
 
     if (fs_rtp_stream_add_substream_unlock (stream, substream, &error))
     {
-      fs_rtp_sub_stream_verify_codec (substream);
       GST_DEBUG ("Associated SSRC %x in session %u", ssrc, session->id);
     }
     else
@@ -3782,9 +3770,7 @@ _substream_no_rtcp_timedout_cb (FsRtpSubStream *substream,
 
   first_stream = g_list_first (session->priv->streams)->data;
   g_object_ref (first_stream);
-  if (fs_rtp_stream_add_substream_unlock (first_stream, substream, &error))
-    fs_rtp_sub_stream_verify_codec (substream);
-  else
+  if (!fs_rtp_stream_add_substream_unlock (first_stream, substream, &error))
     fs_session_emit_error (FS_SESSION (session),
         error ? error->code : FS_ERROR_INTERNAL,
         "Could not link the substream to a stream",
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index b465fb2..1004ead 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -892,6 +892,8 @@ fs_rtp_stream_add_substream_unlock (FsRtpStream *stream,
   g_signal_connect (substream, "error",
                     G_CALLBACK (_substream_error), stream);
 
+  fs_rtp_sub_stream_verify_codec (substream);
+
   /* Only announce a pad if it has a codec attached to it */
   if (substream->codec)
     ret = fs_rtp_sub_stream_add_output_ghostpad_unlock (substream, error);
-- 
1.5.6.5




More information about the farsight-commits mailing list