timestamp_extrapolator.h 1.5 KB

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