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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 EXPECT_TRUE(audio_processing->voice_detection()->is_enabled()); | 147 EXPECT_TRUE(audio_processing->voice_detection()->is_enabled()); |
148 EXPECT_TRUE(audio_processing->voice_detection()->likelihood() == | 148 EXPECT_TRUE(audio_processing->voice_detection()->likelihood() == |
149 webrtc::VoiceDetection::kVeryLowLikelihood); | 149 webrtc::VoiceDetection::kVeryLowLikelihood); |
150 #endif | 150 #endif |
151 } | 151 } |
152 | 152 |
153 media::AudioParameters params_; | 153 media::AudioParameters params_; |
154 }; | 154 }; |
155 | 155 |
156 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { | 156 TEST_F(MediaStreamAudioProcessorTest, WithoutAudioProcessing) { |
157 // Setup the audio processor without enabling the flag. | 157 // Setup the audio processor with disabled flag on. |
| 158 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 159 switches::kDisableAudioTrackProcessing); |
158 MockMediaConstraintFactory constraint_factory; | 160 MockMediaConstraintFactory constraint_factory; |
159 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 161 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
160 new WebRtcAudioDeviceImpl()); | 162 new WebRtcAudioDeviceImpl()); |
161 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 163 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
162 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 164 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
163 constraint_factory.CreateWebMediaConstraints(), 0, | 165 constraint_factory.CreateWebMediaConstraints(), 0, |
164 webrtc_audio_device.get())); | 166 webrtc_audio_device.get())); |
165 EXPECT_FALSE(audio_processor->has_audio_processing()); | 167 EXPECT_FALSE(audio_processor->has_audio_processing()); |
166 audio_processor->OnCaptureFormatChanged(params_); | 168 audio_processor->OnCaptureFormatChanged(params_); |
167 | 169 |
168 ProcessDataAndVerifyFormat(audio_processor, | 170 ProcessDataAndVerifyFormat(audio_processor, |
169 params_.sample_rate(), | 171 params_.sample_rate(), |
170 params_.channels(), | 172 params_.channels(), |
171 params_.sample_rate() / 100); | 173 params_.sample_rate() / 100); |
172 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 174 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives |
173 // |audio_processor|. | 175 // |audio_processor|. |
174 audio_processor = NULL; | 176 audio_processor = NULL; |
175 } | 177 } |
176 | 178 |
177 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { | 179 TEST_F(MediaStreamAudioProcessorTest, WithAudioProcessing) { |
178 // Setup the audio processor with the flag enabled. | |
179 CommandLine::ForCurrentProcess()->AppendSwitch( | |
180 switches::kEnableAudioTrackProcessing); | |
181 MockMediaConstraintFactory constraint_factory; | 180 MockMediaConstraintFactory constraint_factory; |
182 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 181 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
183 new WebRtcAudioDeviceImpl()); | 182 new WebRtcAudioDeviceImpl()); |
184 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 183 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
185 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 184 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
186 constraint_factory.CreateWebMediaConstraints(), 0, | 185 constraint_factory.CreateWebMediaConstraints(), 0, |
187 webrtc_audio_device.get())); | 186 webrtc_audio_device.get())); |
188 EXPECT_TRUE(audio_processor->has_audio_processing()); | 187 EXPECT_TRUE(audio_processor->has_audio_processing()); |
189 audio_processor->OnCaptureFormatChanged(params_); | 188 audio_processor->OnCaptureFormatChanged(params_); |
190 VerifyDefaultComponents(audio_processor); | 189 VerifyDefaultComponents(audio_processor); |
191 | 190 |
192 ProcessDataAndVerifyFormat(audio_processor, | 191 ProcessDataAndVerifyFormat(audio_processor, |
193 kAudioProcessingSampleRate, | 192 kAudioProcessingSampleRate, |
194 kAudioProcessingNumberOfChannel, | 193 kAudioProcessingNumberOfChannel, |
195 kAudioProcessingSampleRate / 100); | 194 kAudioProcessingSampleRate / 100); |
196 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 195 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives |
197 // |audio_processor|. | 196 // |audio_processor|. |
198 audio_processor = NULL; | 197 audio_processor = NULL; |
199 } | 198 } |
200 | 199 |
201 TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) { | 200 TEST_F(MediaStreamAudioProcessorTest, VerifyTabCaptureWithoutAudioProcessing) { |
202 // Setup the audio processor with enabling the flag. | |
203 CommandLine::ForCurrentProcess()->AppendSwitch( | |
204 switches::kEnableAudioTrackProcessing); | |
205 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 201 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
206 new WebRtcAudioDeviceImpl()); | 202 new WebRtcAudioDeviceImpl()); |
207 // Create MediaStreamAudioProcessor instance for kMediaStreamSourceTab source. | 203 // Create MediaStreamAudioProcessor instance for kMediaStreamSourceTab source. |
208 MockMediaConstraintFactory tab_constraint_factory; | 204 MockMediaConstraintFactory tab_constraint_factory; |
209 const std::string tab_string = kMediaStreamSourceTab; | 205 const std::string tab_string = kMediaStreamSourceTab; |
210 tab_constraint_factory.AddMandatory(kMediaStreamSource, | 206 tab_constraint_factory.AddMandatory(kMediaStreamSource, |
211 tab_string); | 207 tab_string); |
212 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 208 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
213 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 209 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
214 tab_constraint_factory.CreateWebMediaConstraints(), 0, | 210 tab_constraint_factory.CreateWebMediaConstraints(), 0, |
(...skipping 16 matching lines...) Expand all Loading... |
231 system_constraint_factory.CreateWebMediaConstraints(), 0, | 227 system_constraint_factory.CreateWebMediaConstraints(), 0, |
232 webrtc_audio_device.get()); | 228 webrtc_audio_device.get()); |
233 EXPECT_FALSE(audio_processor->has_audio_processing()); | 229 EXPECT_FALSE(audio_processor->has_audio_processing()); |
234 | 230 |
235 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 231 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives |
236 // |audio_processor|. | 232 // |audio_processor|. |
237 audio_processor = NULL; | 233 audio_processor = NULL; |
238 } | 234 } |
239 | 235 |
240 TEST_F(MediaStreamAudioProcessorTest, TurnOffDefaultConstraints) { | 236 TEST_F(MediaStreamAudioProcessorTest, TurnOffDefaultConstraints) { |
241 // Setup the audio processor with enabling the flag. | |
242 CommandLine::ForCurrentProcess()->AppendSwitch( | |
243 switches::kEnableAudioTrackProcessing); | |
244 | |
245 // Turn off the default constraints and pass it to MediaStreamAudioProcessor. | 237 // Turn off the default constraints and pass it to MediaStreamAudioProcessor. |
246 MockMediaConstraintFactory constraint_factory; | 238 MockMediaConstraintFactory constraint_factory; |
247 constraint_factory.DisableDefaultAudioConstraints(); | 239 constraint_factory.DisableDefaultAudioConstraints(); |
248 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( | 240 scoped_refptr<WebRtcAudioDeviceImpl> webrtc_audio_device( |
249 new WebRtcAudioDeviceImpl()); | 241 new WebRtcAudioDeviceImpl()); |
250 scoped_refptr<MediaStreamAudioProcessor> audio_processor( | 242 scoped_refptr<MediaStreamAudioProcessor> audio_processor( |
251 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( | 243 new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
252 constraint_factory.CreateWebMediaConstraints(), 0, | 244 constraint_factory.CreateWebMediaConstraints(), 0, |
253 webrtc_audio_device.get())); | 245 webrtc_audio_device.get())); |
254 EXPECT_FALSE(audio_processor->has_audio_processing()); | 246 EXPECT_FALSE(audio_processor->has_audio_processing()); |
255 audio_processor->OnCaptureFormatChanged(params_); | 247 audio_processor->OnCaptureFormatChanged(params_); |
256 | 248 |
257 ProcessDataAndVerifyFormat(audio_processor, | 249 ProcessDataAndVerifyFormat(audio_processor, |
258 params_.sample_rate(), | 250 params_.sample_rate(), |
259 params_.channels(), | 251 params_.channels(), |
260 params_.sample_rate() / 100); | 252 params_.sample_rate() / 100); |
261 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives | 253 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| outlives |
262 // |audio_processor|. | 254 // |audio_processor|. |
263 audio_processor = NULL; | 255 audio_processor = NULL; |
264 } | 256 } |
265 | 257 |
266 TEST_F(MediaStreamAudioProcessorTest, VerifyConstraints) { | 258 TEST_F(MediaStreamAudioProcessorTest, VerifyConstraints) { |
267 // Setup the audio processor with enabling the flag. | |
268 CommandLine::ForCurrentProcess()->AppendSwitch( | |
269 switches::kEnableAudioTrackProcessing); | |
270 | |
271 static const char* kDefaultAudioConstraints[] = { | 259 static const char* kDefaultAudioConstraints[] = { |
272 MediaAudioConstraints::kEchoCancellation, | 260 MediaAudioConstraints::kEchoCancellation, |
273 MediaAudioConstraints::kGoogAudioMirroring, | 261 MediaAudioConstraints::kGoogAudioMirroring, |
274 MediaAudioConstraints::kGoogAutoGainControl, | 262 MediaAudioConstraints::kGoogAutoGainControl, |
275 MediaAudioConstraints::kGoogEchoCancellation, | 263 MediaAudioConstraints::kGoogEchoCancellation, |
276 MediaAudioConstraints::kGoogExperimentalEchoCancellation, | 264 MediaAudioConstraints::kGoogExperimentalEchoCancellation, |
277 MediaAudioConstraints::kGoogExperimentalAutoGainControl, | 265 MediaAudioConstraints::kGoogExperimentalAutoGainControl, |
278 MediaAudioConstraints::kGoogExperimentalNoiseSuppression, | 266 MediaAudioConstraints::kGoogExperimentalNoiseSuppression, |
279 MediaAudioConstraints::kGoogHighpassFilter, | 267 MediaAudioConstraints::kGoogHighpassFilter, |
280 MediaAudioConstraints::kGoogNoiseSuppression, | 268 MediaAudioConstraints::kGoogNoiseSuppression, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 kAudioProcessingNumberOfChannel, | 378 kAudioProcessingNumberOfChannel, |
391 kAudioProcessingSampleRate / 100); | 379 kAudioProcessingSampleRate / 100); |
392 } | 380 } |
393 | 381 |
394 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| | 382 // Set |audio_processor| to NULL to make sure |webrtc_audio_device| |
395 // outlives |audio_processor|. | 383 // outlives |audio_processor|. |
396 audio_processor = NULL; | 384 audio_processor = NULL; |
397 } | 385 } |
398 | 386 |
399 } // namespace content | 387 } // namespace content |
OLD | NEW |