summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Cerveau <scerveau@collabora.com>2021-02-25 08:18:54 +0100
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-03-23 14:19:17 +0000
commit63dc81d000dfb06a2b61c7789116e900bd64d9e6 (patch)
treec8572cad3eee4ce8ef3a9ce0cccd8b3ff88abdad
parent6adf7dff71b2808e8b5fbef7bf45f1ae50ae1b34 (diff)
downloadgstreamer-plugins-bad-63dc81d000dfb06a2b61c7789116e900bd64d9e6.tar.gz
webrtcdsp: allow per feature registration
Split plugin into features including dynamic types which can be indiviually registered during a static build. More details here: https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199 https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2038>
-rw-r--r--ext/webrtcdsp/gstwebrtcdsp.cpp30
-rw-r--r--ext/webrtcdsp/gstwebrtcdsp.h2
-rw-r--r--ext/webrtcdsp/gstwebrtcdspplugin.cpp90
-rw-r--r--ext/webrtcdsp/gstwebrtcechoprobe.cpp2
-rw-r--r--ext/webrtcdsp/gstwebrtcechoprobe.h2
-rw-r--r--ext/webrtcdsp/meson.build3
6 files changed, 103 insertions, 26 deletions
diff --git a/ext/webrtcdsp/gstwebrtcdsp.cpp b/ext/webrtcdsp/gstwebrtcdsp.cpp
index 87de1bcfc..27b286fa5 100644
--- a/ext/webrtcdsp/gstwebrtcdsp.cpp
+++ b/ext/webrtcdsp/gstwebrtcdsp.cpp
@@ -274,7 +274,11 @@ struct _GstWebrtcDsp
webrtc::VoiceDetection::Likelihood voice_detection_likelihood;
};
-G_DEFINE_TYPE (GstWebrtcDsp, gst_webrtc_dsp, GST_TYPE_AUDIO_FILTER);
+G_DEFINE_TYPE_WITH_CODE (GstWebrtcDsp, gst_webrtc_dsp, GST_TYPE_AUDIO_FILTER,
+ GST_DEBUG_CATEGORY_INIT (webrtc_dsp_debug, "webrtcdsp", 0,
+ "libwebrtcdsp wrapping elements"););
+GST_ELEMENT_REGISTER_DEFINE (webrtcdsp, "webrtcdsp", GST_RANK_NONE,
+ GST_TYPE_WEBRTC_DSP);
static const gchar *
webrtc_error_to_string (gint err)
@@ -1118,27 +1122,3 @@ gst_webrtc_dsp_class_init (GstWebrtcDspClass * klass)
gst_type_mark_as_plugin_api (GST_TYPE_WEBRTC_ECHO_SUPPRESSION_LEVEL, (GstPluginAPIFlags) 0);
gst_type_mark_as_plugin_api (GST_TYPE_WEBRTC_VOICE_DETECTION_LIKELIHOOD, (GstPluginAPIFlags) 0);
}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- GST_DEBUG_CATEGORY_INIT
- (webrtc_dsp_debug, "webrtcdsp", 0, "libwebrtcdsp wrapping elements");
-
- if (!gst_element_register (plugin, "webrtcdsp", GST_RANK_NONE,
- GST_TYPE_WEBRTC_DSP)) {
- return FALSE;
- }
- if (!gst_element_register (plugin, "webrtcechoprobe", GST_RANK_NONE,
- GST_TYPE_WEBRTC_ECHO_PROBE)) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- webrtcdsp,
- "Voice pre-processing using WebRTC Audio Processing Library",
- plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/ext/webrtcdsp/gstwebrtcdsp.h b/ext/webrtcdsp/gstwebrtcdsp.h
index 12a9415f6..207465923 100644
--- a/ext/webrtcdsp/gstwebrtcdsp.h
+++ b/ext/webrtcdsp/gstwebrtcdsp.h
@@ -52,6 +52,8 @@ struct _GstWebrtcDspClass
GType gst_webrtc_dsp_get_type (void);
+GST_ELEMENT_REGISTER_DECLARE (webrtcdsp);
+
G_END_DECLS
#endif /* __GST_WEBRTC_DSP_H__ */
diff --git a/ext/webrtcdsp/gstwebrtcdspplugin.cpp b/ext/webrtcdsp/gstwebrtcdspplugin.cpp
new file mode 100644
index 000000000..cec0a05f4
--- /dev/null
+++ b/ext/webrtcdsp/gstwebrtcdspplugin.cpp
@@ -0,0 +1,90 @@
+/*
+ * WebRTC Audio Processing Elements
+ *
+ * Copyright 2016 Collabora Ltd
+ * @author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/**
+ * SECTION:element-webrtcdsp
+ * @short_description: Audio Filter using WebRTC Audio Processing library
+ *
+ * A voice enhancement filter based on WebRTC Audio Processing library. This
+ * library provides a whide variety of enhancement algorithms. This element
+ * tries to enable as much as possible. The currently enabled enhancements are
+ * High Pass Filter, Echo Canceller, Noise Suppression, Automatic Gain Control,
+ * and some extended filters.
+ *
+ * While webrtcdsp element can be used alone, there is an exception for the
+ * echo canceller. The audio canceller need to be aware of the far end streams
+ * that are played to loud speakers. For this, you must place a webrtcechoprobe
+ * element at that far end. Note that the sample rate must match between
+ * webrtcdsp and the webrtechoprobe. Though, the number of channels can differ.
+ * The probe is found by the DSP element using it's object name. By default,
+ * webrtcdsp looks for webrtcechoprobe0, which means it just work if you have
+ * a single probe and DSP.
+ *
+ * The probe can only be used within the same top level GstPipeline.
+ * Additionally, to simplify the code, the probe element must be created
+ * before the DSP sink pad is activated. It does not need to be in any
+ * particular state and does not even need to be added to the pipeline yet.
+ *
+ * # Example launch line
+ *
+ * As a convenience, the echo canceller can be tested using an echo loop. In
+ * this configuration, one would expect a single echo to be heard.
+ *
+ * |[
+ * gst-launch-1.0 pulsesrc ! webrtcdsp ! webrtcechoprobe ! pulsesink
+ * ]|
+ *
+ * In real environment, you'll place the probe before the playback, but only
+ * process the far end streams. The DSP should be placed as close as possible
+ * to the audio capture. The following pipeline is astracted and does not
+ * represent a real pipeline.
+ *
+ * |[
+ * gst-launch-1.0 far-end-src ! audio/x-raw,rate=48000 ! webrtcechoprobe ! pulsesink \
+ * pulsesrc ! audio/x-raw,rate=48000 ! webrtcdsp ! far-end-sink
+ * ]|
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstwebrtcdsp.h"
+#include "gstwebrtcechoprobe.h"
+
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ gboolean ret = FALSE;
+
+ ret |= GST_ELEMENT_REGISTER (webrtcdsp, plugin);
+ ret |= GST_ELEMENT_REGISTER (webrtcechoprobe, plugin);
+
+ return ret;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ webrtcdsp,
+ "Voice pre-processing using WebRTC Audio Processing Library",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/ext/webrtcdsp/gstwebrtcechoprobe.cpp b/ext/webrtcdsp/gstwebrtcechoprobe.cpp
index cfa5b55b2..acdb3d8a7 100644
--- a/ext/webrtcdsp/gstwebrtcechoprobe.cpp
+++ b/ext/webrtcdsp/gstwebrtcechoprobe.cpp
@@ -78,6 +78,8 @@ static GList *gst_aec_probes = NULL;
G_DEFINE_TYPE (GstWebrtcEchoProbe, gst_webrtc_echo_probe,
GST_TYPE_AUDIO_FILTER);
+GST_ELEMENT_REGISTER_DEFINE (webrtcechoprobe, "webrtcechoprobe",
+ GST_RANK_NONE, GST_TYPE_WEBRTC_ECHO_PROBE);
static gboolean
gst_webrtc_echo_probe_setup (GstAudioFilter * filter, const GstAudioInfo * info)
diff --git a/ext/webrtcdsp/gstwebrtcechoprobe.h b/ext/webrtcdsp/gstwebrtcechoprobe.h
index 29f0eb4ca..36fd34f17 100644
--- a/ext/webrtcdsp/gstwebrtcechoprobe.h
+++ b/ext/webrtcdsp/gstwebrtcechoprobe.h
@@ -87,6 +87,8 @@ struct _GstWebrtcEchoProbeClass
GType gst_webrtc_echo_probe_get_type (void);
+GST_ELEMENT_REGISTER_DECLARE (webrtcechoprobe);
+
GstWebrtcEchoProbe *gst_webrtc_acquire_echo_probe (const gchar * name);
void gst_webrtc_release_echo_probe (GstWebrtcEchoProbe * probe);
gint gst_webrtc_echo_probe_read (GstWebrtcEchoProbe * self,
diff --git a/ext/webrtcdsp/meson.build b/ext/webrtcdsp/meson.build
index 45c020fc3..c42cc9091 100644
--- a/ext/webrtcdsp/meson.build
+++ b/ext/webrtcdsp/meson.build
@@ -1,6 +1,7 @@
webrtc_sources = [
'gstwebrtcdsp.cpp',
- 'gstwebrtcechoprobe.cpp'
+ 'gstwebrtcechoprobe.cpp',
+ 'gstwebrtcdspplugin.cpp'
]
webrtc_dep = dependency('webrtc-audio-processing', version : ['>= 0.2', '< 0.4'],