[empathy] Put codec preferences in a configuration file



commit b1642e68a321a80d7557863409455375906c14ba
Author: Olivier Crête <olivier crete collabora co uk>
Date:   Fri Jul 10 15:21:16 2009 +0100

    Put codec preferences in a configuration file

 data/Makefile.am                  |    4 +++
 data/codec-preferences            |   36 +++++++++++++++++++++++++
 libempathy/empathy-call-handler.c |   53 ++++++++----------------------------
 3 files changed, 52 insertions(+), 41 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 52108fb..9473714 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -30,6 +30,10 @@ schemas_in_files = empathy.schemas.in
 schemas_DATA 	 = $(schemas_in_files:.schemas.in=.schemas)
 @INTLTOOL_SCHEMAS_RULE@
 
+streamingprefsdir =  $(datadir)/empathy
+streamingprefs_DATA =		\
+	codec-preferences
+
 if GCONF_SCHEMAS_INSTALL
 install-data-local:
 	if test -z "$(DESTDIR)" ; then \
diff --git a/data/codec-preferences b/data/codec-preferences
new file mode 100644
index 0000000..0cb0910
--- /dev/null
+++ b/data/codec-preferences
@@ -0,0 +1,36 @@
+# Favorite audio codecs
+
+[audio/SPEEX:8000]
+clock-rate=8000
+
+[audio/SPEEX:16000]
+clock-rate=16000
+
+[audio/AMR]
+
+[audio/G729]
+
+[audio/ILBC]
+
+# Disabled audio codecs
+
+[audio/DV]
+id=-1
+
+[audio/MPA]
+id=-1
+
+[audio/VORBIS]
+id=-1
+
+[audio/MP3]
+id=-1
+
+
+# Favorite video codecs
+
+[video/H264]
+
+[video/H263]
+
+[video/THEORA]
diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c
index f73c41e..4565ec1 100644
--- a/libempathy/empathy-call-handler.c
+++ b/libempathy/empathy-call-handler.c
@@ -427,53 +427,24 @@ empathy_call_handler_tf_channel_closed_cb (TfChannel *tfchannel,
 }
 
 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)
+  gchar *filename = empathy_file_lookup ("codec-preferences", "data");
+  GList *codecs;
+  GError *error = NULL;
+
+  codecs = fs_codec_list_from_keyfile (filename, &error);
+  g_free (filename);
+
+  if (!codecs)
     {
-      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);
+      g_warning ("No codec-preferences file: %s",
+          error ? error->message : "No error message");
     }
+  g_clear_error (&error);
 
-  return NULL;
+  return codecs;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]