Enable setting the maximum bitrate limit in RtpSender.
This change allows the application to limit the bitrate of the outgoing
audio and video streams at runtime. The API roughly follows the WebRTC
API draft, defining the RTCRtpParameters structure witn exactly one
encoding (simulcast streams are not exposed in the API for now).
(https://www.w3.org/TR/webrtc/#idl-def-RTCRtpParameters)
BUG=
Review URL: https://codereview.webrtc.org/1788583004
Cr-Commit-Position: refs/heads/master@{#12025}
diff --git a/webrtc/api/webrtcsession_unittest.cc b/webrtc/api/webrtcsession_unittest.cc
index c0fff52..77c4854 100644
--- a/webrtc/api/webrtcsession_unittest.cc
+++ b/webrtc/api/webrtcsession_unittest.cc
@@ -3385,6 +3385,25 @@
EXPECT_EQ(1, volume);
}
+TEST_F(WebRtcSessionTest, AudioMaxSendBitrateNotImplemented) {
+ // This test verifies that RtpParameters for audio RtpSenders cannot be
+ // changed.
+ // TODO(skvlad): Update the test after adding support for bitrate limiting in
+ // WebRtcAudioSendStream.
+
+ Init();
+ SendAudioVideoStream1();
+ CreateAndSetRemoteOfferAndLocalAnswer();
+ cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
+ ASSERT_TRUE(channel != NULL);
+ uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
+ webrtc::RtpParameters params = session_->GetAudioRtpParameters(send_ssrc);
+
+ EXPECT_EQ(0, params.encodings.size());
+ params.encodings.push_back(webrtc::RtpEncodingParameters());
+ EXPECT_FALSE(session_->SetAudioRtpParameters(send_ssrc, params));
+}
+
TEST_F(WebRtcSessionTest, SetAudioSend) {
Init();
SendAudioVideoStream1();
@@ -3451,6 +3470,34 @@
EXPECT_TRUE(channel->sinks().begin()->second == NULL);
}
+TEST_F(WebRtcSessionTest, SetVideoMaxSendBitrate) {
+ Init();
+ SendAudioVideoStream1();
+ CreateAndSetRemoteOfferAndLocalAnswer();
+ cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0);
+ ASSERT_TRUE(channel != NULL);
+ uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
+ EXPECT_EQ(-1, channel->max_bps());
+ webrtc::RtpParameters params = session_->GetVideoRtpParameters(send_ssrc);
+ EXPECT_EQ(1, params.encodings.size());
+ EXPECT_EQ(-1, params.encodings[0].max_bitrate_bps);
+ params.encodings[0].max_bitrate_bps = 1000;
+ EXPECT_TRUE(session_->SetVideoRtpParameters(send_ssrc, params));
+
+ // Read back the parameters and verify they have been changed.
+ params = session_->GetVideoRtpParameters(send_ssrc);
+ EXPECT_EQ(1, params.encodings.size());
+ EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
+
+ // Verify that the video channel received the new parameters.
+ params = channel->GetRtpParameters(send_ssrc);
+ EXPECT_EQ(1, params.encodings.size());
+ EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
+
+ // Verify that the global bitrate limit has not been changed.
+ EXPECT_EQ(-1, channel->max_bps());
+}
+
TEST_F(WebRtcSessionTest, SetVideoSend) {
Init();
SendAudioVideoStream1();