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

Side by Side Diff: webrtc/voice_engine/transmit_mixer.cc

Issue 2544123003: Move WEBRTC_VOICE_ENGINE_TYPING_DETECTION to transmit_mixer.h (Closed)
Patch Set: Created 4 years 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 | « webrtc/voice_engine/transmit_mixer.h ('k') | webrtc/voice_engine/voe_audio_processing_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 16 matching lines...) Expand all
27 namespace webrtc { 27 namespace webrtc {
28 namespace voe { 28 namespace voe {
29 29
30 // TODO(ajm): The thread safety of this is dubious... 30 // TODO(ajm): The thread safety of this is dubious...
31 void 31 void
32 TransmitMixer::OnPeriodicProcess() 32 TransmitMixer::OnPeriodicProcess()
33 { 33 {
34 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, -1), 34 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, -1),
35 "TransmitMixer::OnPeriodicProcess()"); 35 "TransmitMixer::OnPeriodicProcess()");
36 36
37 #if defined(WEBRTC_VOICE_ENGINE_TYPING_DETECTION) 37 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION
38 bool send_typing_noise_warning = false; 38 bool send_typing_noise_warning = false;
39 bool typing_noise_detected = false; 39 bool typing_noise_detected = false;
40 { 40 {
41 rtc::CritScope cs(&_critSect); 41 rtc::CritScope cs(&_critSect);
42 if (_typingNoiseWarningPending) { 42 if (_typingNoiseWarningPending) {
43 send_typing_noise_warning = true; 43 send_typing_noise_warning = true;
44 typing_noise_detected = _typingNoiseDetected; 44 typing_noise_detected = _typingNoiseDetected;
45 _typingNoiseWarningPending = false; 45 _typingNoiseWarningPending = false;
46 } 46 }
47 } 47 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 _processThreadPtr(NULL), 184 _processThreadPtr(NULL),
185 // Avoid conflict with other channels by adding 1024 - 1026, 185 // Avoid conflict with other channels by adding 1024 - 1026,
186 // won't use as much as 1024 channels. 186 // won't use as much as 1024 channels.
187 _filePlayerId(instanceId + 1024), 187 _filePlayerId(instanceId + 1024),
188 _fileRecorderId(instanceId + 1025), 188 _fileRecorderId(instanceId + 1025),
189 _fileCallRecorderId(instanceId + 1026), 189 _fileCallRecorderId(instanceId + 1026),
190 _filePlaying(false), 190 _filePlaying(false),
191 _fileRecording(false), 191 _fileRecording(false),
192 _fileCallRecording(false), 192 _fileCallRecording(false),
193 _audioLevel(), 193 _audioLevel(),
194 #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION 194 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION
195 _typingNoiseWarningPending(false), 195 _typingNoiseWarningPending(false),
196 _typingNoiseDetected(false), 196 _typingNoiseDetected(false),
197 #endif 197 #endif
198 _saturationWarning(false), 198 _saturationWarning(false),
199 _instanceId(instanceId), 199 _instanceId(instanceId),
200 _mixFileWithMicrophone(false), 200 _mixFileWithMicrophone(false),
201 _captureLevel(0), 201 _captureLevel(0),
202 external_postproc_ptr_(NULL), 202 external_postproc_ptr_(NULL),
203 external_preproc_ptr_(NULL), 203 external_preproc_ptr_(NULL),
204 _mute(false), 204 _mute(false),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 335 }
336 336
337 // --- Near-end audio processing. 337 // --- Near-end audio processing.
338 ProcessAudio(totalDelayMS, clockDrift, currentMicLevel, keyPressed); 338 ProcessAudio(totalDelayMS, clockDrift, currentMicLevel, keyPressed);
339 339
340 if (swap_stereo_channels_ && stereo_codec_) 340 if (swap_stereo_channels_ && stereo_codec_)
341 // Only bother swapping if we're using a stereo codec. 341 // Only bother swapping if we're using a stereo codec.
342 AudioFrameOperations::SwapStereoChannels(&_audioFrame); 342 AudioFrameOperations::SwapStereoChannels(&_audioFrame);
343 343
344 // --- Annoying typing detection (utilizes the APM/VAD decision) 344 // --- Annoying typing detection (utilizes the APM/VAD decision)
345 #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION 345 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION
346 TypingDetection(keyPressed); 346 TypingDetection(keyPressed);
347 #endif 347 #endif
348 348
349 // --- Mute signal 349 // --- Mute signal
350 AudioFrameOperations::Mute(&_audioFrame, _mute, _mute); 350 AudioFrameOperations::Mute(&_audioFrame, _mute, _mute);
351 351
352 // --- Mix with file (does not affect the mixing frequency) 352 // --- Mix with file (does not affect the mixing frequency)
353 if (_filePlaying) 353 if (_filePlaying)
354 { 354 {
355 MixOrReplaceAudioWithFile(_audioFrame.sample_rate_hz_); 355 MixOrReplaceAudioWithFile(_audioFrame.sample_rate_hz_);
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 } 1160 }
1161 1161
1162 // Store new capture level. Only updated when analog AGC is enabled. 1162 // Store new capture level. Only updated when analog AGC is enabled.
1163 _captureLevel = agc->stream_analog_level(); 1163 _captureLevel = agc->stream_analog_level();
1164 1164
1165 rtc::CritScope cs(&_critSect); 1165 rtc::CritScope cs(&_critSect);
1166 // Triggers a callback in OnPeriodicProcess(). 1166 // Triggers a callback in OnPeriodicProcess().
1167 _saturationWarning |= agc->stream_is_saturated(); 1167 _saturationWarning |= agc->stream_is_saturated();
1168 } 1168 }
1169 1169
1170 #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION 1170 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION
1171 void TransmitMixer::TypingDetection(bool keyPressed) 1171 void TransmitMixer::TypingDetection(bool keyPressed)
1172 { 1172 {
1173 // We let the VAD determine if we're using this feature or not. 1173 // We let the VAD determine if we're using this feature or not.
1174 if (_audioFrame.vad_activity_ == AudioFrame::kVadUnknown) { 1174 if (_audioFrame.vad_activity_ == AudioFrame::kVadUnknown) {
1175 return; 1175 return;
1176 } 1176 }
1177 1177
1178 bool vadActive = _audioFrame.vad_activity_ == AudioFrame::kVadActive; 1178 bool vadActive = _audioFrame.vad_activity_ == AudioFrame::kVadActive;
1179 if (_typingDetection.Process(keyPressed, vadActive)) { 1179 if (_typingDetection.Process(keyPressed, vadActive)) {
1180 rtc::CritScope cs(&_critSect); 1180 rtc::CritScope cs(&_critSect);
(...skipping 10 matching lines...) Expand all
1191 } 1191 }
1192 } 1192 }
1193 #endif 1193 #endif
1194 1194
1195 int TransmitMixer::GetMixingFrequency() 1195 int TransmitMixer::GetMixingFrequency()
1196 { 1196 {
1197 assert(_audioFrame.sample_rate_hz_ != 0); 1197 assert(_audioFrame.sample_rate_hz_ != 0);
1198 return _audioFrame.sample_rate_hz_; 1198 return _audioFrame.sample_rate_hz_;
1199 } 1199 }
1200 1200
1201 #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION 1201 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION
1202 int TransmitMixer::TimeSinceLastTyping(int &seconds) 1202 int TransmitMixer::TimeSinceLastTyping(int &seconds)
1203 { 1203 {
1204 // We check in VoEAudioProcessingImpl that this is only called when 1204 // We check in VoEAudioProcessingImpl that this is only called when
1205 // typing detection is active. 1205 // typing detection is active.
1206 seconds = _typingDetection.TimeSinceLastDetectionInSeconds(); 1206 seconds = _typingDetection.TimeSinceLastDetectionInSeconds();
1207 return 0; 1207 return 0;
1208 } 1208 }
1209 #endif 1209 #endif
1210 1210
1211 #ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION 1211 #if WEBRTC_VOICE_ENGINE_TYPING_DETECTION
1212 int TransmitMixer::SetTypingDetectionParameters(int timeWindow, 1212 int TransmitMixer::SetTypingDetectionParameters(int timeWindow,
1213 int costPerTyping, 1213 int costPerTyping,
1214 int reportingThreshold, 1214 int reportingThreshold,
1215 int penaltyDecay, 1215 int penaltyDecay,
1216 int typeEventDelay) 1216 int typeEventDelay)
1217 { 1217 {
1218 _typingDetection.SetParameters(timeWindow, 1218 _typingDetection.SetParameters(timeWindow,
1219 costPerTyping, 1219 costPerTyping,
1220 reportingThreshold, 1220 reportingThreshold,
1221 penaltyDecay, 1221 penaltyDecay,
1222 typeEventDelay, 1222 typeEventDelay,
1223 0); 1223 0);
1224 return 0; 1224 return 0;
1225 } 1225 }
1226 #endif 1226 #endif
1227 1227
1228 void TransmitMixer::EnableStereoChannelSwapping(bool enable) { 1228 void TransmitMixer::EnableStereoChannelSwapping(bool enable) {
1229 swap_stereo_channels_ = enable; 1229 swap_stereo_channels_ = enable;
1230 } 1230 }
1231 1231
1232 bool TransmitMixer::IsStereoChannelSwappingEnabled() { 1232 bool TransmitMixer::IsStereoChannelSwappingEnabled() {
1233 return swap_stereo_channels_; 1233 return swap_stereo_channels_;
1234 } 1234 }
1235 1235
1236 } // namespace voe 1236 } // namespace voe
1237 } // namespace webrtc 1237 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/voice_engine/transmit_mixer.h ('k') | webrtc/voice_engine/voe_audio_processing_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698