[farsight2/master] Have the substream emit its own error signal instead of emitting it on its parent objects

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


---
 gst/fsrtpconference/fs-rtp-marshal.list |    1 +
 gst/fsrtpconference/fs-rtp-session.c    |   50 +++++++++++++++++++++---------
 gst/fsrtpconference/fs-rtp-stream.c     |   15 +++++++++
 gst/fsrtpconference/fs-rtp-substream.c  |   27 +++++++++++++----
 4 files changed, 72 insertions(+), 21 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-marshal.list b/gst/fsrtpconference/fs-rtp-marshal.list
index 73ccad0..2c46dad 100644
--- a/gst/fsrtpconference/fs-rtp-marshal.list
+++ b/gst/fsrtpconference/fs-rtp-marshal.list
@@ -1 +1,2 @@
 VOID:BOXED,BOXED
+VOID:INT,STRING,STRING
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index a9eda35..43b513e 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -1689,6 +1689,19 @@ fs_rtp_session_negotiate_codecs (FsRtpSession *session,
 }
 
 
+static void
+_substream_error (FsRtpSubStream *substream,
+    gint errorno,
+    gchar *error_msg,
+    gchar *debug_msg,
+    gpointer user_data)
+{
+  FsSession *session = FS_SESSION (user_data);
+
+  fs_session_emit_error (session, errorno, error_msg, debug_msg);
+}
+
+
 /**
  * fs_rtp_session_new_recv_pad:
  * @session: a #FsSession
@@ -1753,29 +1766,25 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
   if (stream)
     GST_DEBUG ("Already have a stream with SSRC %x, using it", ssrc);
 
-  /* Add the substream directly if the no_rtcp_timeout is 0 */
+  /* Add the substream directly if the no_rtcp_timeout is 0 and
+   * there is only one stream */
   if (!stream)
   {
-    if (no_rtcp_timeout == 0)
+    if (no_rtcp_timeout == 0 &&
+        g_list_length (session->priv->streams) == 1)
     {
-      if (g_list_length (session->priv->streams) == 1)
-      {
-        stream = g_object_ref (g_list_first (session->priv->streams)->data);
-        GST_DEBUG ("No RTCP timeout and only one stream, giving it substream"
-            " for SSRC %x in session %u", ssrc, session->id);
-      }
-      else
-      {
-        GST_WARNING ("No RTCP timeout is 0, but there is more than one stream,"
-            " we will wait forever for an RTCP SDES to arrive for SSRC %u in"
-            " session %u", ssrc, session->id);
-      }
+      stream = g_object_ref (g_list_first (session->priv->streams)->data);
+      GST_DEBUG ("No RTCP timeout and only one stream, giving it substream"
+          " for SSRC %x in session %u", ssrc, session->id);
     }
     else
     {
       session->priv->free_substreams =
         g_list_prepend (session->priv->free_substreams, substream);
 
+      g_signal_connect (substream, "error", G_CALLBACK (_substream_error),
+          session);
+
       if (no_rtcp_timeout > 0)
       {
         g_signal_connect (substream, "no-rtcp-timedout",
@@ -1783,12 +1792,18 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
         GST_DEBUG ("No stream for SSRC %x, waiting for %d ms before associating"
             "in session %u", ssrc, no_rtcp_timeout, session->id);
       }
-      else  /* rtcp_timeout < 0 */
+      else if (no_rtcp_timeout < 0)
       {
         GST_DEBUG ("No RTCP timeout is < 0, we will wait forever for an"
             " RTCP SDES to arrive for SSRC %x in session %u",
             ssrc, session->id);
       }
+      else
+      {
+        GST_WARNING ("No RTCP timeout is 0, but there is more than one stream,"
+            " we will wait forever for an RTCP SDES to arrive for SSRC %u in"
+            " session %u", ssrc, session->id);
+      }
     }
   }
 
@@ -2596,6 +2611,8 @@ fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
     return;
   }
 
+  while (
+      g_signal_handlers_disconnect_by_func(substream, "error", session) > 0) {}
 
   if (!fs_rtp_stream_add_substream (stream, substream, &error))
     fs_session_emit_error (FS_SESSION (session), error->code,
@@ -2633,6 +2650,9 @@ _substream_no_rtcp_timedout_cb (FsRtpSubStream *substream,
     g_list_remove (session->priv->free_substreams,
         substream);
 
+  while (
+      g_signal_handlers_disconnect_by_func(substream, "error", session) > 0) {}
+
   if (!fs_rtp_stream_add_substream (
           g_list_first (session->priv->streams)->data,
           substream, &error))
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index f56c719..ff72f81 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -628,6 +628,19 @@ _substream_src_pad_added (FsRtpSubStream *substream, GstPad *pad,
   fs_stream_emit_src_pad_added (stream, pad, codec);
 }
 
+
+static void
+_substream_error (FsRtpSubStream *substream,
+    gint errorno,
+    gchar *error_msg,
+    gchar *debug_msg,
+    gpointer user_data)
+{
+  FsStream *stream = FS_STREAM (user_data);
+
+  fs_stream_emit_error (stream, errorno, error_msg, debug_msg);
+}
+
 /**
  * fs_rtp_stream_add_substream:
  * @stream: a #FsRtpStream
@@ -655,6 +668,8 @@ fs_rtp_stream_add_substream (FsRtpStream *stream,
 
   g_signal_connect (substream, "src-pad-added",
                     G_CALLBACK (_substream_src_pad_added), stream);
+  g_signal_connect (substream, "error",
+                    G_CALLBACK (_substream_error), stream);
 
   g_object_get (substream, "codec", &codec, NULL);
 
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index 10ae690..3524c4e 100644
--- a/gst/fsrtpconference/fs-rtp-substream.c
+++ b/gst/fsrtpconference/fs-rtp-substream.c
@@ -50,6 +50,7 @@ enum
 {
   NO_RTCP_TIMEDOUT,
   SRC_PAD_ADDED,
+  ERROR,
   LAST_SIGNAL
 };
 
@@ -280,6 +281,25 @@ fs_rtp_sub_stream_class_init (FsRtpSubStreamClass *klass)
       _fs_rtp_marshal_VOID__BOXED_BOXED,
       G_TYPE_NONE, 2, GST_TYPE_PAD, FS_TYPE_CODEC);
 
+  /**
+   * FsRtpSubStream::error:
+   * @self: #FsRtpSubStream that emitted the signal
+   * @errorno: The number of the error
+   * @error_msg: Error message to be displayed to user
+   * @debug_msg: Debugging error message
+   *
+   * This signal is emitted in any error condition
+   *
+   */
+  signals[ERROR] = g_signal_new ("error",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST,
+      0,
+      NULL,
+      NULL,
+      _fs_rtp_marshal_VOID__INT_STRING_STRING,
+      G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING);
+
 
   g_type_class_add_private (klass, sizeof (FsRtpSubStreamPrivate));
 }
@@ -954,10 +974,5 @@ fs_rtp_sub_stream_emit_error (FsRtpSubStream *substream,
     gchar *error_msg,
     gchar *debug_msg)
 {
-  if (substream->priv->stream)
-    fs_stream_emit_error (FS_STREAM (substream->priv->stream), error_no,
-        error_msg, debug_msg);
-  else
-    fs_session_emit_error (FS_SESSION (substream->priv->session), error_no,
-        error_msg, debug_msg);
+  g_signal_emit (substream, signals[ERROR], 0, error_no, error_msg, debug_msg);
 }
-- 
1.5.6.5




More information about the farsight-commits mailing list