Use monotonic clock to derive NTP timestamps in RTCP module
Use helper TimeMicrosToNtp() on clock TimeInMicroseconds() instead of CurrentNtpTime() and CurrentNtpTimeMillis() Also update TimeMicrosToNtp() to not introduce fractional in milliseconds offset. Expose that offset in time_utils.h Add test showing indended behavior. Bug: webrtc:9919 Change-Id: I8b019e11ae5b79d0b8ba113a84066b0369cd2575 Reviewed-on: https://webrtc-review.googlesource.com/c/107889 Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25391}
This commit is contained in:
committed by
Commit Bot
parent
fdee701fa8
commit
88c2c50dbd
@ -208,7 +208,8 @@ TEST_F(RtcpReceiverTest, InjectSrPacketCalculatesRTT) {
|
||||
EXPECT_EQ(
|
||||
-1, rtcp_receiver_.RTT(kSenderSsrc, &rtt_ms, nullptr, nullptr, nullptr));
|
||||
|
||||
uint32_t sent_ntp = CompactNtp(system_clock_.CurrentNtpTime());
|
||||
uint32_t sent_ntp =
|
||||
CompactNtp(TimeMicrosToNtp(system_clock_.TimeInMicroseconds()));
|
||||
system_clock_.AdvanceTimeMilliseconds(kRttMs + kDelayMs);
|
||||
|
||||
rtcp::SenderReport sr;
|
||||
@ -238,7 +239,8 @@ TEST_F(RtcpReceiverTest, InjectSrPacketCalculatesNegativeRTTAsOne) {
|
||||
EXPECT_EQ(
|
||||
-1, rtcp_receiver_.RTT(kSenderSsrc, &rtt_ms, nullptr, nullptr, nullptr));
|
||||
|
||||
uint32_t sent_ntp = CompactNtp(system_clock_.CurrentNtpTime());
|
||||
uint32_t sent_ntp =
|
||||
CompactNtp(TimeMicrosToNtp(system_clock_.TimeInMicroseconds()));
|
||||
system_clock_.AdvanceTimeMilliseconds(kRttMs + kDelayMs);
|
||||
|
||||
rtcp::SenderReport sr;
|
||||
@ -266,7 +268,8 @@ TEST_F(
|
||||
const uint32_t kDelayNtp = 123000;
|
||||
const int64_t kDelayMs = CompactNtpRttToMs(kDelayNtp);
|
||||
|
||||
uint32_t sent_ntp = CompactNtp(system_clock_.CurrentNtpTime());
|
||||
uint32_t sent_ntp =
|
||||
CompactNtp(TimeMicrosToNtp(system_clock_.TimeInMicroseconds()));
|
||||
system_clock_.AdvanceTimeMilliseconds(kRttMs + kDelayMs);
|
||||
|
||||
rtcp::SenderReport sr;
|
||||
@ -737,7 +740,8 @@ TEST_F(RtcpReceiverTest, InjectExtendedReportsDlrrPacketWithSubBlock) {
|
||||
|
||||
InjectRtcpPacket(xr);
|
||||
|
||||
uint32_t compact_ntp_now = CompactNtp(system_clock_.CurrentNtpTime());
|
||||
uint32_t compact_ntp_now =
|
||||
CompactNtp(TimeMicrosToNtp(system_clock_.TimeInMicroseconds()));
|
||||
EXPECT_TRUE(rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms));
|
||||
uint32_t rtt_ntp = compact_ntp_now - kDelay - kLastRR;
|
||||
EXPECT_NEAR(CompactNtpRttToMs(rtt_ntp), rtt_ms, 1);
|
||||
@ -756,7 +760,8 @@ TEST_F(RtcpReceiverTest, InjectExtendedReportsDlrrPacketWithMultipleSubBlocks) {
|
||||
|
||||
InjectRtcpPacket(xr);
|
||||
|
||||
uint32_t compact_ntp_now = CompactNtp(system_clock_.CurrentNtpTime());
|
||||
uint32_t compact_ntp_now =
|
||||
CompactNtp(TimeMicrosToNtp(system_clock_.TimeInMicroseconds()));
|
||||
int64_t rtt_ms = 0;
|
||||
EXPECT_TRUE(rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms));
|
||||
uint32_t rtt_ntp = compact_ntp_now - kDelay - kLastRR;
|
||||
@ -818,7 +823,7 @@ TEST_F(RtcpReceiverTest, RttCalculatedAfterExtendedReportsDlrr) {
|
||||
const uint32_t kDelayNtp = rand.Rand(0, 0x7fffffff);
|
||||
const int64_t kDelayMs = CompactNtpRttToMs(kDelayNtp);
|
||||
rtcp_receiver_.SetRtcpXrRrtrStatus(true);
|
||||
NtpTime now = system_clock_.CurrentNtpTime();
|
||||
NtpTime now = TimeMicrosToNtp(system_clock_.TimeInMicroseconds());
|
||||
uint32_t sent_ntp = CompactNtp(now);
|
||||
system_clock_.AdvanceTimeMilliseconds(kRttMs + kDelayMs);
|
||||
|
||||
@ -838,7 +843,7 @@ TEST_F(RtcpReceiverTest, XrDlrrCalculatesNegativeRttAsOne) {
|
||||
const int64_t kRttMs = rand.Rand(-3600 * 1000, -1);
|
||||
const uint32_t kDelayNtp = rand.Rand(0, 0x7fffffff);
|
||||
const int64_t kDelayMs = CompactNtpRttToMs(kDelayNtp);
|
||||
NtpTime now = system_clock_.CurrentNtpTime();
|
||||
NtpTime now = TimeMicrosToNtp(system_clock_.TimeInMicroseconds());
|
||||
uint32_t sent_ntp = CompactNtp(now);
|
||||
system_clock_.AdvanceTimeMilliseconds(kRttMs + kDelayMs);
|
||||
rtcp_receiver_.SetRtcpXrRrtrStatus(true);
|
||||
|
||||
Reference in New Issue
Block a user