Migrate RemoteNtpTimeEstimator to more precise time representations
Reland of https://webrtc-review.googlesource.com/c/src/+/261311 Bug: webrtc:13757 Change-Id: I34a58100b8fadfe3dbea9ffce71829b7670daad8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261726 Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36838}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
bf2d75d86f
commit
edcb25b623
@ -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