OLD | NEW |
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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 audio_processor->PushCaptureData(data_bus.get()); | 79 audio_processor->PushCaptureData(data_bus.get()); |
80 | 80 |
81 // |audio_processor| does nothing when the audio processing is off in | 81 // |audio_processor| does nothing when the audio processing is off in |
82 // the processor. | 82 // the processor. |
83 audio_processor->PushRenderData( | 83 audio_processor->PushRenderData( |
84 data_ptr, | 84 data_ptr, |
85 params_.sample_rate(), params_.channels(), | 85 params_.sample_rate(), params_.channels(), |
86 params_.frames_per_buffer(), base::TimeDelta::FromMilliseconds(10)); | 86 params_.frames_per_buffer(), base::TimeDelta::FromMilliseconds(10)); |
87 | 87 |
88 int16* output = NULL; | 88 int16* output = NULL; |
| 89 int new_volume = 0; |
89 while(audio_processor->ProcessAndConsumeData( | 90 while(audio_processor->ProcessAndConsumeData( |
90 base::TimeDelta::FromMilliseconds(10), 255, false, &output)) { | 91 base::TimeDelta::FromMilliseconds(10), 255, false, &new_volume, |
| 92 &output)) { |
91 EXPECT_TRUE(output != NULL); | 93 EXPECT_TRUE(output != NULL); |
92 EXPECT_EQ(audio_processor->OutputFormat().sample_rate(), | 94 EXPECT_EQ(audio_processor->OutputFormat().sample_rate(), |
93 expected_output_sample_rate); | 95 expected_output_sample_rate); |
94 EXPECT_EQ(audio_processor->OutputFormat().channels(), | 96 EXPECT_EQ(audio_processor->OutputFormat().channels(), |
95 expected_output_channels); | 97 expected_output_channels); |
96 EXPECT_EQ(audio_processor->OutputFormat().frames_per_buffer(), | 98 EXPECT_EQ(audio_processor->OutputFormat().frames_per_buffer(), |
97 expected_output_buffer_size); | 99 expected_output_buffer_size); |
98 } | 100 } |
99 | 101 |
100 data_ptr += params_.frames_per_buffer() * params_.channels(); | 102 data_ptr += params_.frames_per_buffer() * params_.channels(); |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
| 106 void VerifyDefaultComponents(MediaStreamAudioProcessor* audio_processor) { |
| 107 webrtc::AudioProcessing* audio_processing = |
| 108 audio_processor->audio_processing_.get(); |
| 109 #if defined(OS_ANDROID) |
| 110 EXPECT_TRUE(audio_processing->echo_control_mobile()->is_enabled()); |
| 111 EXPECT_TRUE(audio_processing->echo_control_mobile()->routing_mode() == |
| 112 webrtc::EchoControlMobile::kSpeakerphone); |
| 113 EXPECT_FALSE(audio_processing->echo_cancellation()->is_enabled()); |
| 114 #elif !defined(OS_IOS) |
| 115 EXPECT_TRUE(audio_processing->echo_cancellation()->is_enabled()); |
| 116 EXPECT_TRUE(audio_processing->echo_cancellation()->suppression_level() == |
| 117 webrtc::EchoCancellation::kHighSuppression); |
| 118 EXPECT_TRUE(audio_processing->echo_cancellation()->are_metrics_enabled()); |
| 119 EXPECT_TRUE( |
| 120 audio_processing->echo_cancellation()->is_delay_logging_enabled()); |
| 121 #endif |
| 122 |
| 123 EXPECT_TRUE(audio_processing->noise_suppression()->is_enabled()); |
| 124 EXPECT_TRUE(audio_processing->noise_suppression()->level() == |
| 125 webrtc::NoiseSuppression::kHigh); |
| 126 EXPECT_TRUE(audio_processing->high_pass_filter()->is_enabled()); |
| 127 EXPECT_TRUE(audio_processing->voice_detection()->is_enabled()); |
| 128 EXPECT_TRUE(audio_processing->voice_detection()->likelihood() == |
| 129 webrtc::VoiceDetection::kVeryLowLikelihood); |
| 130 EXPECT_TRUE(audio_processing->gain_control()->is_enabled()); |
| 131 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 132 EXPECT_TRUE(audio_processing->gain_control()->mode() == |
| 133 webrtc::GainControl::kFixedDigital); |
| 134 #else |
| 135 EXPECT_TRUE(audio_processing->gain_control()->mode() == |
| 136 webrtc::GainControl::kAdaptiveAnalog); |
| 137 #endif |
| 138 } |
| 139 |
104 media::AudioParameters params_; | 140 media::AudioParameters params_; |
105 }; | 141 }; |
106 | 142 |
107 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { | 143 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { |
108 // Setup the audio processor without enabling the flag. | 144 // Setup the audio processor without enabling the flag. |
109 blink::WebMediaConstraints constraints; | 145 blink::WebMediaConstraints constraints; |
110 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 146 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
111 new MediaStreamAudioProcessor(params_, constraints, 0)); | 147 new MediaStreamAudioProcessor(params_, constraints, 0)); |
112 EXPECT_FALSE(audio_processor->has_audio_processing()); | 148 EXPECT_FALSE(audio_processor->has_audio_processing()); |
113 | 149 |
114 ProcessDataAndVerifyFormat(audio_processor, | 150 ProcessDataAndVerifyFormat(audio_processor, |
115 params_.sample_rate(), | 151 params_.sample_rate(), |
116 params_.channels(), | 152 params_.channels(), |
117 params_.sample_rate() / 100); | 153 params_.sample_rate() / 100); |
118 } | 154 } |
119 | 155 |
120 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { | 156 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { |
121 // Setup the audio processor with enabling the flag. | 157 // Setup the audio processor with enabling the flag. |
122 CommandLine::ForCurrentProcess()->AppendSwitch( | 158 CommandLine::ForCurrentProcess()->AppendSwitch( |
123 switches::kEnableAudioTrackProcessing); | 159 switches::kEnableAudioTrackProcessing); |
124 blink::WebMediaConstraints constraints; | 160 blink::WebMediaConstraints constraints; |
125 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 161 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
126 new MediaStreamAudioProcessor(params_, constraints, 0)); | 162 new MediaStreamAudioProcessor(params_, constraints, 0)); |
127 EXPECT_TRUE(audio_processor->has_audio_processing()); | 163 EXPECT_TRUE(audio_processor->has_audio_processing()); |
| 164 VerifyDefaultComponents(audio_processor); |
128 | 165 |
129 ProcessDataAndVerifyFormat(audio_processor, | 166 ProcessDataAndVerifyFormat(audio_processor, |
130 kAudioProcessingSampleRate, | 167 kAudioProcessingSampleRate, |
131 kAudioProcessingNumberOfChannel, | 168 kAudioProcessingNumberOfChannel, |
132 kAudioProcessingSampleRate / 100); | 169 kAudioProcessingSampleRate / 100); |
133 } | 170 } |
134 | 171 |
135 } // namespace content | 172 } // namespace content |
OLD | NEW |