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:
jiayl@webrtc.org 2013-09-17 18:09:20 +00:00
parent da79008ab4
commit bf00740c92
4 changed files with 31 additions and 12 deletions

View File

@ -65,8 +65,7 @@
#define WEBRTC_VOICE_ENGINE_NR // Near-end NS #define WEBRTC_VOICE_ENGINE_NR // Near-end NS
#define WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT #define WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT
#if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS) && \ #if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS)
!defined(WEBRTC_CHROMIUM_BUILD)
#define WEBRTC_VOICE_ENGINE_TYPING_DETECTION // Typing detection #define WEBRTC_VOICE_ENGINE_TYPING_DETECTION // Typing detection
#endif #endif

View File

@ -88,6 +88,7 @@
#define VE_CANNOT_SET_SECONDARY_SEND_CODEC 8113 #define VE_CANNOT_SET_SECONDARY_SEND_CODEC 8113
#define VE_CANNOT_GET_SECONDARY_SEND_CODEC 8114 #define VE_CANNOT_GET_SECONDARY_SEND_CODEC 8114
#define VE_CANNOT_REMOVE_SECONDARY_SEND_CODEC 8115 #define VE_CANNOT_REMOVE_SECONDARY_SEND_CODEC 8115
#define VE_TYPING_NOISE_OFF_WARNING 8116
// Errors causing limited functionality // Errors causing limited functionality
#define VE_RTCP_SOCKET_ERROR 9001 #define VE_RTCP_SOCKET_ERROR 9001

View File

@ -41,18 +41,26 @@ TransmitMixer::OnPeriodicProcess()
"TransmitMixer::OnPeriodicProcess()"); "TransmitMixer::OnPeriodicProcess()");
#if defined(WEBRTC_VOICE_ENGINE_TYPING_DETECTION) #if defined(WEBRTC_VOICE_ENGINE_TYPING_DETECTION)
if (_typingNoiseWarning) if (_typingNoiseWarningPending)
{ {
CriticalSectionScoped cs(&_callbackCritSect); CriticalSectionScoped cs(&_callbackCritSect);
if (_voiceEngineObserverPtr) if (_voiceEngineObserverPtr)
{ {
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1), if (_typingNoiseDetected) {
"TransmitMixer::OnPeriodicProcess() => " WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, -1),
"CallbackOnError(VE_TYPING_NOISE_WARNING)"); "TransmitMixer::OnPeriodicProcess() => "
_voiceEngineObserverPtr->CallbackOnError(-1, "CallbackOnError(VE_TYPING_NOISE_WARNING)");
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 #endif
@ -189,7 +197,8 @@ TransmitMixer::TransmitMixer(uint32_t instanceId) :
_timeActive(0), _timeActive(0),
_timeSinceLastTyping(0), _timeSinceLastTyping(0),
_penaltyCounter(0), _penaltyCounter(0),
_typingNoiseWarning(false), _typingNoiseWarningPending(false),
_typingNoiseDetected(false),
_timeWindow(10), // 10ms slots accepted to count as a hit _timeWindow(10), // 10ms slots accepted to count as a hit
_costPerTyping(100), // Penalty added for a typing + activity coincide _costPerTyping(100), // Penalty added for a typing + activity coincide
_reportingThreshold(300), // Threshold for _penaltyCounter _reportingThreshold(300), // Threshold for _penaltyCounter
@ -1380,10 +1389,19 @@ int TransmitMixer::TypingDetection(bool keyPressed)
if (_penaltyCounter > _reportingThreshold) if (_penaltyCounter > _reportingThreshold)
{ {
// Triggers a callback in OnPeriodicProcess(). // 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) if (_penaltyCounter > 0)
_penaltyCounter-=_penaltyDecay; _penaltyCounter-=_penaltyDecay;

View File

@ -217,7 +217,8 @@ private:
int32_t _timeActive; int32_t _timeActive;
int32_t _timeSinceLastTyping; int32_t _timeSinceLastTyping;
int32_t _penaltyCounter; int32_t _penaltyCounter;
bool _typingNoiseWarning; bool _typingNoiseWarningPending;
bool _typingNoiseDetected;
// Tunable treshold values // Tunable treshold values
int _timeWindow; // nr of10ms slots accepted to count as a hit. int _timeWindow; // nr of10ms slots accepted to count as a hit.