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

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

index b6fe48d80600b1a7bd4a296adfee0e0ed3a2c7fb..16526d3544d4e5b6aa945703d257fe9da099605c 100644 (file)
@@ -255,18 +255,23 @@ empathy_call_set_stream_properties (GstElement *element,
 {
   GstStructure *props;
   GSettings *gsettings_call;
+  gboolean echo_cancellation_setting;
 
   gsettings_call = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
 
-  echo_cancellation = echo_cancellation &&
-    g_settings_get_boolean (gsettings_call,
+  echo_cancellation_setting = g_settings_get_boolean (gsettings_call,
       EMPATHY_PREFS_CALL_ECHO_CANCELLATION);
 
+  DEBUG ("Echo cancellation: element allowed: %s, user enabled: %s",
+    echo_cancellation ? " yes" : "no",
+    echo_cancellation_setting ? " yes" : "no");
+
+
   props = gst_structure_new ("props",
       PA_PROP_MEDIA_ROLE, G_TYPE_STRING, "phone",
       NULL);
 
-  if (echo_cancellation)
+  if (echo_cancellation && echo_cancellation_setting)
     {
       gst_structure_set (props,
           "filter.want", G_TYPE_STRING, "echo-cancel",
index 7a8d42bfc05f15ea1aff015f62d07052f5caa804..b35edb3315e7958587dbe36ff263d0fabcf234a4 100644 (file)
@@ -61,6 +61,7 @@ enum {
 struct _EmpathyGstAudioSinkPrivate
 {
   GstElement *sink;
+  gboolean echo_cancel;
 };
 
 #define EMPATHY_GST_AUDIO_SINK_GET_PRIVATE(o) \
@@ -71,6 +72,7 @@ static void
 empathy_audio_sink_init (EmpathyGstAudioSink *self)
 {
   self->priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self);
+  self->priv->echo_cancel = TRUE;
 }
 
 static GstPad * empathy_audio_sink_request_new_pad (GstElement *self,
@@ -191,7 +193,7 @@ empathy_audio_sink_get_volume (EmpathyGstAudioSink *sink)
 }
 
 static GstElement *
-create_sink (void)
+create_sink (EmpathyGstAudioSink *self)
 {
   GstElement *sink;
   const gchar *description;
@@ -217,7 +219,7 @@ create_sink (void)
   if (sink == NULL)
     return NULL;
 
-  empathy_call_set_stream_properties (sink, TRUE);
+  empathy_call_set_stream_properties (sink, self->priv->echo_cancel);
 
   return sink;
 }
@@ -258,7 +260,7 @@ empathy_audio_sink_request_new_pad (GstElement *element,
 
   gst_bin_add (GST_BIN (bin), volume);
 
-  self->priv->sink = create_sink ();
+  self->priv->sink = create_sink (self);
   if (self->priv->sink == NULL)
     goto error;
 
@@ -311,3 +313,14 @@ empathy_audio_sink_release_pad (GstElement *element,
   gst_pad_set_active (pad, FALSE);
   gst_element_remove_pad (element, pad);
 }
+
+void
+empathy_audio_sink_set_echo_cancel (EmpathyGstAudioSink *sink,
+  gboolean echo_cancel)
+{
+  DEBUG ("Sink echo cancellation setting: %s", echo_cancel ? "on" : "off");
+  sink->priv->echo_cancel = echo_cancel;
+  if (sink->priv->sink != NULL)
+    empathy_call_set_stream_properties (sink->priv->sink,
+      sink->priv->echo_cancel);
+}
index cc21fc4675d7ae691b79f4ef343577127f3c651b..ceb0bbe360d8c2b38c96c6b8252b297062563ea6 100644 (file)
@@ -63,6 +63,8 @@ GstElement *empathy_audio_sink_new (void);
 void empathy_audio_sink_set_volume (EmpathyGstAudioSink *sink, gdouble volume);
 
 gdouble empathy_audio_sink_get_volume (EmpathyGstAudioSink *sink);
+void empathy_audio_sink_set_echo_cancel (EmpathyGstAudioSink *sink,
+  gboolean echo_cancel);
 
 G_END_DECLS
 
index 24a2e8ed40e20251765f1b6602e487aefd013b43..19af8877a65623fdde67f5a97fc1c7d181b46547 100644 (file)
@@ -519,6 +519,7 @@ void
 empathy_audio_src_set_echo_cancel (EmpathyGstAudioSrc *src,
   gboolean enable)
 {
+  DEBUG ("Src echo cancellation setting: %s", enable ? "on" : "off");
   empathy_call_set_stream_properties (src->priv->src, enable);
 }
 
index 0477cd7c06a3caf36f4d384f3bfcc297fa38f59c..4014ad6c663aca92935cab37deff9db77ed861bb 100644 (file)
@@ -479,7 +479,7 @@ empathy_call_handler_class_init (EmpathyCallHandlerClass *klass)
       G_SIGNAL_RUN_LAST, 0, NULL, NULL,
       g_cclosure_marshal_generic,
       G_TYPE_BOOLEAN,
-      2, GST_TYPE_PAD, G_TYPE_UINT);
+      2, TF_TYPE_CONTENT, GST_TYPE_PAD);
 
   signals[CONTENT_ADDED] =
     g_signal_new ("content-added", G_TYPE_FROM_CLASS (klass),
@@ -763,13 +763,10 @@ on_tf_content_src_pad_added_cb (TfContent *content,
   FsCodec *codec,
   EmpathyCallHandler *handler)
 {
-  guint media_type;
   gboolean retval;
 
-  g_object_get (content, "media-type", &media_type, NULL);
-
   g_signal_emit (G_OBJECT (handler), signals[SRC_PAD_ADDED], 0,
-      pad, media_type, &retval);
+      content, pad, &retval);
 
   if (!retval)
     g_idle_add (src_pad_added_error_idle, g_object_ref (content));
index de29f15c08c124d89abf881f5301d1dca100af73..9ecc47ba2bd79dcf77f7c73587a25e6302de2222 100644 (file)
@@ -2868,7 +2868,8 @@ empathy_call_window_get_video_sink_pad (EmpathyCallWindow *self)
 
 /* Called with global lock held */
 static GstPad *
-empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
+empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self,
+  TfContent *content)
 {
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   GstPad *pad;
@@ -2893,6 +2894,13 @@ empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self)
         }
     }
 
+  /* For raw audio conferences assume that the producer of the raw data
+   * has already processed it, so turn off any echo cancellation and any
+   * other audio improvements that come with it */
+  empathy_audio_sink_set_echo_cancel (
+    EMPATHY_GST_AUDIO_SINK (priv->audio_output),
+    !empathy_call_window_content_is_raw (content));
+
   template = gst_element_class_get_pad_template (
     GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
 
@@ -3343,20 +3351,23 @@ empathy_call_window_video_probe_cb (GstPad *pad,
 /* Called from the streaming thread */
 static gboolean
 empathy_call_window_src_added_cb (EmpathyCallHandler *handler,
-  GstPad *src, guint media_type, gpointer user_data)
+  TfContent *content, GstPad *src, gpointer user_data)
 {
   EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (user_data);
   EmpathyCallWindowPriv *priv = GET_PRIV (self);
   gboolean retval = FALSE;
+  guint media_type;
 
   GstPad *pad;
 
   g_mutex_lock (priv->lock);
 
+  g_object_get (content, "media-type", &media_type, NULL);
+
   switch (media_type)
     {
       case TP_MEDIA_STREAM_TYPE_AUDIO:
-        pad = empathy_call_window_get_audio_sink_pad (self);
+        pad = empathy_call_window_get_audio_sink_pad (self, content);
         break;
       case TP_MEDIA_STREAM_TYPE_VIDEO:
         g_idle_add (empathy_call_window_show_video_output_cb, self);