andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [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 | |
| 11 | #ifndef WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_ |
| 13 | |
pbos@webrtc.org | a557f43 | 2013-07-16 12:32:05 | [diff] [blame] | 14 | #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" |
| 15 | #include "webrtc/typedefs.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 16 | |
| 17 | namespace webrtc |
| 18 | { |
| 19 | |
stefan@webrtc.org | 1bb2146 | 2013-01-21 07:42:11 | [diff] [blame] | 20 | class Clock; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 21 | |
| 22 | class VCMTimestampExtrapolator |
| 23 | { |
| 24 | public: |
stefan@webrtc.org | 8edccce | 2014-04-11 14:08:35 | [diff] [blame^] | 25 | explicit VCMTimestampExtrapolator(Clock* clock); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 26 | ~VCMTimestampExtrapolator(); |
stefan@webrtc.org | 8edccce | 2014-04-11 14:08:35 | [diff] [blame^] | 27 | void Update(int64_t tMs, uint32_t ts90khz); |
stefan@webrtc.org | c7979e0 | 2013-05-17 12:55:07 | [diff] [blame] | 28 | int64_t ExtrapolateLocalTime(uint32_t timestamp90khz); |
| 29 | void Reset(); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 30 | |
| 31 | private: |
pbos@webrtc.org | dba5f45 | 2013-04-02 15:54:38 | [diff] [blame] | 32 | void CheckForWrapArounds(uint32_t ts90khz); |
stefan@webrtc.org | 8edccce | 2014-04-11 14:08:35 | [diff] [blame^] | 33 | bool DelayChangeDetection(double error); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 34 | RWLockWrapper* _rwLock; |
stefan@webrtc.org | 1bb2146 | 2013-01-21 07:42:11 | [diff] [blame] | 35 | Clock* _clock; |
| 36 | double _w[2]; |
| 37 | double _P[2][2]; |
pbos@webrtc.org | dba5f45 | 2013-04-02 15:54:38 | [diff] [blame] | 38 | int64_t _startMs; |
| 39 | int64_t _prevMs; |
| 40 | uint32_t _firstTimestamp; |
| 41 | int32_t _wrapArounds; |
stefan@webrtc.org | c7979e0 | 2013-05-17 12:55:07 | [diff] [blame] | 42 | int64_t _prevUnwrappedTimestamp; |
| 43 | int64_t _prevWrapTimestamp; |
stefan@webrtc.org | 1bb2146 | 2013-01-21 07:42:11 | [diff] [blame] | 44 | const double _lambda; |
| 45 | bool _firstAfterReset; |
pbos@webrtc.org | dba5f45 | 2013-04-02 15:54:38 | [diff] [blame] | 46 | uint32_t _packetCount; |
| 47 | const uint32_t _startUpFilterDelayInPackets; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 48 | |
| 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.org | 3b89e10 | 2013-07-03 15:12:26 | [diff] [blame] | 57 | } // namespace webrtc |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 58 | |
| 59 | #endif // WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_ |