• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * WebRTC Audio Processing Elements
3  *
4  *  Copyright 2016 Collabora Ltd
5  *    @author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
20  *
21  */
22 
23 /**
24  * SECTION:element-webrtcdsp
25  * @short_description: Audio Filter using WebRTC Audio Processing library
26  *
27  * A voice enhancement filter based on WebRTC Audio Processing library. This
28  * library provides a whide variety of enhancement algorithms. This element
29  * tries to enable as much as possible. The currently enabled enhancements are
30  * High Pass Filter, Echo Canceller, Noise Suppression, Automatic Gain Control,
31  * and some extended filters.
32  *
33  * While webrtcdsp element can be used alone, there is an exception for the
34  * echo canceller. The audio canceller need to be aware of the far end streams
35  * that are played to loud speakers. For this, you must place a webrtcechoprobe
36  * element at that far end. Note that the sample rate must match between
37  * webrtcdsp and the webrtechoprobe. Though, the number of channels can differ.
38  * The probe is found by the DSP element using it's object name. By default,
39  * webrtcdsp looks for webrtcechoprobe0, which means it just work if you have
40  * a single probe and DSP.
41  *
42  * The probe can only be used within the same top level GstPipeline.
43  * Additionally, to simplify the code, the probe element must be created
44  * before the DSP sink pad is activated. It does not need to be in any
45  * particular state and does not even need to be added to the pipeline yet.
46  *
47  * # Example launch line
48  *
49  * As a convenience, the echo canceller can be tested using an echo loop. In
50  * this configuration, one would expect a single echo to be heard.
51  *
52  * |[
53  * gst-launch-1.0 pulsesrc ! webrtcdsp ! webrtcechoprobe ! pulsesink
54  * ]|
55  *
56  * In real environment, you'll place the probe before the playback, but only
57  * process the far end streams. The DSP should be placed as close as possible
58  * to the audio capture. The following pipeline is astracted and does not
59  * represent a real pipeline.
60  *
61  * |[
62  * gst-launch-1.0 far-end-src ! audio/x-raw,rate=48000 ! webrtcechoprobe ! pulsesink \
63  *                pulsesrc ! audio/x-raw,rate=48000 ! webrtcdsp ! far-end-sink
64  * ]|
65  */
66 
67 #ifdef HAVE_CONFIG_H
68 #include "config.h"
69 #endif
70 
71 #include "gstwebrtcdsp.h"
72 #include "gstwebrtcechoprobe.h"
73 
74 
75 static gboolean
plugin_init(GstPlugin * plugin)76 plugin_init (GstPlugin * plugin)
77 {
78   gboolean ret = FALSE;
79 
80   ret |= GST_ELEMENT_REGISTER (webrtcdsp, plugin);
81   ret |= GST_ELEMENT_REGISTER (webrtcechoprobe, plugin);
82 
83   return ret;
84 }
85 
86 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
87     GST_VERSION_MINOR,
88     webrtcdsp,
89     "Voice pre-processing using WebRTC Audio Processing Library",
90     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
91