From 4228784609afcea28174a673e4a2024b9a75c628 Mon Sep 17 00:00:00 2001 From: danilchap Date: Mon, 20 Feb 2017 06:40:18 -0800 Subject: [PATCH] Replace use Clock::CurrentNtp with CurrentNtpTime BUG=None Review-Url: https://codereview.webrtc.org/2694713002 Cr-Commit-Position: refs/heads/master@{#16721} --- webrtc/modules/rtp_rtcp/source/rtcp_sender.cc | 9 +++------ webrtc/system_wrappers/source/clock_unittest.cc | 8 +++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc index 48a016d70a..776e5bb620 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc @@ -38,6 +38,7 @@ #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h" +#include "webrtc/modules/rtp_rtcp/source/time_util.h" #include "webrtc/modules/rtp_rtcp/source/tmmbr_help.h" namespace webrtc { @@ -906,17 +907,13 @@ bool RTCPSender::AddReportBlock(const FeedbackState& feedback_state, // TODO(sprang): Do we really need separate time stamps for each report? // Get our NTP as late as possible to avoid a race. - uint32_t ntp_secs; - uint32_t ntp_frac; - clock_->CurrentNtp(ntp_secs, ntp_frac); + NtpTime ntp = clock_->CurrentNtpTime(); // Delay since last received report. if ((feedback_state.last_rr_ntp_secs != 0) || (feedback_state.last_rr_ntp_frac != 0)) { // Get the 16 lowest bits of seconds and the 16 highest bits of fractions. - uint32_t now = ntp_secs & 0x0000FFFF; - now <<= 16; - now += (ntp_frac & 0xffff0000) >> 16; + uint32_t now = CompactNtp(ntp); uint32_t receiveTime = feedback_state.last_rr_ntp_secs & 0x0000FFFF; receiveTime <<= 16; diff --git a/webrtc/system_wrappers/source/clock_unittest.cc b/webrtc/system_wrappers/source/clock_unittest.cc index 5010d37c18..dcd932774e 100644 --- a/webrtc/system_wrappers/source/clock_unittest.cc +++ b/webrtc/system_wrappers/source/clock_unittest.cc @@ -16,8 +16,6 @@ namespace webrtc { TEST(ClockTest, NtpTime) { Clock* clock = Clock::GetRealTimeClock(); - uint32_t seconds; - uint32_t fractions; // To ensure the test runs correctly even on a heavily loaded system, do not // compare the seconds/fractions and millisecond values directly. Instead, @@ -26,11 +24,11 @@ TEST(ClockTest, NtpTime) { // The comparison includes 1 ms of margin to account for the rounding error in // the conversion. int64_t milliseconds_lower_bound = clock->CurrentNtpInMilliseconds(); - clock->CurrentNtp(seconds, fractions); + NtpTime ntp_time = clock->CurrentNtpTime(); int64_t milliseconds_upper_bound = clock->CurrentNtpInMilliseconds(); EXPECT_GT(milliseconds_lower_bound / 1000, kNtpJan1970); - EXPECT_LE(milliseconds_lower_bound - 1, Clock::NtpToMs(seconds, fractions)); - EXPECT_GE(milliseconds_upper_bound + 1, Clock::NtpToMs(seconds, fractions)); + EXPECT_LE(milliseconds_lower_bound - 1, ntp_time.ToMs()); + EXPECT_GE(milliseconds_upper_bound + 1, ntp_time.ToMs()); } } // namespace webrtc