mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: aec: Add support for webrtc-audio-processing-2
This commit is contained in:
parent
3752535171
commit
71e403bbdb
3 changed files with 65 additions and 20 deletions
28
meson.build
28
meson.build
|
|
@ -431,20 +431,28 @@ cdata.set('HAVE_GSTREAMER_DMA_DRM', gst_dma_drm_found)
|
||||||
|
|
||||||
if get_option('echo-cancel-webrtc').disabled()
|
if get_option('echo-cancel-webrtc').disabled()
|
||||||
webrtc_dep = dependency('', required: false)
|
webrtc_dep = dependency('', required: false)
|
||||||
summary({'WebRTC Echo Canceling >= 1.2': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
summary({'WebRTC Echo Canceling': webrtc_dep.found()}, bool_yn: false, section: 'Misc dependencies')
|
||||||
else
|
else
|
||||||
webrtc_dep = dependency('webrtc-audio-processing-1',
|
webrtc_dep = dependency('webrtc-audio-processing-2',
|
||||||
version : ['>= 1.2' ],
|
version : ['>= 2.0' ],
|
||||||
required : false)
|
required : false)
|
||||||
cdata.set('HAVE_WEBRTC1', webrtc_dep.found())
|
cdata.set('HAVE_WEBRTC2', webrtc_dep.found())
|
||||||
if webrtc_dep.found()
|
if webrtc_dep.found()
|
||||||
summary({'WebRTC Echo Canceling >= 1.2': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
summary({'WebRTC Echo Canceling >= 2.0': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
||||||
else
|
else
|
||||||
webrtc_dep = dependency('webrtc-audio-processing',
|
webrtc_dep = dependency('webrtc-audio-processing-1',
|
||||||
version : ['>= 0.2', '< 1.0'],
|
version : ['>= 1.2' ],
|
||||||
required : get_option('echo-cancel-webrtc'))
|
required : false)
|
||||||
cdata.set('HAVE_WEBRTC', webrtc_dep.found())
|
cdata.set('HAVE_WEBRTC1', webrtc_dep.found())
|
||||||
summary({'WebRTC Echo Canceling < 1.0': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
if webrtc_dep.found()
|
||||||
|
summary({'WebRTC Echo Canceling >= 1.2': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
||||||
|
else
|
||||||
|
webrtc_dep = dependency('webrtc-audio-processing',
|
||||||
|
version : ['>= 0.2', '< 1.0'],
|
||||||
|
required : get_option('echo-cancel-webrtc'))
|
||||||
|
cdata.set('HAVE_WEBRTC', webrtc_dep.found())
|
||||||
|
summary({'WebRTC Echo Canceling < 1.0': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,11 @@ struct impl_data {
|
||||||
struct spa_audio_aec aec;
|
struct spa_audio_aec aec;
|
||||||
|
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
|
#if defined(HAVE_WEBRTC) || defined(HAVE_WEBRTC1)
|
||||||
std::unique_ptr<webrtc::AudioProcessing> apm;
|
std::unique_ptr<webrtc::AudioProcessing> apm;
|
||||||
|
#elif defined(HAVE_WEBRTC2)
|
||||||
|
rtc::scoped_refptr<webrtc::AudioProcessing> apm;
|
||||||
|
#endif
|
||||||
spa_audio_info_raw rec_info;
|
spa_audio_info_raw rec_info;
|
||||||
spa_audio_info_raw out_info;
|
spa_audio_info_raw out_info;
|
||||||
spa_audio_info_raw play_info;
|
spa_audio_info_raw play_info;
|
||||||
|
|
@ -103,16 +107,17 @@ static int webrtc_init2(void *object, const struct spa_dict *args,
|
||||||
|
|
||||||
bool high_pass_filter = webrtc_get_spa_bool(args, "webrtc.high_pass_filter", true);
|
bool high_pass_filter = webrtc_get_spa_bool(args, "webrtc.high_pass_filter", true);
|
||||||
bool noise_suppression = webrtc_get_spa_bool(args, "webrtc.noise_suppression", true);
|
bool noise_suppression = webrtc_get_spa_bool(args, "webrtc.noise_suppression", true);
|
||||||
bool voice_detection = webrtc_get_spa_bool(args, "webrtc.voice_detection", true);
|
#if defined(HAVE_WEBRTC)
|
||||||
#ifdef HAVE_WEBRTC
|
|
||||||
bool extended_filter = webrtc_get_spa_bool(args, "webrtc.extended_filter", true);
|
bool extended_filter = webrtc_get_spa_bool(args, "webrtc.extended_filter", true);
|
||||||
bool delay_agnostic = webrtc_get_spa_bool(args, "webrtc.delay_agnostic", true);
|
bool delay_agnostic = webrtc_get_spa_bool(args, "webrtc.delay_agnostic", true);
|
||||||
// Disable experimental flags by default
|
// Disable experimental flags by default
|
||||||
bool experimental_agc = webrtc_get_spa_bool(args, "webrtc.experimental_agc", false);
|
bool experimental_agc = webrtc_get_spa_bool(args, "webrtc.experimental_agc", false);
|
||||||
bool experimental_ns = webrtc_get_spa_bool(args, "webrtc.experimental_ns", false);
|
bool experimental_ns = webrtc_get_spa_bool(args, "webrtc.experimental_ns", false);
|
||||||
|
|
||||||
|
bool voice_detection = webrtc_get_spa_bool(args, "webrtc.voice_detection", true);
|
||||||
bool beamforming = webrtc_get_spa_bool(args, "webrtc.beamforming", false);
|
bool beamforming = webrtc_get_spa_bool(args, "webrtc.beamforming", false);
|
||||||
#else
|
#elif defined(HAVE_WEBRTC1)
|
||||||
|
bool voice_detection = webrtc_get_spa_bool(args, "webrtc.voice_detection", true);
|
||||||
bool transient_suppression = webrtc_get_spa_bool(args, "webrtc.transient_suppression", true);
|
bool transient_suppression = webrtc_get_spa_bool(args, "webrtc.transient_suppression", true);
|
||||||
#endif
|
#endif
|
||||||
// Note: AGC seems to mess up with Agnostic Delay Detection, especially with speech,
|
// Note: AGC seems to mess up with Agnostic Delay Detection, especially with speech,
|
||||||
|
|
@ -123,7 +128,7 @@ static int webrtc_init2(void *object, const struct spa_dict *args,
|
||||||
// This filter will modify playback buffer (when calling ProcessReverseStream), but now
|
// This filter will modify playback buffer (when calling ProcessReverseStream), but now
|
||||||
// playback buffer modifications are discarded.
|
// playback buffer modifications are discarded.
|
||||||
|
|
||||||
#ifdef HAVE_WEBRTC
|
#if defined(HAVE_WEBRTC)
|
||||||
webrtc::Config config;
|
webrtc::Config config;
|
||||||
config.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(extended_filter));
|
config.Set<webrtc::ExtendedFilter>(new webrtc::ExtendedFilter(extended_filter));
|
||||||
config.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(delay_agnostic));
|
config.Set<webrtc::DelayAgnostic>(new webrtc::DelayAgnostic(delay_agnostic));
|
||||||
|
|
@ -167,7 +172,7 @@ static int webrtc_init2(void *object, const struct spa_dict *args,
|
||||||
config.Set<webrtc::Beamforming>(new webrtc::Beamforming(true, geometry));
|
config.Set<webrtc::Beamforming>(new webrtc::Beamforming(true, geometry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(HAVE_WEBRTC1)
|
||||||
webrtc::AudioProcessing::Config config;
|
webrtc::AudioProcessing::Config config;
|
||||||
config.echo_canceller.enabled = true;
|
config.echo_canceller.enabled = true;
|
||||||
config.pipeline.multi_channel_capture = rec_info->channels > 1;
|
config.pipeline.multi_channel_capture = rec_info->channels > 1;
|
||||||
|
|
@ -184,20 +189,43 @@ static int webrtc_init2(void *object, const struct spa_dict *args,
|
||||||
// FIXME: expose pre/postamp gain
|
// FIXME: expose pre/postamp gain
|
||||||
config.transient_suppression.enabled = transient_suppression;
|
config.transient_suppression.enabled = transient_suppression;
|
||||||
config.voice_detection.enabled = voice_detection;
|
config.voice_detection.enabled = voice_detection;
|
||||||
|
#elif defined(HAVE_WEBRTC2)
|
||||||
|
webrtc::AudioProcessing::Config config;
|
||||||
|
config.pipeline.multi_channel_capture = rec_info->channels > 1;
|
||||||
|
config.pipeline.multi_channel_render = play_info->channels > 1;
|
||||||
|
// FIXME: Example code enables both gain controllers, but that seems sus
|
||||||
|
config.gain_controller1.enabled = gain_control;
|
||||||
|
config.gain_controller1.mode = webrtc::AudioProcessing::Config::GainController1::Mode::kAdaptiveDigital;
|
||||||
|
config.gain_controller2.enabled = gain_control;
|
||||||
|
config.high_pass_filter.enabled = high_pass_filter;
|
||||||
|
config.noise_suppression.enabled = noise_suppression;
|
||||||
|
config.noise_suppression.level = webrtc::AudioProcessing::Config::NoiseSuppression::kHigh;
|
||||||
|
// FIXME: expose pre/postamp gain
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_WEBRTC) || defined(HAVE_WEBRTC1)
|
||||||
webrtc::ProcessingConfig pconfig = {{
|
webrtc::ProcessingConfig pconfig = {{
|
||||||
webrtc::StreamConfig(rec_info->rate, rec_info->channels, false), /* input stream */
|
webrtc::StreamConfig(rec_info->rate, rec_info->channels, false), /* input stream */
|
||||||
webrtc::StreamConfig(out_info->rate, out_info->channels, false), /* output stream */
|
webrtc::StreamConfig(out_info->rate, out_info->channels, false), /* output stream */
|
||||||
webrtc::StreamConfig(play_info->rate, play_info->channels, false), /* reverse input stream */
|
webrtc::StreamConfig(play_info->rate, play_info->channels, false), /* reverse input stream */
|
||||||
webrtc::StreamConfig(play_info->rate, play_info->channels, false), /* reverse output stream */
|
webrtc::StreamConfig(play_info->rate, play_info->channels, false), /* reverse output stream */
|
||||||
}};
|
}};
|
||||||
|
#elif defined(HAVE_WEBRTC2)
|
||||||
|
webrtc::ProcessingConfig pconfig = {{
|
||||||
|
webrtc::StreamConfig(rec_info->rate, rec_info->channels), /* input stream */
|
||||||
|
webrtc::StreamConfig(out_info->rate, out_info->channels), /* output stream */
|
||||||
|
webrtc::StreamConfig(play_info->rate, play_info->channels), /* reverse input stream */
|
||||||
|
webrtc::StreamConfig(play_info->rate, play_info->channels), /* reverse output stream */
|
||||||
|
}};
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_WEBRTC
|
#if defined(HAVE_WEBRTC)
|
||||||
auto apm = std::unique_ptr<webrtc::AudioProcessing>(webrtc::AudioProcessing::Create(config));
|
auto apm = std::unique_ptr<webrtc::AudioProcessing>(webrtc::AudioProcessing::Create(config));
|
||||||
#else
|
#elif defined(HAVE_WEBRTC1)
|
||||||
auto apm = std::unique_ptr<webrtc::AudioProcessing>(webrtc::AudioProcessingBuilder().Create());
|
auto apm = std::unique_ptr<webrtc::AudioProcessing>(webrtc::AudioProcessingBuilder().Create());
|
||||||
|
apm->ApplyConfig(config);
|
||||||
|
#elif defined(HAVE_WEBRTC2)
|
||||||
|
auto apm = webrtc::AudioProcessingBuilder().Create();
|
||||||
apm->ApplyConfig(config);
|
apm->ApplyConfig(config);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -250,12 +278,21 @@ static int webrtc_run(void *object, const float *rec[], const float *play[], flo
|
||||||
auto impl = static_cast<struct impl_data*>(object);
|
auto impl = static_cast<struct impl_data*>(object);
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
#if defined(HAVE_WEBRTC) || defined(HAVE_WEBRTC1)
|
||||||
webrtc::StreamConfig play_config =
|
webrtc::StreamConfig play_config =
|
||||||
webrtc::StreamConfig(impl->play_info.rate, impl->play_info.channels, false);
|
webrtc::StreamConfig(impl->play_info.rate, impl->play_info.channels, false);
|
||||||
webrtc::StreamConfig rec_config =
|
webrtc::StreamConfig rec_config =
|
||||||
webrtc::StreamConfig(impl->rec_info.rate, impl->rec_info.channels, false);
|
webrtc::StreamConfig(impl->rec_info.rate, impl->rec_info.channels, false);
|
||||||
webrtc::StreamConfig out_config =
|
webrtc::StreamConfig out_config =
|
||||||
webrtc::StreamConfig(impl->out_info.rate, impl->out_info.channels, false);
|
webrtc::StreamConfig(impl->out_info.rate, impl->out_info.channels, false);
|
||||||
|
#elif defined(HAVE_WEBRTC2)
|
||||||
|
webrtc::StreamConfig play_config =
|
||||||
|
webrtc::StreamConfig(impl->play_info.rate, impl->play_info.channels);
|
||||||
|
webrtc::StreamConfig rec_config =
|
||||||
|
webrtc::StreamConfig(impl->rec_info.rate, impl->rec_info.channels);
|
||||||
|
webrtc::StreamConfig out_config =
|
||||||
|
webrtc::StreamConfig(impl->out_info.rate, impl->out_info.channels);
|
||||||
|
#endif
|
||||||
unsigned int num_blocks = n_samples * 1000 / impl->play_info.rate / 10;
|
unsigned int num_blocks = n_samples * 1000 / impl->play_info.rate / 10;
|
||||||
|
|
||||||
if (n_samples * 1000 / impl->play_info.rate % 10 != 0) {
|
if (n_samples * 1000 / impl->play_info.rate % 10 != 0) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
directory = webrtc-audio-processing
|
directory = webrtc-audio-processing
|
||||||
url = https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing.git
|
url = https://gitlab.freedesktop.org/pulseaudio/webrtc-audio-processing.git
|
||||||
push-url = git@gitlab.freedesktop.org:pulseaudio/webrtc-audio-processing.git
|
push-url = git@gitlab.freedesktop.org:pulseaudio/webrtc-audio-processing.git
|
||||||
revision = v1.3
|
revision = v2.0
|
||||||
|
|
||||||
[provide]
|
[provide]
|
||||||
dependency_names = webrtc-audio-coding-1, webrtc-audio-processing-1
|
dependency_names = webrtc-audio-processing-2
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue