From 6c330ab63f075d69ac8c2857853521178008c05f Mon Sep 17 00:00:00 2001 From: Sam Zackrisson Date: Fri, 4 Jan 2019 10:35:53 +0100 Subject: [PATCH] Update some audio processing tests to new VAD API This updates some tests to use AudioProcesing::Config() and AudioProcessing::GetStatistics() instead. Some tests are left with voice_detection() because a) not all tests make sense to run both APIs in parallel, and b) we want test coverage of the old VoiceDetection until it is removed. Bug: webrtc:9947 Change-Id: Ifb21a1e6e931d7ad3c3a4e38f5cc4f146da3c9a3 Reviewed-on: https://webrtc-review.googlesource.com/c/116160 Reviewed-by: Alex Loiko Commit-Queue: Sam Zackrisson Cr-Commit-Position: refs/heads/master@{#26134} --- .../audio_processing_impl_locking_unittest.cc | 2 ++ .../audio_processing_performance_unittest.cc | 6 +++--- .../audio_processing_unittest.cc | 20 +++++++++++++++++-- .../audio_processing_configs_fuzzer.cc | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/modules/audio_processing/audio_processing_impl_locking_unittest.cc index 9685ef95e9..18ee9cf449 100644 --- a/modules/audio_processing/audio_processing_impl_locking_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_locking_unittest.cc @@ -590,6 +590,8 @@ bool StatsProcessor::Process() { apm_->noise_suppression()->speech_probability(); apm_->voice_detection()->is_enabled(); + apm_->GetStatistics(/*has_remote_tracks=*/true); + return true; } diff --git a/modules/audio_processing/audio_processing_performance_unittest.cc b/modules/audio_processing/audio_processing_performance_unittest.cc index 84cb574307..80c2b382e4 100644 --- a/modules/audio_processing/audio_processing_performance_unittest.cc +++ b/modules/audio_processing/audio_processing_performance_unittest.cc @@ -450,10 +450,10 @@ class CallSimulator : public ::testing::TestWithParam { apm->gain_control()->set_mode(GainControl::kAdaptiveDigital)); ASSERT_EQ(apm->kNoError, apm->gain_control()->Enable(true)); ASSERT_EQ(apm->kNoError, apm->noise_suppression()->Enable(true)); - ASSERT_EQ(apm->kNoError, apm->voice_detection()->Enable(true)); AudioProcessing::Config apm_config = apm->GetConfig(); apm_config.echo_canceller.enabled = true; apm_config.echo_canceller.mobile_mode = false; + apm_config.voice_detection.enabled = true; apm->ApplyConfig(apm_config); }; @@ -465,10 +465,10 @@ class CallSimulator : public ::testing::TestWithParam { apm->gain_control()->set_mode(GainControl::kAdaptiveDigital)); ASSERT_EQ(apm->kNoError, apm->gain_control()->Enable(true)); ASSERT_EQ(apm->kNoError, apm->noise_suppression()->Enable(true)); - ASSERT_EQ(apm->kNoError, apm->voice_detection()->Enable(true)); AudioProcessing::Config apm_config = apm->GetConfig(); apm_config.echo_canceller.enabled = true; apm_config.echo_canceller.mobile_mode = true; + apm_config.voice_detection.enabled = true; apm->ApplyConfig(apm_config); }; @@ -481,9 +481,9 @@ class CallSimulator : public ::testing::TestWithParam { apm->gain_control()->set_mode(GainControl::kAdaptiveDigital)); ASSERT_EQ(apm->kNoError, apm->gain_control()->Enable(false)); ASSERT_EQ(apm->kNoError, apm->noise_suppression()->Enable(false)); - ASSERT_EQ(apm->kNoError, apm->voice_detection()->Enable(false)); AudioProcessing::Config apm_config = apm->GetConfig(); apm_config.echo_canceller.enabled = false; + apm_config.voice_detection.enabled = false; apm->ApplyConfig(apm_config); }; diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc index 5bd2faef83..314d777e90 100644 --- a/modules/audio_processing/audio_processing_unittest.cc +++ b/modules/audio_processing/audio_processing_unittest.cc @@ -1278,6 +1278,7 @@ TEST_F(ApmTest, AllProcessingDisabledByDefault) { EXPECT_FALSE(config.echo_canceller.enabled); EXPECT_FALSE(config.high_pass_filter.enabled); EXPECT_FALSE(config.level_estimation.enabled); + EXPECT_FALSE(config.voice_detection.enabled); EXPECT_FALSE(apm_->gain_control()->is_enabled()); EXPECT_FALSE(apm_->level_estimator()->is_enabled()); EXPECT_FALSE(apm_->noise_suppression()->is_enabled()); @@ -1399,20 +1400,35 @@ TEST_F(ApmTest, SplittingFilter) { EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(false)); - // 4. Both VAD and the level estimator are enabled... + // 4. Only GetStatistics-reporting VAD is enabled... + SetFrameTo(frame_, 1000); + frame_copy.CopyFrom(*frame_); + auto apm_config = apm_->GetConfig(); + apm_config.voice_detection.enabled = true; + apm_->ApplyConfig(apm_config); + EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); + EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); + EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); + apm_config.voice_detection.enabled = false; + apm_->ApplyConfig(apm_config); + + // 5. Both VADs and the level estimator are enabled... SetFrameTo(frame_, 1000); frame_copy.CopyFrom(*frame_); EXPECT_EQ(apm_->kNoError, apm_->level_estimator()->Enable(true)); EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(true)); + apm_config.voice_detection.enabled = true; + apm_->ApplyConfig(apm_config); EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); EXPECT_EQ(apm_->kNoError, apm_->level_estimator()->Enable(false)); EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(false)); + apm_config.voice_detection.enabled = false; + apm_->ApplyConfig(apm_config); // Check the test is valid. We should have distortion from the filter // when AEC is enabled (which won't affect the audio). - AudioProcessing::Config apm_config = apm_->GetConfig(); apm_config.echo_canceller.enabled = true; apm_config.echo_canceller.mobile_mode = false; apm_->ApplyConfig(apm_config); diff --git a/test/fuzzers/audio_processing_configs_fuzzer.cc b/test/fuzzers/audio_processing_configs_fuzzer.cc index 1ca8b86362..d8648540aa 100644 --- a/test/fuzzers/audio_processing_configs_fuzzer.cc +++ b/test/fuzzers/audio_processing_configs_fuzzer.cc @@ -171,6 +171,7 @@ std::unique_ptr CreateApm(test::FuzzDataHelper* fuzz_data, kPeak; apm_config.gain_controller2.adaptive_digital.use_saturation_protector = use_agc2_adaptive_digital_saturation_protector; + apm_config.voice_detection.enabled = use_vad; apm->ApplyConfig(apm_config);