Adding time since last typing
Review URL: https://webrtc-codereview.appspot.com/471001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1960 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
1b1a39fdef
commit
3dc886561c
@ -187,6 +187,12 @@ public:
|
||||
// Gets the current typing detection status.
|
||||
virtual int GetTypingDetectionStatus(bool& enabled) = 0;
|
||||
|
||||
// Reports the lower of:
|
||||
// * Time in seconds since the last typing event.
|
||||
// * Time in seconds since the typing detection was enabled.
|
||||
// Returns error if typing detection is disabled.
|
||||
virtual int TimeSinceLastTyping(int &seconds) = 0;
|
||||
|
||||
protected:
|
||||
VoEAudioProcessing() {}
|
||||
virtual ~VoEAudioProcessing() {}
|
||||
|
@ -183,6 +183,7 @@ TransmitMixer::TransmitMixer(const WebRtc_UWord32 instanceId) :
|
||||
_callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
||||
_timeActive(0),
|
||||
_timeSinceLastTyping(0),
|
||||
_penaltyCounter(0),
|
||||
_typingNoiseWarning(0),
|
||||
#endif
|
||||
@ -1384,6 +1385,16 @@ int TransmitMixer::TypingDetection()
|
||||
else
|
||||
_timeActive = 0;
|
||||
|
||||
// Keep track if time since last typing event
|
||||
if (keyPressed)
|
||||
{
|
||||
_timeSinceLastTyping = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++_timeSinceLastTyping;
|
||||
}
|
||||
|
||||
if (keyPressed && (_audioFrame._vadActivity == AudioFrame::kVadActive)
|
||||
&& (_timeActive < 10))
|
||||
{
|
||||
@ -1419,6 +1430,18 @@ int TransmitMixer::GetMixingFrequency()
|
||||
return (_mixingFrequency);
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
||||
int TransmitMixer::TimeSinceLastTyping(int &seconds)
|
||||
{
|
||||
// We check in VoEAudioProcessingImpl that this is only called when
|
||||
// typing detection is active.
|
||||
|
||||
// Round to whole seconds
|
||||
seconds = (_timeSinceLastTyping + 50) / 100;
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace voe
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
@ -148,6 +148,11 @@ public: // FileCallback
|
||||
|
||||
void RecordFileEnded(const WebRtc_Word32 id);
|
||||
|
||||
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
||||
public: // Typing detection
|
||||
int TimeSinceLastTyping(int &seconds);
|
||||
#endif
|
||||
|
||||
private:
|
||||
TransmitMixer(const WebRtc_UWord32 instanceId);
|
||||
|
||||
@ -197,6 +202,7 @@ private: // owns
|
||||
|
||||
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
||||
WebRtc_Word32 _timeActive;
|
||||
WebRtc_Word32 _timeSinceLastTyping;
|
||||
WebRtc_Word32 _penaltyCounter;
|
||||
WebRtc_UWord32 _typingNoiseWarning;
|
||||
#endif
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "channel.h"
|
||||
#include "critical_section_wrapper.h"
|
||||
#include "trace.h"
|
||||
#include "transmit_mixer.h"
|
||||
#include "voe_errors.h"
|
||||
#include "voice_engine_impl.h"
|
||||
|
||||
@ -1031,6 +1032,40 @@ int VoEAudioProcessingImpl::GetTypingDetectionStatus(bool& enabled) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int VoEAudioProcessingImpl::TimeSinceLastTyping(int &seconds) {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_instanceId, -1),
|
||||
"TimeSinceLastTyping()");
|
||||
ANDROID_NOT_SUPPORTED(_engineStatistics);
|
||||
IPHONE_NOT_SUPPORTED();
|
||||
|
||||
#ifdef WEBRTC_VOICE_ENGINE_TYPING_DETECTION
|
||||
if (!_engineStatistics.Initialized()) {
|
||||
_engineStatistics.SetLastError(VE_NOT_INITED, kTraceError);
|
||||
return -1;
|
||||
}
|
||||
// Check if typing detection is enabled
|
||||
bool enabled = _audioProcessingModulePtr->voice_detection()->is_enabled();
|
||||
if (enabled)
|
||||
{
|
||||
_transmitMixerPtr->TimeSinceLastTyping(seconds);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
|
||||
"SetTypingDetectionStatus is not enabled");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
_engineStatistics.SetLastError(VE_FUNC_NOT_SUPPORTED, kTraceError,
|
||||
"SetTypingDetectionStatus is not supported");
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // #ifdef WEBRTC_VOICE_ENGINE_AUDIO_PROCESSING_API
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -89,6 +89,8 @@ class VoEAudioProcessingImpl
|
||||
|
||||
virtual int GetTypingDetectionStatus(bool& enabled);
|
||||
|
||||
virtual int TimeSinceLastTyping(int &seconds);
|
||||
|
||||
protected:
|
||||
VoEAudioProcessingImpl();
|
||||
virtual ~VoEAudioProcessingImpl();
|
||||
|
Loading…
Reference in New Issue
Block a user