diff options
author | Erwin Jansen <jansene@google.com> | 2021-06-30 07:29:26 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-06-30 07:29:26 +0000 |
commit | 059cdc5996938f5f6b5343b6c969c12098275587 (patch) | |
tree | 6eacaffe4bebf8e00c290c1e1839e084b0c52e88 /system_wrappers/include/clock.h | |
parent | 97e54a7e73c7b24e464ef06ef3c3b3716f21bb15 (diff) | |
parent | 16be34ae72cdb525c88c2b31b21b976f35fe36d8 (diff) | |
download | webrtc-emu-31-release.tar.gz |
Merge "Merge upstream-master and enable ARM64" into emu-master-devemu-31-stable-releaseemu-31-release
Diffstat (limited to 'system_wrappers/include/clock.h')
-rw-r--r-- | system_wrappers/include/clock.h | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/system_wrappers/include/clock.h b/system_wrappers/include/clock.h index bcb7feaa7d..271291c214 100644 --- a/system_wrappers/include/clock.h +++ b/system_wrappers/include/clock.h @@ -34,22 +34,23 @@ class RTC_EXPORT Clock { virtual ~Clock() {} // Return a timestamp relative to an unspecified epoch. - // TODO(bugs.webrtc.org/11327): Make this a pure virtual function. - virtual Timestamp CurrentTime() { - return Timestamp::Micros(TimeInMicroseconds()); - } - - // TODO(bugs.webrtc.org/11327): Make the following two methods non-virtual - // or completely remove them. - virtual int64_t TimeInMilliseconds() { return CurrentTime().ms(); } - virtual int64_t TimeInMicroseconds() { return CurrentTime().us(); } + virtual Timestamp CurrentTime() = 0; + int64_t TimeInMilliseconds() { return CurrentTime().ms(); } + int64_t TimeInMicroseconds() { return CurrentTime().us(); } // Retrieve an NTP absolute timestamp (with an epoch of Jan 1, 1900). - virtual NtpTime CurrentNtpTime() = 0; + // TODO(bugs.webrtc.org/11327): Make this non-virtual once + // "WebRTC-SystemIndependentNtpTimeKillSwitch" is removed. + virtual NtpTime CurrentNtpTime() { + return ConvertTimestampToNtpTime(CurrentTime()); + } + int64_t CurrentNtpInMilliseconds() { return CurrentNtpTime().ToMs(); } - // TODO(bugs.webrtc.org/11327): Make the following method non-virtual - // or completely remove it. - virtual int64_t CurrentNtpInMilliseconds() { return CurrentNtpTime().ToMs(); } + // Converts between a relative timestamp returned by this clock, to NTP time. + virtual NtpTime ConvertTimestampToNtpTime(Timestamp timestamp) = 0; + int64_t ConvertTimestampToNtpTimeInMilliseconds(int64_t timestamp_ms) { + return ConvertTimestampToNtpTime(Timestamp::Millis(timestamp_ms)).ToMs(); + } // Returns an instance of the real-time system clock implementation. static Clock* GetRealTimeClock(); @@ -65,7 +66,7 @@ class SimulatedClock : public Clock { // Return a timestamp with an epoch of Jan 1, 1970. Timestamp CurrentTime() override; - NtpTime CurrentNtpTime() override; + NtpTime ConvertTimestampToNtpTime(Timestamp timestamp) override; // Advance the simulated clock with a given number of milliseconds or // microseconds. |