Adding parameter setting for typing detection
Review URL: https://webrtc-codereview.appspot.com/476001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1984 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -193,6 +193,14 @@ public:
|
||||
// Returns error if typing detection is disabled.
|
||||
virtual int TimeSinceLastTyping(int &seconds) = 0;
|
||||
|
||||
// Optional setting of typing detection parameters
|
||||
// Parameter with value == 0 will be ignored
|
||||
// and left with default config.
|
||||
virtual int SetTypingDetectionParameters(int timeWindow,
|
||||
int costPerTyping,
|
||||
int reportingThreshold,
|
||||
int penaltyDecay) = 0;
|
||||
|
||||
protected:
|
||||
VoEAudioProcessing() {}
|
||||
virtual ~VoEAudioProcessing() {}
|
||||
|
||||
@@ -186,6 +186,10 @@ TransmitMixer::TransmitMixer(const WebRtc_UWord32 instanceId) :
|
||||
_timeSinceLastTyping(0),
|
||||
_penaltyCounter(0),
|
||||
_typingNoiseWarning(0),
|
||||
_timeWindow(10), // 10ms slots accepted to count as a hit
|
||||
_costPerTyping(100), // Penalty added for a typing + activity coincide
|
||||
_reportingThreshold(300), // Threshold for _penaltyCounter
|
||||
_penaltyDecay(1), // how much we reduce _penaltyCounter every 10 ms.
|
||||
#endif
|
||||
_saturationWarning(0),
|
||||
_noiseWarning(0),
|
||||
@@ -1396,10 +1400,10 @@ int TransmitMixer::TypingDetection()
|
||||
}
|
||||
|
||||
if (keyPressed && (_audioFrame._vadActivity == AudioFrame::kVadActive)
|
||||
&& (_timeActive < 10))
|
||||
&& (_timeActive < _timeWindow))
|
||||
{
|
||||
_penaltyCounter += 100;
|
||||
if (_penaltyCounter > 300)
|
||||
_penaltyCounter += _costPerTyping;
|
||||
if (_penaltyCounter > _reportingThreshold)
|
||||
{
|
||||
if (_typingNoiseWarning == 1)
|
||||
{
|
||||
@@ -1418,7 +1422,7 @@ int TransmitMixer::TypingDetection()
|
||||
}
|
||||
|
||||
if (_penaltyCounter > 0)
|
||||
_penaltyCounter--;
|
||||
_penaltyCounter-=_penaltyDecay;
|
||||
|
||||
return (0);
|
||||
}
|
||||
@@ -1442,6 +1446,25 @@ int TransmitMixer::TimeSinceLastTyping(int &seconds)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
||||
int TransmitMixer::SetTypingDetectionParameters(int timeWindow,
|
||||
int costPerTyping,
|
||||
int reportingThreshold,
|
||||
int penaltyDecay)
|
||||
{
|
||||
if(timeWindow != 0)
|
||||
_timeWindow = timeWindow;
|
||||
if(costPerTyping != 0)
|
||||
_costPerTyping = costPerTyping;
|
||||
if(reportingThreshold != 0)
|
||||
_reportingThreshold = reportingThreshold;
|
||||
if(penaltyDecay != 0)
|
||||
_penaltyDecay = penaltyDecay;
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace voe
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@@ -151,6 +151,10 @@ public: // FileCallback
|
||||
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
||||
public: // Typing detection
|
||||
int TimeSinceLastTyping(int &seconds);
|
||||
int SetTypingDetectionParameters(int timeWindow,
|
||||
int costPerTyping,
|
||||
int reportingThreshold,
|
||||
int penaltyDecay);
|
||||
#endif
|
||||
|
||||
private:
|
||||
@@ -205,6 +209,13 @@ private: // owns
|
||||
WebRtc_Word32 _timeSinceLastTyping;
|
||||
WebRtc_Word32 _penaltyCounter;
|
||||
WebRtc_UWord32 _typingNoiseWarning;
|
||||
|
||||
// Tunable treshold values
|
||||
int _timeWindow; // nr of10ms slots accepted to count as a hit.
|
||||
int _costPerTyping; // Penalty added for a typing + activity coincide.
|
||||
int _reportingThreshold; // Threshold for _penaltyCounter.
|
||||
int _penaltyDecay; // How much we reduce _penaltyCounter every 10 ms.
|
||||
|
||||
#endif
|
||||
WebRtc_UWord32 _saturationWarning;
|
||||
WebRtc_UWord32 _noiseWarning;
|
||||
|
||||
@@ -1065,6 +1065,35 @@ int VoEAudioProcessingImpl::TimeSinceLastTyping(int &seconds) {
|
||||
|
||||
}
|
||||
|
||||
int VoEAudioProcessingImpl::SetTypingDetectionParameters(int timeWindow,
|
||||
int costPerTyping,
|
||||
int reportingThreshold,
|
||||
int penaltyDecay) {
|
||||
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
|
||||
"SetTypingDetectionParameters()");
|
||||
ANDROID_NOT_SUPPORTED(_engineStatistics);
|
||||
IPHONE_NOT_SUPPORTED();
|
||||
|
||||
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
||||
if (!_engineStatistics.Initialized()) {
|
||||
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
|
||||
return -1;
|
||||
}
|
||||
return (_transmitMixerPtr->SetTypingDetectionParameters(timeWindow,
|
||||
costPerTyping,
|
||||
reportingThreshold,
|
||||
penaltyDecay));
|
||||
|
||||
#else
|
||||
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
|
||||
"SetTypingDetectionParameters is not supported");
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // #ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
|
||||
|
||||
|
||||
@@ -91,6 +91,11 @@ class VoEAudioProcessingImpl
|
||||
|
||||
virtual int TimeSinceLastTyping(int &seconds);
|
||||
|
||||
virtual int SetTypingDetectionParameters(int timeWindow,
|
||||
int costPerTyping,
|
||||
int reportingThreshold,
|
||||
int penaltyDecay);
|
||||
|
||||
protected:
|
||||
VoEAudioProcessingImpl();
|
||||
virtual ~VoEAudioProcessingImpl();
|
||||
|
||||
Reference in New Issue
Block a user