Restarting channel when swapping AudioReceiveStreams in WebrtcVoE.

BUG=webrtc:6346

Review-Url: https://codereview.webrtc.org/2383143002
Cr-Commit-Position: refs/heads/master@{#14493}
This commit is contained in:
aleloi 2016-10-04 02:45:47 -07:00 committed by Commit bot
parent ebb0b8ec9a
commit 18e0b67815
4 changed files with 20 additions and 0 deletions

View File

@ -144,6 +144,7 @@ AudioReceiveStream::AudioReceiveStream(
AudioReceiveStream::~AudioReceiveStream() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString();
Stop();
channel_proxy_->DeRegisterExternalTransport();
channel_proxy_->ResetCongestionControlObjects();
channel_proxy_->SetRtcEventLog(nullptr);

View File

@ -119,6 +119,7 @@ struct ConfigHelper {
.After(expect_set);
return channel_proxy_;
}));
EXPECT_CALL(voice_engine_, StopPlayout(kChannelId)).WillOnce(Return(0));
stream_config_.voe_channel_id = kChannelId;
stream_config_.rtp.local_ssrc = kLocalSsrc;
stream_config_.rtp.remote_ssrc = kRemoteSsrc;

View File

@ -1424,6 +1424,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
LOG(LS_INFO) << "Stopping playout for channel #" << channel();
stream_->Stop();
}
playout_ = playout;
}
private:
@ -1444,6 +1445,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
RTC_DCHECK(!stream_);
stream_ = call_->CreateAudioReceiveStream(config_);
RTC_CHECK(stream_);
SetPlayout(playout_);
}
rtc::ThreadChecker worker_thread_checker_;
@ -1452,6 +1454,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
// The stream is owned by WebRtcAudioReceiveStream and may be reallocated if
// configuration changes.
webrtc::AudioReceiveStream* stream_ = nullptr;
bool playout_ = false;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioReceiveStream);
};

View File

@ -3340,6 +3340,21 @@ TEST_F(WebRtcVoiceEngineTestFake, OnReadyToSendSignalsNetworkState) {
call_.GetNetworkState(webrtc::MediaType::VIDEO));
}
// Test that playout is still started after changing parameters
TEST_F(WebRtcVoiceEngineTestFake, PreservePlayoutWhenRecreateRecvStream) {
SetupRecvStream();
channel_->SetPlayout(true);
EXPECT_TRUE(GetRecvStream(kSsrc1).started());
// Changing RTP header extensions will recreate the AudioReceiveStream.
cricket::AudioRecvParameters parameters;
parameters.extensions.push_back(
webrtc::RtpExtension(webrtc::RtpExtension::kAudioLevelUri, 12));
channel_->SetRecvParameters(parameters);
EXPECT_TRUE(GetRecvStream(kSsrc1).started());
}
// Tests that the library initializes and shuts down properly.
TEST(WebRtcVoiceEngineTest, StartupShutdown) {
// If the VoiceEngine wants to gather available codecs early, that's fine but