[farsight2/master] Move codec selection/addition on codew change to session from substream

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


---
 gst/fsrtpconference/fs-rtp-session.c   |   51 ++++++++++++++++++++++++++++++++
 gst/fsrtpconference/fs-rtp-substream.c |   39 +-----------------------
 2 files changed, 52 insertions(+), 38 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index f93e9a0..63b988d 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -2470,6 +2470,57 @@ static void
 _substream_blocked (FsRtpSubStream *substream, FsRtpStream *stream,
     FsRtpSession *session)
 {
+  FsCodec *codec = NULL;
+  FsCodec *current_codec = NULL;
+  GError *error = NULL;
+  gint pt;
+  guint32 ssrc;
+
+  g_object_get (substream,
+      "pt", &pt,
+      "ssrc", &ssrc,
+      "codec", &current_codec,
+      NULL);
+
+  codec = fs_rtp_session_get_recv_codec_for_pt (session, pt);
+
+  if (!codec)
+  {
+    gchar *str = g_strdup_printf ("Could not get the new recv codec for"
+        " pt %d", pt);
+    if (stream)
+      fs_stream_emit_error (FS_STREAM (stream), FS_ERROR_UNKNOWN_CODEC, str,
+          str);
+    else
+      fs_session_emit_error (FS_SESSION (session), FS_ERROR_UNKNOWN_CODEC, str,
+          str);
+    goto done;
+  }
+
+  if (fs_codec_are_equal (codec, current_codec))
+    goto done;
+
+  if (!fs_rtp_session_substream_add_codec_bin (session, substream, ssrc, pt,
+          &error))
+  {
+    gchar *str = g_strdup_printf ("Could not add the new recv codec bin for"
+        " ssrc %u and payload type %d to the state NULL", ssrc, pt);
+
+    if (stream)
+      fs_stream_emit_error (FS_STREAM (stream), FS_ERROR_CONSTRUCTION,
+          "Could not add the new recv codec bin", error->message);
+    else
+      fs_session_emit_error (FS_SESSION (session), FS_ERROR_CONSTRUCTION,
+          "Could not add the new recv codec bin", error->message);
+    g_free (str);
+    goto done;
+  }
+
+ done:
+
+  fs_codec_destroy (current_codec);
+
+  g_clear_error (&error);
 }
 
 /**
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index 79ffe91..81a018b 100644
--- a/gst/fsrtpconference/fs-rtp-substream.c
+++ b/gst/fsrtpconference/fs-rtp-substream.c
@@ -971,48 +971,11 @@ _rtpbin_pad_have_data_callback (GstPad *pad, GstMiniObject *miniobj,
     gpointer user_data)
 {
   FsRtpSubStream *self = FS_RTP_SUB_STREAM (user_data);
-  FsCodec *codec = NULL;
   gboolean ret = TRUE;
-  GError *error = NULL;
-
-  FS_RTP_SESSION_LOCK (self->priv->session);
 
   g_signal_emit (self, signals[BLOCKED], 0, self->priv->stream);
 
-  codec = fs_rtp_session_get_recv_codec_for_pt (self->priv->session,
-      self->priv->pt);
-
-  if (!codec)
-  {
-    gchar *str = g_strdup_printf ("Could not get the new recv codec for"
-        " pt %d", self->priv->pt);
-    fs_rtp_sub_stream_emit_error (self, FS_ERROR_UNKNOWN_CODEC, str,
-        str);
-    goto done;
-  }
-
-  g_clear_error (&error);
-
-  if (fs_codec_are_equal (codec, self->priv->codec))
-    goto done;
-
-
-  if (!fs_rtp_session_substream_add_codec_bin (self->priv->session,
-          self, self->priv->ssrc, self->priv->pt, &error))
-  {
-    gchar *str = g_strdup_printf ("Could not add the new recv codec bin for"
-        " ssrc %u and payload type %d to the state NULL", self->priv->ssrc,
-        self->priv->pt);
-
-    fs_rtp_sub_stream_emit_error (self, FS_ERROR_CONSTRUCTION,
-        "Could not add the new recv codec bin", str);
-    g_free (str);
-    goto done;
-  }
-
-  g_clear_error (&error);
-
- done:
+  FS_RTP_SESSION_LOCK (self->priv->session);
 
   if (!self->priv->codecbin || !self->priv->codec)
   {
-- 
1.5.6.5




More information about the farsight-commits mailing list