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 11 #ifndef RTC_BASE_TIME_TIMESTAMP_EXTRAPOLATOR_H_ 12 #define RTC_BASE_TIME_TIMESTAMP_EXTRAPOLATOR_H_ 13 14 #include <stdint.h> 15 16 #include "rtc_base/synchronization/rw_lock_wrapper.h" 17 18 namespace webrtc { 19 20 class TimestampExtrapolator { 21 public: 22 explicit TimestampExtrapolator(int64_t start_ms); 23 ~TimestampExtrapolator(); 24 void Update(int64_t tMs, uint32_t ts90khz); 25 int64_t ExtrapolateLocalTime(uint32_t timestamp90khz); 26 void Reset(int64_t start_ms); 27 28 private: 29 void CheckForWrapArounds(uint32_t ts90khz); 30 bool DelayChangeDetection(double error); 31 RWLockWrapper* _rwLock; 32 double _w[2]; 33 double _pP[2][2]; 34 int64_t _startMs; 35 int64_t _prevMs; 36 uint32_t _firstTimestamp; 37 int32_t _wrapArounds; 38 int64_t _prevUnwrappedTimestamp; 39 int64_t _prevWrapTimestamp; 40 const double _lambda; 41 bool _firstAfterReset; 42 uint32_t _packetCount; 43 const uint32_t _startUpFilterDelayInPackets; 44 45 double _detectorAccumulatorPos; 46 double _detectorAccumulatorNeg; 47 const double _alarmThreshold; 48 const double _accDrift; 49 const double _accMaxError; 50 const double _pP11; 51 }; 52 53 } // namespace webrtc 54 55 #endif // RTC_BASE_TIME_TIMESTAMP_EXTRAPOLATOR_H_ 56