2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-01 18:34:25 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/tick_util.h"
|
2013-01-02 16:06:39 +00:00
|
|
|
#include "webrtc/voice_engine/monitor_module.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
namespace voe {
|
|
|
|
|
|
|
|
|
|
MonitorModule::MonitorModule() :
|
|
|
|
|
_observerPtr(NULL),
|
2013-01-02 16:06:39 +00:00
|
|
|
_lastProcessTime(TickTime::MillisecondTimestamp())
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MonitorModule::~MonitorModule()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-29 12:12:49 +00:00
|
|
|
int32_t
|
2011-07-07 08:21:25 +00:00
|
|
|
MonitorModule::RegisterObserver(MonitorObserver& observer)
|
|
|
|
|
{
|
2016-01-21 10:37:37 -08:00
|
|
|
rtc::CritScope lock(&_callbackCritSect);
|
2011-07-07 08:21:25 +00:00
|
|
|
if (_observerPtr)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
_observerPtr = &observer;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-29 12:12:49 +00:00
|
|
|
int32_t
|
2011-07-07 08:21:25 +00:00
|
|
|
MonitorModule::DeRegisterObserver()
|
|
|
|
|
{
|
2016-01-21 10:37:37 -08:00
|
|
|
rtc::CritScope lock(&_callbackCritSect);
|
2011-07-07 08:21:25 +00:00
|
|
|
if (!_observerPtr)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
_observerPtr = NULL;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t
|
2011-07-07 08:21:25 +00:00
|
|
|
MonitorModule::TimeUntilNextProcess()
|
|
|
|
|
{
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t now = TickTime::MillisecondTimestamp();
|
|
|
|
|
const int64_t kAverageProcessUpdateTimeMs = 1000;
|
|
|
|
|
return kAverageProcessUpdateTimeMs - (now - _lastProcessTime);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-29 12:12:49 +00:00
|
|
|
int32_t
|
2011-07-07 08:21:25 +00:00
|
|
|
MonitorModule::Process()
|
|
|
|
|
{
|
2013-01-02 16:06:39 +00:00
|
|
|
_lastProcessTime = TickTime::MillisecondTimestamp();
|
2016-01-21 10:37:37 -08:00
|
|
|
rtc::CritScope lock(&_callbackCritSect);
|
2011-07-07 08:21:25 +00:00
|
|
|
if (_observerPtr)
|
|
|
|
|
{
|
|
|
|
|
_observerPtr->OnPeriodicProcess();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace voe
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|