[telepathy-gabble/master] _gabble_media_channel_typeflags_to_caps and its inverse: move to GabbleMediaFactory

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Aug 26 09:33:39 PDT 2009


That's where we'll do new-style caps.
---
 src/capabilities.c  |    6 ++--
 src/media-channel.c |   77 ---------------------------------------------------
 src/media-channel.h |    6 ----
 src/media-factory.c |   77 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/media-factory.h |    6 ++++
 5 files changed, 86 insertions(+), 86 deletions(-)

diff --git a/src/capabilities.c b/src/capabilities.c
index 1070b92..7a40929 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -35,7 +35,7 @@
 #include "debug.h"
 #include "namespaces.h"
 #include "presence-cache.h"
-#include "media-channel.h"
+#include "media-factory.h"
 #include "util.h"
 
 typedef struct _Feature Feature;
@@ -317,8 +317,8 @@ capabilities_fill_cache (GabblePresenceCache *cache)
 const CapabilityConversionData capabilities_conversions[] =
 {
   { TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA,
-    _gabble_media_channel_typeflags_to_caps,
-    _gabble_media_channel_caps_to_typeflags },
+    _gabble_media_factory_typeflags_to_caps,
+    _gabble_media_factory_caps_to_typeflags },
   { NULL, NULL, NULL}
 };
 
diff --git a/src/media-channel.c b/src/media-channel.c
index f434a47..ef028db 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -2493,49 +2493,6 @@ stream_direction_changed_cb (GabbleMediaStream *stream,
       chan, id, direction, pending_send);
 }
 
-void
-_gabble_media_channel_typeflags_to_caps (TpChannelMediaCapabilities flags,
-    GabbleCapabilitySet *caps)
-{
-  gboolean gtalk_p2p;
-
-  DEBUG ("adding Jingle caps %u (%s, %s, %s, %s)", flags,
-    flags & TP_CHANNEL_MEDIA_CAPABILITY_AUDIO ? "audio" : "no audio",
-    flags & TP_CHANNEL_MEDIA_CAPABILITY_VIDEO ? "video" : "no video",
-    flags & TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P
-        ? "gtalk-p2p" : "no gtalk-p2p",
-    flags & TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_ICE_UDP
-        ? "ice-udp" : "no ice-udp");
-
-  if (flags & TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_ICE_UDP)
-    gabble_capability_set_add (caps, NS_JINGLE_TRANSPORT_ICEUDP);
-
-  gtalk_p2p = flags & TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P;
-
-  if (gtalk_p2p)
-    gabble_capability_set_add (caps, NS_GOOGLE_TRANSPORT_P2P);
-
-  if (flags & TP_CHANNEL_MEDIA_CAPABILITY_AUDIO)
-    {
-      gabble_capability_set_add (caps, NS_JINGLE_RTP);
-      gabble_capability_set_add (caps, NS_JINGLE_RTP_AUDIO);
-      gabble_capability_set_add (caps, NS_JINGLE_DESCRIPTION_AUDIO);
-
-      if (gtalk_p2p)
-        gabble_capability_set_add (caps, NS_GOOGLE_FEAT_VOICE);
-    }
-
-  if (flags & TP_CHANNEL_MEDIA_CAPABILITY_VIDEO)
-    {
-      gabble_capability_set_add (caps, NS_JINGLE_RTP);
-      gabble_capability_set_add (caps, NS_JINGLE_RTP_VIDEO);
-      gabble_capability_set_add (caps, NS_JINGLE_DESCRIPTION_VIDEO);
-
-      if (gtalk_p2p)
-        gabble_capability_set_add (caps, NS_GOOGLE_FEAT_VIDEO);
-    }
-}
-
 static void
 construct_stream (GabbleMediaChannel *chan,
                   GabbleJingleContent *c,
@@ -2800,40 +2757,6 @@ session_new_content_cb (GabbleJingleSession *session,
   create_stream_from_content (chan, c);
 }
 
-TpChannelMediaCapabilities
-_gabble_media_channel_caps_to_typeflags (const GabbleCapabilitySet *caps)
-{
-  TpChannelMediaCapabilities typeflags = 0;
-  gboolean has_a_transport;
-
-  /* FIXME: shouldn't we support audio/video for people with any transport
-   * that we ourselves support, not just gtalk-p2p? */
-  has_a_transport = gabble_capability_set_has (caps, NS_GOOGLE_TRANSPORT_P2P);
-
-  if (has_a_transport &&
-      gabble_capability_set_has_one (caps,
-        gabble_capabilities_get_any_audio ()))
-    typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_AUDIO;
-
-  if (has_a_transport &&
-      gabble_capability_set_has_one (caps,
-        gabble_capabilities_get_any_video ()))
-    typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_VIDEO;
-
-  /* The checks below are an intentional asymmetry with the function going the
-   * other way - we don't require the other end to advertise the GTalk-P2P
-   * transport capability separately because old GTalk clients didn't do that.
-   * Having Google voice implied Google session and GTalk-P2P. */
-
-  if (gabble_capability_set_has (caps, NS_GOOGLE_FEAT_VOICE))
-    typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_AUDIO;
-
-  if (gabble_capability_set_has (caps, NS_GOOGLE_FEAT_VIDEO))
-    typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_VIDEO;
-
-  return typeflags;
-}
-
 static void
 _emit_new_stream (GabbleMediaChannel *chan,
                   GabbleMediaStream *stream)
diff --git a/src/media-channel.h b/src/media-channel.h
index 224212f..b10886c 100644
--- a/src/media-channel.h
+++ b/src/media-channel.h
@@ -71,12 +71,6 @@ GType gabble_media_channel_get_type (void);
   (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_MEDIA_CHANNEL, \
                               GabbleMediaChannelClass))
 
-void _gabble_media_channel_typeflags_to_caps (TpChannelMediaCapabilities flags,
-    GabbleCapabilitySet *caps);
-
-TpChannelMediaCapabilities
-_gabble_media_channel_caps_to_typeflags (const GabbleCapabilitySet *caps);
-
 void gabble_media_channel_request_initial_streams (GabbleMediaChannel *chan,
     GFunc succeeded_cb,
     GFunc failed_cb,
diff --git a/src/media-factory.c b/src/media-factory.c
index 0e56fc5..a4e1fc4 100644
--- a/src/media-factory.c
+++ b/src/media-factory.c
@@ -656,6 +656,83 @@ channel_manager_iface_init (gpointer g_iface,
   iface->ensure_channel = gabble_media_factory_ensure_channel;
 }
 
+TpChannelMediaCapabilities
+_gabble_media_factory_caps_to_typeflags (const GabbleCapabilitySet *caps)
+{
+  TpChannelMediaCapabilities typeflags = 0;
+  gboolean has_a_transport;
+
+  /* FIXME: shouldn't we support audio/video for people with any transport
+   * that we ourselves support, not just gtalk-p2p? */
+  has_a_transport = gabble_capability_set_has (caps, NS_GOOGLE_TRANSPORT_P2P);
+
+  if (has_a_transport &&
+      gabble_capability_set_has_one (caps,
+        gabble_capabilities_get_any_audio ()))
+    typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_AUDIO;
+
+  if (has_a_transport &&
+      gabble_capability_set_has_one (caps,
+        gabble_capabilities_get_any_video ()))
+    typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_VIDEO;
+
+  /* The checks below are an intentional asymmetry with the function going the
+   * other way - we don't require the other end to advertise the GTalk-P2P
+   * transport capability separately because old GTalk clients didn't do that.
+   * Having Google voice implied Google session and GTalk-P2P. */
+
+  if (gabble_capability_set_has (caps, NS_GOOGLE_FEAT_VOICE))
+    typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_AUDIO;
+
+  if (gabble_capability_set_has (caps, NS_GOOGLE_FEAT_VIDEO))
+    typeflags |= TP_CHANNEL_MEDIA_CAPABILITY_VIDEO;
+
+  return typeflags;
+}
+
+void
+_gabble_media_factory_typeflags_to_caps (TpChannelMediaCapabilities flags,
+    GabbleCapabilitySet *caps)
+{
+  gboolean gtalk_p2p;
+
+  DEBUG ("adding Jingle caps %u (%s, %s, %s, %s)", flags,
+    flags & TP_CHANNEL_MEDIA_CAPABILITY_AUDIO ? "audio" : "no audio",
+    flags & TP_CHANNEL_MEDIA_CAPABILITY_VIDEO ? "video" : "no video",
+    flags & TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P
+        ? "gtalk-p2p" : "no gtalk-p2p",
+    flags & TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_ICE_UDP
+        ? "ice-udp" : "no ice-udp");
+
+  if (flags & TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_ICE_UDP)
+    gabble_capability_set_add (caps, NS_JINGLE_TRANSPORT_ICEUDP);
+
+  gtalk_p2p = flags & TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P;
+
+  if (gtalk_p2p)
+    gabble_capability_set_add (caps, NS_GOOGLE_TRANSPORT_P2P);
+
+  if (flags & TP_CHANNEL_MEDIA_CAPABILITY_AUDIO)
+    {
+      gabble_capability_set_add (caps, NS_JINGLE_RTP);
+      gabble_capability_set_add (caps, NS_JINGLE_RTP_AUDIO);
+      gabble_capability_set_add (caps, NS_JINGLE_DESCRIPTION_AUDIO);
+
+      if (gtalk_p2p)
+        gabble_capability_set_add (caps, NS_GOOGLE_FEAT_VOICE);
+    }
+
+  if (flags & TP_CHANNEL_MEDIA_CAPABILITY_VIDEO)
+    {
+      gabble_capability_set_add (caps, NS_JINGLE_RTP);
+      gabble_capability_set_add (caps, NS_JINGLE_RTP_VIDEO);
+      gabble_capability_set_add (caps, NS_JINGLE_DESCRIPTION_VIDEO);
+
+      if (gtalk_p2p)
+        gabble_capability_set_add (caps, NS_GOOGLE_FEAT_VIDEO);
+    }
+}
+
 static void
 gabble_media_factory_get_contact_caps (GabbleCapsChannelManager *manager,
     TpHandle handle,
diff --git a/src/media-factory.h b/src/media-factory.h
index 6d906ec..0a745c8 100644
--- a/src/media-factory.h
+++ b/src/media-factory.h
@@ -66,6 +66,12 @@ const gchar * _gabble_media_factory_register_sid (GabbleMediaFactory *fac,
 void _gabble_media_factory_free_sid (GabbleMediaFactory *fac,
     const gchar *sid);
 
+void _gabble_media_factory_typeflags_to_caps (TpChannelMediaCapabilities flags,
+    GabbleCapabilitySet *caps);
+
+TpChannelMediaCapabilities
+_gabble_media_factory_caps_to_typeflags (const GabbleCapabilitySet *caps);
+
 G_END_DECLS
 
 #endif /* #ifndef __MEDIA_FACTORY_H__ */
-- 
1.5.6.5




More information about the telepathy-commits mailing list