summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-10-26 16:13:14 +0000
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-12-07 18:58:04 +0000
commit61bd59de232c53941b21452f2d30fbbe51c356a5 (patch)
tree4eed8525edf3df1e84d745cbeee11ca7f96f6ac0 /src/util.c
parentfd5b9865d38c2b44a5ca155d98561703b66c1c1b (diff)
Move _pick_best_content_type to utils.c
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 49a73ce67..6e3b64f39 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1162,3 +1162,39 @@ FINALLY:
gabble_capability_set_free (caps);
return resource;
}
+
+#define TWICE(x) x, x
+
+const gchar *
+jingle_pick_best_content_type (GabbleConnection *conn,
+ TpHandle peer,
+ const gchar *resource,
+ JingleMediaType type)
+{
+ GabblePresence *presence;
+ const GabbleFeatureFallback content_types[] = {
+ /* if $thing is supported, then use it */
+ { TRUE, TWICE (NS_JINGLE_RTP) },
+ { type == JINGLE_MEDIA_TYPE_VIDEO,
+ TWICE (NS_JINGLE_DESCRIPTION_VIDEO) },
+ { type == JINGLE_MEDIA_TYPE_AUDIO,
+ TWICE (NS_JINGLE_DESCRIPTION_AUDIO) },
+ /* odd Google ones: if $thing is supported, use $other_thing */
+ { type == JINGLE_MEDIA_TYPE_AUDIO,
+ NS_GOOGLE_FEAT_VOICE, NS_GOOGLE_SESSION_PHONE },
+ { type == JINGLE_MEDIA_TYPE_VIDEO,
+ NS_GOOGLE_FEAT_VIDEO, NS_GOOGLE_SESSION_VIDEO },
+ { FALSE, NULL, NULL }
+ };
+
+ presence = gabble_presence_cache_get (conn->presence_cache, peer);
+
+ if (presence == NULL)
+ {
+ DEBUG ("contact %d has no presence available", peer);
+ return NULL;
+ }
+
+ return gabble_presence_resource_pick_best_feature (presence, resource,
+ content_types, gabble_capability_set_predicate_has);
+}