| 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 "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/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 MediaAudioConstraints::kGoogHighpassFilter); | 401 MediaAudioConstraints::kGoogHighpassFilter); |
| 402 | 402 |
| 403 // Return immediately if no goog constraint is enabled. | 403 // Return immediately if no goog constraint is enabled. |
| 404 if (!echo_cancellation && !goog_experimental_aec && !goog_ns && | 404 if (!echo_cancellation && !goog_experimental_aec && !goog_ns && |
| 405 !goog_high_pass_filter && !goog_typing_detection && | 405 !goog_high_pass_filter && !goog_typing_detection && |
| 406 !goog_agc && !goog_experimental_ns) { | 406 !goog_agc && !goog_experimental_ns) { |
| 407 RecordProcessingState(AUDIO_PROCESSING_DISABLED); | 407 RecordProcessingState(AUDIO_PROCESSING_DISABLED); |
| 408 return; | 408 return; |
| 409 } | 409 } |
| 410 | 410 |
| 411 // Experimental options provided at creation. |
| 412 webrtc::Config config; |
| 413 if (goog_experimental_aec) |
| 414 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); |
| 415 if (goog_experimental_ns) |
| 416 config.Set<webrtc::ExperimentalNs>(new webrtc::ExperimentalNs(true)); |
| 417 |
| 411 // Create and configure the webrtc::AudioProcessing. | 418 // Create and configure the webrtc::AudioProcessing. |
| 412 audio_processing_.reset(webrtc::AudioProcessing::Create()); | 419 audio_processing_.reset(webrtc::AudioProcessing::Create(config)); |
| 413 | 420 |
| 414 // Enable the audio processing components. | 421 // Enable the audio processing components. |
| 415 if (echo_cancellation) { | 422 if (echo_cancellation) { |
| 416 EnableEchoCancellation(audio_processing_.get()); | 423 EnableEchoCancellation(audio_processing_.get()); |
| 417 | 424 |
| 418 if (goog_experimental_aec) | |
| 419 EnableExperimentalEchoCancellation(audio_processing_.get()); | |
| 420 | |
| 421 if (playout_data_source_) | 425 if (playout_data_source_) |
| 422 playout_data_source_->AddPlayoutSink(this); | 426 playout_data_source_->AddPlayoutSink(this); |
| 423 } | 427 } |
| 424 | 428 |
| 425 if (goog_ns) | 429 if (goog_ns) |
| 426 EnableNoiseSuppression(audio_processing_.get()); | 430 EnableNoiseSuppression(audio_processing_.get()); |
| 427 | 431 |
| 428 if (goog_experimental_ns) | |
| 429 EnableExperimentalNoiseSuppression(audio_processing_.get()); | |
| 430 | |
| 431 if (goog_high_pass_filter) | 432 if (goog_high_pass_filter) |
| 432 EnableHighPassFilter(audio_processing_.get()); | 433 EnableHighPassFilter(audio_processing_.get()); |
| 433 | 434 |
| 434 if (goog_typing_detection) { | 435 if (goog_typing_detection) { |
| 435 // TODO(xians): Remove this |typing_detector_| after the typing suppression | 436 // TODO(xians): Remove this |typing_detector_| after the typing suppression |
| 436 // is enabled by default. | 437 // is enabled by default. |
| 437 typing_detector_.reset(new webrtc::TypingDetection()); | 438 typing_detector_.reset(new webrtc::TypingDetection()); |
| 438 EnableTypingDetection(audio_processing_.get(), typing_detector_.get()); | 439 EnableTypingDetection(audio_processing_.get(), typing_detector_.get()); |
| 439 } | 440 } |
| 440 | 441 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 vad->stream_has_voice()); | 572 vad->stream_has_voice()); |
| 572 base::subtle::Release_Store(&typing_detected_, detected); | 573 base::subtle::Release_Store(&typing_detected_, detected); |
| 573 } | 574 } |
| 574 | 575 |
| 575 // Return 0 if the volume hasn't been changed, and otherwise the new volume. | 576 // Return 0 if the volume hasn't been changed, and otherwise the new volume. |
| 576 return (agc->stream_analog_level() == volume) ? | 577 return (agc->stream_analog_level() == volume) ? |
| 577 0 : agc->stream_analog_level(); | 578 0 : agc->stream_analog_level(); |
| 578 } | 579 } |
| 579 | 580 |
| 580 } // namespace content | 581 } // namespace content |
| OLD | NEW |