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

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

Issue 227743004: Added a kEchoCancellation constraint to turn off the audio processing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: addressed the comments. Created 6 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 ba938a6d019adcf101f9d03f4df938520dff8d2b..b8231a3667ad5699ed18212b2dbbac5264bc0af2 100644
--- a/content/renderer/media/media_stream_audio_processor_unittest.cc
+++ b/content/renderer/media/media_stream_audio_processor_unittest.cc
@@ -11,6 +11,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/media_stream_request.h"
#include "content/renderer/media/media_stream_audio_processor.h"
+#include "content/renderer/media/media_stream_audio_processor_options.h"
#include "content/renderer/media/mock_media_constraint_factory.h"
#include "media/audio/audio_parameters.h"
#include "media/base/audio_bus.h"
@@ -153,12 +154,12 @@ class MediaStreamAudioProcessorTest : public ::testing::Test {
TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) {
// Setup the audio processor without enabling the flag.
- blink::WebMediaConstraints constraints;
+ MockMediaConstraintFactory constraint_factory;
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new WebRtcAudioDeviceImpl());
scoped_refptr<MediaStreamAudioProcessor> audio_processor(
new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
- constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE,
+ constraint_factory.CreateWebMediaConstraints(), 0,
webrtc_audio_device.get()));
EXPECT_FALSE(audio_processor->has_audio_processing());
audio_processor->OnCaptureFormatChanged(params_);
@@ -176,12 +177,12 @@ TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) {
// Setup the audio processor with the flag enabled.
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableAudioTrackProcessing);
- blink::WebMediaConstraints constraints;
+ MockMediaConstraintFactory constraint_factory;
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new WebRtcAudioDeviceImpl());
scoped_refptr<MediaStreamAudioProcessor> audio_processor(
new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
- constraints, 0, MEDIA_DEVICE_AUDIO_CAPTURE,
+ constraint_factory.CreateWebMediaConstraints(), 0,
webrtc_audio_device.get()));
EXPECT_TRUE(audio_processor->has_audio_processing());
audio_processor->OnCaptureFormatChanged(params_);
@@ -200,13 +201,15 @@ TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) {
// Setup the audio processor with enabling the flag.
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableAudioTrackProcessing);
- blink::WebMediaConstraints constraints;
scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device(
new WebRtcAudioDeviceImpl());
- // Create MediaStreamAudioProcessor instance for MEDIA_TAB_AUDIO_CAPTURE type.
+ // Create MediaStreamAudioProcessor instance for kMediaStreamSourceTab source.
+ MockMediaConstraintFactory tab_constraint_factory;
+ tab_constraint_factory.AddMandatory(kMediaStreamSource,
+ kMediaStreamSourceTab);
scoped_refptr<MediaStreamAudioProcessor> audio_processor(
new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
- constraints, 0, MEDIA_TAB_AUDIO_CAPTURE,
+ tab_constraint_factory.CreateWebMediaConstraints(), 0,
webrtc_audio_device.get()));
EXPECT_FALSE(audio_processor->has_audio_processing());
audio_processor->OnCaptureFormatChanged(params_);
@@ -216,11 +219,14 @@ TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) {
params_.channels(),
params_.sample_rate() / 100);
- // Create MediaStreamAudioProcessor instance for MEDIA_LOOPBACK_AUDIO_CAPTURE.
- audio_processor =
- new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
- constraints, 0, MEDIA_LOOPBACK_AUDIO_CAPTURE,
- webrtc_audio_device.get());
+ // Create MediaStreamAudioProcessor instance for kMediaStreamSourceSystem
+ // source.
+ MockMediaConstraintFactory system_constraint_factory;
+ system_constraint_factory.AddMandatory(kMediaStreamSource,
+ kMediaStreamSourceSystem);
+ audio_processor = new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
+ system_constraint_factory.CreateWebMediaConstraints(), 0,
+ webrtc_audio_device.get());
EXPECT_FALSE(audio_processor->has_audio_processing());
// Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives
@@ -241,7 +247,7 @@ TEST_F(MediaStreamAudioProcessorTest, TurnOffDefaultConstraints) {
scoped_refptr<MediaStreamAudioProcessor> audio_processor(
new talk_base::RefCountedObject<MediaStreamAudioProcessor>(
constraint_factory.CreateWebMediaConstraints(), 0,
- MEDIA_DEVICE_AUDIO_CAPTURE, webrtc_audio_device.get()));
+ webrtc_audio_device.get()));
EXPECT_FALSE(audio_processor->has_audio_processing());
audio_processor->OnCaptureFormatChanged(params_);
@@ -254,4 +260,60 @@ TEST_F(MediaStreamAudioProcessorTest, TurnOffDefaultConstraints) {
audio_processor = NULL;
}
+TEST_F(MediaStreamAudioProcessorTest, VerifyConstraints) {
+ // Setup the audio processor with enabling the flag.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableAudioTrackProcessing);
+
+ static const char* kDefaultAudioConstraints[] = {
+ kEchoCancellation,
+ kGoogEchoCancellation,
+ kGoogExperimentalEchoCancellation,
+ kGoogAutoGainControl,
+ kGoogExperimentalAutoGainControl,
+ kGoogNoiseSuppression,
+ kGoogExperimentalNoiseSuppression,
+ kGoogHighpassFilter,
+ kGoogTypingNoiseDetection,
+ kGoogAudioMirroring
+ };
+
+ // Verify mandatory constraints.
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) {
perkj_chrome 2014/04/11 11:45:04 why not array_size() ?
no longer working on chromium 2014/04/11 16:47:05 I guess you meant arraysize, if so, done.
+ MockMediaConstraintFactory constraint_factory;
+ constraint_factory.AddMandatory(kDefaultAudioConstraints[i], false);
+ blink::WebMediaConstraints constraints =
+ constraint_factory.CreateWebMediaConstraints();
+ EXPECT_FALSE(GetPropertyFromConstraints(constraints,
+ kDefaultAudioConstraints[i],
+ 0));
+ }
+
+ // Verify optional constraints.
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) {
+ MockMediaConstraintFactory constraint_factory;
+ constraint_factory.AddOptional(kDefaultAudioConstraints[i], false);
+ blink::WebMediaConstraints constraints =
+ constraint_factory.CreateWebMediaConstraints();
+ EXPECT_FALSE(GetPropertyFromConstraints(constraints,
+ kDefaultAudioConstraints[i],
+ 0));
+ }
+
+ // Verify echo cancellation is off when platform aec effect is on.
+ MockMediaConstraintFactory constraint_factory;
+ EXPECT_FALSE(GetPropertyFromConstraints(
+ constraint_factory.CreateWebMediaConstraints(),
+ kGoogEchoCancellation,
+ media::AudioParameters::ECHO_CANCELLER));
+}
+
+TEST_F(MediaStreamAudioProcessorTest, VerifyAllMandatoryConstraints) {
+ // Verify gUM will fail if getting an invalid mandatory audio constraint.
+ MockMediaConstraintFactory constraint_factory;
+ const std::string dummy_constraint = "dummy";
+ constraint_factory.AddMandatory(dummy_constraint, true);
+ EXPECT_FALSE(IsValid(constraint_factory.CreateWebMediaConstraints()));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698