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

Side by Side Diff: content/renderer/media/media_stream_audio_processor.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: 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 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 "content/renderer/media/media_stream_audio_processor.h" 5 #include "content/renderer/media/media_stream_audio_processor.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 stats->typing_noise_detected = 273 stats->typing_noise_detected =
274 (base::subtle::Acquire_Load(&typing_detected_) != false); 274 (base::subtle::Acquire_Load(&typing_detected_) != false);
275 GetAecStats(audio_processing_.get(), stats); 275 GetAecStats(audio_processing_.get(), stats);
276 } 276 }
277 277
278 void MediaStreamAudioProcessor::InitializeAudioProcessingModule( 278 void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
279 const blink::WebMediaConstraints& constraints, int effects, 279 const blink::WebMediaConstraints& constraints, int effects,
280 MediaStreamType type) { 280 MediaStreamType type) {
281 DCHECK(!audio_processing_); 281 DCHECK(!audio_processing_);
282 282
283 RTCMediaConstraints native_constraints(constraints);
284
285 // Audio mirroring can be enabled even though audio processing is otherwise 283 // Audio mirroring can be enabled even though audio processing is otherwise
286 // disabled. 284 // disabled.
287 audio_mirroring_ = GetPropertyFromConstraints( 285 audio_mirroring_ = GetPropertyFromConstraints(
288 &native_constraints, webrtc::MediaConstraintsInterface::kAudioMirroring); 286 constraints, kGoogAudioMirroring, effects, type);
289 287
290 if (!IsAudioTrackProcessingEnabled()) { 288 if (!IsAudioTrackProcessingEnabled()) {
291 RecordProcessingState(AUDIO_PROCESSING_IN_WEBRTC); 289 RecordProcessingState(AUDIO_PROCESSING_IN_WEBRTC);
292 return; 290 return;
293 } 291 }
294 292
295 // Only apply the fixed constraints for gUM of MEDIA_DEVICE_AUDIO_CAPTURE. 293 const bool echo_calcellation = GetPropertyFromConstraints(
perkj_chrome 2014/04/08 10:28:12 nit: move to where its used.
tommi (sloooow) - chröme 2014/04/08 10:49:30 echo_cancellation (not calcellation) Actually, I
no longer working on chromium 2014/04/11 08:56:30 Added code to return immediately when the echo_can
no longer working on chromium 2014/04/11 08:56:30 Done.
296 DCHECK(IsAudioMediaType(type)); 294 constraints, kEchoCancellation, effects, type);
297 if (type == MEDIA_DEVICE_AUDIO_CAPTURE)
298 ApplyFixedAudioConstraints(&native_constraints);
299
300 if (effects & media::AudioParameters::ECHO_CANCELLER) {
301 // If platform echo canceller is enabled, disable the software AEC.
302 native_constraints.AddMandatory(
303 MediaConstraintsInterface::kEchoCancellation,
304 MediaConstraintsInterface::kValueFalse, true);
305 }
306 295
307 #if defined(OS_IOS) 296 #if defined(OS_IOS)
308 // On iOS, VPIO provides built-in AEC and AGC. 297 // On iOS, VPIO provides built-in AEC and AGC.
309 const bool enable_aec = false; 298 const bool enable_aec = false;
310 const bool enable_agc = false; 299 const bool enable_agc = false;
311 #else 300 #else
312 const bool enable_aec = GetPropertyFromConstraints( 301 const bool enable_aec = GetPropertyFromConstraints(
tommi (sloooow) - chröme 2014/04/08 10:49:30 can you change the name of this variable to e.g. g
no longer working on chromium 2014/04/11 08:56:30 Done.
313 &native_constraints, MediaConstraintsInterface::kEchoCancellation); 302 constraints, kGoogEchoCancellation, effects, type);
314 const bool enable_agc = GetPropertyFromConstraints( 303 const bool enable_agc = GetPropertyFromConstraints(
tommi (sloooow) - chröme 2014/04/08 10:49:30 same here and below.
no longer working on chromium 2014/04/11 08:56:30 Done.
315 &native_constraints, webrtc::MediaConstraintsInterface::kAutoGainControl); 304 constraints, kGoogAutoGainControl, effects, type);
316 #endif 305 #endif
317 306
318 #if defined(OS_IOS) || defined(OS_ANDROID) 307 #if defined(OS_IOS) || defined(OS_ANDROID)
319 const bool enable_experimental_aec = false; 308 const bool enable_experimental_aec = false;
320 const bool enable_typing_detection = false; 309 const bool enable_typing_detection = false;
321 #else 310 #else
322 const bool enable_experimental_aec = GetPropertyFromConstraints( 311 const bool enable_experimental_aec = GetPropertyFromConstraints(
323 &native_constraints, 312 constraints, kGoogExperimentalEchoCancellation, effects, type);
324 MediaConstraintsInterface::kExperimentalEchoCancellation);
325 const bool enable_typing_detection = GetPropertyFromConstraints( 313 const bool enable_typing_detection = GetPropertyFromConstraints(
326 &native_constraints, MediaConstraintsInterface::kTypingNoiseDetection); 314 constraints, kGoogTypingNoiseDetection, effects, type);
327 #endif 315 #endif
328 316
329 const bool enable_ns = GetPropertyFromConstraints( 317 const bool enable_ns = GetPropertyFromConstraints(
330 &native_constraints, MediaConstraintsInterface::kNoiseSuppression); 318 constraints, kGoogNoiseSuppression, effects, type);
331 const bool enable_experimental_ns = GetPropertyFromConstraints( 319 const bool enable_experimental_ns = GetPropertyFromConstraints(
332 &native_constraints, 320 constraints, kGoogExperimentalNoiseSuppression, effects, type);
333 MediaConstraintsInterface::kExperimentalNoiseSuppression);
334 const bool enable_high_pass_filter = GetPropertyFromConstraints( 321 const bool enable_high_pass_filter = GetPropertyFromConstraints(
335 &native_constraints, MediaConstraintsInterface::kHighpassFilter); 322 constraints, kGoogHighpassFilter, effects, type);
336 323
337 // Return immediately if no audio processing component is enabled. 324 // |echo_calcellation| is used as a master control on enabling/disabling
tommi (sloooow) - chröme 2014/04/08 10:49:30 fix typo here as well
no longer working on chromium 2014/04/11 08:56:30 Done.
338 if (!enable_aec && !enable_experimental_aec && !enable_ns && 325 // the audio processing. Another way to disable the audio processing is to
339 !enable_high_pass_filter && !enable_typing_detection && !enable_agc && 326 // turn off all the goog* constraints explicitly.
340 !enable_experimental_ns) { 327 if (!echo_calcellation ||
no longer working on chromium 2014/04/08 10:02:53 The main change is here, echo_calcellation is true
perkj_chrome 2014/04/08 10:28:12 fix name echo_calcellation
tommi (sloooow) - chröme 2014/04/08 10:49:30 I think that we're unnecessarily querying all the
no longer working on chromium 2014/04/11 08:56:30 Done.
no longer working on chromium 2014/04/11 08:56:30 Done with avoid querying the constraints when echo
328 (!enable_aec && !enable_experimental_aec && !enable_ns &&
329 !enable_high_pass_filter && !enable_typing_detection &&
330 !enable_agc && !enable_experimental_ns)) {
341 RecordProcessingState(AUDIO_PROCESSING_DISABLED); 331 RecordProcessingState(AUDIO_PROCESSING_DISABLED);
342 return; 332 return;
343 } 333 }
344 334
345 // Create and configure the webrtc::AudioProcessing. 335 // Create and configure the webrtc::AudioProcessing.
346 audio_processing_.reset(webrtc::AudioProcessing::Create(0)); 336 audio_processing_.reset(webrtc::AudioProcessing::Create(0));
347 337
348 // Enable the audio processing components. 338 // Enable the audio processing components.
349 if (enable_aec) { 339 if (enable_aec) {
350 EnableEchoCancellation(audio_processing_.get()); 340 EnableEchoCancellation(audio_processing_.get());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 } 500 }
511 501
512 bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const { 502 bool MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled() const {
513 const std::string group_name = 503 const std::string group_name =
514 base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing"); 504 base::FieldTrialList::FindFullName("MediaStreamAudioTrackProcessing");
515 return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch( 505 return group_name == "Enabled" || CommandLine::ForCurrentProcess()->HasSwitch(
516 switches::kEnableAudioTrackProcessing); 506 switches::kEnableAudioTrackProcessing);
517 } 507 }
518 508
519 } // namespace content 509 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698