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

Side by Side Diff: content/renderer/media/media_stream_audio_processor_unittest.cc

Issue 2801853005: Create a private API for controlling WebRTC's AEC3 (Closed)
Patch Set: After grunell's second round of comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 EXPECT_FALSE(audio_processing->voice_detection()->is_enabled()); 192 EXPECT_FALSE(audio_processing->voice_detection()->is_enabled());
193 #else 193 #else
194 EXPECT_TRUE(audio_processing->gain_control()->mode() == 194 EXPECT_TRUE(audio_processing->gain_control()->mode() ==
195 webrtc::GainControl::kAdaptiveAnalog); 195 webrtc::GainControl::kAdaptiveAnalog);
196 EXPECT_TRUE(audio_processing->voice_detection()->is_enabled()); 196 EXPECT_TRUE(audio_processing->voice_detection()->is_enabled());
197 EXPECT_TRUE(audio_processing->voice_detection()->likelihood() == 197 EXPECT_TRUE(audio_processing->voice_detection()->likelihood() ==
198 webrtc::VoiceDetection::kVeryLowLikelihood); 198 webrtc::VoiceDetection::kVeryLowLikelihood);
199 #endif 199 #endif
200 } 200 }
201 201
202 bool GetAec3ConfigState(MediaStreamAudioProcessor* audio_processor) {
203 DCHECK(audio_processor);
204 if (!audio_processor->audio_processing_) {
205 ADD_FAILURE() << "AudioProcessing object missing where it shouldn't be";
206 return false;
207 }
208 return audio_processor->audio_processing_->GetConfig()
209 .echo_canceller3.enabled;
210 }
211
202 base::MessageLoop main_thread_message_loop_; 212 base::MessageLoop main_thread_message_loop_;
203 media::AudioParameters params_; 213 media::AudioParameters params_;
204 MediaStreamDevice::AudioDeviceParameters input_device_params_; 214 MediaStreamDevice::AudioDeviceParameters input_device_params_;
205 }; 215 };
206 216
207 // Test crashing with ASAN on Android. crbug.com/468762 217 // Test crashing with ASAN on Android. crbug.com/468762
208 #if defined(OS_ANDROID) && defined(ADDRESS_SANITIZER) 218 #if defined(OS_ANDROID) && defined(ADDRESS_SANITIZER)
209 #define MAYBE_WithAudioProcessing DISABLED_WithAudioProcessing 219 #define MAYBE_WithAudioProcessing DISABLED_WithAudioProcessing
210 #else 220 #else
211 #define MAYBE_WithAudioProcessing WithAudioProcessing 221 #define MAYBE_WithAudioProcessing WithAudioProcessing
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 ProcessDataAndVerifyFormat(audio_processor.get(), 595 ProcessDataAndVerifyFormat(audio_processor.get(),
586 kAudioProcessingSampleRate, 596 kAudioProcessingSampleRate,
587 kAudioProcessingNumberOfChannel, 597 kAudioProcessingNumberOfChannel,
588 kAudioProcessingSampleRate / 100); 598 kAudioProcessingSampleRate / 100);
589 599
590 // Stop |audio_processor| so that it removes itself from 600 // Stop |audio_processor| so that it removes itself from
591 // |webrtc_audio_device| and clears its pointer to it. 601 // |webrtc_audio_device| and clears its pointer to it.
592 audio_processor->Stop(); 602 audio_processor->Stop();
593 } 603 }
594 604
605 // Test that the OnAec3Enable method has the desired effect on the APM config.
606 TEST_F(MediaStreamAudioProcessorTest, TestAec3Switch) {
Henrik Grunell 2017/04/10 17:08:40 Great tests. Interesting that no test has a Initi
hlundin-chromium 2017/04/11 09:19:37 Acknowledged.
607 MockConstraintFactory constraint_factory;
608 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
609 new WebRtcAudioDeviceImpl());
610 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
611 new rtc::RefCountedObject<MediaStreamAudioProcessor>(
612 constraint_factory.CreateWebMediaConstraints(), input_device_params_,
613 webrtc_audio_device.get()));
614
615 audio_processor->OnAec3Enable(true);
616 EXPECT_TRUE(GetAec3ConfigState(audio_processor.get()));
617
618 audio_processor->OnAec3Enable(false);
619 EXPECT_FALSE(GetAec3ConfigState(audio_processor.get()));
620
621 // Stop |audio_processor| so that it removes itself from
622 // |webrtc_audio_device| and clears its pointer to it.
623 audio_processor->Stop();
624 }
625
626 // Same test as above, but when AEC is disabled in the constrants. The expected
627 // outcome is that AEC3 should be disabled in all cases.
628 TEST_F(MediaStreamAudioProcessorTest, TestAec3Switch_AecOff) {
629 MockConstraintFactory constraint_factory;
630 // Disable the AEC.
631 constraint_factory.DisableAecAudioConstraints();
632 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
633 new WebRtcAudioDeviceImpl());
634 scoped_refptr<MediaStreamAudioProcessor> audio_processor(
635 new rtc::RefCountedObject<MediaStreamAudioProcessor>(
636 constraint_factory.CreateWebMediaConstraints(), input_device_params_,
637 webrtc_audio_device.get()));
638
639 EXPECT_FALSE(GetAec3ConfigState(audio_processor.get()));
640
641 audio_processor->OnAec3Enable(true);
642 EXPECT_FALSE(GetAec3ConfigState(audio_processor.get()));
643
644 audio_processor->OnAec3Enable(false);
645 EXPECT_FALSE(GetAec3ConfigState(audio_processor.get()));
646
647 // Stop |audio_processor| so that it removes itself from
648 // |webrtc_audio_device| and clears its pointer to it.
649 audio_processor->Stop();
650 }
651
595 } // namespace content 652 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698