[farsight2/master] Transform the upwards call on the no-rtcp timeout into a signal

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


---
 gst/fsrtpconference/fs-rtp-session.c   |   21 ++++++++++++++-------
 gst/fsrtpconference/fs-rtp-session.h   |    3 ---
 gst/fsrtpconference/fs-rtp-substream.c |   29 ++++++++++++++++++++++++++++-
 3 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index f876412..ff00518 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -185,6 +185,9 @@ static gboolean fs_rtp_session_verify_send_codec_bin_locked (
     FsRtpSession *self,
     GError **error);
 
+static void _substream_no_rtcp_timedout_cb (FsRtpSubStream *substream,
+    FsRtpSession *session);
+
 
 static FsStreamTransmitter *fs_rtp_session_get_new_stream_transmitter (
   FsRtpSession *self,
@@ -1720,8 +1723,12 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
     stream = g_object_ref (g_list_first (session->priv->streams)->data);
 
   if (!stream)
+  {
     session->priv->free_substreams =
       g_list_prepend (session->priv->free_substreams, substream);
+    g_signal_connect (substream, "no-rtcp-timedout",
+        G_CALLBACK (_substream_no_rtcp_timedout_cb), session);
+  }
   FS_RTP_SESSION_UNLOCK (session);
   if (stream) {
     if (!fs_rtp_stream_add_substream (stream, substream, &error)) {
@@ -2442,19 +2449,19 @@ fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
   g_clear_error (&error);
 }
 
-void
-fs_rtp_session_substream_timedout (FsRtpSession *session,
-    gpointer substream)
+static void
+_substream_no_rtcp_timedout_cb (FsRtpSubStream *substream,
+    FsRtpSession *session)
 {
   GError *error = NULL;
-  FsRtpSubStream *realsubstream = substream;
+
   FS_RTP_SESSION_LOCK (session);
 
   if (g_list_length (session->priv->streams) != 1)
   {
     guint ssrc, pt;
     gint timeout;
-    g_object_get (realsubstream,
+    g_object_get (substream,
         "ssrc", &ssrc,
         "pt", &pt,
         "no-rtcp-timeout", &timeout,
@@ -2467,11 +2474,11 @@ fs_rtp_session_substream_timedout (FsRtpSession *session,
 
   session->priv->free_substreams =
     g_list_remove (session->priv->free_substreams,
-        realsubstream);
+        substream);
 
   if (!fs_rtp_stream_add_substream (
           g_list_first (session->priv->streams)->data,
-          realsubstream, &error))
+          substream, &error))
   {
     fs_session_emit_error (FS_SESSION (session),
         error ? error->code : FS_ERROR_INTERNAL,
diff --git a/gst/fsrtpconference/fs-rtp-session.h b/gst/fsrtpconference/fs-rtp-session.h
index 575c095..7445b2b 100644
--- a/gst/fsrtpconference/fs-rtp-session.h
+++ b/gst/fsrtpconference/fs-rtp-session.h
@@ -109,9 +109,6 @@ void fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
     const gchar *cname);
 
 
-void fs_rtp_session_substream_timedout (FsRtpSession *session,
-    gpointer substream);
-
 G_END_DECLS
 
 #endif /* __FS_RTP_SESSION_H__ */
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index e769fa3..524d50a 100644
--- a/gst/fsrtpconference/fs-rtp-substream.c
+++ b/gst/fsrtpconference/fs-rtp-substream.c
@@ -45,6 +45,13 @@
  *
  */
 
+/* signals */
+enum
+{
+  NO_RTCP_TIMEDOUT,
+  LAST_SIGNAL
+};
+
 /* props */
 enum
 {
@@ -104,6 +111,7 @@ struct _FsRtpSubStreamPrivate {
 };
 
 static GObjectClass *parent_class = NULL;
+static guint signals[LAST_SIGNAL] = { 0 };
 
 G_DEFINE_TYPE(FsRtpSubStream, fs_rtp_sub_stream, G_TYPE_OBJECT);
 
@@ -225,6 +233,25 @@ fs_rtp_sub_stream_class_init (FsRtpSubStreamClass *klass)
           -1, G_MAXINT, DEFAULT_NO_RTCP_TIMEOUT,
           G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
 
+
+  /**
+   * FsRtpSubStream::no-rtcp-timedout:
+   * @self: #FsSubStream that emitted the signal
+   *
+   * This signal is emitted after the timeout specified by
+   * #FsRtpSubStream:no-rtcp-timeout if this sub-stream has not been attached
+   * to a stream.
+   *
+   */
+  signals[NO_RTCP_TIMEDOUT] = g_signal_new ("no-rtcp-timedout",
+      G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST,
+      0,
+      NULL,
+      NULL,
+      g_cclosure_marshal_VOID__VOID,
+      G_TYPE_NONE, 0);
+
   g_type_class_add_private (klass, sizeof (FsRtpSubStreamPrivate));
 }
 
@@ -245,7 +272,7 @@ _no_rtcp_timeout (gpointer user_data)
   FS_RTP_SESSION_LOCK (self->priv->session);
 
   if (!self->priv->stream)
-    fs_rtp_session_substream_timedout (self->priv->session, self);
+    g_signal_emit (self, signals[NO_RTCP_TIMEDOUT], 0);
 
   if (self->priv->no_rtcp_timeout_id)
     self->priv->no_rtcp_timeout_id = 0;
-- 
1.5.6.5




More information about the farsight-commits mailing list