diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index 82ad8cfc43..c98c24b495 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -303,9 +303,8 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface { // Must be called on the packet delivery thread. virtual void SetNackHistory(TimeDelta history) = 0; - virtual void SetUlpfecPayloadType(int ulpfec_payload_type) = 0; - - virtual void SetRedPayloadType(int red_payload_type) = 0; + virtual void SetProtectionPayloadTypes(int red_payload_type, + int ulpfec_payload_type) = 0; virtual void SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) = 0; diff --git a/media/engine/fake_webrtc_call.h b/media/engine/fake_webrtc_call.h index 26be7801bf..ad4338bfa1 100644 --- a/media/engine/fake_webrtc_call.h +++ b/media/engine/fake_webrtc_call.h @@ -298,12 +298,10 @@ class FakeVideoReceiveStream final config_.rtp.nack.rtp_history_ms = history.ms(); } - void SetUlpfecPayloadType(int ulpfec_payload_type) override { - config_.rtp.ulpfec_payload_type = ulpfec_payload_type; - } - - void SetRedPayloadType(int red_payload_type) override { + void SetProtectionPayloadTypes(int red_payload_type, + int ulpfec_payload_type) override { config_.rtp.red_payload_type = red_payload_type; + config_.rtp.ulpfec_payload_type = ulpfec_payload_type; } void SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) override { diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc index 774368cec4..24d6bd7a5e 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -2974,17 +2974,12 @@ bool WebRtcVideoChannel::WebRtcVideoReceiveStream::ReconfigureCodecs( const auto& codec = recv_codecs.front(); - if (config_.rtp.red_payload_type != codec.ulpfec.red_payload_type) { - config_.rtp.red_payload_type = codec.ulpfec.red_payload_type; - stream_->SetRedPayloadType(codec.ulpfec.red_payload_type); - } - - // Check and optionally set `ulpfec_payload_type` _after_ checking the - // `red_payload_type` due to encapsulation. See RtpVideoStreamReceiver2 - // for more details. - if (config_.rtp.ulpfec_payload_type != codec.ulpfec.ulpfec_payload_type) { + if (config_.rtp.red_payload_type != codec.ulpfec.red_payload_type || + config_.rtp.ulpfec_payload_type != codec.ulpfec.ulpfec_payload_type) { config_.rtp.ulpfec_payload_type = codec.ulpfec.ulpfec_payload_type; - stream_->SetUlpfecPayloadType(config_.rtp.ulpfec_payload_type); + config_.rtp.red_payload_type = codec.ulpfec.red_payload_type; + stream_->SetProtectionPayloadTypes(config_.rtp.red_payload_type, + config_.rtp.ulpfec_payload_type); } const bool has_lntf = HasLntf(codec.codec); diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index 9809ddfebc..d2ba1b6e86 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -1003,31 +1003,19 @@ int RtpVideoStreamReceiver2::ulpfec_payload_type() const { return ulpfec_receiver_ ? ulpfec_receiver_->ulpfec_payload_type() : -1; } -void RtpVideoStreamReceiver2::set_ulpfec_payload_type(int payload_type) { - RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - ulpfec_receiver_ = MaybeConstructUlpfecReceiver( - config_.rtp.remote_ssrc, red_payload_type_, payload_type, - config_.rtp.extensions, this, clock_); -} - int RtpVideoStreamReceiver2::red_payload_type() const { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); return red_payload_type_; } -void RtpVideoStreamReceiver2::set_red_payload_type(int payload_type) { +void RtpVideoStreamReceiver2::SetProtectionPayloadTypes( + int red_payload_type, + int ulpfec_payload_type) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - RTC_DCHECK_GE(payload_type, -1); - RTC_DCHECK_LE(payload_type, 0x7f); - // TODO(tommi, brandtr): It would be less error prone to require both - // red and ulpfec payload ids to be set at the same time. - - // Stash away the currently configured ulpfec payload id to carry over to the - // potentially new `ulpfec_receiver_` instance. - int ulpfec_type = ulpfec_payload_type(); - red_payload_type_ = payload_type; + RTC_DCHECK(red_payload_type >= -1 && red_payload_type < 0x80); + RTC_DCHECK(ulpfec_payload_type >= -1 && ulpfec_payload_type < 0x80); ulpfec_receiver_ = MaybeConstructUlpfecReceiver( - config_.rtp.remote_ssrc, red_payload_type_, ulpfec_type, + config_.rtp.remote_ssrc, red_payload_type, ulpfec_payload_type, config_.rtp.extensions, this, clock_); } diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h index 8d54d5ceb9..99ae86b4a0 100644 --- a/video/rtp_video_stream_receiver2.h +++ b/video/rtp_video_stream_receiver2.h @@ -201,10 +201,8 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, void SetNackHistory(TimeDelta history); int ulpfec_payload_type() const; - void set_ulpfec_payload_type(int payload_type); - int red_payload_type() const; - void set_red_payload_type(int payload_type); + void SetProtectionPayloadTypes(int red_payload_type, int ulpfec_payload_type); absl::optional LastReceivedPacketMs() const; absl::optional LastReceivedKeyframePacketMs() const; diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index 5da6ea95df..67720898ae 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -551,14 +551,11 @@ void VideoReceiveStream2::SetNackHistory(TimeDelta history) { frame_buffer_->SetMaxWaits(max_wait_for_keyframe, max_wait_for_frame); } -void VideoReceiveStream2::SetUlpfecPayloadType(int payload_type) { +void VideoReceiveStream2::SetProtectionPayloadTypes(int red_payload_type, + int ulpfec_payload_type) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - rtp_video_stream_receiver_.set_ulpfec_payload_type(payload_type); -} - -void VideoReceiveStream2::SetRedPayloadType(int payload_type) { - RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - rtp_video_stream_receiver_.set_red_payload_type(payload_type); + rtp_video_stream_receiver_.SetProtectionPayloadTypes(red_payload_type, + ulpfec_payload_type); } void VideoReceiveStream2::SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) { diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h index 907a7d43cb..a14638c075 100644 --- a/video/video_receive_stream2.h +++ b/video/video_receive_stream2.h @@ -151,8 +151,8 @@ class VideoReceiveStream2 void SetFlexFecProtection(RtpPacketSinkInterface* flexfec_sink) override; void SetLossNotificationEnabled(bool enabled) override; void SetNackHistory(TimeDelta history) override; - void SetUlpfecPayloadType(int payload_type) override; - void SetRedPayloadType(int payload_type) override; + void SetProtectionPayloadTypes(int red_payload_type, + int ulpfec_payload_type) override; void SetRtcpXr(Config::Rtp::RtcpXr rtcp_xr) override; webrtc::VideoReceiveStreamInterface::Stats GetStats() const override;