mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 22:46:24 +00:00
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>
This commit is contained in:
parent
6adf7dff71
commit
63dc81d000
6 changed files with 103 additions and 26 deletions
|
@ -274,7 +274,11 @@ struct _GstWebrtcDsp
|
||||||
webrtc::VoiceDetection::Likelihood voice_detection_likelihood;
|
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 *
|
static const gchar *
|
||||||
webrtc_error_to_string (gint err)
|
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_ECHO_SUPPRESSION_LEVEL, (GstPluginAPIFlags) 0);
|
||||||
gst_type_mark_as_plugin_api (GST_TYPE_WEBRTC_VOICE_DETECTION_LIKELIHOOD, (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)
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ struct _GstWebrtcDspClass
|
||||||
|
|
||||||
GType gst_webrtc_dsp_get_type (void);
|
GType gst_webrtc_dsp_get_type (void);
|
||||||
|
|
||||||
|
GST_ELEMENT_REGISTER_DECLARE (webrtcdsp);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_WEBRTC_DSP_H__ */
|
#endif /* __GST_WEBRTC_DSP_H__ */
|
||||||
|
|
90
ext/webrtcdsp/gstwebrtcdspplugin.cpp
Normal file
90
ext/webrtcdsp/gstwebrtcdspplugin.cpp
Normal file
|
@ -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)
|
|
@ -78,6 +78,8 @@ static GList *gst_aec_probes = NULL;
|
||||||
|
|
||||||
G_DEFINE_TYPE (GstWebrtcEchoProbe, gst_webrtc_echo_probe,
|
G_DEFINE_TYPE (GstWebrtcEchoProbe, gst_webrtc_echo_probe,
|
||||||
GST_TYPE_AUDIO_FILTER);
|
GST_TYPE_AUDIO_FILTER);
|
||||||
|
GST_ELEMENT_REGISTER_DEFINE (webrtcechoprobe, "webrtcechoprobe",
|
||||||
|
GST_RANK_NONE, GST_TYPE_WEBRTC_ECHO_PROBE);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_webrtc_echo_probe_setup (GstAudioFilter * filter, const GstAudioInfo * info)
|
gst_webrtc_echo_probe_setup (GstAudioFilter * filter, const GstAudioInfo * info)
|
||||||
|
|
|
@ -87,6 +87,8 @@ struct _GstWebrtcEchoProbeClass
|
||||||
|
|
||||||
GType gst_webrtc_echo_probe_get_type (void);
|
GType gst_webrtc_echo_probe_get_type (void);
|
||||||
|
|
||||||
|
GST_ELEMENT_REGISTER_DECLARE (webrtcechoprobe);
|
||||||
|
|
||||||
GstWebrtcEchoProbe *gst_webrtc_acquire_echo_probe (const gchar * name);
|
GstWebrtcEchoProbe *gst_webrtc_acquire_echo_probe (const gchar * name);
|
||||||
void gst_webrtc_release_echo_probe (GstWebrtcEchoProbe * probe);
|
void gst_webrtc_release_echo_probe (GstWebrtcEchoProbe * probe);
|
||||||
gint gst_webrtc_echo_probe_read (GstWebrtcEchoProbe * self,
|
gint gst_webrtc_echo_probe_read (GstWebrtcEchoProbe * self,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
webrtc_sources = [
|
webrtc_sources = [
|
||||||
'gstwebrtcdsp.cpp',
|
'gstwebrtcdsp.cpp',
|
||||||
'gstwebrtcechoprobe.cpp'
|
'gstwebrtcechoprobe.cpp',
|
||||||
|
'gstwebrtcdspplugin.cpp'
|
||||||
]
|
]
|
||||||
|
|
||||||
webrtc_dep = dependency('webrtc-audio-processing', version : ['>= 0.2', '< 0.4'],
|
webrtc_dep = dependency('webrtc-audio-processing', version : ['>= 0.2', '< 0.4'],
|
||||||
|
|
Loading…
Reference in a new issue