Chromium Code Reviews| Index: content/renderer/media/media_stream_audio_processor.cc |
| diff --git a/content/renderer/media/media_stream_audio_processor.cc b/content/renderer/media/media_stream_audio_processor.cc |
| index 4422b506233fc37398e9ed1aa72bf6c341694368..0ffd3d19dc209bec1fc3d0f717b0f6096990236e 100644 |
| --- a/content/renderer/media/media_stream_audio_processor.cc |
| +++ b/content/renderer/media/media_stream_audio_processor.cc |
| @@ -15,6 +15,7 @@ |
| #include "media/base/channel_layout.h" |
| #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h" |
| +#include "third_party/webrtc/modules/audio_processing/typing_detection.h" |
| namespace content { |
| @@ -143,7 +144,8 @@ MediaStreamAudioProcessor::MediaStreamAudioProcessor( |
| const blink::WebMediaConstraints& constraints, |
| int effects) |
| : render_delay_ms_(0), |
| - audio_mirroring_(false) { |
| + audio_mirroring_(false), |
| + typing_detected_(false) { |
| capture_thread_checker_.DetachFromThread(); |
| render_thread_checker_.DetachFromThread(); |
| InitializeAudioProcessingModule(constraints, effects); |
| @@ -264,7 +266,8 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule( |
| // Return immediately if no audio processing component is enabled. |
| if (!enable_aec && !enable_experimental_aec && !enable_ns && |
| - !enable_high_pass_filter && !enable_typing_detection && !enable_agc) { |
| + !enable_high_pass_filter && !enable_typing_detection && !enable_agc && |
| + !audio_mirroring_) { |
| return; |
| } |
| @@ -284,8 +287,15 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule( |
| if (enable_high_pass_filter) |
| EnableHighPassFilter(audio_processing_.get()); |
| - if (enable_typing_detection) |
| + if (enable_typing_detection) { |
| EnableTypingDetection(audio_processing_.get()); |
|
Henrik Grunell
2014/02/19 06:54:42
The semantics/naming is a bit unclear. EnableTypin
no longer working on chromium
2014/02/20 12:44:13
The naming of EnableTypingDetection is correspondi
|
| + // TODO(xians): Remove this |typing_detector_| after the typing suppression |
| + // is enabled by default. |
| + typing_detector_.reset(new webrtc::TypingDetection()); |
| + |
| + // Configure the update period to 100ms (10 * 10ms) in the typing detector. |
|
Henrik Grunell
2014/02/19 06:54:42
Nit: space between number and "ms".
no longer working on chromium
2014/02/20 12:44:13
Discussed offline, in Chrome, it is very common to
|
| + typing_detector_->SetParameters(0, 0, 0, 0, 0, 10); |
| + } |
| if (enable_agc) |
| EnableAutomaticGainControl(audio_processing_.get()); |
| @@ -398,6 +408,14 @@ int MediaStreamAudioProcessor::ProcessData(webrtc::AudioFrame* audio_frame, |
| // TODO(xians): Swap the stereo channels after switching to media::AudioBus. |
| } |
| + if (typing_detector_ && |
| + audio_frame->vad_activity_ != webrtc::AudioFrame::kVadUnknown) { |
| + bool vad_active = |
| + (audio_frame->vad_activity_ == webrtc::AudioFrame::kVadActive); |
| + // TODO(xians): Pass this |typing_detected_| to peer connection. |
| + typing_detected_ = typing_detector_->Process(key_pressed, vad_active); |
| + } |
| + |
| // Return 0 if the volume has not been changed, otherwise return the new |
| // volume. |
| return (agc->stream_analog_level() == volume) ? |