[farsight2/master] Implement associating the substream with a stream based on the cname

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


---
 gst-libs/gst/farsight/fs-conference-iface.h |    6 ++-
 gst/fsrtpconference/fs-rtp-session.c        |   62 ++++++++++++++++++++++++++-
 2 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/gst-libs/gst/farsight/fs-conference-iface.h b/gst-libs/gst/farsight/fs-conference-iface.h
index fbd9dca..1b6abbf 100644
--- a/gst-libs/gst/farsight/fs-conference-iface.h
+++ b/gst-libs/gst/farsight/fs-conference-iface.h
@@ -84,11 +84,12 @@ GType fs_conference_get_type (void);
  * @FS_ERROR_CONSTRUCTION: Error constructing some of the sub-elements
  * @FS_ERROR_INVALID_ARGUMENTS: Invalid arguments to the function
  * @FS_ERROR_NETWORK: A network related error
+ * @FS_ERROR_INTERNAL: An internal error happened in Farsight
  * @FS_ERROR_NOT_IMPLEMENTED: This functionality is not implemented
  * by this plugins
  * @FS_ERROR_NEGOTIATION_FAILED: The codec negotiation has failed
  * @FS_ERROR_UNKNOWN_CODEC: The codec is unknown
- * @FS_ERROR_INTERNAL: An internal error happened in Farsight
+ * @FS_ERROR_UNKNOWN_CNAME: Data was received for an unknown cname
  *
  * This is the enum of error numbers that will come either on the "error"
  * signal or from the Gst Bus.
@@ -97,11 +98,12 @@ GType fs_conference_get_type (void);
 typedef enum {
   FS_ERROR_CONSTRUCTION,
   FS_ERROR_INVALID_ARGUMENTS,
+  FS_ERROR_INTERNAL,
   FS_ERROR_NETWORK,
   FS_ERROR_NOT_IMPLEMENTED,
   FS_ERROR_NEGOTIATION_FAILED,
   FS_ERROR_UNKNOWN_CODEC,
-  FS_ERROR_INTERNAL
+  FS_ERROR_UNKNOWN_CNAME
 } FsError;
 
 /**
diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index ce1df0a..2d78f20 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -33,6 +33,8 @@
 #include "config.h"
 #endif
 
+#include <string.h>
+
 #include <gst/gst.h>
 
 #include <gst/farsight/fs-transmitter.h>
@@ -2163,5 +2165,63 @@ fs_rtp_session_associate_ssrc_cname (FsRtpSession *session,
     guint32 ssrc,
     gchar *cname)
 {
-  
+  FsRtpStream *stream = NULL;
+  FsRtpSubStream *substream = NULL;
+  GList *item;
+  GError *error = NULL;
+
+  FS_RTP_SESSION_LOCK (session);
+  for (item = g_list_first (session->priv->streams);
+       item;
+       item = g_list_next (item))
+  {
+    FsRtpStream *localstream = item->data;
+    FsRtpParticipant *participant = NULL;
+    gchar *localcname = NULL;
+
+    g_object_get (localstream, "participant", &participant, NULL);
+    g_object_get (participant, "cname", &localcname, NULL);
+    g_object_unref (participant);
+
+    if (!strcmp (localcname, cname))
+    {
+      stream = localstream;
+      break;
+    }
+  }
+
+  if (!stream) {
+    gchar *str = g_strdup_printf ("There is no particpant with cname %s for"
+        " ssrc %u", cname, ssrc);
+    fs_session_emit_error (FS_SESSION (session),FS_ERROR_UNKNOWN_CNAME,
+        str, str);
+    g_free (str);
+    goto done;
+  }
+
+  for (item = g_list_first (session->priv->free_substreams);
+       item;
+       item = g_list_next (item))
+  {
+    FsRtpSubStream *localsubstream = item->data;
+    guint32 localssrc;
+
+    g_object_get (localsubstream, "ssrc", &localssrc, NULL);
+    if (ssrc == localssrc) {
+      substream = localsubstream;
+      break;
+    }
+  }
+
+  if (!substream)
+    goto done;
+
+  if (!fs_rtp_stream_add_substream (stream, substream, &error))
+    fs_session_emit_error (FS_SESSION (session), error->code,
+        "Could not associate a substream with its stream",
+        error->message);
+  g_clear_error (&error);
+
+ done:
+  FS_RTP_SESSION_UNLOCK (session);
 }
-- 
1.5.6.5




More information about the farsight-commits mailing list