Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ | 11 #ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ |
| 12 #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ | 12 #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 #include "webrtc/system_wrappers/include/ntp_time.h" | |
| 16 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" | 17 #include "webrtc/system_wrappers/include/rw_lock_wrapper.h" |
| 17 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
| 18 | 19 |
| 19 namespace webrtc { | 20 namespace webrtc { |
| 20 | 21 |
| 21 // January 1970, in NTP seconds. | 22 // January 1970, in NTP seconds. |
| 22 const uint32_t kNtpJan1970 = 2208988800UL; | 23 const uint32_t kNtpJan1970 = 2208988800UL; |
| 23 | 24 |
| 24 // Magic NTP fractional unit. | 25 // Magic NTP fractional unit. |
| 25 const double kMagicNtpFractionalUnit = 4.294967296E+9; | 26 const double kMagicNtpFractionalUnit = 4.294967296E+9; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 36 // Return a timestamp in microseconds relative to some arbitrary source; the | 37 // Return a timestamp in microseconds relative to some arbitrary source; the |
| 37 // source is fixed for this clock. | 38 // source is fixed for this clock. |
| 38 virtual int64_t TimeInMicroseconds() const = 0; | 39 virtual int64_t TimeInMicroseconds() const = 0; |
| 39 | 40 |
| 40 // Retrieve an NTP absolute timestamp in seconds and fractions of a second. | 41 // Retrieve an NTP absolute timestamp in seconds and fractions of a second. |
| 41 virtual void CurrentNtp(uint32_t& seconds, uint32_t& fractions) const = 0; | 42 virtual void CurrentNtp(uint32_t& seconds, uint32_t& fractions) const = 0; |
| 42 | 43 |
| 43 // Retrieve an NTP absolute timestamp in milliseconds. | 44 // Retrieve an NTP absolute timestamp in milliseconds. |
| 44 virtual int64_t CurrentNtpInMilliseconds() const = 0; | 45 virtual int64_t CurrentNtpInMilliseconds() const = 0; |
| 45 | 46 |
| 47 NtpTime CurrentNtpTime() const; | |
|
perkj_webrtc
2017/02/09 17:55:22
please make virtual and add a todo to make pure vi
danilchap
2017/02/09 18:17:32
Done.
| |
| 48 | |
| 46 // Converts an NTP timestamp to a millisecond timestamp. | 49 // Converts an NTP timestamp to a millisecond timestamp. |
| 47 static int64_t NtpToMs(uint32_t seconds, uint32_t fractions); | 50 static int64_t NtpToMs(uint32_t seconds, uint32_t fractions) { |
| 51 return NtpTime(seconds, fractions).ToMs(); | |
| 52 } | |
| 48 | 53 |
| 49 // Returns an instance of the real-time system clock implementation. | 54 // Returns an instance of the real-time system clock implementation. |
| 50 static Clock* GetRealTimeClock(); | 55 static Clock* GetRealTimeClock(); |
| 51 }; | 56 }; |
| 52 | 57 |
| 53 class SimulatedClock : public Clock { | 58 class SimulatedClock : public Clock { |
| 54 public: | 59 public: |
| 55 explicit SimulatedClock(int64_t initial_time_us); | 60 explicit SimulatedClock(int64_t initial_time_us); |
| 56 | 61 |
| 57 ~SimulatedClock() override; | 62 ~SimulatedClock() override; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 76 void AdvanceTimeMicroseconds(int64_t microseconds); | 81 void AdvanceTimeMicroseconds(int64_t microseconds); |
| 77 | 82 |
| 78 private: | 83 private: |
| 79 int64_t time_us_; | 84 int64_t time_us_; |
| 80 std::unique_ptr<RWLockWrapper> lock_; | 85 std::unique_ptr<RWLockWrapper> lock_; |
| 81 }; | 86 }; |
| 82 | 87 |
| 83 }; // namespace webrtc | 88 }; // namespace webrtc |
| 84 | 89 |
| 85 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ | 90 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_CLOCK_H_ |
| OLD | NEW |