Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1794)

Unified Diff: content/renderer/media/media_stream_audio_processor_unittest.cc

Issue 2801853005: Create a private API for controlling WebRTC's AEC3 (Closed)
Patch Set: Fixing typo Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/media_stream_audio_processor_unittest.cc
diff --git a/content/renderer/media/media_stream_audio_processor_unittest.cc b/content/renderer/media/media_stream_audio_processor_unittest.cc
index e675e6c3769a6957597dfa6d0bc4634f6fca2432..3404ed57420c058d736ac385b4a2fac83db4665f 100644
--- a/content/renderer/media/media_stream_audio_processor_unittest.cc
+++ b/content/renderer/media/media_stream_audio_processor_unittest.cc
@@ -199,6 +199,16 @@ class MediaStreamAudioProcessorTest : public ::testing::Test {
#endif
}
+ bool GetAec3ConfigState(MediaStreamAudioProcessor* audio_processor) {
+ DCHECK(audio_processor);
+ if (!audio_processor->audio_processing_) {
+ ADD_FAILURE() << "AudioProcessing object missing where it shouldn't be";
+ return false;
+ }
+ return audio_processor->audio_processing_->GetConfig()
+ .echo_canceller3.enabled;
+ }
+
base::MessageLoop main_thread_message_loop_;
media::AudioParameters params_;
MediaStreamDevice::AudioDeviceParameters input_device_params_;
@@ -592,4 +602,51 @@ TEST_F(MediaStreamAudioProcessorTest, MAYBE_TestWithKeyboardMicChannel) {
audio_processor->Stop();
}
+// Test that the OnAec3Enable method has the desired effect on the APM config.
+TEST_F(MediaStreamAudioProcessorTest, TestAec3Switch) {
+ MockConstraintFactory constraint_factory;
+ scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
+ new WebRtcAudioDeviceImpl());
+ scoped_refptr<MediaStreamAudioProcessor> audio_processor(
+ new rtc::RefCountedObject<MediaStreamAudioProcessor>(
+ constraint_factory.CreateWebMediaConstraints(), input_device_params_,
+ webrtc_audio_device.get()));
+
+ audio_processor->OnAec3Enable(true);
+ EXPECT_TRUE(GetAec3ConfigState(audio_processor.get()));
+
+ audio_processor->OnAec3Enable(false);
+ EXPECT_FALSE(GetAec3ConfigState(audio_processor.get()));
+
+ // Stop |audio_processor| so that it removes itself from
+ // |webrtc_audio_device| and clears its pointer to it.
+ audio_processor->Stop();
+}
+
+// Same test as above, but when AEC is disabled in the constrants. The expected
+// outcome is that AEC3 should be disabled in all cases.
+TEST_F(MediaStreamAudioProcessorTest, TestAec3Switch_AecOff) {
+ MockConstraintFactory constraint_factory;
+ // Disable the AEC.
+ constraint_factory.DisableAecAudioConstraints();
+ scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
+ new WebRtcAudioDeviceImpl());
+ scoped_refptr<MediaStreamAudioProcessor> audio_processor(
+ new rtc::RefCountedObject<MediaStreamAudioProcessor>(
+ constraint_factory.CreateWebMediaConstraints(), input_device_params_,
+ webrtc_audio_device.get()));
+
+ EXPECT_FALSE(GetAec3ConfigState(audio_processor.get()));
+
+ audio_processor->OnAec3Enable(true);
+ EXPECT_FALSE(GetAec3ConfigState(audio_processor.get()));
+
+ audio_processor->OnAec3Enable(false);
+ EXPECT_FALSE(GetAec3ConfigState(audio_processor.get()));
+
+ // Stop |audio_processor| so that it removes itself from
+ // |webrtc_audio_device| and clears its pointer to it.
+ audio_processor->Stop();
+}
+
} // namespace content
« no previous file with comments | « content/renderer/media/media_stream_audio_processor.cc ('k') | content/renderer/media/mock_constraint_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698