[Telepathy-commits] [telepathy-gabble/master] Get the right component

Olivier Crête olivier.crete at collabora.co.uk
Tue Nov 4 12:08:01 PST 2008


---
 src/media-stream.c |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/media-stream.c b/src/media-stream.c
index e3f57a7..689bd6c 100644
--- a/src/media-stream.c
+++ b/src/media-stream.c
@@ -795,6 +795,7 @@ gabble_media_stream_new_native_candidate (TpSvcMediaStreamHandler *iface,
   guint component_id;
   const gchar *addr;
   GType candidate_struct_type = TP_STRUCT_TYPE_MEDIA_STREAM_HANDLER_CANDIDATE;
+  guint i;
 
   g_assert (GABBLE_IS_MEDIA_STREAM (self));
 
@@ -824,7 +825,7 @@ gabble_media_stream_new_native_candidate (TpSvcMediaStreamHandler *iface,
 
   if (transports->len < 1)
     {
-      GError only_one = { TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED, "google p2p "
+      GError only_one = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, "google p2p "
           "connections only support the concept of one transport per "
           "candidate" };
       GMS_DEBUG_WARNING (priv->session, "%s: number of transports was not 1; "
@@ -840,7 +841,38 @@ gabble_media_stream_new_native_candidate (TpSvcMediaStreamHandler *iface,
           "candidate, ignoring other components");
     }
 
-  transport = g_ptr_array_index (transports, 0);
+  for (i = 0; i < transports->len; i++)
+    {
+      guint component;
+
+      transport = g_ptr_array_index (transports, 0);
+      component = g_value_get_uint (g_value_array_get_nth (transport, 1));
+
+      /* Accept component 0 because old farsight1 stream-engine didn't set the
+       * component
+       */
+      if (component == 0 || component == 1)
+        {
+          break;
+        }
+      else
+        {
+          transport = NULL;
+        }
+    }
+
+
+  if (transport == NULL)
+    {
+      GError only_one = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT, "You need"
+          " at least a component 1." };
+      GMS_DEBUG_WARNING (priv->session, "%s: number of transports was not 1; "
+          "rejecting", G_STRFUNC);
+      dbus_g_method_return_error (context, &only_one);
+      return;
+    }
+
+
   addr = g_value_get_string (g_value_array_get_nth (transport, 1));
   if (!strcmp (addr, "127.0.0.1"))
     {
-- 
1.5.6.5



More information about the Telepathy-commits mailing list