Skip to content

Commit

Permalink
[M104] Do not allow simulcast to be turned off using SDP munging
Browse files Browse the repository at this point in the history
This is an error that puts the PC into an inconsistent state, so
causing a crash is the right thing to do.

(cherry picked from commit 3fe8b0d)

Bug: chromium:1341043
Change-Id: Ie1eb89400ad87f0c83634b7073236b07e92ec7ab
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267281
Reviewed-by: Mirko Bonadei <[email protected]>
Reviewed-by: Henrik Boström <[email protected]>
Commit-Queue: Harald Alvestrand <[email protected]>
Cr-Original-Commit-Position: refs/heads/main@{#37391}
No-Presubmit: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267940
Cr-Commit-Position: refs/branch-heads/5112@{#4}
Cr-Branched-From: a976a87-refs/heads/main@{#37168}
  • Loading branch information
Harald Alvestrand authored and WebRTC LUCI CQ committed Jul 6, 2022
1 parent e836f5f commit 56b2087
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pc/rtp_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ void RtpSenderBase::SetSsrc(uint32_t ssrc) {
// we need to copy.
RtpParameters current_parameters =
media_channel_->GetRtpSendParameters(ssrc_);
RTC_DCHECK_GE(current_parameters.encodings.size(),
init_parameters_.encodings.size());
RTC_CHECK_GE(current_parameters.encodings.size(),
init_parameters_.encodings.size());
for (size_t i = 0; i < init_parameters_.encodings.size(); ++i) {
init_parameters_.encodings[i].ssrc =
current_parameters.encodings[i].ssrc;
Expand Down
38 changes: 38 additions & 0 deletions pc/rtp_sender_receiver_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,44 @@ TEST_F(RtpSenderReceiverTest,
DestroyVideoRtpSender();
}

#if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
using RtpSenderReceiverDeathTest = RtpSenderReceiverTest;

TEST_F(RtpSenderReceiverDeathTest,
VideoSenderManualRemoveSimulcastFailsDeathTest) {
AddVideoTrack(false);

std::unique_ptr<MockSetStreamsObserver> set_streams_observer =
std::make_unique<MockSetStreamsObserver>();
video_rtp_sender_ = VideoRtpSender::Create(worker_thread_, video_track_->id(),
set_streams_observer.get());
ASSERT_TRUE(video_rtp_sender_->SetTrack(video_track_.get()));
EXPECT_CALL(*set_streams_observer, OnSetStreams());
video_rtp_sender_->SetStreams({local_stream_->id()});

std::vector<RtpEncodingParameters> init_encodings(2);
init_encodings[0].max_bitrate_bps = 60000;
init_encodings[1].max_bitrate_bps = 120000;
video_rtp_sender_->set_init_send_encodings(init_encodings);

RtpParameters params = video_rtp_sender_->GetParameters();
ASSERT_EQ(2u, params.encodings.size());
EXPECT_EQ(params.encodings[0].max_bitrate_bps, 60000);

// Simulate the setLocalDescription call as if the user used SDP munging
// to disable simulcast.
std::vector<uint32_t> ssrcs;
ssrcs.reserve(2);
for (int i = 0; i < 2; ++i)
ssrcs.push_back(kVideoSsrcSimulcast + i);
cricket::StreamParams stream_params =
cricket::StreamParams::CreateLegacy(kVideoSsrc);
video_media_channel()->AddSendStream(stream_params);
video_rtp_sender_->SetMediaChannel(video_media_channel());
EXPECT_DEATH(video_rtp_sender_->SetSsrc(kVideoSsrcSimulcast), "");
}
#endif

TEST_F(RtpSenderReceiverTest,
VideoSenderMustCallGetParametersBeforeSetParametersBeforeNegotiation) {
video_rtp_sender_ =
Expand Down

0 comments on commit 56b2087

Please sign in to comment.