From: Andreas Pehrson Date: Tue, 2 Nov 2021 14:35:00 +0000 Subject: Bug 1729455 - Add to stats the local receive time for receiving video Sender Reports. r=ng Differential Revision: https://phabricator.services.mozilla.com/D125712 Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/99267b6d193fbcb3e4c845c5e80770424d6d06e2 --- call/video_receive_stream.h | 3 ++- modules/rtp_rtcp/source/rtcp_receiver.cc | 6 ++++-- modules/rtp_rtcp/source/rtcp_receiver.h | 3 ++- modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 10 +++++----- modules/rtp_rtcp/source/rtp_rtcp_impl.h | 3 ++- modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 10 +++++----- modules/rtp_rtcp/source/rtp_rtcp_impl2.h | 3 ++- modules/rtp_rtcp/source/rtp_rtcp_interface.h | 5 +++-- video/rtp_video_stream_receiver2.cc | 5 +++-- video/rtp_video_stream_receiver2.h | 3 ++- video/video_receive_stream2.cc | 3 ++- 11 files changed, 32 insertions(+), 22 deletions(-) diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index 01fb08a009..87ee39e142 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -152,10 +152,11 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface { RtcpPacketTypeCounter rtcp_packet_type_counts; absl::optional rtx_rtp_stats; - // Mozilla modification: Init these three. + // Mozilla modification: Init these. uint32_t rtcp_sender_packets_sent = 0; uint32_t rtcp_sender_octets_sent = 0; int64_t rtcp_sender_ntp_timestamp_ms = 0; + int64_t rtcp_sender_remote_ntp_timestamp_ms = 0; // Timing frame info: all important timestamps for a full lifetime of a // single 'timing frame'. diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc index e2ad674012..94de316421 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver.cc +++ b/modules/rtp_rtcp/source/rtcp_receiver.cc @@ -365,11 +365,13 @@ RTCPReceiver::ConsumeReceivedXrReferenceTimeInfo() { void RTCPReceiver::RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const { + int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const { MutexLock lock(&rtcp_receiver_lock_); *packet_count = remote_sender_packet_count_; *octet_count = remote_sender_octet_count_; - *ntp_timestamp_ms = remote_sender_ntp_time_.ToMs(); + *ntp_timestamp_ms = last_received_sr_ntp_.ToMs(); + *remote_ntp_timestamp_ms = remote_sender_ntp_time_.ToMs(); } std::vector RTCPReceiver::GetLatestReportBlockData() const { diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h index 36e117af55..7fc541585c 100644 --- a/modules/rtp_rtcp/source/rtcp_receiver.h +++ b/modules/rtp_rtcp/source/rtcp_receiver.h @@ -120,7 +120,8 @@ class RTCPReceiver final { // Get received sender packet and octet counts void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const; + int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const; absl::optional AverageRtt() const; absl::optional LastRtt() const; diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 18508a4554..cca9a40250 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -499,11 +499,11 @@ void ModuleRtpRtcpImpl::GetSendStreamDataCounters( } // Received RTCP report. -void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo(uint32_t* packet_count, - uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const { - return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count, - ntp_timestamp_ms); +void ModuleRtpRtcpImpl::RemoteRTCPSenderInfo( + uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const { + return rtcp_receiver_.RemoteRTCPSenderInfo( + packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms); } std::vector ModuleRtpRtcpImpl::GetLatestReportBlockData() diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/modules/rtp_rtcp/source/rtp_rtcp_impl.h index 742a69cce3..0b1266a2db 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.h @@ -184,7 +184,8 @@ class ABSL_DEPRECATED("") ModuleRtpRtcpImpl void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const override; + int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const override; // A snapshot of the most recent Report Block with additional data of // interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats. diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc index d7e3c50f82..31e8b71117 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -503,11 +503,11 @@ void ModuleRtpRtcpImpl2::GetSendStreamDataCounters( } // Received RTCP report. -void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo(uint32_t* packet_count, - uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const { - return rtcp_receiver_.RemoteRTCPSenderInfo(packet_count, octet_count, - ntp_timestamp_ms); +void ModuleRtpRtcpImpl2::RemoteRTCPSenderInfo( + uint32_t* packet_count, uint32_t* octet_count, int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const { + return rtcp_receiver_.RemoteRTCPSenderInfo( + packet_count, octet_count, ntp_timestamp_ms, remote_ntp_timestamp_ms); } std::vector ModuleRtpRtcpImpl2::GetLatestReportBlockData() diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h index a9d18ec44a..54ca61a705 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h @@ -196,7 +196,8 @@ class ModuleRtpRtcpImpl2 final : public RtpRtcpInterface, void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const override; + int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const override; // A snapshot of the most recent Report Block with additional data of // interest to statistics. Used to implement RTCRemoteInboundRtpStreamStats. diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h index 2c56dccd2a..f196d11b58 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h +++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h @@ -391,10 +391,11 @@ class RtpRtcpInterface : public RtcpFeedbackSenderInterface { StreamDataCounters* rtx_counters) const = 0; - // Returns packet count, octet count, and timestamp from RTCP sender report. + // Returns packet count, octet count, and timestamps from RTCP sender report. virtual void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const = 0; + int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const = 0; // A snapshot of Report Blocks with additional data of interest to statistics. // Within this list, the sender-source SSRC pair is unique and per-pair the // ReportBlockData represents the latest Report Block that was received for diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index 0a215f79cc..47c31812f3 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -1071,9 +1071,10 @@ absl::optional RtpVideoStreamReceiver2::LastReceivedKeyframePacketMs() // seem to be any support for these stats right now. So, we hack this in. void RtpVideoStreamReceiver2::RemoteRTCPSenderInfo( uint32_t* packet_count, uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const { + int64_t* ntp_timestamp_ms, int64_t* remote_ntp_timestamp_ms) const { RTC_DCHECK_RUN_ON(&worker_task_checker_); - rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms); + rtp_rtcp_->RemoteRTCPSenderInfo(packet_count, octet_count, ntp_timestamp_ms, + remote_ntp_timestamp_ms); } void RtpVideoStreamReceiver2::ManageFrame( diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h index be8bce770f..0e96d7f2cd 100644 --- a/video/rtp_video_stream_receiver2.h +++ b/video/rtp_video_stream_receiver2.h @@ -211,7 +211,8 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, // stats at all, and even on the most recent libwebrtc code there does not // seem to be any support for these stats right now. So, we hack this in. void RemoteRTCPSenderInfo(uint32_t* packet_count, uint32_t* octet_count, - int64_t* ntp_timestamp_ms) const; + int64_t* ntp_timestamp_ms, + int64_t* remote_ntp_timestamp_ms) const; private: // Implements RtpVideoFrameReceiver. diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index 776c49042b..c04b43a1d1 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -576,7 +576,8 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const { // seem to be any support for these stats right now. So, we hack this in. rtp_video_stream_receiver_.RemoteRTCPSenderInfo( &stats.rtcp_sender_packets_sent, &stats.rtcp_sender_octets_sent, - &stats.rtcp_sender_ntp_timestamp_ms); + &stats.rtcp_sender_ntp_timestamp_ms, + &stats.rtcp_sender_remote_ntp_timestamp_ms); return stats; }