Render-side pre-processing in APM.

This CL adds a way to insert a custom render-side pre-processor to
APM. The pre-processor operates in full-band mode before anything
else. Currently the render processing chain is (if everything is
enabled):

Network --> [Pre processing] --> [Band split] -->
[IntelligibilityEnhancer] --> [Echo canceller (read-only)] -->
[Band merge] --> Playout

Since the render pre processor and capture post processor have the
same interface, I renamed webrtc::PostProcessing into
webrtc::CustomProcessing.

The old APM factory method PostProcessing will be deprecated and
dependencies updated as part of webrtc:8665

NOTRY=True

Bug: webrtc:8665
Change-Id: Ia381cbf12e336d6587406a14d77243d931f69a31
Reviewed-on: https://webrtc-review.googlesource.com/29201
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21327}
This commit is contained in:
Alex Loiko
2017-12-18 16:02:40 +01:00
committed by Commit Bot
parent 88bc9d5e53
commit 5825aa673c
7 changed files with 112 additions and 33 deletions

View File

@ -1318,7 +1318,7 @@ TEST_F(ApmTest, AgcOnlyAdaptsWhenTargetSignalIsPresent) {
testing::NiceMock<MockNonlinearBeamformer>* beamformer =
new testing::NiceMock<MockNonlinearBeamformer>(geometry, 1u);
std::unique_ptr<AudioProcessing> apm(
AudioProcessing::Create(config, nullptr, nullptr, beamformer));
AudioProcessing::Create(config, nullptr, nullptr, nullptr, beamformer));
EXPECT_EQ(kNoErr, apm->gain_control()->Enable(true));
ChannelBuffer<float> src_buf(kSamplesPerChannel, kNumInputChannels);
ChannelBuffer<float> dest_buf(kSamplesPerChannel, kNumOutputChannels);
@ -2912,11 +2912,11 @@ TEST(ApmConfiguration, EnablePostProcessing) {
// Verify that apm uses a capture post processing module if one is provided.
webrtc::Config webrtc_config;
auto mock_post_processor_ptr =
new testing::NiceMock<test::MockPostProcessing>();
new testing::NiceMock<test::MockCustomProcessing>();
auto mock_post_processor =
std::unique_ptr<PostProcessing>(mock_post_processor_ptr);
std::unique_ptr<CustomProcessing>(mock_post_processor_ptr);
rtc::scoped_refptr<AudioProcessing> apm = AudioProcessing::Create(
webrtc_config, std::move(mock_post_processor), nullptr, nullptr);
webrtc_config, std::move(mock_post_processor), nullptr, nullptr, nullptr);
AudioFrame audio;
audio.num_channels_ = 1;
@ -2926,6 +2926,24 @@ TEST(ApmConfiguration, EnablePostProcessing) {
apm->ProcessStream(&audio);
}
TEST(ApmConfiguration, EnablePreProcessing) {
// Verify that apm uses a capture post processing module if one is provided.
webrtc::Config webrtc_config;
auto mock_pre_processor_ptr =
new testing::NiceMock<test::MockCustomProcessing>();
auto mock_pre_processor =
std::unique_ptr<CustomProcessing>(mock_pre_processor_ptr);
rtc::scoped_refptr<AudioProcessing> apm = AudioProcessing::Create(
webrtc_config, nullptr, std::move(mock_pre_processor), nullptr, nullptr);
AudioFrame audio;
audio.num_channels_ = 1;
SetFrameSampleRate(&audio, AudioProcessing::NativeRate::kSampleRate16kHz);
EXPECT_CALL(*mock_pre_processor_ptr, Process(testing::_)).Times(1);
apm->ProcessReverseStream(&audio);
}
class MyEchoControlFactory : public EchoControlFactory {
public:
std::unique_ptr<EchoControl> Create(int sample_rate_hz) {
@ -2943,8 +2961,9 @@ TEST(ApmConfiguration, EchoControlInjection) {
std::unique_ptr<EchoControlFactory> echo_control_factory(
new MyEchoControlFactory());
rtc::scoped_refptr<AudioProcessing> apm = AudioProcessing::Create(
webrtc_config, nullptr, std::move(echo_control_factory), nullptr);
rtc::scoped_refptr<AudioProcessing> apm =
AudioProcessing::Create(webrtc_config, nullptr, nullptr,
std::move(echo_control_factory), nullptr);
AudioFrame audio;
audio.num_channels_ = 1;