[telepathy-gabble/master] Add and use a canned "any audio/video" caps set

Will Thompson will.thompson at collabora.co.uk
Mon Oct 19 08:23:09 PDT 2009


---
 src/capabilities.c  |   12 ++++++++++++
 src/capabilities.h  |    1 +
 src/media-channel.c |   14 ++++++--------
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/capabilities.c b/src/capabilities.c
index c962092..4b9f44a 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -96,6 +96,7 @@ static GabbleCapabilitySet *voice_v1_caps = NULL;
 static GabbleCapabilitySet *video_v1_caps = NULL;
 static GabbleCapabilitySet *any_audio_caps = NULL;
 static GabbleCapabilitySet *any_video_caps = NULL;
+static GabbleCapabilitySet *any_audio_video_caps = NULL;
 static GabbleCapabilitySet *any_google_av_caps = NULL;
 static GabbleCapabilitySet *any_jingle_av_caps = NULL;
 static GabbleCapabilitySet *any_transport_caps = NULL;
@@ -134,6 +135,12 @@ gabble_capabilities_get_any_video (void)
 }
 
 const GabbleCapabilitySet *
+gabble_capabilities_get_any_audio_video (void)
+{
+  return any_audio_video_caps;
+}
+
+const GabbleCapabilitySet *
 gabble_capabilities_get_any_google_av (void)
 {
   return any_google_av_caps;
@@ -255,6 +262,9 @@ gabble_capabilities_init (GabbleConnection *conn)
       gabble_capability_set_add (any_video_caps, NS_JINGLE_DESCRIPTION_VIDEO);
       gabble_capability_set_add (any_video_caps, NS_GOOGLE_FEAT_VIDEO);
 
+      any_audio_video_caps = gabble_capability_set_copy (any_audio_caps);
+      gabble_capability_set_update (any_audio_video_caps, any_video_caps);
+
       any_google_av_caps = gabble_capability_set_new ();
       gabble_capability_set_add (any_google_av_caps, NS_GOOGLE_FEAT_VOICE);
       gabble_capability_set_add (any_google_av_caps, NS_GOOGLE_FEAT_VIDEO);
@@ -305,6 +315,7 @@ gabble_capabilities_finalize (GabbleConnection *conn)
       gabble_capability_set_free (video_v1_caps);
       gabble_capability_set_free (any_audio_caps);
       gabble_capability_set_free (any_video_caps);
+      gabble_capability_set_free (any_audio_video_caps);
       gabble_capability_set_free (any_google_av_caps);
       gabble_capability_set_free (any_jingle_av_caps);
       gabble_capability_set_free (any_transport_caps);
@@ -317,6 +328,7 @@ gabble_capabilities_finalize (GabbleConnection *conn)
       video_v1_caps = NULL;
       any_audio_caps = NULL;
       any_video_caps = NULL;
+      any_audio_video_caps = NULL;
       any_google_av_caps = NULL;
       any_jingle_av_caps = NULL;
       any_transport_caps = NULL;
diff --git a/src/capabilities.h b/src/capabilities.h
index b66c500..6b42668 100644
--- a/src/capabilities.h
+++ b/src/capabilities.h
@@ -90,6 +90,7 @@ typedef gboolean (*GabbleCapabilitySetPredicate) (
 const GabbleCapabilitySet *gabble_capabilities_get_legacy (void);
 const GabbleCapabilitySet *gabble_capabilities_get_any_audio (void);
 const GabbleCapabilitySet *gabble_capabilities_get_any_video (void);
+const GabbleCapabilitySet *gabble_capabilities_get_any_audio_video (void);
 const GabbleCapabilitySet *gabble_capabilities_get_any_google_av (void);
 const GabbleCapabilitySet *gabble_capabilities_get_any_jingle_av (void);
 const GabbleCapabilitySet *gabble_capabilities_get_any_transport (void);
diff --git a/src/media-channel.c b/src/media-channel.c
index 8934ced..0066029 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -2106,15 +2106,13 @@ contact_is_media_capable (GabbleMediaChannel *chan,
 
   presence = gabble_presence_cache_get (priv->conn->presence_cache, peer);
 
-  if (presence != NULL &&
-      (gabble_presence_has_cap (presence, NS_GOOGLE_FEAT_VOICE) ||
-       gabble_presence_has_cap (presence, NS_GOOGLE_FEAT_VIDEO) ||
-       gabble_presence_has_cap (presence, NS_JINGLE_RTP_AUDIO) ||
-       gabble_presence_has_cap (presence, NS_JINGLE_RTP_VIDEO) ||
-       gabble_presence_has_cap (presence, NS_JINGLE_DESCRIPTION_AUDIO) ||
-       gabble_presence_has_cap (presence, NS_JINGLE_DESCRIPTION_VIDEO)))
+  if (presence != NULL)
     {
-      return TRUE;
+      const GabbleCapabilitySet *caps = gabble_presence_peek_caps (presence);
+
+      if (gabble_capability_set_has_one (caps,
+            gabble_capabilities_get_any_audio_video ()))
+        return TRUE;
     }
 
   /* Okay, they're not capable (yet). Let's figure out whether we should wait,
-- 
1.5.6.5




More information about the telepathy-commits mailing list