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..e7ff166c0c685ee29931edb0450e64e6a5213a22 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_) { |
Henrik Grunell
2014/02/18 09:24:06
I assume this doesn't have to do with the typing d
no longer working on chromium
2014/02/18 17:47:09
Trivial fix to the existing code. As discussed off
|
return; |
} |
@@ -284,8 +287,12 @@ 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/18 09:24:06
As we talked about offline before, I think you sho
Henrik Grunell
2014/02/18 09:34:14
Use e.g. |report_detection_update_period| = 10 if
no longer working on chromium
2014/02/18 17:47:09
Done, thanks.
|
+ // TODO(xians): Remove this |typing_detector_| after the typing suppression |
+ // is enabled by default. |
+ typing_detector_.reset(new webrtc::TypingDetection()); |
+ } |
if (enable_agc) |
EnableAutomaticGainControl(audio_processing_.get()); |
@@ -398,6 +405,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) ? |