Adds a new voice engine warning for the typing noise off state.
The old VE_TYPING_NOISE_WARNING is unchanged and fired whenever typing noise is detected. The new VE_TYPING_NOISE_OFF_WARNING is fired when typing noise was detected and is gone now. This is necessary for converting the typing state to a PeerConnection stats. R=niklas.enbom@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2209004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4770 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
da79008ab4
commit
bf00740c92
@ -65,8 +65,7 @@
|
||||
#define WEBRTC_VOICE_ENGINE_NR // Near-end NS
|
||||
#define WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
|
||||
|
||||
#if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS) && \
|
||||
!defined(WEBRTC_CHROMIUM_BUILD)
|
||||
#if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS)
|
||||
#define WEBRTC_VOICE_ENGINE_TYPING_DETECTION // Typing detection
|
||||
#endif
|
||||
|
||||
|
@ -88,6 +88,7 @@
|
||||
#define VE_CANNOT_SET_SECONDARY_SEND_CODEC 8113
|
||||
#define VE_CANNOT_GET_SECONDARY_SEND_CODEC 8114
|
||||
#define VE_CANNOT_REMOVE_SECONDARY_SEND_CODEC 8115
|
||||
#define VE_TYPING_NOISE_OFF_WARNING 8116
|
||||
|
||||
// Errors causing limited functionality
|
||||
#define VE_RTCP_SOCKET_ERROR 9001
|
||||
|
@ -41,18 +41,26 @@ TransmitMixer::OnPeriodicProcess()
|
||||
"TransmitMixer::OnPeriodicProcess()");
|
||||
|
||||
#if defined(WEBRTC_VOICE_ENGINE_TYPING_DETECTION)
|
||||
if (_typingNoiseWarning)
|
||||
if (_typingNoiseWarningPending)
|
||||
{
|
||||
CriticalSectionScoped cs(&_callbackCritSect);
|
||||
if (_voiceEngineObserverPtr)
|
||||
{
|
||||
if (_typingNoiseDetected) {
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
|
||||
"TransmitMixer::OnPeriodicProcess() => "
|
||||
"CallbackOnError(VE_TYPING_NOISE_WARNING)");
|
||||
_voiceEngineObserverPtr->CallbackOnError(-1,
|
||||
VE_TYPING_NOISE_WARNING);
|
||||
} else {
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
|
||||
"TransmitMixer::OnPeriodicProcess() => "
|
||||
"CallbackOnError(VE_TYPING_NOISE_OFF_WARNING)");
|
||||
_voiceEngineObserverPtr->CallbackOnError(
|
||||
-1, VE_TYPING_NOISE_OFF_WARNING);
|
||||
}
|
||||
_typingNoiseWarning = false;
|
||||
}
|
||||
_typingNoiseWarningPending = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -189,7 +197,8 @@ TransmitMixer::TransmitMixer(uint32_t instanceId) :
|
||||
_timeActive(0),
|
||||
_timeSinceLastTyping(0),
|
||||
_penaltyCounter(0),
|
||||
_typingNoiseWarning(false),
|
||||
_typingNoiseWarningPending(false),
|
||||
_typingNoiseDetected(false),
|
||||
_timeWindow(10), // 10ms slots accepted to count as a hit
|
||||
_costPerTyping(100), // Penalty added for a typing + activity coincide
|
||||
_reportingThreshold(300), // Threshold for _penaltyCounter
|
||||
@ -1380,10 +1389,19 @@ int TransmitMixer::TypingDetection(bool keyPressed)
|
||||
if (_penaltyCounter > _reportingThreshold)
|
||||
{
|
||||
// Triggers a callback in OnPeriodicProcess().
|
||||
_typingNoiseWarning = true;
|
||||
_typingNoiseWarningPending = true;
|
||||
_typingNoiseDetected = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If there is already a warning pending, do not change the state.
|
||||
// Otherwise sets a warning pending if noise is off now but previously on.
|
||||
if (!_typingNoiseWarningPending && _typingNoiseDetected) {
|
||||
// Triggers a callback in OnPeriodicProcess().
|
||||
_typingNoiseWarningPending = true;
|
||||
_typingNoiseDetected = false;
|
||||
}
|
||||
|
||||
if (_penaltyCounter > 0)
|
||||
_penaltyCounter-=_penaltyDecay;
|
||||
|
||||
|
@ -217,7 +217,8 @@ private:
|
||||
int32_t _timeActive;
|
||||
int32_t _timeSinceLastTyping;
|
||||
int32_t _penaltyCounter;
|
||||
bool _typingNoiseWarning;
|
||||
bool _typingNoiseWarningPending;
|
||||
bool _typingNoiseDetected;
|
||||
|
||||
// Tunable treshold values
|
||||
int _timeWindow; // nr of10ms slots accepted to count as a hit.
|
||||
|
Loading…
x
Reference in New Issue
Block a user