Index: webrtc/system_wrappers/source/clock.cc |
diff --git a/webrtc/system_wrappers/source/clock.cc b/webrtc/system_wrappers/source/clock.cc |
index f31556fc4ff38b1073877bdd2ea8ee264276dfec..f65adfcbb18ae8438fa14b0a6e10fd98eba15803 100644 |
--- a/webrtc/system_wrappers/source/clock.cc |
+++ b/webrtc/system_wrappers/source/clock.cc |
@@ -25,13 +25,6 @@ |
namespace webrtc { |
-NtpTime Clock::CurrentNtpTime() const { |
- uint32_t seconds; |
- uint32_t fractions; |
- CurrentNtp(seconds, fractions); |
- return NtpTime(seconds, fractions); |
-} |
- |
class RealTimeClock : public Clock { |
// Return a timestamp in milliseconds relative to some arbitrary source; the |
// source is fixed for this clock. |
@@ -45,13 +38,15 @@ class RealTimeClock : public Clock { |
return rtc::TimeMicros(); |
} |
- // Retrieve an NTP absolute timestamp in seconds and fractions of a second. |
- void CurrentNtp(uint32_t& seconds, uint32_t& fractions) const override { |
+ // Retrieve an NTP absolute timestamp. |
+ NtpTime CurrentNtpTime() const override { |
timeval tv = CurrentTimeVal(); |
double microseconds_in_seconds; |
+ uint32_t seconds; |
Adjust(tv, &seconds, µseconds_in_seconds); |
- fractions = static_cast<uint32_t>( |
+ uint32_t fractions = static_cast<uint32_t>( |
microseconds_in_seconds * kMagicNtpFractionalUnit + 0.5); |
+ return NtpTime(seconds, fractions); |
} |
// Retrieve an NTP absolute timestamp in milliseconds. |
@@ -247,11 +242,12 @@ int64_t SimulatedClock::TimeInMicroseconds() const { |
return time_us_; |
} |
-void SimulatedClock::CurrentNtp(uint32_t& seconds, uint32_t& fractions) const { |
+NtpTime SimulatedClock::CurrentNtpTime() const { |
int64_t now_ms = TimeInMilliseconds(); |
- seconds = (now_ms / 1000) + kNtpJan1970; |
- fractions = |
+ uint32_t seconds = (now_ms / 1000) + kNtpJan1970; |
+ uint32_t fractions = |
static_cast<uint32_t>((now_ms % 1000) * kMagicNtpFractionalUnit / 1000); |
+ return NtpTime(seconds, fractions); |
} |
int64_t SimulatedClock::CurrentNtpInMilliseconds() const { |