[telepathy-gabble/master] Force codec names' cases to match Google Talk

Will Thompson will.thompson at collabora.co.uk
Wed Jul 1 03:52:24 PDT 2009


The Google Talk desktop client doesn't believe that "ILBC" is the same
codec as "iLBC", even though SDP defines codecs' names to be case
insensitive. So when using a Google dialect, let's make the names' cases
match what the desktop client wants.

Reviewed-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
---
 src/jingle-media-rtp.c |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/src/jingle-media-rtp.c b/src/jingle-media-rtp.c
index e39411a..0aba13a 100644
--- a/src/jingle-media-rtp.c
+++ b/src/jingle-media-rtp.c
@@ -574,6 +574,39 @@ parse_description (GabbleJingleContent *content,
   update_remote_codecs (self, codecs, error);
 }
 
+/* The Google Talk desktop client is picky about the case of codec names, even
+ * though SDP defines them to be case-insensitive. The particular case that was
+ * causing problems was ILBC vs iLBC, but it seems safer to special-case the
+ * lot. This list is taken from the initiate sent by the desktop client on
+ * 2009-07-01.
+ */
+static const gchar * const codec_cases[] = {
+    "CN",
+    "EG711A",
+    "EG711U",
+    "G723",
+    "IPCMWB",
+    "ISAC",
+    "PCMA",
+    "PCMU",
+    "iLBC",
+    "speex",
+    "telephone-event",
+    NULL
+};
+
+static const gchar *
+gtalk_case (const gchar *codec)
+{
+  const gchar * const *ret = codec_cases;
+
+  for (; *ret != NULL; ret++)
+    if (g_ascii_strcasecmp (*ret, codec) == 0)
+      return *ret;
+
+  return codec;
+}
+
 static void
 _produce_extra_param (gpointer key, gpointer value, gpointer user_data)
 {
@@ -632,7 +665,12 @@ produce_payload_type (LmMessageNode *desc_node,
 
   /* name: optional */
   if (*p->name != '\0')
-    lm_message_node_set_attribute (pt_node, "name", p->name);
+    {
+      if (JINGLE_IS_GOOGLE_DIALECT (dialect))
+        lm_message_node_set_attribute (pt_node, "name", gtalk_case (p->name));
+      else
+        lm_message_node_set_attribute (pt_node, "name", p->name);
+    }
 
   /* clock rate: optional */
   if (p->clockrate != 0)
-- 
1.5.6.5



More information about the telepathy-commits mailing list