From f3e464071c9134f48c40fec33b4373a29eba9b33 Mon Sep 17 00:00:00 2001 From: Dan Minor Date: Fri, 20 Dec 2019 20:53:19 +0000 Subject: [PATCH] Bug 1595479 - Add RtcpEventObserver to RtcpReceiver; r=ng Differential Revision: https://phabricator.services.mozilla.com/D57858 --HG-- extra : moz-landing-system : lando --- .../trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h | 3 +++ .../modules/rtp_rtcp/include/rtp_rtcp_defines.h | 8 ++++++++ .../webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc | 12 ++++++++++++ .../webrtc/modules/rtp_rtcp/source/rtcp_receiver.h | 2 ++ .../webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 1 + 5 files changed, 26 insertions(+) diff --git a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h index 779e9062b15b..582968dfe44e 100644 --- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h +++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp.h @@ -68,6 +68,9 @@ class RtpRtcp : public Module { // stream. RtcpBandwidthObserver* bandwidth_callback = nullptr; + // Called when we receive a RTCP bye or timeout + RtcpEventObserver* event_callback = nullptr; + TransportFeedbackObserver* transport_feedback_callback = nullptr; VideoBitrateAllocationObserver* bitrate_allocation_observer = nullptr; RtcpRttStats* rtt_stats = nullptr; diff --git a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h index 564ad80036ba..f951a7df049e 100644 --- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h +++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h @@ -286,6 +286,14 @@ class RtcpBandwidthObserver { virtual ~RtcpBandwidthObserver() {} }; +class RtcpEventObserver { + public: + virtual void OnRtcpBye() = 0; + virtual void OnRtcpTimeout() = 0; + + virtual ~RtcpEventObserver() {} +}; + struct PacketFeedback { PacketFeedback(int64_t arrival_time_ms, uint16_t sequence_number) : PacketFeedback(-1, diff --git a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc index b26a87077334..fc5e0ef23045 100644 --- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc +++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_receiver.cc @@ -109,6 +109,7 @@ RTCPReceiver::RTCPReceiver( bool receiver_only, RtcpPacketTypeCounterObserver* packet_type_counter_observer, RtcpBandwidthObserver* rtcp_bandwidth_observer, + RtcpEventObserver* rtcp_event_observer, RtcpIntraFrameObserver* rtcp_intra_frame_observer, TransportFeedbackObserver* transport_feedback_observer, VideoBitrateAllocationObserver* bitrate_allocation_observer, @@ -117,6 +118,7 @@ RTCPReceiver::RTCPReceiver( receiver_only_(receiver_only), rtp_rtcp_(owner), rtcp_bandwidth_observer_(rtcp_bandwidth_observer), + rtcp_event_observer_(rtcp_event_observer), rtcp_intra_frame_observer_(rtcp_intra_frame_observer), transport_feedback_observer_(transport_feedback_observer), bitrate_allocation_observer_(bitrate_allocation_observer), @@ -555,6 +557,9 @@ bool RTCPReceiver::RtcpRrTimeout(int64_t rtcp_interval_ms) { if (clock_->TimeInMilliseconds() > last_received_rb_ms_ + time_out_ms) { // Reset the timer to only trigger one log. last_received_rb_ms_ = 0; + if (rtcp_event_observer_) { + rtcp_event_observer_->OnRtcpTimeout(); + } return true; } return false; @@ -570,6 +575,9 @@ bool RTCPReceiver::RtcpRrSequenceNumberTimeout(int64_t rtcp_interval_ms) { last_increased_sequence_number_ms_ + time_out_ms) { // Reset the timer to only trigger one log. last_increased_sequence_number_ms_ = 0; + if (rtcp_event_observer_) { + rtcp_event_observer_->OnRtcpTimeout(); + } return true; } return false; @@ -674,6 +682,10 @@ void RTCPReceiver::HandleBye(const CommonHeader& rtcp_block) { return; } + if (rtcp_event_observer_) { + rtcp_event_observer_->OnRtcpBye(); + } + // Clear our lists. for (auto& reports_per_receiver : received_report_blocks_) reports_per_receiver.second.erase(bye.sender_ssrc()); diff --git a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h index b9327c38a054..8642fb96bfaa 100644 --- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h +++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtcp_receiver.h @@ -58,6 +58,7 @@ class RTCPReceiver { bool receiver_only, RtcpPacketTypeCounterObserver* packet_type_counter_observer, RtcpBandwidthObserver* rtcp_bandwidth_observer, + RtcpEventObserver* rtcp_event_observer, RtcpIntraFrameObserver* rtcp_intra_frame_observer, TransportFeedbackObserver* transport_feedback_observer, VideoBitrateAllocationObserver* bitrate_allocation_observer, @@ -220,6 +221,7 @@ class RTCPReceiver { rtc::CriticalSection feedbacks_lock_; RtcpBandwidthObserver* const rtcp_bandwidth_observer_; + RtcpEventObserver* const rtcp_event_observer_; RtcpIntraFrameObserver* const rtcp_intra_frame_observer_; TransportFeedbackObserver* const transport_feedback_observer_; VideoBitrateAllocationObserver* const bitrate_allocation_observer_; diff --git a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 0858a86687a9..c2fd334f0c91 100644 --- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -98,6 +98,7 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration) configuration.receiver_only, configuration.rtcp_packet_type_counter_observer, configuration.bandwidth_callback, + configuration.event_callback, configuration.intra_frame_callback, configuration.transport_feedback_callback, configuration.bitrate_allocation_observer,