]> git.0d.be Git - empathy.git/commitdiff
Don't turn on echo cancellation on the source if it's for raw conferences
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Wed, 9 Nov 2011 19:00:10 +0000 (19:00 +0000)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Fri, 11 Nov 2011 14:01:07 +0000 (15:01 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=663842

libempathy-gtk/empathy-call-utils.c
libempathy-gtk/empathy-call-utils.h
src/empathy-audio-sink.c
src/empathy-audio-src.c
src/empathy-audio-src.h
src/empathy-call-window.c

index adf4987bad0e6b8197c38a97b0eadaf7b5e5b6b1..b6fe48d80600b1a7bd4a296adfee0e0ed3a2c7fb 100644 (file)
@@ -250,15 +250,16 @@ empathy_call_new_with_streams (const gchar *contact,
 }
 
 void
-empathy_call_set_stream_properties (GstElement *element)
+empathy_call_set_stream_properties (GstElement *element,
+  gboolean echo_cancellation)
 {
   GstStructure *props;
   GSettings *gsettings_call;
-  gboolean echo_cancellation;
 
   gsettings_call = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
 
-  echo_cancellation = g_settings_get_boolean (gsettings_call,
+  echo_cancellation = echo_cancellation &&
+    g_settings_get_boolean (gsettings_call,
       EMPATHY_PREFS_CALL_ECHO_CANCELLATION);
 
   props = gst_structure_new ("props",
index 87676161c698d176dcb5b92ba7e1dac536fc80c3..8361031002ac3b5df5d3195daae582601bb48b9a 100644 (file)
@@ -40,7 +40,8 @@ GHashTable * empathy_call_create_streamed_media_request (const gchar *contact,
     gboolean initial_audio,
     gboolean initial_video);
 
-void empathy_call_set_stream_properties (GstElement *element);
+void empathy_call_set_stream_properties (GstElement *element,
+    gboolean echo_cancellation);
 
 G_END_DECLS
 
index 3d4496cd144d3b57493c407628775db11f3c93dc..7a8d42bfc05f15ea1aff015f62d07052f5caa804 100644 (file)
@@ -217,7 +217,7 @@ create_sink (void)
   if (sink == NULL)
     return NULL;
 
-  empathy_call_set_stream_properties (sink);
+  empathy_call_set_stream_properties (sink, TRUE);
 
   return sink;
 }
index 350a29a8d161a608bb157217f0cb6e863e1d346e..24a2e8ed40e20251765f1b6602e487aefd013b43 100644 (file)
@@ -53,8 +53,6 @@ enum {
 };
 
 /* private structure */
-typedef struct _EmpathyGstAudioSrcPrivate EmpathyGstAudioSrcPrivate;
-
 struct _EmpathyGstAudioSrcPrivate
 {
   gboolean dispose_has_run;
@@ -207,7 +205,7 @@ create_src (void)
   if (src == NULL)
     return NULL;
 
-  empathy_call_set_stream_properties (src);
+  empathy_call_set_stream_properties (src, TRUE);
 
   return src;
 }
@@ -220,6 +218,7 @@ empathy_audio_src_init (EmpathyGstAudioSrc *obj)
   GstElement *capsfilter;
   GstCaps *caps;
 
+  obj->priv = priv;
   priv->peak_level = -G_MAXDOUBLE;
   priv->lock = g_mutex_new ();
 
@@ -516,6 +515,13 @@ empathy_audio_src_new (void)
   return gst_element_factory_make ("empathyaudiosrc", NULL);
 }
 
+void
+empathy_audio_src_set_echo_cancel (EmpathyGstAudioSrc *src,
+  gboolean enable)
+{
+  empathy_call_set_stream_properties (src->priv->src, enable);
+}
+
 void
 empathy_audio_src_set_volume (EmpathyGstAudioSrc *src, gdouble volume)
 {
index 14813abc19c58da171ac104bda83f84f4871cd5d..ff568ce30e070b98f1659f10cf30b315639646af 100644 (file)
@@ -29,6 +29,8 @@ G_BEGIN_DECLS
 
 typedef struct _EmpathyGstAudioSrc EmpathyGstAudioSrc;
 typedef struct _EmpathyGstAudioSrcClass EmpathyGstAudioSrcClass;
+typedef struct _EmpathyGstAudioSrcPrivate EmpathyGstAudioSrcPrivate;
+
 
 struct _EmpathyGstAudioSrcClass {
     GstBinClass parent_class;
@@ -36,6 +38,7 @@ struct _EmpathyGstAudioSrcClass {
 
 struct _EmpathyGstAudioSrc {
     GstBin parent;
+    EmpathyGstAudioSrcPrivate *priv;
 };
 
 GType empathy_audio_src_get_type (void);
@@ -59,6 +62,9 @@ GType empathy_audio_src_get_type (void);
 
 GstElement *empathy_audio_src_new (void);
 
+void empathy_audio_src_set_echo_cancel (EmpathyGstAudioSrc *src, gboolean
+  enable);
+
 void empathy_audio_src_set_volume (EmpathyGstAudioSrc *src, gdouble volume);
 gdouble empathy_audio_src_get_volume (EmpathyGstAudioSrc *src);
 
index 8a4a3aa29041ec25f45ed77e9e4f17401d68eacc..de29f15c08c124d89abf881f5301d1dca100af73 100644 (file)
@@ -2690,6 +2690,23 @@ empathy_call_window_channel_closed_cb (EmpathyCallHandler *handler,
       empathy_call_window_restart_call (self);
 }
 
+static gboolean
+empathy_call_window_content_is_raw (TfContent *content)
+{
+  FsConference *conference;
+  gboolean israw;
+
+  g_object_get (content, "fs-conference", &conference, NULL);
+  g_assert (conference != NULL);
+
+  /* FIXME: Ugly hack, update when moving a packetization property into
+   * farstream */
+  israw = g_str_has_prefix (GST_OBJECT_NAME (conference), "fsrawconf");
+  gst_object_unref (conference);
+
+  return israw;
+}
+
 static gboolean
 empathy_call_window_content_removed_cb (EmpathyCallHandler *handler,
     TfContent *content,
@@ -3420,6 +3437,14 @@ empathy_call_window_content_added_cb (EmpathyCallHandler *handler,
   switch (media_type)
     {
       case FS_MEDIA_TYPE_AUDIO:
+
+        /* For raw audio conferences assume that the receiver of the raw data
+         * wants it unprocessed, so turn off any echo cancellation and any
+         * other audio improvements that come with it */
+        empathy_audio_src_set_echo_cancel (
+          EMPATHY_GST_AUDIO_SRC (priv->audio_input),
+          !empathy_call_window_content_is_raw (content));
+
         if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_input))
           {
             g_warning ("Could not add audio source to pipeline");