Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Unified Diff: webrtc/system_wrappers/source/clock.cc

Issue 2733823002: Replace Clock::CurrentNtp with Clock::CurrentNtpTime (Closed)
Patch Set: Remove CurrentNtp instead of deprecate Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/system_wrappers/include/clock.h ('k') | webrtc/test/drifting_clock.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, &microseconds_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 {
« no previous file with comments | « webrtc/system_wrappers/include/clock.h ('k') | webrtc/test/drifting_clock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698