Commit 9d9e947b authored by Per Åhgren's avatar Per Åhgren Committed by Commit Bot

Update/modify the activation of multi-channel processing in APM

This CL
-Updates the multi-channel processing activation flags to match the
 the intended use in WebRTC.
-Makes sure that the APM in the audio processor complies to properly
run capture-side multi-channel processing.

Note: This CL can only land once the WebRTC CL
https://webrtc-review.googlesource.com/c/src/+/160707
has been landed and imported into Chromium.

Bug: webrtc:10859
Change-Id: Ied2b185d36e43187d90b5d608243702ec929ec1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937030
Commit-Queue: Per Åhgren <peah@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719944}
parent f449d893
......@@ -29,6 +29,11 @@ namespace media {
namespace {
bool UseMultiChannelCaptureProcessing() {
return base::FeatureList::IsEnabled(
features::kWebRtcEnableCaptureMultiChannelApm);
}
constexpr int kBuffersPerSecond = 100; // 10 ms per buffer.
} // namespace
......@@ -46,7 +51,9 @@ AudioProcessor::AudioProcessor(const AudioParameters& audio_parameters,
: audio_parameters_(audio_parameters),
settings_(settings),
output_bus_(AudioBus::Create(audio_parameters_)),
audio_delay_stats_reporter_(kBuffersPerSecond) {
audio_delay_stats_reporter_(kBuffersPerSecond),
use_capture_multi_channel_processing_(
UseMultiChannelCaptureProcessing()) {
DCHECK(audio_parameters.IsValid());
DCHECK_EQ(audio_parameters_.GetBufferDuration(),
base::TimeDelta::FromMilliseconds(10));
......@@ -232,7 +239,9 @@ void AudioProcessor::InitializeAPM() {
webrtc::AudioProcessing::Config apm_config = audio_processing_->GetConfig();
// APM audio pipeline setup.
apm_config.pipeline.experimental_multi_channel = true;
apm_config.pipeline.multi_channel_render = true;
apm_config.pipeline.multi_channel_capture =
use_capture_multi_channel_processing_;
// Typing detection setup.
if (settings_.typing_detection) {
......
......@@ -110,6 +110,9 @@ class COMPONENT_EXPORT(MEDIA_WEBRTC) AudioProcessor final
// thread.
std::unique_ptr<rtc::TaskQueue> worker_queue_;
// Flag indicating whether capture multi channel processing should be active.
const bool use_capture_multi_channel_processing_;
DISALLOW_COPY_AND_ASSIGN(AudioProcessor);
};
......
......@@ -61,6 +61,11 @@ namespace {
using webrtc::AudioProcessing;
bool UseMultiChannelCaptureProcessing() {
return base::FeatureList::IsEnabled(
features::kWebRtcEnableCaptureMultiChannelApm);
}
constexpr int kAudioProcessingNumberOfChannels = 1;
constexpr int kBuffersPerSecond = 100; // 10 ms per buffer.
......@@ -234,7 +239,9 @@ MediaStreamAudioProcessor::MediaStreamAudioProcessor(
audio_mirroring_(false),
typing_detected_(false),
aec_dump_agent_impl_(AecDumpAgentImpl::Create(this)),
stopped_(false) {
stopped_(false),
use_capture_multi_channel_processing_(
UseMultiChannelCaptureProcessing()) {
DCHECK(main_thread_runner_);
DETACH_FROM_THREAD(capture_thread_checker_);
DETACH_FROM_THREAD(render_thread_checker_);
......@@ -556,7 +563,9 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
}
webrtc::AudioProcessing::Config apm_config = audio_processing_->GetConfig();
apm_config.pipeline.experimental_multi_channel = true;
apm_config.pipeline.multi_channel_render = true;
apm_config.pipeline.multi_channel_capture =
use_capture_multi_channel_processing_;
base::Optional<double> gain_control_compression_gain_db;
blink::PopulateApmConfig(&apm_config, properties,
......@@ -617,9 +626,7 @@ void MediaStreamAudioProcessor::InitializeCaptureFifo(
: input_format.sample_rate();
media::ChannelLayout output_channel_layout;
if (!audio_processing_ ||
base::FeatureList::IsEnabled(
features::kWebRtcEnableCaptureMultiChannelApm)) {
if (!audio_processing_ || use_capture_multi_channel_processing_) {
output_channel_layout = input_format.channel_layout();
} else {
output_channel_layout =
......
......@@ -213,6 +213,9 @@ class MODULES_EXPORT MediaStreamAudioProcessor
size_t apm_playout_error_code_log_count_ = 0;
size_t large_delay_log_count_ = 0;
// Flag indicating whether capture multi channel processing should be active.
const bool use_capture_multi_channel_processing_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioProcessor);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment