Create an RtpEncodingParameters struct for each simulcast stream

The additional structs are not used anywhere yet.

Bug: webrtc:8653
Change-Id: I8b3891e7f8d92286ffd43ea6010258a5828fa3b8
Reviewed-on: https://webrtc-review.googlesource.com/35007
Commit-Queue: Zach Stein <zstein@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21682}
This commit is contained in:
Zach Stein 2018-01-18 10:01:24 -08:00 committed by Commit Bot
parent d367921eb1
commit 3ca452be48
4 changed files with 42 additions and 14 deletions

View File

@ -19,4 +19,18 @@ webrtc::RtpParameters CreateRtpParametersWithOneEncoding() {
return parameters;
}
webrtc::RtpParameters CreateRtpParametersWithEncodings(StreamParams sp) {
std::vector<uint32_t> primary_ssrcs;
sp.GetPrimarySsrcs(&primary_ssrcs);
size_t encoding_count = primary_ssrcs.size();
std::vector<webrtc::RtpEncodingParameters> encodings(encoding_count);
for (size_t i = 0; i < encodings.size(); ++i) {
encodings[i].ssrc = primary_ssrcs[i];
}
webrtc::RtpParameters parameters;
parameters.encodings = encodings;
return parameters;
}
}; // namespace cricket

View File

@ -160,6 +160,7 @@ class DataEngineInterface {
};
webrtc::RtpParameters CreateRtpParametersWithOneEncoding();
webrtc::RtpParameters CreateRtpParametersWithEncodings(StreamParams sp);
} // namespace cricket

View File

@ -1557,7 +1557,7 @@ WebRtcVideoChannel::WebRtcVideoSendStream::WebRtcVideoSendStream(
stream_(nullptr),
encoder_sink_(nullptr),
parameters_(std::move(config), options, max_bitrate_bps, codec_settings),
rtp_parameters_(CreateRtpParametersWithOneEncoding()),
rtp_parameters_(CreateRtpParametersWithEncodings(sp)),
sending_(false) {
parameters_.config.rtp.max_packet_size = kVideoMtu;
parameters_.conference_mode = send_params.conference_mode;
@ -1814,9 +1814,9 @@ WebRtcVideoChannel::WebRtcVideoSendStream::GetRtpParameters() const {
bool WebRtcVideoChannel::WebRtcVideoSendStream::ValidateRtpParameters(
const webrtc::RtpParameters& rtp_parameters) {
RTC_DCHECK_RUN_ON(&thread_checker_);
if (rtp_parameters.encodings.size() != 1) {
if (rtp_parameters.encodings.size() != rtp_parameters_.encodings.size()) {
RTC_LOG(LS_ERROR)
<< "Attempted to set RtpParameters without exactly one encoding";
<< "Attempted to set RtpParameters with different encoding count";
return false;
}
if (rtp_parameters.encodings[0].ssrc != rtp_parameters_.encodings[0].ssrc) {
@ -1833,8 +1833,7 @@ bool WebRtcVideoChannel::WebRtcVideoSendStream::ValidateRtpParameters(
void WebRtcVideoChannel::WebRtcVideoSendStream::UpdateSendState() {
RTC_DCHECK_RUN_ON(&thread_checker_);
// TODO(deadbeef): Need to handle more than one encoding in the future.
RTC_DCHECK(rtp_parameters_.encodings.size() == 1u);
// TODO(zstein): Handle multiple encodings.
if (sending_ && rtp_parameters_.encodings[0].active) {
RTC_DCHECK(stream_ != nullptr);
stream_->Start();

View File

@ -4364,11 +4364,6 @@ TEST_F(WebRtcVideoChannelTest, CannotSetMaxBitrateForNonexistentStream) {
TEST_F(WebRtcVideoChannelTest,
CannotSetRtpSendParametersWithIncorrectNumberOfEncodings) {
// This test verifies that setting RtpParameters succeeds only if
// the structure contains exactly one encoding.
// TODO(skvlad): Update this test when we start supporting setting parameters
// for each encoding individually.
AddSendStream();
webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
// Two or more encodings should result in failure.
@ -4379,6 +4374,22 @@ TEST_F(WebRtcVideoChannelTest,
EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
}
TEST_F(WebRtcVideoChannelTest,
CannotSetSimulcastRtpSendParametersWithIncorrectNumberOfEncodings) {
std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
StreamParams sp = CreateSimStreamParams("cname", ssrcs);
AddSendStream(sp);
webrtc::RtpParameters parameters = channel_->GetRtpSendParameters(last_ssrc_);
// Additional encodings should result in failure.
parameters.encodings.push_back(webrtc::RtpEncodingParameters());
EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
// Zero encodings should also fail.
parameters.encodings.clear();
EXPECT_FALSE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
}
// Changing the SSRC through RtpParameters is not allowed.
TEST_F(WebRtcVideoChannelTest, CannotSetSsrcInRtpSendParameters) {
AddSendStream();
@ -4464,7 +4475,7 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPrioritySimulcastStreams) {
// Get and set the rtp encoding parameters.
webrtc::RtpParameters parameters =
channel_->GetRtpSendParameters(primary_ssrc);
EXPECT_EQ(1UL, parameters.encodings.size());
EXPECT_EQ(kNumSimulcastStreams, parameters.encodings.size());
EXPECT_EQ(webrtc::kDefaultBitratePriority,
parameters.encodings[0].bitrate_priority);
// Change the value and set it on the VideoChannel.
@ -4474,7 +4485,7 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPrioritySimulcastStreams) {
// Verify that the encoding parameters priority is set on the VideoChannel.
parameters = channel_->GetRtpSendParameters(primary_ssrc);
EXPECT_EQ(1UL, parameters.encodings.size());
EXPECT_EQ(kNumSimulcastStreams, parameters.encodings.size());
EXPECT_EQ(new_bitrate_priority, parameters.encodings[0].bitrate_priority);
// Verify that the new value propagated down to the encoder.
@ -4505,8 +4516,8 @@ TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersPrioritySimulcastStreams) {
// Test that a stream will not be sending if its encoding is made inactive
// through SetRtpSendParameters.
// TODO(deadbeef): Update this test when we start supporting setting parameters
// for each encoding individually.
// TODO(bugs.webrtc.org/8653): Update this test when we support active/inactive
// for individual encodings.
TEST_F(WebRtcVideoChannelTest, SetRtpSendParametersEncodingsActive) {
FakeVideoSendStream* stream = AddSendStream();
EXPECT_TRUE(channel_->SetSend(true));
@ -4845,6 +4856,9 @@ class WebRtcVideoChannelSimulcastTest : public testing::Test {
channel_->SetSend(true);
EXPECT_TRUE(capturer.CaptureFrame());
auto rtp_parameters = channel_->GetRtpSendParameters(kSsrcs3[0]);
EXPECT_EQ(num_configured_streams, rtp_parameters.encodings.size());
std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
ASSERT_EQ(expected_num_streams, video_streams.size());