blob: f3cf74f7b8c1dacb9b6fbd5788c2b77924e27c7e [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:231/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_
12#define WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_
13
pbos@webrtc.orga557f432013-07-16 12:32:0514#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
15#include "webrtc/typedefs.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:2316
17namespace webrtc
18{
19
stefan@webrtc.org1bb21462013-01-21 07:42:1120class Clock;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2321
22class VCMTimestampExtrapolator
23{
24public:
stefan@webrtc.org8edccce2014-04-11 14:08:3525 explicit VCMTimestampExtrapolator(Clock* clock);
andrew@webrtc.orgb015cbe2012-10-22 18:19:2326 ~VCMTimestampExtrapolator();
stefan@webrtc.org8edccce2014-04-11 14:08:3527 void Update(int64_t tMs, uint32_t ts90khz);
stefan@webrtc.orgc7979e02013-05-17 12:55:0728 int64_t ExtrapolateLocalTime(uint32_t timestamp90khz);
29 void Reset();
andrew@webrtc.orgb015cbe2012-10-22 18:19:2330
31private:
pbos@webrtc.orgdba5f452013-04-02 15:54:3832 void CheckForWrapArounds(uint32_t ts90khz);
stefan@webrtc.org8edccce2014-04-11 14:08:3533 bool DelayChangeDetection(double error);
andrew@webrtc.orgb015cbe2012-10-22 18:19:2334 RWLockWrapper* _rwLock;
stefan@webrtc.org1bb21462013-01-21 07:42:1135 Clock* _clock;
36 double _w[2];
37 double _P[2][2];
pbos@webrtc.orgdba5f452013-04-02 15:54:3838 int64_t _startMs;
39 int64_t _prevMs;
40 uint32_t _firstTimestamp;
41 int32_t _wrapArounds;
stefan@webrtc.orgc7979e02013-05-17 12:55:0742 int64_t _prevUnwrappedTimestamp;
43 int64_t _prevWrapTimestamp;
stefan@webrtc.org1bb21462013-01-21 07:42:1144 const double _lambda;
45 bool _firstAfterReset;
pbos@webrtc.orgdba5f452013-04-02 15:54:3846 uint32_t _packetCount;
47 const uint32_t _startUpFilterDelayInPackets;
andrew@webrtc.orgb015cbe2012-10-22 18:19:2348
49 double _detectorAccumulatorPos;
50 double _detectorAccumulatorNeg;
51 const double _alarmThreshold;
52 const double _accDrift;
53 const double _accMaxError;
54 const double _P11;
55};
56
pbos@webrtc.org3b89e102013-07-03 15:12:2657} // namespace webrtc
andrew@webrtc.orgb015cbe2012-10-22 18:19:2358
59#endif // WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_