[farsight2/master] Add ssrcs from to the known list if they come inside valid buffers

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


---
 gst/fsrtpconference/Makefile.am      |    1 +
 gst/fsrtpconference/fs-rtp-session.c |   52 ++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/gst/fsrtpconference/Makefile.am b/gst/fsrtpconference/Makefile.am
index f8025ff..6f11f1c 100644
--- a/gst/fsrtpconference/Makefile.am
+++ b/gst/fsrtpconference/Makefile.am
@@ -47,6 +47,7 @@ libfsrtpconference_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libfsrtpconference_la_LIBADD = \
 	$(top_builddir)/gst-libs/gst/farsight/libgstfarsight-0.10.la \
 	$(FS2_LIBS) \
+	-lgstrtp- at GST_MAJORMINOR@ \
 	$(GST_BASE_LIBS) \
 	$(GST_LIBS)
 
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index 2abab05..dff7370 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -37,6 +37,9 @@
 
 #include <gst/gst.h>
 
+#include <gst/rtp/gstrtpbuffer.h>
+#include <gst/rtp/gstrtcpbuffer.h>
+
 #include <gst/farsight/fs-transmitter.h>
 
 #include "fs-rtp-session.h"
@@ -1248,6 +1251,53 @@ fs_rtp_session_constructed (GObject *object)
 }
 
 
+static void
+_stream_known_source_packet_received (FsRtpStream *stream, guint component,
+    GstBuffer *buffer, FsRtpSession *self)
+{
+  guint32 ssrc;
+
+  if (component == 1)
+  {
+    if (gst_rtp_buffer_validate (buffer))
+    {
+      ssrc = gst_rtp_buffer_get_ssrc (buffer);
+      goto ok;
+    }
+  }
+  else if (component == 2)
+  {
+    GstRTCPPacket rtcppacket;
+
+    if (gst_rtcp_buffer_validate (buffer))
+    {
+      if (gst_rtcp_buffer_get_first_packet (buffer, &rtcppacket))
+      {
+        do {
+          if (gst_rtcp_packet_get_type (&rtcppacket) == GST_RTCP_TYPE_SDES)
+          {
+            ssrc = gst_rtcp_packet_sdes_get_ssrc (&rtcppacket);
+            goto ok;
+          }
+        } while (gst_rtcp_packet_move_to_next (&rtcppacket));
+      }
+    }
+  }
+
+  /* We would have jumped to OK if we had a valid packet */
+  return;
+
+ ok:
+
+  FS_RTP_SESSION_LOCK (self);
+
+  if (!g_hash_table_lookup (self->priv->ssrc_streams,  GUINT_TO_POINTER (ssrc)))
+    g_hash_table_insert (self->priv->ssrc_streams, GUINT_TO_POINTER (ssrc),
+        stream);
+
+  FS_RTP_SESSION_UNLOCK (self);
+}
+
 static gboolean
 _remove_stream_from_ht (gpointer key, gpointer value, gpointer user_data)
 {
@@ -1316,6 +1366,8 @@ fs_rtp_session_new_stream (FsSession *session,
 
   g_signal_connect (new_stream, "new-remote-codecs",
       G_CALLBACK (_stream_new_remote_codecs), self);
+  g_signal_connect (new_stream, "known-source-packet-received",
+      G_CALLBACK (_stream_known_source_packet_received), self);
 
   FS_RTP_SESSION_LOCK (self);
   self->priv->streams = g_list_append (self->priv->streams, new_stream);
-- 
1.5.6.5




More information about the farsight-commits mailing list