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}
This commit is contained in:
skvlad
2016-03-16 19:07:43 -07:00
committed by Commit bot
parent df6416aa50
commit dc1c62cd30
20 changed files with 551 additions and 12 deletions

View File

@ -27,6 +27,7 @@
using ::testing::_;
using ::testing::Exactly;
using ::testing::Return;
static const char kStreamLabel1[] = "local_stream_1";
static const char kVideoTrackId[] = "video_1";
@ -52,6 +53,9 @@ class MockAudioProvider : public AudioProviderInterface {
const cricket::AudioOptions& options,
cricket::AudioSource* source));
MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32_t ssrc, double volume));
MOCK_CONST_METHOD1(GetAudioRtpParameters, RtpParameters(uint32_t ssrc));
MOCK_METHOD2(SetAudioRtpParameters,
bool(uint32_t ssrc, const RtpParameters&));
void SetRawAudioSink(uint32_t,
rtc::scoped_ptr<AudioSinkInterface> sink) override {
@ -76,6 +80,10 @@ class MockVideoProvider : public VideoProviderInterface {
void(uint32_t ssrc,
bool enable,
const cricket::VideoOptions* options));
MOCK_CONST_METHOD1(GetVideoRtpParameters, RtpParameters(uint32_t ssrc));
MOCK_METHOD2(SetVideoRtpParameters,
bool(uint32_t ssrc, const RtpParameters&));
};
class FakeVideoTrackSource : public VideoTrackSource {
@ -497,4 +505,30 @@ TEST_F(RtpSenderReceiverTest, VideoSenderSsrcChanged) {
EXPECT_CALL(video_provider_, SetVideoSend(kVideoSsrc2, false, _)).Times(1);
}
TEST_F(RtpSenderReceiverTest, AudioSenderCanSetParameters) {
CreateAudioRtpSender();
EXPECT_CALL(audio_provider_, GetAudioRtpParameters(kAudioSsrc))
.WillOnce(Return(RtpParameters()));
EXPECT_CALL(audio_provider_, SetAudioRtpParameters(kAudioSsrc, _))
.WillOnce(Return(true));
RtpParameters params = audio_rtp_sender_->GetParameters();
EXPECT_TRUE(audio_rtp_sender_->SetParameters(params));
DestroyAudioRtpSender();
}
TEST_F(RtpSenderReceiverTest, VideoSenderCanSetParameters) {
CreateVideoRtpSender();
EXPECT_CALL(video_provider_, GetVideoRtpParameters(kVideoSsrc))
.WillOnce(Return(RtpParameters()));
EXPECT_CALL(video_provider_, SetVideoRtpParameters(kVideoSsrc, _))
.WillOnce(Return(true));
RtpParameters params = video_rtp_sender_->GetParameters();
EXPECT_TRUE(video_rtp_sender_->SetParameters(params));
DestroyVideoRtpSender();
}
} // namespace webrtc