Removed calls to VoE::SetPlayout() from WebRTCVoiceEngine.
This is part of rewriting the ConferenceMixer and OutputMixer. Calls are instead routed through AudioReceiveStream::Start/Stop. NOTRY=True Review-Url: https://codereview.webrtc.org/2206223002 Cr-Commit-Position: refs/heads/master@{#13636}
This commit is contained in:
parent
cb56065c62
commit
84ef615a5d
@ -154,10 +154,17 @@ AudioReceiveStream::~AudioReceiveStream() {
|
||||
|
||||
void AudioReceiveStream::Start() {
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
ScopedVoEInterface<VoEBase> base(voice_engine());
|
||||
int error = base->StartPlayout(config_.voe_channel_id);
|
||||
if (error != 0) {
|
||||
LOG(LS_ERROR) << "AudioReceiveStream::Start failed with error: " << error;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioReceiveStream::Stop() {
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
ScopedVoEInterface<VoEBase> base(voice_engine());
|
||||
base->StopPlayout(config_.voe_channel_id);
|
||||
}
|
||||
|
||||
webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
|
||||
|
||||
@ -319,10 +319,7 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
SetRecvRtpHeaderExtensions(params.extensions));
|
||||
}
|
||||
|
||||
virtual bool SetPlayout(bool playout) {
|
||||
set_playout(playout);
|
||||
return true;
|
||||
}
|
||||
virtual void SetPlayout(bool playout) { set_playout(playout); }
|
||||
virtual void SetSend(bool send) { set_sending(send); }
|
||||
virtual bool SetAudioSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
|
||||
@ -908,7 +908,7 @@ class VoiceMediaChannel : public MediaChannel {
|
||||
uint32_t ssrc,
|
||||
const webrtc::RtpParameters& parameters) = 0;
|
||||
// Starts or stops playout of received audio.
|
||||
virtual bool SetPlayout(bool playout) = 0;
|
||||
virtual void SetPlayout(bool playout) = 0;
|
||||
// Starts or stops sending (and potentially capture) of local audio.
|
||||
virtual void SetSend(bool send) = 0;
|
||||
// Configure stream for sending.
|
||||
|
||||
@ -79,11 +79,12 @@ class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream {
|
||||
bool DeliverRtp(const uint8_t* packet,
|
||||
size_t length,
|
||||
const webrtc::PacketTime& packet_time);
|
||||
bool started() const { return started_; }
|
||||
|
||||
private:
|
||||
// webrtc::AudioReceiveStream implementation.
|
||||
void Start() override {}
|
||||
void Stop() override {}
|
||||
void Start() override { started_ = true; }
|
||||
void Stop() override { started_ = false; }
|
||||
|
||||
webrtc::AudioReceiveStream::Stats GetStats() const override;
|
||||
void SetSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) override;
|
||||
@ -95,6 +96,7 @@ class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream {
|
||||
std::unique_ptr<webrtc::AudioSinkInterface> sink_;
|
||||
float gain_ = 1.0f;
|
||||
rtc::Buffer last_packet_;
|
||||
bool started_ = false;
|
||||
};
|
||||
|
||||
class FakeVideoSendStream final : public webrtc::VideoSendStream,
|
||||
|
||||
@ -128,7 +128,6 @@ class FakeWebRtcVoiceEngine
|
||||
Channel() {
|
||||
memset(&send_codec, 0, sizeof(send_codec));
|
||||
}
|
||||
bool playout = false;
|
||||
bool vad = false;
|
||||
bool codec_fec = false;
|
||||
int max_encoding_bandwidth = 0;
|
||||
@ -154,9 +153,6 @@ class FakeWebRtcVoiceEngine
|
||||
bool IsInited() const { return inited_; }
|
||||
int GetLastChannel() const { return last_channel_; }
|
||||
int GetNumChannels() const { return static_cast<int>(channels_.size()); }
|
||||
bool GetPlayout(int channel) {
|
||||
return channels_[channel]->playout;
|
||||
}
|
||||
bool GetVAD(int channel) {
|
||||
return channels_[channel]->vad;
|
||||
}
|
||||
@ -174,9 +170,6 @@ class FakeWebRtcVoiceEngine
|
||||
channels_[channel]->cn16_type :
|
||||
channels_[channel]->cn8_type;
|
||||
}
|
||||
void set_playout_fail_channel(int channel) {
|
||||
playout_fail_channel_ = channel;
|
||||
}
|
||||
void set_fail_create_channel(bool fail_create_channel) {
|
||||
fail_create_channel_ = fail_create_channel;
|
||||
}
|
||||
@ -245,24 +238,10 @@ class FakeWebRtcVoiceEngine
|
||||
return 0;
|
||||
}
|
||||
WEBRTC_STUB(StartReceive, (int channel));
|
||||
WEBRTC_FUNC(StartPlayout, (int channel)) {
|
||||
if (playout_fail_channel_ != channel) {
|
||||
WEBRTC_CHECK_CHANNEL(channel);
|
||||
channels_[channel]->playout = true;
|
||||
return 0;
|
||||
} else {
|
||||
// When playout_fail_channel_ == channel, fail the StartPlayout on this
|
||||
// channel.
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
WEBRTC_STUB(StartPlayout, (int channel));
|
||||
WEBRTC_STUB(StartSend, (int channel));
|
||||
WEBRTC_STUB(StopReceive, (int channel));
|
||||
WEBRTC_FUNC(StopPlayout, (int channel)) {
|
||||
WEBRTC_CHECK_CHANNEL(channel);
|
||||
channels_[channel]->playout = false;
|
||||
return 0;
|
||||
}
|
||||
WEBRTC_STUB(StopPlayout, (int channel));
|
||||
WEBRTC_STUB(StopSend, (int channel));
|
||||
WEBRTC_STUB(GetVersion, (char version[1024]));
|
||||
WEBRTC_STUB(LastError, ());
|
||||
@ -300,8 +279,6 @@ class FakeWebRtcVoiceEngine
|
||||
const webrtc::CodecInst& codec)) {
|
||||
WEBRTC_CHECK_CHANNEL(channel);
|
||||
Channel* ch = channels_[channel];
|
||||
if (ch->playout)
|
||||
return -1; // Channel is in use.
|
||||
// Check if something else already has this slot.
|
||||
if (codec.pltype != -1) {
|
||||
for (std::vector<webrtc::CodecInst>::iterator it =
|
||||
@ -583,7 +560,6 @@ class FakeWebRtcVoiceEngine
|
||||
webrtc::NsModes ns_mode_ = webrtc::kNsDefault;
|
||||
webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault;
|
||||
webrtc::AgcConfig agc_config_;
|
||||
int playout_fail_channel_ = -1;
|
||||
FakeAudioProcessing audio_processing_;
|
||||
};
|
||||
|
||||
|
||||
@ -1363,6 +1363,18 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
|
||||
stream_->SetGain(volume);
|
||||
}
|
||||
|
||||
void SetPlayout(bool playout) {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
RTC_DCHECK(stream_);
|
||||
if (playout) {
|
||||
LOG(LS_INFO) << "Starting playout for channel #" << channel();
|
||||
stream_->Start();
|
||||
} else {
|
||||
LOG(LS_INFO) << "Stopping playout for channel #" << channel();
|
||||
stream_->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void RecreateAudioReceiveStream(
|
||||
uint32_t local_ssrc,
|
||||
@ -1642,7 +1654,7 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs(
|
||||
if (playout_) {
|
||||
// Receive codecs can not be changed while playing. So we temporarily
|
||||
// pause playout.
|
||||
PausePlayout();
|
||||
ChangePlayout(false);
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
@ -1670,7 +1682,7 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs(
|
||||
}
|
||||
|
||||
if (desired_playout_ && !playout_) {
|
||||
ResumePlayout();
|
||||
ChangePlayout(desired_playout_);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -1925,35 +1937,22 @@ bool WebRtcVoiceMediaChannel::SetSendCodec(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRtcVoiceMediaChannel::SetPlayout(bool playout) {
|
||||
void WebRtcVoiceMediaChannel::SetPlayout(bool playout) {
|
||||
desired_playout_ = playout;
|
||||
return ChangePlayout(desired_playout_);
|
||||
}
|
||||
|
||||
bool WebRtcVoiceMediaChannel::PausePlayout() {
|
||||
return ChangePlayout(false);
|
||||
}
|
||||
|
||||
bool WebRtcVoiceMediaChannel::ResumePlayout() {
|
||||
return ChangePlayout(desired_playout_);
|
||||
}
|
||||
|
||||
bool WebRtcVoiceMediaChannel::ChangePlayout(bool playout) {
|
||||
void WebRtcVoiceMediaChannel::ChangePlayout(bool playout) {
|
||||
TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::ChangePlayout");
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
if (playout_ == playout) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& ch : recv_streams_) {
|
||||
if (!SetPlayout(ch.second->channel(), playout)) {
|
||||
LOG(LS_ERROR) << "SetPlayout " << playout << " on channel "
|
||||
<< ch.second->channel() << " failed";
|
||||
return false;
|
||||
}
|
||||
for (const auto& kv : recv_streams_) {
|
||||
kv.second->SetPlayout(playout);
|
||||
}
|
||||
playout_ = playout;
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRtcVoiceMediaChannel::SetSend(bool send) {
|
||||
@ -2180,7 +2179,7 @@ bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
|
||||
sp.sync_label, recv_rtp_extensions_,
|
||||
call_, this,
|
||||
engine()->decoder_factory_)));
|
||||
SetPlayout(channel, playout_);
|
||||
recv_streams_[ssrc]->SetPlayout(playout_);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2614,20 +2613,6 @@ int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool WebRtcVoiceMediaChannel::SetPlayout(int channel, bool playout) {
|
||||
if (playout) {
|
||||
LOG(LS_INFO) << "Starting playout for channel #" << channel;
|
||||
if (engine()->voe()->base()->StartPlayout(channel) == -1) {
|
||||
LOG_RTCERR1(StartPlayout, channel);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LOG(LS_INFO) << "Stopping playout for channel #" << channel;
|
||||
engine()->voe()->base()->StopPlayout(channel);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace cricket
|
||||
|
||||
#endif // HAVE_WEBRTC_VOICE
|
||||
|
||||
@ -177,9 +177,7 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel,
|
||||
uint32_t ssrc,
|
||||
const webrtc::RtpParameters& parameters) override;
|
||||
|
||||
bool SetPlayout(bool playout) override;
|
||||
bool PausePlayout();
|
||||
bool ResumePlayout();
|
||||
void SetPlayout(bool playout) override;
|
||||
void SetSend(bool send) override;
|
||||
bool SetAudioSend(uint32_t ssrc,
|
||||
bool enable,
|
||||
@ -245,8 +243,7 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel,
|
||||
WebRtcVoiceEngine* engine() { return engine_; }
|
||||
int GetLastEngineError() { return engine()->GetLastEngineError(); }
|
||||
int GetOutputLevel(int channel);
|
||||
bool SetPlayout(int channel, bool playout);
|
||||
bool ChangePlayout(bool playout);
|
||||
void ChangePlayout(bool playout);
|
||||
int CreateVoEChannel();
|
||||
bool DeleteVoEChannel(int channel);
|
||||
bool IsDefaultRecvStream(uint32_t ssrc) {
|
||||
|
||||
@ -753,14 +753,13 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) {
|
||||
parameters.codecs.push_back(kIsacCodec);
|
||||
parameters.codecs.push_back(kCn16000Codec);
|
||||
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
|
||||
EXPECT_TRUE(channel_->SetPlayout(true));
|
||||
channel_->SetPlayout(true);
|
||||
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
|
||||
|
||||
// Changing the payload type of a codec should fail.
|
||||
parameters.codecs[0].id = 127;
|
||||
EXPECT_FALSE(channel_->SetRecvParameters(parameters));
|
||||
int channel_num = voe_.GetLastChannel();
|
||||
EXPECT_TRUE(voe_.GetPlayout(channel_num));
|
||||
EXPECT_TRUE(GetRecvStream(kSsrc1).started());
|
||||
}
|
||||
|
||||
// Test that we can add a codec while playing.
|
||||
@ -770,12 +769,11 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) {
|
||||
parameters.codecs.push_back(kIsacCodec);
|
||||
parameters.codecs.push_back(kCn16000Codec);
|
||||
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
|
||||
EXPECT_TRUE(channel_->SetPlayout(true));
|
||||
channel_->SetPlayout(true);
|
||||
|
||||
parameters.codecs.push_back(kOpusCodec);
|
||||
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
|
||||
int channel_num = voe_.GetLastChannel();
|
||||
EXPECT_TRUE(voe_.GetPlayout(channel_num));
|
||||
EXPECT_TRUE(GetRecvStream(kSsrc1).started());
|
||||
webrtc::CodecInst gcodec;
|
||||
EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &gcodec));
|
||||
EXPECT_EQ(kOpusCodec.id, gcodec.pltype);
|
||||
@ -2173,12 +2171,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SendStateWhenStreamsAreRecreated) {
|
||||
// Test that we can create a channel and start playing out on it.
|
||||
TEST_F(WebRtcVoiceEngineTestFake, Playout) {
|
||||
EXPECT_TRUE(SetupRecvStream());
|
||||
int channel_num = voe_.GetLastChannel();
|
||||
EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_));
|
||||
EXPECT_TRUE(channel_->SetPlayout(true));
|
||||
EXPECT_TRUE(voe_.GetPlayout(channel_num));
|
||||
EXPECT_TRUE(channel_->SetPlayout(false));
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num));
|
||||
channel_->SetPlayout(true);
|
||||
EXPECT_TRUE(GetRecvStream(kSsrc1).started());
|
||||
channel_->SetPlayout(false);
|
||||
EXPECT_FALSE(GetRecvStream(kSsrc1).started());
|
||||
}
|
||||
|
||||
// Test that we can add and remove send streams.
|
||||
@ -2332,50 +2329,41 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) {
|
||||
// We can receive on multiple streams while sending one stream.
|
||||
TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) {
|
||||
EXPECT_TRUE(SetupSendStream());
|
||||
int channel_num1 = voe_.GetLastChannel();
|
||||
|
||||
// Start playout without a receive stream.
|
||||
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
|
||||
EXPECT_TRUE(channel_->SetPlayout(true));
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num1));
|
||||
channel_->SetPlayout(true);
|
||||
|
||||
// Adding another stream should enable playout on the new stream only.
|
||||
EXPECT_TRUE(AddRecvStream(kSsrc2));
|
||||
int channel_num2 = voe_.GetLastChannel();
|
||||
SetSend(channel_, true);
|
||||
EXPECT_TRUE(GetSendStream(kSsrc1).IsSending());
|
||||
|
||||
// Make sure only the new stream is played out.
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num1));
|
||||
EXPECT_TRUE(voe_.GetPlayout(channel_num2));
|
||||
EXPECT_TRUE(GetRecvStream(kSsrc2).started());
|
||||
|
||||
// Adding yet another stream should have stream 2 and 3 enabled for playout.
|
||||
EXPECT_TRUE(AddRecvStream(kSsrc3));
|
||||
int channel_num3 = voe_.GetLastChannel();
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num1));
|
||||
EXPECT_TRUE(voe_.GetPlayout(channel_num2));
|
||||
EXPECT_TRUE(voe_.GetPlayout(channel_num3));
|
||||
EXPECT_TRUE(GetRecvStream(kSsrc2).started());
|
||||
EXPECT_TRUE(GetRecvStream(kSsrc3).started());
|
||||
|
||||
// Stop sending.
|
||||
SetSend(channel_, false);
|
||||
EXPECT_FALSE(GetSendStream(kSsrc1).IsSending());
|
||||
|
||||
// Stop playout.
|
||||
EXPECT_TRUE(channel_->SetPlayout(false));
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num1));
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num2));
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num3));
|
||||
channel_->SetPlayout(false);
|
||||
EXPECT_FALSE(GetRecvStream(kSsrc2).started());
|
||||
EXPECT_FALSE(GetRecvStream(kSsrc3).started());
|
||||
|
||||
// Restart playout and make sure only recv streams are played out.
|
||||
EXPECT_TRUE(channel_->SetPlayout(true));
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num1));
|
||||
EXPECT_TRUE(voe_.GetPlayout(channel_num2));
|
||||
EXPECT_TRUE(voe_.GetPlayout(channel_num3));
|
||||
// Restart playout and make sure recv streams are played out.
|
||||
channel_->SetPlayout(true);
|
||||
EXPECT_TRUE(GetRecvStream(kSsrc2).started());
|
||||
EXPECT_TRUE(GetRecvStream(kSsrc3).started());
|
||||
|
||||
// Now remove the recv streams and verify that the send stream doesn't play.
|
||||
// Now remove the recv streams.
|
||||
EXPECT_TRUE(channel_->RemoveRecvStream(3));
|
||||
EXPECT_TRUE(channel_->RemoveRecvStream(2));
|
||||
EXPECT_FALSE(voe_.GetPlayout(channel_num1));
|
||||
}
|
||||
|
||||
// Test that we can create a channel configured for Codian bridges,
|
||||
@ -2741,18 +2729,6 @@ TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) {
|
||||
TestInsertDtmf(kSsrc1, false);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) {
|
||||
EXPECT_TRUE(SetupSendStream());
|
||||
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
|
||||
SetSend(channel_, true);
|
||||
EXPECT_TRUE(AddRecvStream(2));
|
||||
EXPECT_TRUE(AddRecvStream(3));
|
||||
EXPECT_TRUE(channel_->SetPlayout(true));
|
||||
voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1);
|
||||
EXPECT_TRUE(channel_->SetPlayout(false));
|
||||
EXPECT_FALSE(channel_->SetPlayout(true));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) {
|
||||
EXPECT_TRUE(SetupSendStream());
|
||||
EXPECT_CALL(adm_,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user