Replace use Clock::CurrentNtp with CurrentNtpTime

BUG=None

Review-Url: https://codereview.webrtc.org/2694713002
Cr-Commit-Position: refs/heads/master@{#16721}
This commit is contained in:
danilchap 2017-02-20 06:40:18 -08:00 committed by Commit bot
parent 9bf610ea8c
commit 4228784609
2 changed files with 6 additions and 11 deletions

View File

@ -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;

View File

@ -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