[empathy] Make it possible to set element properties from a config file



commit a885bc90fd4c27676090a59bb615b14258ff8579
Author: Olivier Crête <olivier crete collabora co uk>
Date:   Fri Jul 10 15:41:27 2009 +0100

    Make it possible to set element properties from a config file

 data/Makefile.am                  |    3 +-
 data/element-properties           |   17 ++++++++++++
 libempathy/empathy-call-handler.c |   50 ++++++++++++------------------------
 3 files changed, 36 insertions(+), 34 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 9473714..81ca5a7 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -32,7 +32,8 @@ schemas_DATA 	 = $(schemas_in_files:.schemas.in=.schemas)
 
 streamingprefsdir =  $(datadir)/empathy
 streamingprefs_DATA =		\
-	codec-preferences
+	codec-preferences	\
+	element-properties
 
 if GCONF_SCHEMAS_INSTALL
 install-data-local:
diff --git a/data/element-properties b/data/element-properties
new file mode 100644
index 0000000..e8bd9c0
--- /dev/null
+++ b/data/element-properties
@@ -0,0 +1,17 @@
+# Put the desired properties in the style of
+#
+# [element name]
+# prop1=val1
+
+[gstrtpbin]
+latency=100
+
+[x264enc]
+byte-stream=1
+bframes=0
+b-adapt=0
+cabac=0
+dct8x8=0
+
+[ffenc_h263]
+rtp-payload-size=1
diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c
index 4565ec1..09ea5a1 100644
--- a/libempathy/empathy-call-handler.c
+++ b/libempathy/empathy-call-handler.c
@@ -322,48 +322,32 @@ empathy_call_handler_bus_message (EmpathyCallHandler *handler,
 }
 
 static void
-conference_element_added (FsElementAddedNotifier *notifier,
-    GstBin *bin,
-    GstElement *element,
-    gpointer user_data)
-{
-  GstElementFactory *factory;
-  const gchar *name;
-
-  factory = gst_element_get_factory (element);
-  name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
-
-  if (!tp_strdiff (name, "x264enc"))
-    {
-      /* Ensure that the encoder creates the baseline profile */
-      g_object_set (element,
-          "byte-stream", TRUE,
-          "bframes", 0,
-          "b-adapt", FALSE,
-          "cabac", FALSE,
-          "dct8x8", FALSE,
-          NULL);
-    }
-  else if (!tp_strdiff (name, "gstrtpbin"))
-    {
-      /* Lower the jitterbuffer latency to make it more suitable for video
-       * conferencing */
-      g_object_set (element, "latency", 100, NULL);
-    }
-}
-
-static void
 empathy_call_handler_tf_channel_session_created_cb (TfChannel *tfchannel,
   FsConference *conference, FsParticipant *participant,
   EmpathyCallHandler *self)
 {
   EmpathyCallHandlerPriv *priv = GET_PRIV (self);
+  GKeyFile *keyfile;
+  gchar *filename;
+  GError *error = NULL;
 
   priv->fsnotifier = fs_element_added_notifier_new ();
   fs_element_added_notifier_add (priv->fsnotifier, GST_BIN (conference));
 
-  g_signal_connect (priv->fsnotifier, "element-added",
-    G_CALLBACK (conference_element_added), NULL);
+  keyfile = g_key_file_new ();
+  filename = empathy_file_lookup ("element-properties", "data");
+  if (g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, &error))
+    {
+      fs_element_added_notifier_set_properties_from_keyfile (priv->fsnotifier,
+          keyfile);
+    }
+  else
+    {
+      g_warning ("Could not load element-properties file: %s", error->message);
+      g_key_file_free (keyfile);
+      g_clear_error (&error);
+    }
+  g_free (filename);
 
   g_signal_emit (G_OBJECT (self), signals[CONFERENCE_ADDED], 0,
     GST_ELEMENT (conference));



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