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

Side by Side Diff: content/renderer/media/media_stream_audio_processor_options.cc

Issue 169803003: Adding typing detection to the APM in chrome. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: move the typing detector to EnableTypingDetection() Created 6 years, 10 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
« no previous file with comments | « content/renderer/media/media_stream_audio_processor_options.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_options.h" 5 #include "content/renderer/media/media_stream_audio_processor_options.h"
6 6
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/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "content/common/media/media_stream_options.h" 11 #include "content/common/media/media_stream_options.h"
12 #include "content/renderer/media/rtc_media_constraints.h" 12 #include "content/renderer/media/rtc_media_constraints.h"
13 #include "media/audio/audio_parameters.h" 13 #include "media/audio/audio_parameters.h"
14 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 14 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
15 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h" 15 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h"
16 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h " 16 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h "
17 #include "third_party/webrtc/modules/audio_processing/typing_detection.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 namespace { 21 namespace {
21 22
22 // Constant constraint keys which enables default audio constraints on 23 // Constant constraint keys which enables default audio constraints on
23 // mediastreams with audio. 24 // mediastreams with audio.
24 struct { 25 struct {
25 const char* key; 26 const char* key;
26 const char* value; 27 const char* value;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 int err = audio_processing->noise_suppression()->set_level( 116 int err = audio_processing->noise_suppression()->set_level(
116 webrtc::NoiseSuppression::kHigh); 117 webrtc::NoiseSuppression::kHigh);
117 err |= audio_processing->noise_suppression()->Enable(true); 118 err |= audio_processing->noise_suppression()->Enable(true);
118 CHECK_EQ(err, 0); 119 CHECK_EQ(err, 0);
119 } 120 }
120 121
121 void EnableHighPassFilter(AudioProcessing* audio_processing) { 122 void EnableHighPassFilter(AudioProcessing* audio_processing) {
122 CHECK_EQ(audio_processing->high_pass_filter()->Enable(true), 0); 123 CHECK_EQ(audio_processing->high_pass_filter()->Enable(true), 0);
123 } 124 }
124 125
125 void EnableTypingDetection(AudioProcessing* audio_processing) { 126 void EnableTypingDetection(AudioProcessing* audio_processing,
127 webrtc::TypingDetection* typing_detector) {
126 int err = audio_processing->voice_detection()->Enable(true); 128 int err = audio_processing->voice_detection()->Enable(true);
127 err |= audio_processing->voice_detection()->set_likelihood( 129 err |= audio_processing->voice_detection()->set_likelihood(
128 webrtc::VoiceDetection::kVeryLowLikelihood); 130 webrtc::VoiceDetection::kVeryLowLikelihood);
129 CHECK_EQ(err, 0); 131 CHECK_EQ(err, 0);
132
133 // Configure the update period to 100ms (10 * 10ms) in the typing detector.
134 typing_detector->SetParameters(0, 0, 0, 0, 0, 10);
130 } 135 }
131 136
132 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) { 137 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing) {
133 webrtc::Config config; 138 webrtc::Config config;
134 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true)); 139 config.Set<webrtc::DelayCorrection>(new webrtc::DelayCorrection(true));
135 audio_processing->SetExtraOptions(config); 140 audio_processing->SetExtraOptions(config);
136 } 141 }
137 142
138 void StartAecDump(AudioProcessing* audio_processing) { 143 void StartAecDump(AudioProcessing* audio_processing) {
139 // TODO(grunell): Figure out a more suitable directory for the audio dump 144 // TODO(grunell): Figure out a more suitable directory for the audio dump
(...skipping 27 matching lines...) Expand all
167 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; 172 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital;
168 #else 173 #else
169 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; 174 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog;
170 #endif 175 #endif
171 int err = audio_processing->gain_control()->set_mode(mode); 176 int err = audio_processing->gain_control()->set_mode(mode);
172 err |= audio_processing->gain_control()->Enable(true); 177 err |= audio_processing->gain_control()->Enable(true);
173 CHECK_EQ(err, 0); 178 CHECK_EQ(err, 0);
174 } 179 }
175 180
176 } // namespace content 181 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_audio_processor_options.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698