Delete RtpRtcpInterface::RemoteNtp as redundant to GetSenderReportStats Bug: None Change-Id: I8d5ed723ce29231f805e6819156a16ba275f8e3f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295321 Reviewed-by: Åsa Persson <asapersson@webrtc.org> Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39415}
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 5b7ff7b..9c3f52a 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc
@@ -749,21 +749,18 @@ return; } - uint32_t ntp_secs = 0; - uint32_t ntp_frac = 0; - uint32_t rtp_timestamp = 0; - if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, - /*rtcp_arrival_time_secs=*/nullptr, - /*rtcp_arrival_time_frac=*/nullptr, - &rtp_timestamp) != 0) { + absl::optional<RtpRtcpInterface::SenderReportStats> last_sr = + rtp_rtcp_->GetSenderReportStats(); + if (!last_sr.has_value()) { // Waiting for RTCP. return; } { MutexLock lock(&ts_stats_lock_); - ntp_estimator_.UpdateRtcpTimestamp( - TimeDelta::Millis(rtt), NtpTime(ntp_secs, ntp_frac), rtp_timestamp); + ntp_estimator_.UpdateRtcpTimestamp(TimeDelta::Millis(rtt), + last_sr->last_remote_timestamp, + last_sr->last_remote_rtp_timestamp); absl::optional<int64_t> remote_to_local_clock_offset = ntp_estimator_.EstimateRemoteToLocalClockOffset(); if (remote_to_local_clock_offset.has_value()) { @@ -1033,13 +1030,14 @@ // these locks aren't needed. RTC_DCHECK_RUN_ON(&worker_thread_checker_); Syncable::Info info; - if (rtp_rtcp_->RemoteNTP(&info.capture_time_ntp_secs, - &info.capture_time_ntp_frac, - /*rtcp_arrival_time_secs=*/nullptr, - /*rtcp_arrival_time_frac=*/nullptr, - &info.capture_time_source_clock) != 0) { + absl::optional<RtpRtcpInterface::SenderReportStats> last_sr = + rtp_rtcp_->GetSenderReportStats(); + if (!last_sr.has_value()) { return absl::nullopt; } + info.capture_time_ntp_secs = last_sr->last_remote_timestamp.seconds(); + info.capture_time_ntp_frac = last_sr->last_remote_timestamp.fractions(); + info.capture_time_source_clock = last_sr->last_remote_rtp_timestamp; if (!last_received_rtp_timestamp_ || !last_received_rtp_system_time_ms_) { return absl::nullopt;
diff --git a/audio/voip/audio_ingress.cc b/audio/voip/audio_ingress.cc index 26191c2..d2e7c23 100644 --- a/audio/voip/audio_ingress.cc +++ b/audio/voip/audio_ingress.cc
@@ -218,17 +218,18 @@ return; } - uint32_t ntp_secs = 0, ntp_frac = 0, rtp_timestamp = 0; - if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, nullptr, nullptr, - &rtp_timestamp) != 0) { + absl::optional<RtpRtcpInterface::SenderReportStats> last_sr = + rtp_rtcp_->GetSenderReportStats(); + if (!last_sr.has_value()) { // Waiting for RTCP. return; } { MutexLock lock(&lock_); - ntp_estimator_.UpdateRtcpTimestamp( - TimeDelta::Millis(rtt), NtpTime(ntp_secs, ntp_frac), rtp_timestamp); + ntp_estimator_.UpdateRtcpTimestamp(TimeDelta::Millis(rtt), + last_sr->last_remote_timestamp, + last_sr->last_remote_rtp_timestamp); } }
diff --git a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h index 1bf7f47..029fc1b 100644 --- a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h +++ b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
@@ -118,14 +118,6 @@ MOCK_METHOD(void, SetRTCPStatus, (RtcpMode method), (override)); MOCK_METHOD(int32_t, SetCNAME, (absl::string_view cname), (override)); MOCK_METHOD(int32_t, - RemoteNTP, - (uint32_t * received_ntp_secs, - uint32_t* received_ntp_frac, - uint32_t* rtcp_arrival_time_secs, - uint32_t* rtcp_arrival_time_frac, - uint32_t* rtcp_timestamp), - (const, override)); - MOCK_METHOD(int32_t, RTT, (uint32_t remote_ssrc, int64_t* rtt,
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 8340a66..03d0e31 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -470,21 +470,6 @@ return rtcp_sender_.SetCNAME(c_name); } -int32_t ModuleRtpRtcpImpl::RemoteNTP(uint32_t* received_ntpsecs, - uint32_t* received_ntpfrac, - uint32_t* rtcp_arrival_time_secs, - uint32_t* rtcp_arrival_time_frac, - uint32_t* rtcp_timestamp) const { - return rtcp_receiver_.NTP(received_ntpsecs, received_ntpfrac, - rtcp_arrival_time_secs, rtcp_arrival_time_frac, - rtcp_timestamp, - /*remote_sender_packet_count=*/nullptr, - /*remote_sender_octet_count=*/nullptr, - /*remote_sender_reports_count=*/nullptr) - ? 0 - : -1; -} - // Get RoundTripTime. int32_t ModuleRtpRtcpImpl::RTT(const uint32_t remote_ssrc, int64_t* rtt, @@ -541,7 +526,7 @@ uint32_t arrival_timestamp_frac; if (rtcp_receiver_.NTP(&remote_timestamp_secs, &remote_timestamp_frac, &arrival_timestamp_secs, &arrival_timestamp_frac, - /*rtcp_timestamp=*/nullptr, &stats.packets_sent, + &stats.last_remote_rtp_timestamp, &stats.packets_sent, &stats.bytes_sent, &stats.reports_count)) { stats.last_remote_timestamp.Set(remote_timestamp_secs, remote_timestamp_frac);
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h index 58e7b9d..c8e90c2 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -167,13 +167,6 @@ // Set RTCP CName. int32_t SetCNAME(absl::string_view c_name) override; - // Get remote NTP. - int32_t RemoteNTP(uint32_t* received_ntp_secs, - uint32_t* received_ntp_frac, - uint32_t* rtcp_arrival_time_secs, - uint32_t* rtcp_arrival_time_frac, - uint32_t* rtcp_timestamp) const override; - // Get RoundTripTime. int32_t RTT(uint32_t remote_ssrc, int64_t* rtt,
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc index 565e1ea..8183e4a 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -448,21 +448,6 @@ return rtcp_sender_.SetCNAME(c_name); } -int32_t ModuleRtpRtcpImpl2::RemoteNTP(uint32_t* received_ntpsecs, - uint32_t* received_ntpfrac, - uint32_t* rtcp_arrival_time_secs, - uint32_t* rtcp_arrival_time_frac, - uint32_t* rtcp_timestamp) const { - return rtcp_receiver_.NTP(received_ntpsecs, received_ntpfrac, - rtcp_arrival_time_secs, rtcp_arrival_time_frac, - rtcp_timestamp, - /*remote_sender_packet_count=*/nullptr, - /*remote_sender_octet_count=*/nullptr, - /*remote_sender_reports_count=*/nullptr) - ? 0 - : -1; -} - // TODO(tommi): Check if `avg_rtt_ms`, `min_rtt_ms`, `max_rtt_ms` params are // actually used in practice (some callers ask for it but don't use it). It // could be that only `rtt` is needed and if so, then the fast path could be to @@ -522,7 +507,7 @@ uint32_t arrival_timestamp_frac; if (rtcp_receiver_.NTP(&remote_timestamp_secs, &remote_timestamp_frac, &arrival_timestamp_secs, &arrival_timestamp_frac, - /*rtcp_timestamp=*/nullptr, &stats.packets_sent, + &stats.last_remote_rtp_timestamp, &stats.packets_sent, &stats.bytes_sent, &stats.reports_count)) { stats.last_remote_timestamp.Set(remote_timestamp_secs, remote_timestamp_frac);
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h index 59a9901..e6da549 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -179,13 +179,6 @@ // Set RTCP CName. int32_t SetCNAME(absl::string_view c_name) override; - // Get remote NTP. - int32_t RemoteNTP(uint32_t* received_ntp_secs, - uint32_t* received_ntp_frac, - uint32_t* rtcp_arrival_time_secs, - uint32_t* rtcp_arrival_time_frac, - uint32_t* rtcp_timestamp) const override; - // Get RoundTripTime. int32_t RTT(uint32_t remote_ssrc, int64_t* rtt,
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h index f0c1650..c1ec671 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -158,6 +158,8 @@ NtpTime last_arrival_timestamp; // Received (a.k.a., remote) NTP timestamp for the last received RTCP SR. NtpTime last_remote_timestamp; + // Received (a.k.a., remote) RTP timestamp from the last received RTCP SR. + uint32_t last_remote_rtp_timestamp; // Total number of RTP data packets transmitted by the sender since starting // transmission up until the time this SR packet was generated. The count // should be reset if the sender changes its SSRC identifier. @@ -370,14 +372,6 @@ // Returns -1 on failure else 0. virtual int32_t SetCNAME(absl::string_view cname) = 0; - // Returns remote NTP. - // Returns -1 on failure else 0. - virtual int32_t RemoteNTP(uint32_t* received_ntp_secs, - uint32_t* received_ntp_frac, - uint32_t* rtcp_arrival_time_secs, - uint32_t* rtcp_arrival_time_frac, - uint32_t* rtcp_timestamp) const = 0; - // Returns current RTT (round-trip time) estimate. // Returns -1 on failure else 0. virtual int32_t RTT(uint32_t remote_ssrc,
diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index d7a7895..c35be91 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc
@@ -404,13 +404,14 @@ absl::optional<Syncable::Info> RtpVideoStreamReceiver2::GetSyncInfo() const { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); Syncable::Info info; - if (rtp_rtcp_->RemoteNTP(&info.capture_time_ntp_secs, - &info.capture_time_ntp_frac, - /*rtcp_arrival_time_secs=*/nullptr, - /*rtcp_arrival_time_frac=*/nullptr, - &info.capture_time_source_clock) != 0) { + absl::optional<RtpRtcpInterface::SenderReportStats> last_sr = + rtp_rtcp_->GetSenderReportStats(); + if (!last_sr.has_value()) { return absl::nullopt; } + info.capture_time_ntp_secs = last_sr->last_remote_timestamp.seconds(); + info.capture_time_ntp_frac = last_sr->last_remote_timestamp.fractions(); + info.capture_time_source_clock = last_sr->last_remote_rtp_timestamp; if (!last_received_rtp_timestamp_ || !last_received_rtp_system_time_) { return absl::nullopt; @@ -1140,23 +1141,20 @@ // Waiting for valid rtt. return true; } - uint32_t ntp_secs = 0; - uint32_t ntp_frac = 0; - uint32_t rtp_timestamp = 0; - uint32_t received_ntp_secs = 0; - uint32_t received_ntp_frac = 0; - if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, &received_ntp_secs, - &received_ntp_frac, &rtp_timestamp) != 0) { + + absl::optional<RtpRtcpInterface::SenderReportStats> last_sr = + rtp_rtcp_->GetSenderReportStats(); + if (!last_sr.has_value()) { // Waiting for RTCP. return true; } - NtpTime received_ntp(received_ntp_secs, received_ntp_frac); - int64_t time_since_received = - clock_->CurrentNtpInMilliseconds() - received_ntp.ToMs(); + int64_t time_since_received = clock_->CurrentNtpInMilliseconds() - + last_sr->last_arrival_timestamp.ToMs(); // Don't use old SRs to estimate time. if (time_since_received <= 1) { - ntp_estimator_.UpdateRtcpTimestamp( - TimeDelta::Millis(rtt), NtpTime(ntp_secs, ntp_frac), rtp_timestamp); + ntp_estimator_.UpdateRtcpTimestamp(TimeDelta::Millis(rtt), + last_sr->last_remote_timestamp, + last_sr->last_remote_rtp_timestamp); absl::optional<int64_t> remote_to_local_clock_offset = ntp_estimator_.EstimateRemoteToLocalClockOffset(); if (remote_to_local_clock_offset.has_value()) {