]> git.0d.be Git - empathy.git/blob - src/empathy-audio-utils.c
Reorder header inclusions accordingly to the Telepathy coding style
[empathy.git] / src / empathy-audio-utils.c
1 /*
2  * Copyright (C) 2011 Collabora Ltd.
3  *
4  * The code contained in this file is free software; you can redistribute
5  * it and/or modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either version
7  * 2.1 of the License, or (at your option) any later version.
8  *
9  * This file is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this code; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  * Authors: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
19  */
20
21 #include "config.h"
22 #include "empathy-audio-utils.h"
23
24 #include <pulse/pulseaudio.h>
25
26 #include "empathy-gsettings.h"
27
28 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
29 #include "empathy-debug.h"
30
31 void
32 empathy_audio_set_stream_properties (GstElement *element,
33   gboolean echo_cancellation)
34 {
35   GstStructure *props;
36   GSettings *gsettings_call;
37   gboolean echo_cancellation_setting;
38
39   gsettings_call = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
40
41   echo_cancellation_setting = g_settings_get_boolean (gsettings_call,
42       EMPATHY_PREFS_CALL_ECHO_CANCELLATION);
43
44   DEBUG ("Echo cancellation: element allowed: %s, user enabled: %s",
45     echo_cancellation ? " yes" : "no",
46     echo_cancellation_setting ? " yes" : "no");
47
48
49   props = gst_structure_new ("props",
50       PA_PROP_MEDIA_ROLE, G_TYPE_STRING, "phone",
51       NULL);
52
53   if (echo_cancellation && echo_cancellation_setting)
54     {
55       gst_structure_set (props,
56           "filter.want", G_TYPE_STRING, "echo-cancel",
57           NULL);
58     }
59
60   g_object_set (element, "stream-properties", props, NULL);
61   gst_structure_free (props);
62
63   g_object_unref (gsettings_call);
64 }