Migrate RemoteNtpTimeEstimator to more precise time representations
Bug: webrtc:13757 Change-Id: I880ab3cc6e4f72da587ae42ddca051332907c07f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261311 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Emil Lundmark <lndmrk@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36817}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
14d01508be
commit
a154a15c97
@ -95,4 +95,20 @@ TEST(TimeUtilTest, SaturatedToCompactNtp) {
|
||||
5'515, 16);
|
||||
}
|
||||
|
||||
TEST(TimeUtilTest, ToNtpUnits) {
|
||||
EXPECT_EQ(ToNtpUnits(TimeDelta::Zero()), 0);
|
||||
EXPECT_EQ(ToNtpUnits(TimeDelta::Seconds(1)), int64_t{1} << 32);
|
||||
EXPECT_EQ(ToNtpUnits(TimeDelta::Seconds(-1)), -(int64_t{1} << 32));
|
||||
|
||||
EXPECT_EQ(ToNtpUnits(TimeDelta::Millis(500)), int64_t{1} << 31);
|
||||
EXPECT_EQ(ToNtpUnits(TimeDelta::Millis(-1'500)), -(int64_t{3} << 31));
|
||||
|
||||
// Smallest TimeDelta that can be converted without precision loss.
|
||||
EXPECT_EQ(ToNtpUnits(TimeDelta::Micros(15'625)), int64_t{1} << 26);
|
||||
|
||||
// 1 us ~= 4'294.97 NTP units. ToNtpUnits makes no rounding promises.
|
||||
EXPECT_GE(ToNtpUnits(TimeDelta::Micros(1)), 4'294);
|
||||
EXPECT_LE(ToNtpUnits(TimeDelta::Micros(1)), 4'295);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user