diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 5b7ff7bb30..9c3f52a651 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -749,21 +749,18 @@ void ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) { 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 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 remote_to_local_clock_offset = ntp_estimator_.EstimateRemoteToLocalClockOffset(); if (remote_to_local_clock_offset.has_value()) { @@ -1033,13 +1030,14 @@ absl::optional ChannelReceive::GetSyncInfo() const { // 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 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 26191c256f..d2e7c2396a 100644 --- a/audio/voip/audio_ingress.cc +++ b/audio/voip/audio_ingress.cc @@ -218,17 +218,18 @@ void AudioIngress::ReceivedRTCPPacket( 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 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 1bf7f4766d..029fc1bea3 100644 --- a/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h +++ b/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h @@ -117,14 +117,6 @@ class MockRtpRtcpInterface : public RtpRtcpInterface { MOCK_METHOD(RtcpMode, RTCP, (), (const, override)); 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, diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 8340a667f3..03d0e31ddb 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -470,21 +470,6 @@ int32_t ModuleRtpRtcpImpl::SetCNAME(absl::string_view c_name) { 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 @@ ModuleRtpRtcpImpl::GetSenderReportStats() const { 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 58e7b9da9f..c8e90c25b0 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h @@ -167,13 +167,6 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl // 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 565e1ea785..8183e4a4e2 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -448,21 +448,6 @@ int32_t ModuleRtpRtcpImpl2::SetCNAME(absl::string_view c_name) { 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 @@ ModuleRtpRtcpImpl2::GetSenderReportStats() const { 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 59a99019f2..e6da54929b 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h @@ -179,13 +179,6 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, // 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 f0c1650daf..c1ec671c9d 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h @@ -158,6 +158,8 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { 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 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { // 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 d7a789515b..c35be9142d 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -404,13 +404,14 @@ void RtpVideoStreamReceiver2::RemoveReceiveCodecs() { absl::optional 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 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 @@ bool RtpVideoStreamReceiver2::DeliverRtcp(const uint8_t* rtcp_packet, // 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 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 remote_to_local_clock_offset = ntp_estimator_.EstimateRemoteToLocalClockOffset(); if (remote_to_local_clock_offset.has_value()) {