Files
platform-external-webrtc/media/engine/apm_helpers_unittest.cc
Sam Zackrisson f0d1c03c31 Add replacement interface for webrtc::GainConrol
The pointer-to-submodule interfaces are being removed.
This CL:
1) introduces AudioProcessing::Config::GainController1 with most config,
2) adds functions to APM for setting and getting analog gain,
3) creates a temporary GainControlConfigProxy to support the transition
   to the new config.
4) Moves the lock references in GainControlForExperimentalAgc and
   GainControlImpl into the GainControlConfigProxy, as it becomes the
   sole AGC object with functionality exposed to the client.

Bug: webrtc:9947, webrtc:9878
Change-Id: Ic31e15e9bb26d6497a92b77874e0b6cab21ff2b2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126485
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27316}
2019-03-27 15:19:41 +00:00

92 lines
2.9 KiB
C++

/*
* Copyright (c) 2017 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 "media/engine/apm_helpers.h"
#include "api/scoped_refptr.h"
#include "modules/audio_processing/include/audio_processing.h"
#include "test/gmock.h"
#include "test/gtest.h"
namespace webrtc {
namespace {
struct TestHelper {
TestHelper() {
// This replicates the conditions from voe_auto_test.
Config config;
config.Set<ExperimentalAgc>(new ExperimentalAgc(false));
apm_ = rtc::scoped_refptr<AudioProcessing>(
AudioProcessingBuilder().Create(config));
apm_helpers::Init(apm());
}
AudioProcessing* apm() { return apm_.get(); }
const AudioProcessing* apm() const { return apm_.get(); }
private:
rtc::scoped_refptr<AudioProcessing> apm_;
};
} // namespace
TEST(ApmHelpersTest, EcStatus_DefaultMode) {
TestHelper helper;
webrtc::AudioProcessing::Config config = helper.apm()->GetConfig();
EXPECT_FALSE(config.echo_canceller.enabled);
}
TEST(ApmHelpersTest, EcStatus_EnableDisable) {
TestHelper helper;
webrtc::AudioProcessing::Config config;
apm_helpers::SetEcStatus(helper.apm(), true, kEcAecm);
config = helper.apm()->GetConfig();
EXPECT_TRUE(config.echo_canceller.enabled);
EXPECT_TRUE(config.echo_canceller.mobile_mode);
apm_helpers::SetEcStatus(helper.apm(), false, kEcAecm);
config = helper.apm()->GetConfig();
EXPECT_FALSE(config.echo_canceller.enabled);
apm_helpers::SetEcStatus(helper.apm(), true, kEcConference);
config = helper.apm()->GetConfig();
EXPECT_TRUE(config.echo_canceller.enabled);
EXPECT_FALSE(config.echo_canceller.mobile_mode);
apm_helpers::SetEcStatus(helper.apm(), false, kEcConference);
config = helper.apm()->GetConfig();
EXPECT_FALSE(config.echo_canceller.enabled);
apm_helpers::SetEcStatus(helper.apm(), true, kEcAecm);
config = helper.apm()->GetConfig();
EXPECT_TRUE(config.echo_canceller.enabled);
EXPECT_TRUE(config.echo_canceller.mobile_mode);
}
TEST(ApmHelpersTest, NsStatus_DefaultMode) {
TestHelper helper;
NoiseSuppression* ns = helper.apm()->noise_suppression();
EXPECT_EQ(NoiseSuppression::kModerate, ns->level());
EXPECT_FALSE(ns->is_enabled());
}
TEST(ApmHelpersTest, NsStatus_EnableDisable) {
TestHelper helper;
NoiseSuppression* ns = helper.apm()->noise_suppression();
apm_helpers::SetNsStatus(helper.apm(), true);
EXPECT_EQ(NoiseSuppression::kHigh, ns->level());
EXPECT_TRUE(ns->is_enabled());
apm_helpers::SetNsStatus(helper.apm(), false);
EXPECT_EQ(NoiseSuppression::kHigh, ns->level());
EXPECT_FALSE(ns->is_enabled());
}
} // namespace webrtc