Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / video_coding / main / source / timestamp_extrapolator.h
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
14 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
15 #include "webrtc/typedefs.h"
16
17 namespace webrtc
18 {
19
20 class Clock;
21
22 class VCMTimestampExtrapolator
23 {
24 public:
25     VCMTimestampExtrapolator(Clock* clock,
26                              int32_t vcmId = 0,
27                              int32_t receiverId = 0);
28     ~VCMTimestampExtrapolator();
29     void Update(int64_t tMs, uint32_t ts90khz, bool trace = true);
30     int64_t ExtrapolateLocalTime(uint32_t timestamp90khz);
31     void Reset();
32
33 private:
34     void CheckForWrapArounds(uint32_t ts90khz);
35     bool DelayChangeDetection(double error, bool trace = true);
36     RWLockWrapper*        _rwLock;
37     int32_t         _vcmId;
38     int32_t         _id;
39     Clock*                _clock;
40     double                _w[2];
41     double                _P[2][2];
42     int64_t         _startMs;
43     int64_t         _prevMs;
44     uint32_t        _firstTimestamp;
45     int32_t         _wrapArounds;
46     int64_t         _prevUnwrappedTimestamp;
47     int64_t         _prevWrapTimestamp;
48     const double          _lambda;
49     bool                  _firstAfterReset;
50     uint32_t        _packetCount;
51     const uint32_t  _startUpFilterDelayInPackets;
52
53     double              _detectorAccumulatorPos;
54     double              _detectorAccumulatorNeg;
55     const double        _alarmThreshold;
56     const double        _accDrift;
57     const double        _accMaxError;
58     const double        _P11;
59 };
60
61 }  // namespace webrtc
62
63 #endif // WEBRTC_MODULES_VIDEO_CODING_TIMESTAMP_EXTRAPOLATOR_H_