diff --git a/call/rtp_config.h b/call/rtp_config.h index 96fe15fbb1..8f8d03a3a8 100644 --- a/call/rtp_config.h +++ b/call/rtp_config.h @@ -22,6 +22,7 @@ namespace webrtc { struct RtpPayloadState { int16_t picture_id = -1; uint8_t tl0_pic_idx = 0; + int64_t shared_frame_id = 0; }; // Settings for NACK, see RFC 4585 for details. struct NackConfig { diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc index a7a57705f0..8c627b498b 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc @@ -10,6 +10,7 @@ #include "call/rtp_video_sender.h" +#include #include #include #include @@ -206,6 +207,7 @@ RtpVideoSender::RtpVideoSender( auto it = states.find(ssrc); if (it != states.end()) { state = &it->second; + shared_frame_id_ = std::max(shared_frame_id_, state->shared_frame_id); } params_.push_back(RtpPayloadParams(ssrc, state)); } @@ -541,6 +543,7 @@ std::map RtpVideoSender::GetRtpPayloadStates() std::map payload_states; for (const auto& param : params_) { payload_states[param.ssrc()] = param.state(); + payload_states[param.ssrc()].shared_frame_id = shared_frame_id_; } return payload_states; } diff --git a/call/rtp_video_sender.h b/call/rtp_video_sender.h index 02feff27d9..1735dc751a 100644 --- a/call/rtp_video_sender.h +++ b/call/rtp_video_sender.h @@ -118,6 +118,11 @@ class RtpVideoSender : public RtpVideoSenderInterface { const RtpConfig rtp_config_; RtpTransportControllerSendInterface* const transport_; + // When using the generic descriptor we want all simulcast streams to share + // one frame id space (so that the SFU can switch stream without having to + // rewrite the frame id), therefore |shared_frame_id| has to live in a place + // where we are aware of all the different streams. + int64_t shared_frame_id_ = 0; std::vector params_ RTC_GUARDED_BY(crit_); RTC_DISALLOW_COPY_AND_ASSIGN(RtpVideoSender); diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc index 45f8149bba..b819e696d9 100644 --- a/call/rtp_video_sender_unittest.cc +++ b/call/rtp_video_sender_unittest.cc @@ -270,12 +270,16 @@ TEST(RtpVideoSenderTest, CreateWithNoPreviousStates) { } TEST(RtpVideoSenderTest, CreateWithPreviousStates) { + const int64_t kState1SharedFrameId = 123; + const int64_t kState2SharedFrameId = 234; RtpPayloadState state1; state1.picture_id = kInitialPictureId1; state1.tl0_pic_idx = kInitialTl0PicIdx1; + state1.shared_frame_id = kState1SharedFrameId; RtpPayloadState state2; state2.picture_id = kInitialPictureId2; state2.tl0_pic_idx = kInitialTl0PicIdx2; + state2.shared_frame_id = kState2SharedFrameId; std::map states = {{kSsrc1, state1}, {kSsrc2, state2}}; @@ -289,5 +293,7 @@ TEST(RtpVideoSenderTest, CreateWithPreviousStates) { EXPECT_EQ(kInitialTl0PicIdx1, initial_states[kSsrc1].tl0_pic_idx); EXPECT_EQ(kInitialPictureId2, initial_states[kSsrc2].picture_id); EXPECT_EQ(kInitialTl0PicIdx2, initial_states[kSsrc2].tl0_pic_idx); + EXPECT_EQ(kState2SharedFrameId, initial_states[kSsrc1].shared_frame_id); + EXPECT_EQ(kState2SharedFrameId, initial_states[kSsrc2].shared_frame_id); } } // namespace webrtc