[farsight2/master] Have the substream emit a signal when its codec changes

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


---
 gst/fsrtpconference/fs-rtp-stream.c    |   15 ++++++++++++++-
 gst/fsrtpconference/fs-rtp-stream.h    |    3 ---
 gst/fsrtpconference/fs-rtp-substream.c |   20 ++++++++++++++++++--
 3 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index ff72f81..9467ae0 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -110,6 +110,9 @@ static gboolean fs_rtp_stream_select_candidate_pair (FsStream *stream,
 static gboolean fs_rtp_stream_set_remote_codecs (FsStream *stream,
                                                  GList *remote_codecs,
                                                  GError **error);
+static void
+fs_rtp_stream_maybe_emit_codecs_changed (FsRtpStream *stream,
+    FsRtpSubStream *substream);
 
 static void _local_candidates_prepared (
     FsStreamTransmitter *stream_transmitter,
@@ -628,6 +631,14 @@ _substream_src_pad_added (FsRtpSubStream *substream, GstPad *pad,
   fs_stream_emit_src_pad_added (stream, pad, codec);
 }
 
+static void
+_substream_codec_changed (FsRtpSubStream *substream,
+    gpointer user_data)
+{
+  FsRtpStream *stream = FS_RTP_STREAM (user_data);
+
+  fs_rtp_stream_maybe_emit_codecs_changed (stream, substream);
+}
 
 static void
 _substream_error (FsRtpSubStream *substream,
@@ -668,6 +679,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, "codec-changed",
+                    G_CALLBACK (_substream_codec_changed), stream);
   g_signal_connect (substream, "error",
                     G_CALLBACK (_substream_error), stream);
 
@@ -754,7 +767,7 @@ _idle_emit_recv_codecs_changed (gpointer data)
  * to emit the signal on the main thread.
  */
 
-void
+static void
 fs_rtp_stream_maybe_emit_codecs_changed (FsRtpStream *stream,
     FsRtpSubStream *substream)
 {
diff --git a/gst/fsrtpconference/fs-rtp-stream.h b/gst/fsrtpconference/fs-rtp-stream.h
index 5c989c9..86c324f 100644
--- a/gst/fsrtpconference/fs-rtp-stream.h
+++ b/gst/fsrtpconference/fs-rtp-stream.h
@@ -95,9 +95,6 @@ void fs_rtp_stream_invalidate_codec_locked (FsRtpStream *stream,
     gint pt,
     const FsCodec *codec);
 
-void fs_rtp_stream_maybe_emit_codecs_changed (FsRtpStream *stream,
-    FsRtpSubStream *substream);
-
 void fs_rtp_stream_add_known_ssrc (FsRtpStream *stream,
     guint32 ssrc);
 
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index a430ef6..7f3f2f8 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,
+  CODEC_CHANGED,
   ERROR,
   LAST_SIGNAL
 };
@@ -300,6 +301,22 @@ fs_rtp_sub_stream_class_init (FsRtpSubStreamClass *klass)
       _fs_rtp_marshal_VOID__INT_STRING_STRING,
       G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING);
 
+ /**
+   * FsRtpSubStream:codec-changed
+   * @self: #FsStream that emitted the signal
+   *
+   * This signal is emitted when the code for this substream has
+   * changed. It can be fetvched from the #FsRtpSubStream:codec property
+   * This is useful for displaying the current active reception codecs.
+   */
+  signals[CODEC_CHANGED] = g_signal_new ("codec-changed",
+      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));
 }
@@ -655,8 +672,7 @@ fs_rtp_sub_stream_add_codecbin_locked (FsRtpSubStream *substream,
     if (!substream->priv->output_ghostpad)
       ret =  fs_rtp_sub_stream_add_output_ghostpad_locked (substream, error);
 
-    fs_rtp_stream_maybe_emit_codecs_changed (substream->priv->stream,
-        substream);
+    g_signal_emit (substream, signals[CODEC_CHANGED], 0);
 
     return ret;
   }
-- 
1.5.6.5




More information about the farsight-commits mailing list