From a36f10bd73c36a9db45929e3b3db61b6b77dfbd6 Mon Sep 17 00:00:00 2001 From: Nico Grunbaum Date: Wed, 8 Dec 2021 20:59:31 -0800 Subject: [PATCH] Add a way to set keyframe request method on VideoReceiveStream This patch adds a method for setting the keyframe request method to VideoReceiveStream. This code exists in the version that Mozilla is shipping, with a review https://phabricator.services.mozilla.com/D105773 . Bug: webrtc:13486 Change-Id: I7cc19dec95d6523368d73395319854bd8c2166f7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/240140 Reviewed-by: Stefan Holmer Commit-Queue: Stefan Holmer Cr-Commit-Position: refs/heads/main@{#35793} --- call/video_receive_stream.h | 4 ++++ modules/rtp_rtcp/include/rtp_rtcp_defines.h | 6 ++++++ video/rtp_video_stream_receiver2.cc | 5 ++++- video/rtp_video_stream_receiver2.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index d39762834a..614d5dba76 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -191,6 +191,10 @@ class VideoReceiveStream : public MediaReceiveStream { bool receiver_reference_time_report = false; } rtcp_xr; + // How to request keyframes from a remote sender. Applies only if lntf is + // disabled. + KeyFrameReqMethod keyframe_method = KeyFrameReqMethod::kPliRtcp; + // See LntfConfig for description. LntfConfig lntf; diff --git a/modules/rtp_rtcp/include/rtp_rtcp_defines.h b/modules/rtp_rtcp/include/rtp_rtcp_defines.h index 45cb659b5f..79626255ed 100644 --- a/modules/rtp_rtcp/include/rtp_rtcp_defines.h +++ b/modules/rtp_rtcp/include/rtp_rtcp_defines.h @@ -103,6 +103,12 @@ enum RTCPPacketType : uint32_t { kRtcpXrTargetBitrate = 0x200000 }; +enum class KeyFrameReqMethod : uint8_t { + kNone, // Don't request keyframes. + kPliRtcp, // Request keyframes through Picture Loss Indication. + kFirRtcp // Request keyframes through Full Intra-frame Request. +}; + enum RtxMode { kRtxOff = 0x0, kRtxRetransmitted = 0x1, // Only send retransmissions over RTX. diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index 3a3e89572e..7000f6b6bc 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -242,6 +242,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( config_.rtp.local_ssrc)), complete_frame_callback_(complete_frame_callback), keyframe_request_sender_(keyframe_request_sender), + keyframe_request_method_(config_.rtp.keyframe_method), // TODO(bugs.webrtc.org/10336): Let `rtcp_feedback_buffer_` communicate // directly with `rtp_rtcp_`. rtcp_feedback_buffer_(this, nack_sender, this), @@ -671,8 +672,10 @@ void RtpVideoStreamReceiver2::RequestKeyFrame() { // sender) is relying on LNTF alone. if (keyframe_request_sender_) { keyframe_request_sender_->RequestKeyFrame(); - } else { + } else if (keyframe_request_method_ == KeyFrameReqMethod::kPliRtcp) { rtp_rtcp_->SendPictureLossIndication(); + } else if (keyframe_request_method_ == KeyFrameReqMethod::kFirRtcp) { + rtp_rtcp_->SendFullIntraRequest(); } } diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h index ff9e43fa6d..a361b497ed 100644 --- a/video/rtp_video_stream_receiver2.h +++ b/video/rtp_video_stream_receiver2.h @@ -319,6 +319,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, OnCompleteFrameCallback* complete_frame_callback_; KeyFrameRequestSender* const keyframe_request_sender_; + const KeyFrameReqMethod keyframe_request_method_; RtcpFeedbackBuffer rtcp_feedback_buffer_; const std::unique_ptr nack_module_;