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

Unified Diff: webrtc/system_wrappers/include/ntp_time.h

Issue 2393723004: replace NtpTime->Clock with Clock->NtpTime dependency (Closed)
Patch Set: . Created 3 years, 10 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/system_wrappers/source/clock.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/system_wrappers/include/ntp_time.h
diff --git a/webrtc/system_wrappers/include/ntp_time.h b/webrtc/system_wrappers/include/ntp_time.h
index 9c554197b0ee9ecbe1da9e39d86bb4f7007a6a56..ecb303ae18f89a7063e9ae4b140eef67c7330a45 100644
--- a/webrtc/system_wrappers/include/ntp_time.h
+++ b/webrtc/system_wrappers/include/ntp_time.h
@@ -12,25 +12,17 @@
#include <stdint.h>
-#include "webrtc/system_wrappers/include/clock.h"
-
namespace webrtc {
class NtpTime {
public:
NtpTime() : seconds_(0), fractions_(0) {}
- explicit NtpTime(const Clock& clock) {
- clock.CurrentNtp(seconds_, fractions_);
- }
NtpTime(uint32_t seconds, uint32_t fractions)
: seconds_(seconds), fractions_(fractions) {}
NtpTime(const NtpTime&) = default;
NtpTime& operator=(const NtpTime&) = default;
- void SetCurrent(const Clock& clock) {
- clock.CurrentNtp(seconds_, fractions_);
- }
void Set(uint32_t seconds, uint32_t fractions) {
seconds_ = seconds;
fractions_ = fractions;
@@ -40,8 +32,12 @@ class NtpTime {
fractions_ = 0;
}
- int64_t ToMs() const { return Clock::NtpToMs(seconds_, fractions_); }
-
+ int64_t ToMs() const {
+ static constexpr double kNtpFracPerMs = 4.294967296E6; // 2^32 / 1000.
+ const double frac_ms = static_cast<double>(fractions_) / kNtpFracPerMs;
+ return 1000 * static_cast<int64_t>(seconds_) +
+ static_cast<int64_t>(frac_ms + 0.5);
+ }
// NTP standard (RFC1305, section 3.1) explicitly state value 0/0 is invalid.
bool Valid() const { return !(seconds_ == 0 && fractions_ == 0); }
« no previous file with comments | « webrtc/system_wrappers/include/clock.h ('k') | webrtc/system_wrappers/source/clock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698