| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 webrtc::NsModes expected_ns_mode) { | 59 webrtc::NsModes expected_ns_mode) { |
| 60 EXPECT_EQ(0, voe_apm_->SetNsStatus(true, ns_mode_to_set)); | 60 EXPECT_EQ(0, voe_apm_->SetNsStatus(true, ns_mode_to_set)); |
| 61 | 61 |
| 62 bool ns_status = true; | 62 bool ns_status = true; |
| 63 webrtc::NsModes ns_mode = webrtc::kNsDefault; | 63 webrtc::NsModes ns_mode = webrtc::kNsDefault; |
| 64 EXPECT_EQ(0, voe_apm_->GetNsStatus(ns_status, ns_mode)); | 64 EXPECT_EQ(0, voe_apm_->GetNsStatus(ns_status, ns_mode)); |
| 65 | 65 |
| 66 EXPECT_TRUE(ns_status); | 66 EXPECT_TRUE(ns_status); |
| 67 EXPECT_EQ(expected_ns_mode, ns_mode); | 67 EXPECT_EQ(expected_ns_mode, ns_mode); |
| 68 } | 68 } |
| 69 | |
| 70 void TryDetectingSilence() { | |
| 71 // Here, speech is running. Shut down speech. | |
| 72 EXPECT_EQ(0, voe_codec_->SetVADStatus(channel_, true)); | |
| 73 EXPECT_EQ(0, voe_volume_control_->SetInputMute(channel_, true)); | |
| 74 EXPECT_EQ(0, voe_file_->StopPlayingFileAsMicrophone(channel_)); | |
| 75 | |
| 76 // We should detect the silence after a short time. | |
| 77 Sleep(50); | |
| 78 for (int i = 0; i < 25; i++) { | |
| 79 EXPECT_EQ(0, voe_apm_->VoiceActivityIndicator(channel_)); | |
| 80 Sleep(10); | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 void TryDetectingSpeechAfterSilence() { | |
| 85 // Re-enable speech. | |
| 86 RestartFakeMicrophone(); | |
| 87 EXPECT_EQ(0, voe_codec_->SetVADStatus(channel_, false)); | |
| 88 EXPECT_EQ(0, voe_volume_control_->SetInputMute(channel_, false)); | |
| 89 | |
| 90 // We should detect the speech after a short time. | |
| 91 for (int i = 0; i < 50; i++) { | |
| 92 if (voe_apm_->VoiceActivityIndicator(channel_) == 1) { | |
| 93 return; | |
| 94 } | |
| 95 Sleep(10); | |
| 96 } | |
| 97 | |
| 98 ADD_FAILURE() << "Failed to detect speech within 500 ms."; | |
| 99 } | |
| 100 }; | 69 }; |
| 101 | 70 |
| 102 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) | 71 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) |
| 103 | 72 |
| 104 // Duplicated in apm_helpers_unittest.cc. | 73 // Duplicated in apm_helpers_unittest.cc. |
| 105 TEST_F(AudioProcessingTest, AgcIsOnByDefault) { | 74 TEST_F(AudioProcessingTest, AgcIsOnByDefault) { |
| 106 bool agc_enabled = false; | 75 bool agc_enabled = false; |
| 107 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; | 76 webrtc::AgcModes agc_mode = webrtc::kAgcAdaptiveAnalog; |
| 108 | 77 |
| 109 EXPECT_EQ(0, voe_apm_->GetAgcStatus(agc_enabled, agc_mode)); | 78 EXPECT_EQ(0, voe_apm_->GetAgcStatus(agc_enabled, agc_mode)); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 // Duplicated in apm_helpers_unittest.cc. | 290 // Duplicated in apm_helpers_unittest.cc. |
| 322 TEST_F(AudioProcessingTest, EcIsDisabledAndAecmIsDefaultEcMode) { | 291 TEST_F(AudioProcessingTest, EcIsDisabledAndAecmIsDefaultEcMode) { |
| 323 bool ec_enabled = true; | 292 bool ec_enabled = true; |
| 324 webrtc::EcModes ec_mode = webrtc::kEcDefault; | 293 webrtc::EcModes ec_mode = webrtc::kEcDefault; |
| 325 | 294 |
| 326 EXPECT_EQ(0, voe_apm_->GetEcStatus(ec_enabled, ec_mode)); | 295 EXPECT_EQ(0, voe_apm_->GetEcStatus(ec_enabled, ec_mode)); |
| 327 EXPECT_FALSE(ec_enabled); | 296 EXPECT_FALSE(ec_enabled); |
| 328 EXPECT_EQ(webrtc::kEcAecm, ec_mode); | 297 EXPECT_EQ(webrtc::kEcAecm, ec_mode); |
| 329 } | 298 } |
| 330 | 299 |
| 331 // Not needed anymore - API is unused. | |
| 332 TEST_F(AudioProcessingTest, TestVoiceActivityDetection) { | |
| 333 TryDetectingSilence(); | |
| 334 TryDetectingSpeechAfterSilence(); | |
| 335 } | |
| 336 | |
| 337 #endif // WEBRTC_IOS || WEBRTC_ANDROID | 300 #endif // WEBRTC_IOS || WEBRTC_ANDROID |
| OLD | NEW |