From 6817809e26f7631b1caa3013ee45075b9fef58d3 Mon Sep 17 00:00:00 2001 From: Paul Hallak Date: Thu, 8 Apr 2021 16:00:39 +0200 Subject: [PATCH] Stop trying to compensate for the offset between the different NTP clocks. There is only one NTP clock now. Bug: webrtc:11327 Change-Id: I8c2808cf665f92bd251d68e32062beeffabb0f43 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214132 Commit-Queue: Paul Hallak Reviewed-by: Danil Chapovalov Reviewed-by: Minyue Li Cr-Commit-Position: refs/heads/master@{#33657} --- .../rtp_rtcp/source/remote_ntp_time_estimator.cc | 13 ++----------- .../source/remote_ntp_time_estimator_unittest.cc | 5 +---- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc index 131118f15e..723064eeba 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc @@ -52,8 +52,7 @@ bool RemoteNtpTimeEstimator::UpdateRtcpTimestamp(int64_t rtt, // Update extrapolator with the new arrival time. // The extrapolator assumes the ntp time. - int64_t receiver_arrival_time_ms = - clock_->TimeInMilliseconds() + NtpOffsetMs(); + int64_t receiver_arrival_time_ms = clock_->CurrentNtpInMilliseconds(); int64_t sender_send_time_ms = NtpTime(ntp_secs, ntp_frac).ToMs(); int64_t sender_arrival_time_ms = sender_send_time_ms + rtt / 2; int64_t remote_to_local_clocks_offset = @@ -73,16 +72,7 @@ int64_t RemoteNtpTimeEstimator::Estimate(uint32_t rtp_timestamp) { int64_t receiver_capture_ntp_ms = sender_capture_ntp_ms + remote_to_local_clocks_offset; - // TODO(bugs.webrtc.org/11327): Clock::CurrentNtpInMilliseconds() was - // previously used to calculate the offset between the local and the remote - // clock. However, rtc::TimeMillis() + NtpOffsetMs() is now used as the local - // ntp clock value. To preserve the old behavior of this method, the return - // value is adjusted with the difference between the two local ntp clocks. int64_t now_ms = clock_->TimeInMilliseconds(); - int64_t offset_between_local_ntp_clocks = - clock_->CurrentNtpInMilliseconds() - now_ms - NtpOffsetMs(); - receiver_capture_ntp_ms += offset_between_local_ntp_clocks; - if (now_ms - last_timing_log_ms_ > kTimingLogIntervalMs) { RTC_LOG(LS_INFO) << "RTP timestamp: " << rtp_timestamp << " in NTP clock: " << sender_capture_ntp_ms @@ -90,6 +80,7 @@ int64_t RemoteNtpTimeEstimator::Estimate(uint32_t rtp_timestamp) { << receiver_capture_ntp_ms; last_timing_log_ms_ = now_ms; } + return receiver_capture_ntp_ms; } diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc index 85f08483ea..73c3e9b9b8 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator_unittest.cc @@ -10,7 +10,6 @@ #include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h" #include "absl/types/optional.h" -#include "modules/rtp_rtcp/source/time_util.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/ntp_time.h" #include "test/gmock.h" @@ -43,9 +42,7 @@ class RemoteNtpTimeEstimatorTest : public ::testing::Test { kTimestampOffset; } - NtpTime GetRemoteNtpTime() { - return TimeMicrosToNtp(remote_clock_.TimeInMicroseconds()); - } + NtpTime GetRemoteNtpTime() { return remote_clock_.CurrentNtpTime(); } void SendRtcpSr() { uint32_t rtcp_timestamp = GetRemoteTimestamp();