]> git.0d.be Git - empathy.git/commitdiff
Hardcode some a default codec preferences
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Tue, 3 Mar 2009 17:35:00 +0000 (17:35 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 3 Mar 2009 17:35:00 +0000 (17:35 +0000)
For video use H264 over Theora as it's better quality and there is
no reason to prefer a free codec if people already have the patented bits
installed anyway. Also prefer H263 as it's reasonable and it works around our
H263-1998 negotiation being slightly broken because of gstreamer :(

For audio prefer speex wideband over speex smallband and all other audio
codecs.

And in general disable various codecs that are not really suitable for use in
conferencing.

From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

svn path=/trunk/; revision=2567

libempathy/empathy-call-handler.c

index 59afe3f9975a591e08a4c4320c85f0ad8ee38c6f..8d159cdd481cde21448505a3172969e4fabc3d37 100644 (file)
@@ -289,6 +289,56 @@ empathy_call_handler_tf_channel_closed_cb (TfChannel *tfchannel,
   g_signal_emit (G_OBJECT (handler), signals[CLOSED], 0);
 }
 
+static GList *
+empathy_call_handler_tf_channel_codec_config_get_defaults (FsCodec *codecs)
+{
+  GList *l = NULL;
+  int i;
+
+  for (i = 0; codecs[i].encoding_name != NULL; i++)
+      l = g_list_append (l, fs_codec_copy (codecs + i));
+
+  return l;
+}
+
+static GList *
+empathy_call_handler_tf_channel_codec_config_cb (TfChannel *channel,
+  guint stream_id, FsMediaType media_type, guint direction, gpointer user_data)
+{
+  FsCodec audio_codecs[] = {
+    { FS_CODEC_ID_ANY, "SPEEX", FS_MEDIA_TYPE_AUDIO, 16000, },
+    { FS_CODEC_ID_ANY, "SPEEX", FS_MEDIA_TYPE_AUDIO, 8000, },
+
+    { FS_CODEC_ID_DISABLE, "DV",     FS_MEDIA_TYPE_AUDIO, },
+    { FS_CODEC_ID_DISABLE, "MPA",    FS_MEDIA_TYPE_AUDIO, },
+    { FS_CODEC_ID_DISABLE, "VORBIS", FS_MEDIA_TYPE_AUDIO, },
+    { FS_CODEC_ID_DISABLE, "MP3",    FS_MEDIA_TYPE_AUDIO, },
+    { 0, NULL, 0,}
+  };
+  FsCodec video_codecs[] = {
+    { FS_CODEC_ID_ANY, "H264",   FS_MEDIA_TYPE_VIDEO, },
+    { FS_CODEC_ID_ANY, "THEORA", FS_MEDIA_TYPE_VIDEO, },
+    { FS_CODEC_ID_ANY, "H263",   FS_MEDIA_TYPE_VIDEO, },
+
+    { FS_CODEC_ID_DISABLE, "DV",   FS_MEDIA_TYPE_VIDEO, },
+    { FS_CODEC_ID_DISABLE, "JPEG", FS_MEDIA_TYPE_VIDEO, },
+    { FS_CODEC_ID_DISABLE, "MPV",  FS_MEDIA_TYPE_VIDEO, },
+    { 0, NULL, 0}
+  };
+
+  switch (media_type)
+    {
+      case FS_MEDIA_TYPE_AUDIO:
+        return empathy_call_handler_tf_channel_codec_config_get_defaults
+          (audio_codecs);
+      case FS_MEDIA_TYPE_VIDEO:
+        return empathy_call_handler_tf_channel_codec_config_get_defaults
+          (video_codecs);
+    }
+
+  return NULL;
+}
+
 static void
 empathy_call_handler_start_tpfs (EmpathyCallHandler *self)
 {
@@ -308,6 +358,8 @@ empathy_call_handler_start_tpfs (EmpathyCallHandler *self)
       G_CALLBACK (empathy_call_handler_tf_channel_stream_created_cb), self);
   g_signal_connect (priv->tfchannel, "closed",
       G_CALLBACK (empathy_call_handler_tf_channel_closed_cb), self);
+  g_signal_connect (priv->tfchannel, "stream-get-codec-config",
+      G_CALLBACK (empathy_call_handler_tf_channel_codec_config_cb), self);
 
   g_object_unref (channel);
 }