Support RtpEncodingParameters::active in voice engine.

R=solenberg@webrtc.org

Review URL: https://codereview.webrtc.org/1943073003 .

Cr-Commit-Position: refs/heads/master@{#12615}
This commit is contained in:
Taylor Brandstetter 2016-05-03 13:50:11 -07:00
parent 1746179c96
commit 55dd70842c
2 changed files with 26 additions and 3 deletions

View File

@ -1216,16 +1216,19 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
return rtp_parameters_;
}
void set_rtp_parameters(const webrtc::RtpParameters& parameters) {
void SetRtpParameters(const webrtc::RtpParameters& parameters) {
RTC_CHECK_EQ(1UL, parameters.encodings.size());
rtp_parameters_ = parameters;
// parameters.encodings[0].active could have changed.
UpdateSendState();
}
private:
void UpdateSendState() {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
RTC_DCHECK(stream_);
if (send_ && source_ != nullptr) {
RTC_DCHECK_EQ(1UL, rtp_parameters_.encodings.size());
if (send_ && source_ != nullptr && rtp_parameters_.encodings[0].active) {
stream_->Start();
} else { // !send || source_ = nullptr
stream_->Stop();
@ -1457,7 +1460,7 @@ bool WebRtcVoiceMediaChannel::SetRtpParameters(
// Codecs are handled at the WebRtcVoiceMediaChannel level.
webrtc::RtpParameters reduced_params = parameters;
reduced_params.codecs.clear();
it->second->set_rtp_parameters(reduced_params);
it->second->SetRtpParameters(reduced_params);
return true;
}

View File

@ -892,6 +892,26 @@ TEST_F(WebRtcVoiceEngineTestFake,
EXPECT_FALSE(channel_->SetRtpParameters(kSsrc1, parameters));
}
// Test that a stream will not be sending if its encoding is made
// inactive through SetRtpParameters.
TEST_F(WebRtcVoiceEngineTestFake, SetRtpParametersEncodingsActive) {
EXPECT_TRUE(SetupSendStream());
SetSend(channel_, true);
EXPECT_TRUE(GetSendStream(kSsrc1).IsSending());
// Get current parameters and change "active" to false.
webrtc::RtpParameters parameters = channel_->GetRtpParameters(kSsrc1);
ASSERT_EQ(1u, parameters.encodings.size());
ASSERT_TRUE(parameters.encodings[0].active);
parameters.encodings[0].active = false;
EXPECT_TRUE(channel_->SetRtpParameters(kSsrc1, parameters));
EXPECT_FALSE(GetSendStream(kSsrc1).IsSending());
// Now change it back to active and verify we resume sending.
parameters.encodings[0].active = true;
EXPECT_TRUE(channel_->SetRtpParameters(kSsrc1, parameters));
EXPECT_TRUE(GetSendStream(kSsrc1).IsSending());
}
// Test that SetRtpParameters configures the correct encoding channel for each
// SSRC.
TEST_F(WebRtcVoiceEngineTestFake, RtpParametersArePerStream) {