niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
kjellander | d56d68c | 2015-11-02 02:12:41 -0800 | [diff] [blame] | 11 | #ifndef SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ |
| 12 | #define SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "system_wrappers/include/rw_lock_wrapper.h" |
| 15 | #include "typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | |
| 17 | namespace webrtc |
| 18 | { |
| 19 | |
wu@webrtc.org | 66773a0 | 2014-05-07 17:09:44 +0000 | [diff] [blame] | 20 | class TimestampExtrapolator |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | { |
| 22 | public: |
wu@webrtc.org | 66773a0 | 2014-05-07 17:09:44 +0000 | [diff] [blame] | 23 | explicit TimestampExtrapolator(int64_t start_ms); |
| 24 | ~TimestampExtrapolator(); |
stefan@webrtc.org | 34c5da6 | 2014-04-11 14:08:35 +0000 | [diff] [blame] | 25 | void Update(int64_t tMs, uint32_t ts90khz); |
stefan@webrtc.org | 9f557c1 | 2013-05-17 12:55:07 +0000 | [diff] [blame] | 26 | int64_t ExtrapolateLocalTime(uint32_t timestamp90khz); |
wu@webrtc.org | ed4cb56 | 2014-05-06 04:50:49 +0000 | [diff] [blame] | 27 | void Reset(int64_t start_ms); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | |
| 29 | private: |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 30 | void CheckForWrapArounds(uint32_t ts90khz); |
stefan@webrtc.org | 34c5da6 | 2014-04-11 14:08:35 +0000 | [diff] [blame] | 31 | bool DelayChangeDetection(double error); |
stefan@webrtc.org | 7889a9b | 2011-12-12 08:18:24 +0000 | [diff] [blame] | 32 | RWLockWrapper* _rwLock; |
stefan@webrtc.org | a678a3b | 2013-01-21 07:42:11 +0000 | [diff] [blame] | 33 | double _w[2]; |
andrew@webrtc.org | cc476aa | 2014-10-31 16:01:25 +0000 | [diff] [blame] | 34 | double _pP[2][2]; |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 35 | int64_t _startMs; |
| 36 | int64_t _prevMs; |
| 37 | uint32_t _firstTimestamp; |
| 38 | int32_t _wrapArounds; |
stefan@webrtc.org | 9f557c1 | 2013-05-17 12:55:07 +0000 | [diff] [blame] | 39 | int64_t _prevUnwrappedTimestamp; |
| 40 | int64_t _prevWrapTimestamp; |
stefan@webrtc.org | a678a3b | 2013-01-21 07:42:11 +0000 | [diff] [blame] | 41 | const double _lambda; |
| 42 | bool _firstAfterReset; |
pbos@webrtc.org | 7b859cc | 2013-04-02 15:54:38 +0000 | [diff] [blame] | 43 | uint32_t _packetCount; |
| 44 | const uint32_t _startUpFilterDelayInPackets; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 45 | |
| 46 | double _detectorAccumulatorPos; |
| 47 | double _detectorAccumulatorNeg; |
| 48 | const double _alarmThreshold; |
| 49 | const double _accDrift; |
| 50 | const double _accMaxError; |
andrew@webrtc.org | cc476aa | 2014-10-31 16:01:25 +0000 | [diff] [blame] | 51 | const double _pP11; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 54 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
kjellander | d56d68c | 2015-11-02 02:12:41 -0800 | [diff] [blame] | 56 | #endif // SYSTEM_WRAPPERS_INCLUDE_TIMESTAMP_EXTRAPOLATOR_H_ |