mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 22:00:47 +01:00

The features have two safety fallbacks: - multichannel config has a killswitch WebRTC-Aec3SetupSpecificDefaultConfigDefaultsKillSwitch - stereo detection has a killswitch WebRTC-Aec3StereoContentDetectionKillSwitch Both features are enabled by default in the AEC3 config. Tested: Bitexact on a large number of aecdumps. Bug: chromium:1295710 Change-Id: I340cdc9140dacd4ca22d0911eb9f732b6cf8b226 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258129 Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Sam Zackrisson <saza@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36482}
116 lines
4.3 KiB
C++
116 lines
4.3 KiB
C++
/*
|
|
* Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "modules/audio_processing/aec3/config_selector.h"
|
|
|
|
#include <tuple>
|
|
|
|
#include "absl/types/optional.h"
|
|
#include "api/audio/echo_canceller3_config.h"
|
|
#include "test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
|
|
class ConfigSelectorChannelsAndContentDetection
|
|
: public ::testing::Test,
|
|
public ::testing::WithParamInterface<std::tuple<int, bool>> {};
|
|
|
|
INSTANTIATE_TEST_SUITE_P(ConfigSelectorMultiParameters,
|
|
ConfigSelectorChannelsAndContentDetection,
|
|
::testing::Combine(::testing::Values(1, 2, 8),
|
|
::testing::Values(false, true)));
|
|
|
|
class ConfigSelectorChannels : public ::testing::Test,
|
|
public ::testing::WithParamInterface<int> {};
|
|
|
|
INSTANTIATE_TEST_SUITE_P(ConfigSelectorMultiParameters,
|
|
ConfigSelectorChannels,
|
|
::testing::Values(1, 2, 8));
|
|
|
|
TEST_P(ConfigSelectorChannelsAndContentDetection,
|
|
MonoConfigIsSelectedWhenNoMultiChannelConfigPresent) {
|
|
const auto [num_channels, detect_stereo_content] = GetParam();
|
|
EchoCanceller3Config config;
|
|
config.multi_channel.detect_stereo_content = detect_stereo_content;
|
|
absl::optional<EchoCanceller3Config> multichannel_config;
|
|
|
|
config.delay.default_delay = config.delay.default_delay + 1;
|
|
const size_t custom_delay_value_in_config = config.delay.default_delay;
|
|
|
|
ConfigSelector cs(config, multichannel_config,
|
|
/*num_render_input_channels=*/num_channels);
|
|
EXPECT_EQ(cs.active_config().delay.default_delay,
|
|
custom_delay_value_in_config);
|
|
|
|
cs.Update(/*multichannel_content=*/false);
|
|
EXPECT_EQ(cs.active_config().delay.default_delay,
|
|
custom_delay_value_in_config);
|
|
|
|
cs.Update(/*multichannel_content=*/true);
|
|
EXPECT_EQ(cs.active_config().delay.default_delay,
|
|
custom_delay_value_in_config);
|
|
}
|
|
|
|
TEST_P(ConfigSelectorChannelsAndContentDetection,
|
|
CorrectInitialConfigIsSelected) {
|
|
const auto [num_channels, detect_stereo_content] = GetParam();
|
|
EchoCanceller3Config config;
|
|
config.multi_channel.detect_stereo_content = detect_stereo_content;
|
|
absl::optional<EchoCanceller3Config> multichannel_config = config;
|
|
|
|
config.delay.default_delay += 1;
|
|
const size_t custom_delay_value_in_config = config.delay.default_delay;
|
|
multichannel_config->delay.default_delay += 2;
|
|
const size_t custom_delay_value_in_multichannel_config =
|
|
multichannel_config->delay.default_delay;
|
|
|
|
ConfigSelector cs(config, multichannel_config,
|
|
/*num_render_input_channels=*/num_channels);
|
|
|
|
if (num_channels == 1 || detect_stereo_content) {
|
|
EXPECT_EQ(cs.active_config().delay.default_delay,
|
|
custom_delay_value_in_config);
|
|
} else {
|
|
EXPECT_EQ(cs.active_config().delay.default_delay,
|
|
custom_delay_value_in_multichannel_config);
|
|
}
|
|
}
|
|
|
|
TEST_P(ConfigSelectorChannels, CorrectConfigUpdateBehavior) {
|
|
const int num_channels = GetParam();
|
|
EchoCanceller3Config config;
|
|
config.multi_channel.detect_stereo_content = true;
|
|
absl::optional<EchoCanceller3Config> multichannel_config = config;
|
|
|
|
config.delay.default_delay += 1;
|
|
const size_t custom_delay_value_in_config = config.delay.default_delay;
|
|
multichannel_config->delay.default_delay += 2;
|
|
const size_t custom_delay_value_in_multichannel_config =
|
|
multichannel_config->delay.default_delay;
|
|
|
|
ConfigSelector cs(config, multichannel_config,
|
|
/*num_render_input_channels=*/num_channels);
|
|
|
|
cs.Update(/*multichannel_content=*/false);
|
|
EXPECT_EQ(cs.active_config().delay.default_delay,
|
|
custom_delay_value_in_config);
|
|
|
|
if (num_channels == 1) {
|
|
cs.Update(/*multichannel_content=*/false);
|
|
EXPECT_EQ(cs.active_config().delay.default_delay,
|
|
custom_delay_value_in_config);
|
|
} else {
|
|
cs.Update(/*multichannel_content=*/true);
|
|
EXPECT_EQ(cs.active_config().delay.default_delay,
|
|
custom_delay_value_in_multichannel_config);
|
|
}
|
|
}
|
|
|
|
} // namespace webrtc
|