Remove timestamp_extrapolator's dependency to Clock and vcm defines.
TEST=existing tests BUG= R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12399004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6058 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
5ee0f05d5f
commit
ed4cb56575
@ -8,15 +8,14 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
|
||||
#include "webrtc/modules/video_coding/main/source/timestamp_extrapolator.h"
|
||||
#include "webrtc/system_wrappers/interface/clock.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
VCMTimestampExtrapolator::VCMTimestampExtrapolator(Clock* clock)
|
||||
VCMTimestampExtrapolator::VCMTimestampExtrapolator(int64_t start_ms)
|
||||
: _rwLock(RWLockWrapper::CreateRWLock()),
|
||||
_clock(clock),
|
||||
_startMs(0),
|
||||
_firstTimestamp(0),
|
||||
_wrapArounds(0),
|
||||
@ -32,7 +31,7 @@ VCMTimestampExtrapolator::VCMTimestampExtrapolator(Clock* clock)
|
||||
_accDrift(6600), // in timestamp ticks, i.e. 15 ms
|
||||
_accMaxError(7000),
|
||||
_P11(1e10) {
|
||||
Reset();
|
||||
Reset(start_ms);
|
||||
}
|
||||
|
||||
VCMTimestampExtrapolator::~VCMTimestampExtrapolator()
|
||||
@ -41,10 +40,10 @@ VCMTimestampExtrapolator::~VCMTimestampExtrapolator()
|
||||
}
|
||||
|
||||
void
|
||||
VCMTimestampExtrapolator::Reset()
|
||||
VCMTimestampExtrapolator::Reset(int64_t start_ms)
|
||||
{
|
||||
WriteLockScoped wl(*_rwLock);
|
||||
_startMs = _clock->TimeInMilliseconds();
|
||||
_startMs = start_ms;
|
||||
_prevMs = _startMs;
|
||||
_firstTimestamp = 0;
|
||||
_w[0] = 90.0;
|
||||
@ -71,7 +70,7 @@ VCMTimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz)
|
||||
// Ten seconds without a complete frame.
|
||||
// Reset the extrapolator
|
||||
_rwLock->ReleaseLockExclusive();
|
||||
Reset();
|
||||
Reset(tMs);
|
||||
_rwLock->AcquireLockExclusive();
|
||||
}
|
||||
else
|
||||
@ -214,9 +213,12 @@ bool
|
||||
VCMTimestampExtrapolator::DelayChangeDetection(double error)
|
||||
{
|
||||
// CUSUM detection of sudden delay changes
|
||||
error = (error > 0) ? VCM_MIN(error, _accMaxError) : VCM_MAX(error, -_accMaxError);
|
||||
_detectorAccumulatorPos = VCM_MAX(_detectorAccumulatorPos + error - _accDrift, (double)0);
|
||||
_detectorAccumulatorNeg = VCM_MIN(_detectorAccumulatorNeg + error + _accDrift, (double)0);
|
||||
error = (error > 0) ? std::min(error, _accMaxError) :
|
||||
std::max(error, -_accMaxError);
|
||||
_detectorAccumulatorPos =
|
||||
std::max(_detectorAccumulatorPos + error - _accDrift, (double)0);
|
||||
_detectorAccumulatorNeg =
|
||||
std::min(_detectorAccumulatorNeg + error + _accDrift, (double)0);
|
||||
if (_detectorAccumulatorPos > _alarmThreshold || _detectorAccumulatorNeg < -_alarmThreshold)
|
||||
{
|
||||
// Alarm
|
||||
|
@ -17,22 +17,19 @@
|
||||
namespace webrtc
|
||||
{
|
||||
|
||||
class Clock;
|
||||
|
||||
class VCMTimestampExtrapolator
|
||||
{
|
||||
public:
|
||||
explicit VCMTimestampExtrapolator(Clock* clock);
|
||||
explicit VCMTimestampExtrapolator(int64_t start_ms);
|
||||
~VCMTimestampExtrapolator();
|
||||
void Update(int64_t tMs, uint32_t ts90khz);
|
||||
int64_t ExtrapolateLocalTime(uint32_t timestamp90khz);
|
||||
void Reset();
|
||||
void Reset(int64_t start_ms);
|
||||
|
||||
private:
|
||||
void CheckForWrapArounds(uint32_t ts90khz);
|
||||
bool DelayChangeDetection(double error);
|
||||
RWLockWrapper* _rwLock;
|
||||
Clock* _clock;
|
||||
double _w[2];
|
||||
double _P[2][2];
|
||||
int64_t _startMs;
|
||||
|
@ -35,7 +35,8 @@ VCMTiming::VCMTiming(Clock* clock,
|
||||
prev_frame_timestamp_(0) {
|
||||
if (master_timing == NULL) {
|
||||
master_ = true;
|
||||
ts_extrapolator_ = new VCMTimestampExtrapolator(clock_);
|
||||
ts_extrapolator_ =
|
||||
new VCMTimestampExtrapolator(clock_->TimeInMilliseconds());
|
||||
} else {
|
||||
ts_extrapolator_ = master_timing->ts_extrapolator_;
|
||||
}
|
||||
@ -50,7 +51,7 @@ VCMTiming::~VCMTiming() {
|
||||
|
||||
void VCMTiming::Reset() {
|
||||
CriticalSectionScoped cs(crit_sect_);
|
||||
ts_extrapolator_->Reset();
|
||||
ts_extrapolator_->Reset(clock_->TimeInMilliseconds());
|
||||
codec_timer_.Reset();
|
||||
render_delay_ms_ = kDefaultRenderDelayMs;
|
||||
min_playout_delay_ms_ = 0;
|
||||
|
@ -48,7 +48,8 @@ ViEReceiver::ViEReceiver(const int32_t channel_id,
|
||||
vcm_(module_vcm),
|
||||
remote_bitrate_estimator_(remote_bitrate_estimator),
|
||||
clock_(Clock::GetRealTimeClock()),
|
||||
ts_extrapolator_(new VCMTimestampExtrapolator(clock_)),
|
||||
ts_extrapolator_(
|
||||
new VCMTimestampExtrapolator(clock_->TimeInMilliseconds())),
|
||||
rtp_dump_(NULL),
|
||||
receiving_(false),
|
||||
restored_packet_in_use_(false),
|
||||
|
Loading…
x
Reference in New Issue
Block a user