| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright (c) 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_BASE_TIMESTAMPALIGNER_H_ | 11 #ifndef WEBRTC_BASE_TIMESTAMPALIGNER_H_ |
| 12 #define WEBRTC_BASE_TIMESTAMPALIGNER_H_ | 12 #define WEBRTC_BASE_TIMESTAMPALIGNER_H_ |
| 13 | 13 |
| 14 #include "webrtc/base/basictypes.h" | 14 #include "webrtc/base/basictypes.h" |
| 15 #include "webrtc/base/constructormagic.h" | 15 #include "webrtc/base/constructormagic.h" |
| 16 #include "webrtc/base/optional.h" | 16 #include "webrtc/base/optional.h" |
| 17 #include "webrtc/base/thread_checker.h" |
| 17 | 18 |
| 18 namespace rtc { | 19 namespace rtc { |
| 19 | 20 |
| 20 class TimestampAligner { | 21 class TimestampAligner { |
| 21 public: | 22 public: |
| 22 TimestampAligner(); | 23 TimestampAligner(); |
| 23 ~TimestampAligner(); | 24 ~TimestampAligner(); |
| 24 | 25 |
| 25 public: | 26 public: |
| 26 // Update the estimated offset between camera time and system monotonic time. | 27 // Update the estimated offset between camera time and system monotonic time. |
| 27 int64_t UpdateOffset(int64_t camera_time_us, int64_t system_time_us); | 28 int64_t UpdateOffset(int64_t camera_time_us, int64_t system_time_us); |
| 28 | 29 |
| 29 int64_t ClipTimestamp(int64_t filtered_time_us, int64_t system_time_us); | 30 int64_t ClipTimestamp(int64_t filtered_time_us, int64_t system_time_us); |
| 30 | 31 |
| 31 private: | 32 private: |
| 33 rtc::ThreadChecker thread_checker_; |
| 34 |
| 32 // State for the timestamp translation. | 35 // State for the timestamp translation. |
| 33 int frames_seen_; | 36 int frames_seen_; |
| 34 // Estimated offset between camera time and system monotonic time. | 37 // Estimated offset between camera time and system monotonic time. |
| 35 int64_t offset_us_; | 38 int64_t offset_us_; |
| 36 | 39 |
| 37 // State for timestamp clipping, applied after the filter, to ensure | 40 // State for timestamp clipping, applied after the filter, to ensure |
| 38 // that translated timestamps are monotonic and not in the future. | 41 // that translated timestamps are monotonic and not in the future. |
| 39 // Subtracted from the translated timestamps. | 42 // Subtracted from the translated timestamps. |
| 40 int64_t clip_bias_us_; | 43 int64_t clip_bias_us_; |
| 41 rtc::Optional<int64_t> prev_translated_time_us_; | 44 rtc::Optional<int64_t> prev_translated_time_us_; |
| 42 RTC_DISALLOW_COPY_AND_ASSIGN(TimestampAligner); | 45 RTC_DISALLOW_COPY_AND_ASSIGN(TimestampAligner); |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 } // namespace rtc | 48 } // namespace rtc |
| 46 | 49 |
| 47 #endif // WEBRTC_BASE_TIMESTAMPALIGNER_H_ | 50 #endif // WEBRTC_BASE_TIMESTAMPALIGNER_H_ |
| OLD | NEW |