aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--talk/media/webrtc/webrtcvoiceengine.cc318
-rw-r--r--talk/media/webrtc/webrtcvoiceengine.h23
-rw-r--r--talk/media/webrtc/webrtcvoiceengine_unittest.cc488
-rw-r--r--talk/session/media/channel.cc3
4 files changed, 340 insertions, 492 deletions
diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc
index 17acd1be0e..a3ea0f9a74 100644
--- a/talk/media/webrtc/webrtcvoiceengine.cc
+++ b/talk/media/webrtc/webrtcvoiceengine.cc
@@ -374,7 +374,6 @@ AudioOptions GetDefaultEngineOptions() {
options.audio_jitter_buffer_max_packets.Set(50);
options.audio_jitter_buffer_fast_accelerate.Set(false);
options.typing_detection.Set(true);
- options.conference_mode.Set(false);
options.adjust_agc_delta.Set(0);
options.experimental_agc.Set(false);
options.extended_filter_aec.Set(false);
@@ -1401,8 +1400,7 @@ WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
typing_noise_detected_(false),
desired_send_(SEND_NOTHING),
send_(SEND_NOTHING),
- call_(call),
- default_receive_ssrc_(0) {
+ call_(call) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
engine->RegisterChannel(this);
LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel "
@@ -1831,14 +1829,6 @@ bool WebRtcVoiceMediaChannel::SetRecvRtpHeaderExtensions(
return true;
}
- // The default channel may or may not be in |receive_channels_|. Set the rtp
- // header extensions for default channel regardless.
- if (!SetChannelRecvRtpHeaderExtensions(default_send_channel_id(),
- extensions)) {
- return false;
- }
-
- // Loop through all receive channels and enable/disable the extensions.
for (const auto& ch : receive_channels_) {
if (!SetChannelRecvRtpHeaderExtensions(ch.second->channel(), extensions)) {
return false;
@@ -1960,25 +1950,15 @@ bool WebRtcVoiceMediaChannel::ChangePlayout(bool playout) {
return true;
}
- // Change the playout of all channels to the new state.
- bool result = true;
- if (receive_channels_.empty()) {
- // Only toggle the default channel if we don't have any other channels.
- result = SetPlayout(default_send_channel_id(), playout);
- }
for (const auto& ch : receive_channels_) {
if (!SetPlayout(ch.second->channel(), playout)) {
LOG(LS_ERROR) << "SetPlayout " << playout << " on channel "
<< ch.second->channel() << " failed";
- result = false;
- break;
+ return false;
}
}
-
- if (result) {
- playout_ = playout;
- }
- return result;
+ playout_ = playout;
+ return true;
}
bool WebRtcVoiceMediaChannel::SetSend(SendFlags send) {
@@ -2070,9 +2050,6 @@ void WebRtcVoiceMediaChannel::ConfigureSendChannel(int channel) {
// Enable RTCP (for quality stats and feedback messages)
EnableRtcp(channel);
- // Reset all recv codecs; they will be enabled via SetRecvCodecs.
- ResetRecvCodecs(channel);
-
// Set RTP header extension for the new channel.
SetChannelSendRtpHeaderExtensions(channel, send_extensions_);
}
@@ -2143,13 +2120,10 @@ bool WebRtcVoiceMediaChannel::AddSendStream(const StreamParams& sp) {
// order to send receiver reports with this SSRC.
if (IsDefaultChannel(channel)) {
for (const auto& ch : receive_channels_) {
- // Only update the SSRC for non-default channels.
- if (!IsDefaultChannel(ch.second->channel())) {
- if (engine()->voe()->rtp()->SetLocalSSRC(ch.second->channel(),
- sp.first_ssrc()) != 0) {
- LOG_RTCERR2(SetLocalSSRC, ch.second->channel(), sp.first_ssrc());
- return false;
- }
+ if (engine()->voe()->rtp()->SetLocalSSRC(ch.second->channel(),
+ sp.first_ssrc()) != 0) {
+ LOG_RTCERR2(SetLocalSSRC, ch.second->channel(), sp.first_ssrc());
+ return false;
}
}
}
@@ -2214,31 +2188,18 @@ bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
return false;
}
- rtc::CritScope lock(&receive_channels_cs_);
+ // Remove the default receive stream if one had been created with this ssrc;
+ // we'll recreate it then.
+ if (IsDefaultRecvStream(ssrc)) {
+ RemoveRecvStream(ssrc);
+ }
if (receive_channels_.find(ssrc) != receive_channels_.end()) {
LOG(LS_ERROR) << "Stream already exists with ssrc " << ssrc;
return false;
}
-
RTC_DCHECK(receive_stream_params_.find(ssrc) == receive_stream_params_.end());
- // Reuse default channel for recv stream in non-conference mode call
- // when the default channel is not being used.
- webrtc::AudioTransport* audio_transport =
- engine()->voe()->base()->audio_transport();
- if (!InConferenceMode() && default_receive_ssrc_ == 0) {
- LOG(LS_INFO) << "Recv stream " << ssrc << " reuse default channel";
- default_receive_ssrc_ = ssrc;
- WebRtcVoiceChannelRenderer* channel_renderer =
- new WebRtcVoiceChannelRenderer(default_send_channel_id(),
- audio_transport);
- receive_channels_.insert(std::make_pair(ssrc, channel_renderer));
- receive_stream_params_[ssrc] = sp;
- AddAudioReceiveStream(ssrc);
- return SetPlayout(default_send_channel_id(), playout_);
- }
-
// Create a new channel for receiving audio data.
int channel = engine()->CreateMediaVoiceChannel();
if (channel == -1) {
@@ -2250,6 +2211,8 @@ bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
return false;
}
+ webrtc::AudioTransport* audio_transport =
+ engine()->voe()->base()->audio_transport();
WebRtcVoiceChannelRenderer* channel_renderer =
new WebRtcVoiceChannelRenderer(channel, audio_transport);
receive_channels_.insert(std::make_pair(ssrc, channel_renderer));
@@ -2292,38 +2255,30 @@ bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) {
<< channel << " is associated with channel #"
<< default_send_channel_id() << ".";
- // Use the same recv payload types as our default channel.
- ResetRecvCodecs(channel);
- if (!recv_codecs_.empty()) {
- for (const auto& codec : recv_codecs_) {
- webrtc::CodecInst voe_codec;
- if (engine()->FindWebRtcCodec(codec, &voe_codec)) {
- voe_codec.pltype = codec.id;
- voe_codec.rate = 0; // Needed to make GetRecPayloadType work for ISAC
- if (engine()->voe()->codec()->GetRecPayloadType(
- default_send_channel_id(), voe_codec) != -1) {
- if (engine()->voe()->codec()->SetRecPayloadType(
- channel, voe_codec) == -1) {
- LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec));
- return false;
- }
- }
+ // Turn off all supported codecs.
+ int ncodecs = engine()->voe()->codec()->NumOfCodecs();
+ for (int i = 0; i < ncodecs; ++i) {
+ webrtc::CodecInst voe_codec;
+ if (engine()->voe()->codec()->GetCodec(i, voe_codec) != -1) {
+ voe_codec.pltype = -1;
+ if (engine()->voe()->codec()->SetRecPayloadType(
+ channel, voe_codec) == -1) {
+ LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec));
+ return false;
}
}
}
- if (InConferenceMode()) {
- // To be in par with the video, default_send_channel_id() is not used for
- // receiving in a conference call.
- if (receive_channels_.empty() && default_receive_ssrc_ == 0 && playout_) {
- // This is the first stream in a multi user meeting. We can now
- // disable playback of the default stream. This since the default
- // stream will probably have received some initial packets before
- // the new stream was added. This will mean that the CN state from
- // the default channel will be mixed in with the other streams
- // throughout the whole meeting, which might be disturbing.
- LOG(LS_INFO) << "Disabling playback on the default voice channel";
- SetPlayout(default_send_channel_id(), false);
+ // Only enable those configured for this channel.
+ for (const auto& codec : recv_codecs_) {
+ webrtc::CodecInst voe_codec;
+ if (engine()->FindWebRtcCodec(codec, &voe_codec)) {
+ voe_codec.pltype = codec.id;
+ if (engine()->voe()->codec()->SetRecPayloadType(
+ channel, voe_codec) == -1) {
+ LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec));
+ return false;
+ }
}
}
@@ -2334,14 +2289,14 @@ bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) {
return false;
}
- return SetPlayout(channel, playout_);
+ SetPlayout(channel, playout_);
+ return true;
}
bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
LOG(LS_INFO) << "RemoveRecvStream: " << ssrc;
- rtc::CritScope lock(&receive_channels_cs_);
ChannelMap::iterator it = receive_channels_.find(ssrc);
if (it == receive_channels_.end()) {
LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc
@@ -2359,42 +2314,14 @@ bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) {
delete it->second;
receive_channels_.erase(it);
- if (ssrc == default_receive_ssrc_) {
- RTC_DCHECK(IsDefaultChannel(channel));
- // Recycle the default channel is for recv stream.
- if (playout_)
- SetPlayout(default_send_channel_id(), false);
-
- default_receive_ssrc_ = 0;
- return true;
+ // Deregister default channel, if that's the one being destroyed.
+ if (IsDefaultRecvStream(ssrc)) {
+ default_recv_ssrc_ = -1;
}
LOG(LS_INFO) << "Removing audio stream " << ssrc
<< " with VoiceEngine channel #" << channel << ".";
- if (!DeleteChannel(channel))
- return false;
-
- bool enable_default_channel_playout = false;
- if (receive_channels_.empty()) {
- // The last stream was removed. We can now enable the default
- // channel for new channels to be played out immediately without
- // waiting for AddStream messages.
- // We do this for both conference mode and non-conference mode.
- // TODO(oja): Does the default channel still have it's CN state?
- enable_default_channel_playout = true;
- }
- if (!InConferenceMode() && receive_channels_.size() == 1 &&
- default_receive_ssrc_ != 0) {
- // Only the default channel is active, enable the playout on default
- // channel.
- enable_default_channel_playout = true;
- }
- if (enable_default_channel_playout && playout_) {
- LOG(LS_INFO) << "Enabling playback on the default voice channel";
- SetPlayout(default_send_channel_id(), true);
- }
-
- return true;
+ return DeleteChannel(channel);
}
bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc,
@@ -2411,10 +2338,11 @@ bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc,
return true;
}
- if (renderer)
+ if (renderer) {
it->second->Start(renderer);
- else
+ } else {
it->second->Stop();
+ }
return true;
}
@@ -2422,8 +2350,6 @@ bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc,
bool WebRtcVoiceMediaChannel::GetActiveStreams(
AudioInfo::StreamList* actives) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- // In conference mode, the default channel should not be in
- // |receive_channels_|.
actives->clear();
for (const auto& ch : receive_channels_) {
int level = GetOutputLevel(ch.second->channel());
@@ -2436,8 +2362,7 @@ bool WebRtcVoiceMediaChannel::GetActiveStreams(
int WebRtcVoiceMediaChannel::GetOutputLevel() {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- // return the highest output level of all streams
- int highest = GetOutputLevel(default_send_channel_id());
+ int highest = 0;
for (const auto& ch : receive_channels_) {
highest = std::max(GetOutputLevel(ch.second->channel()), highest);
}
@@ -2471,35 +2396,26 @@ void WebRtcVoiceMediaChannel::SetTypingDetectionParameters(int time_window,
bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- rtc::CritScope lock(&receive_channels_cs_);
- // Collect the channels to scale the output volume.
- std::vector<int> channels;
- if (0 == ssrc) { // Collect all channels, including the default one.
- // Default channel is not in receive_channels_ if it is not being used for
- // playout.
- if (default_receive_ssrc_ == 0)
- channels.push_back(default_send_channel_id());
- for (const auto& ch : receive_channels_) {
- channels.push_back(ch.second->channel());
- }
- } else { // Collect only the channel of the specified ssrc.
- int channel = GetReceiveChannelId(ssrc);
- if (-1 == channel) {
- LOG(LS_WARNING) << "Cannot find channel for ssrc:" << ssrc;
- return false;
+ if (ssrc == 0) {
+ default_recv_volume_ = volume;
+ if (default_recv_ssrc_ == -1) {
+ return true;
}
- channels.push_back(channel);
+ ssrc = static_cast<uint32_t>(default_recv_ssrc_);
+ }
+ int ch_id = GetReceiveChannelId(ssrc);
+ if (ch_id < 0) {
+ LOG(LS_WARNING) << "Cannot find channel for ssrc:" << ssrc;
+ return false;
}
- for (int ch_id : channels) {
- if (-1 == engine()->voe()->volume()->SetChannelOutputVolumeScaling(
- ch_id, volume)) {
- LOG_RTCERR2(SetChannelOutputVolumeScaling, ch_id, volume);
- return false;
- }
- LOG(LS_INFO) << "SetOutputVolume to " << volume
- << " for channel " << ch_id << " and ssrc " << ssrc;
+ if (-1 == engine()->voe()->volume()->SetChannelOutputVolumeScaling(ch_id,
+ volume)) {
+ LOG_RTCERR2(SetChannelOutputVolumeScaling, ch_id, volume);
+ return false;
}
+ LOG(LS_INFO) << "SetOutputVolume to " << volume
+ << " for channel " << ch_id << " and ssrc " << ssrc;
return true;
}
@@ -2563,26 +2479,43 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
rtc::Buffer* packet, const rtc::PacketTime& packet_time) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- // Forward packet to Call as well.
+ uint32_t ssrc = 0;
+ if (!GetRtpSsrc(packet->data(), packet->size(), &ssrc)) {
+ return;
+ }
+
+ if (receive_channels_.empty()) {
+ // Create new channel, which will be the default receive channel.
+ StreamParams sp;
+ sp.ssrcs.push_back(ssrc);
+ LOG(LS_INFO) << "Creating default receive stream for SSRC=" << ssrc << ".";
+ if (!AddRecvStream(sp)) {
+ LOG(LS_WARNING) << "Could not create default receive stream.";
+ return;
+ }
+ default_recv_ssrc_ = ssrc;
+ SetOutputVolume(default_recv_ssrc_, default_recv_volume_);
+ }
+
+ // Forward packet to Call. If the SSRC is unknown we'll return after this.
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
packet_time.not_before);
- call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO,
- reinterpret_cast<const uint8_t*>(packet->data()), packet->size(),
- webrtc_packet_time);
-
- // Pick which channel to send this packet to. If this packet doesn't match
- // any multiplexed streams, just send it to the default channel. Otherwise,
- // send it to the specific decoder instance for that stream.
- int which_channel =
- GetReceiveChannelId(ParseSsrc(packet->data(), packet->size(), false));
- if (which_channel == -1) {
- which_channel = default_send_channel_id();
+ webrtc::PacketReceiver::DeliveryStatus delivery_result =
+ call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO,
+ reinterpret_cast<const uint8_t*>(packet->data()), packet->size(),
+ webrtc_packet_time);
+ if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) {
+ return;
}
+ // Find the channel to send this packet to. It must exist since webrtc::Call
+ // was able to demux the packet.
+ int channel = GetReceiveChannelId(ssrc);
+ RTC_DCHECK(channel != -1);
+
// Pass it off to the decoder.
engine()->voe()->network()->ReceivedRTPPacket(
- which_channel, packet->data(), packet->size(),
- webrtc::PacketTime(packet_time.timestamp, packet_time.not_before));
+ channel, packet->data(), packet->size(), webrtc_packet_time);
}
void WebRtcVoiceMediaChannel::OnRtcpReceived(
@@ -2607,7 +2540,6 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived(
}
// If it is a sender report, find the receive channel that is listening.
- bool has_sent_to_default_channel = false;
if (type == kRtcpTypeSR) {
uint32_t ssrc = 0;
if (!GetRtcpSsrc(packet->data(), packet->size(), &ssrc)) {
@@ -2617,9 +2549,6 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived(
if (recv_channel_id != -1) {
engine()->voe()->network()->ReceivedRTCPPacket(
recv_channel_id, packet->data(), packet->size());
-
- if (IsDefaultChannel(recv_channel_id))
- has_sent_to_default_channel = true;
}
}
@@ -2627,11 +2556,6 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived(
// channels. So all RTCP packets must be forwarded all send channels. VoE
// will filter out RR internally.
for (const auto& ch : send_channels_) {
- // Make sure not sending the same packet to default channel more than once.
- if (IsDefaultChannel(ch.second->channel()) &&
- has_sent_to_default_channel)
- continue;
-
engine()->voe()->network()->ReceivedRTCPPacket(
ch.second->channel(), packet->data(), packet->size());
}
@@ -2826,18 +2750,9 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) {
info->senders.push_back(sinfo);
}
- // Build the list of receivers, one for each receiving channel, or 1 in
- // a 1:1 call.
- std::vector<int> channels;
+ // Get the SSRC and stats for each receiver.
for (const auto& ch : receive_channels_) {
- channels.push_back(ch.second->channel());
- }
- if (channels.empty()) {
- channels.push_back(default_send_channel_id());
- }
-
- // Get the SSRC and stats for each receiver, based on our own calculations.
- for (int ch_id : channels) {
+ int ch_id = ch.second->channel();
memset(&cs, 0, sizeof(cs));
if (engine()->voe()->rtp()->GetRemoteSSRC(ch_id, ssrc) != -1 &&
engine()->voe()->rtp()->GetRTCPStatistics(ch_id, cs) != -1 &&
@@ -2934,7 +2849,7 @@ int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const {
if (it != receive_channels_.end()) {
return it->second->channel();
}
- return (ssrc == default_receive_ssrc_) ? default_send_channel_id() : -1;
+ return -1;
}
int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const {
@@ -3002,22 +2917,6 @@ bool WebRtcVoiceMediaChannel::EnableRtcp(int channel) {
return true;
}
-bool WebRtcVoiceMediaChannel::ResetRecvCodecs(int channel) {
- int ncodecs = engine()->voe()->codec()->NumOfCodecs();
- for (int i = 0; i < ncodecs; ++i) {
- webrtc::CodecInst voe_codec;
- if (engine()->voe()->codec()->GetCodec(i, voe_codec) != -1) {
- voe_codec.pltype = -1;
- if (engine()->voe()->codec()->SetRecPayloadType(
- channel, voe_codec) == -1) {
- LOG_RTCERR2(SetRecPayloadType, channel, ToString(voe_codec));
- return false;
- }
- }
- }
- return true;
-}
-
bool WebRtcVoiceMediaChannel::SetPlayout(int channel, bool playout) {
if (playout) {
LOG(LS_INFO) << "Starting playout for channel #" << channel;
@@ -3032,17 +2931,6 @@ bool WebRtcVoiceMediaChannel::SetPlayout(int channel, bool playout) {
return true;
}
-uint32_t WebRtcVoiceMediaChannel::ParseSsrc(const void* data,
- size_t len,
- bool rtcp) {
- size_t ssrc_pos = (!rtcp) ? 8 : 4;
- uint32_t ssrc = 0;
- if (len >= (ssrc_pos + sizeof(ssrc))) {
- ssrc = rtc::GetBE32(static_cast<const char*>(data) + ssrc_pos);
- }
- return ssrc;
-}
-
// Convert VoiceEngine error code into VoiceMediaChannel::Error enum.
VoiceMediaChannel::Error
WebRtcVoiceMediaChannel::WebRtcErrorToChannelError(int err_code) {
@@ -3137,22 +3025,6 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecsInternal(
if (engine()->FindWebRtcCodec(codec, &voe_codec)) {
LOG(LS_INFO) << ToString(codec);
voe_codec.pltype = codec.id;
- if (default_receive_ssrc_ == 0) {
- // Set the receive codecs on the default channel explicitly if the
- // default channel is not used by |receive_channels_|, this happens in
- // conference mode or in non-conference mode when there is no playout
- // channel.
- // TODO(xians): Figure out how we use the default channel in conference
- // mode.
- if (engine()->voe()->codec()->SetRecPayloadType(
- default_send_channel_id(), voe_codec) == -1) {
- LOG_RTCERR2(SetRecPayloadType, default_send_channel_id(),
- ToString(voe_codec));
- return false;
- }
- }
-
- // Set the receive codecs on all receiving channels.
for (const auto& ch : receive_channels_) {
if (engine()->voe()->codec()->SetRecPayloadType(
ch.second->channel(), voe_codec) == -1) {
diff --git a/talk/media/webrtc/webrtcvoiceengine.h b/talk/media/webrtc/webrtcvoiceengine.h
index 4250741e05..5121c08b79 100644
--- a/talk/media/webrtc/webrtcvoiceengine.h
+++ b/talk/media/webrtc/webrtcvoiceengine.h
@@ -259,9 +259,7 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
const std::vector<AudioCodec>& all_codecs,
webrtc::CodecInst* send_codec);
bool EnableRtcp(int channel);
- bool ResetRecvCodecs(int channel);
bool SetPlayout(int channel, bool playout);
- static uint32_t ParseSsrc(const void* data, size_t len, bool rtcp);
static Error WebRtcErrorToChannelError(int err_code);
class WebRtcVoiceChannelRenderer;
@@ -282,12 +280,12 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
void ConfigureSendChannel(int channel);
bool ConfigureRecvChannel(int channel);
bool DeleteChannel(int channel);
- bool InConferenceMode() const {
- return options_.conference_mode.GetWithDefaultIfUnset(false);
- }
bool IsDefaultChannel(int channel_id) const {
return channel_id == default_send_channel_id_;
}
+ bool IsDefaultRecvStream(uint32_t ssrc) {
+ return default_recv_ssrc_ == static_cast<int64_t>(ssrc);
+ }
bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs);
bool SetSendBitrateInternal(int bps);
@@ -324,16 +322,17 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
SendFlags send_;
webrtc::Call* const call_;
+ // SSRC of unsignalled receive stream, or -1 if there isn't one.
+ int64_t default_recv_ssrc_ = -1;
+ // Volume for unsignalled stream, which may be set before the stream exists.
+ double default_recv_volume_ = 1.0;
+
// send_channels_ contains the channels which are being used for sending.
// When the default channel (default_send_channel_id) is used for sending, it
// is contained in send_channels_, otherwise not.
ChannelMap send_channels_;
std::vector<RtpHeaderExtension> send_extensions_;
- uint32_t default_receive_ssrc_;
- // Note the default channel (default_send_channel_id()) can reside in both
- // receive_channels_ and send_channels_ in non-conference mode and in that
- // case it will only be there if a non-zero default_receive_ssrc_ is set.
- ChannelMap receive_channels_; // for multiple sources
+ ChannelMap receive_channels_;
std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_;
std::map<uint32_t, StreamParams> receive_stream_params_;
// receive_channels_ can be read from WebRtc callback thread. Access from
@@ -341,10 +340,6 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
// Reads on the worker thread are ok.
std::vector<RtpHeaderExtension> receive_extensions_;
std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
-
- // Do not lock this on the VoE media processor thread; potential for deadlock
- // exists.
- mutable rtc::CriticalSection receive_channels_cs_;
};
} // namespace cricket
diff --git a/talk/media/webrtc/webrtcvoiceengine_unittest.cc b/talk/media/webrtc/webrtcvoiceengine_unittest.cc
index 6300f1df58..b0fc2bb8d7 100644
--- a/talk/media/webrtc/webrtcvoiceengine_unittest.cc
+++ b/talk/media/webrtc/webrtcvoiceengine_unittest.cc
@@ -97,25 +97,31 @@ class WebRtcVoiceEngineTestFake : public testing::Test {
channel_(nullptr) {
send_parameters_.codecs.push_back(kPcmuCodec);
recv_parameters_.codecs.push_back(kPcmuCodec);
- options_conference_.conference_mode.Set(true);
options_adjust_agc_.adjust_agc_delta.Set(-10);
}
- bool SetupEngineWithoutStream() {
+ bool SetupEngine() {
if (!engine_.Init(rtc::Thread::Current())) {
return false;
}
channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
return (channel_ != nullptr);
}
- bool SetupEngine() {
- if (!SetupEngineWithoutStream()) {
+ bool SetupEngineWithRecvStream() {
+ if (!SetupEngine()) {
+ return false;
+ }
+ return channel_->AddRecvStream(
+ cricket::StreamParams::CreateLegacy(kSsrc1));
+ }
+ bool SetupEngineWithSendStream() {
+ if (!SetupEngine()) {
return false;
}
return channel_->AddSendStream(
cricket::StreamParams::CreateLegacy(kSsrc1));
}
void SetupForMultiSendStream() {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
// Remove stream added in Setup, which is corresponding to default channel.
int default_channel_num = voe_.GetLastChannel();
uint32_t default_send_ssrc = 0u;
@@ -206,7 +212,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test {
}
void TestSetSendRtpHeaderExtensions(const std::string& ext) {
- EXPECT_TRUE(SetupEngineWithoutStream());
+ EXPECT_TRUE(SetupEngine());
int channel_num = voe_.GetLastChannel();
// Ensure extensions are off by default.
@@ -248,7 +254,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test {
}
void TestSetRecvRtpHeaderExtensions(const std::string& ext) {
- EXPECT_TRUE(SetupEngineWithoutStream());
+ EXPECT_TRUE(SetupEngineWithRecvStream());
int channel_num = voe_.GetLastChannel();
// Ensure extensions are off by default.
@@ -275,9 +281,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test {
// Ensure extension is set properly on new channel.
// The first stream to occupy the default channel.
EXPECT_TRUE(channel_->AddRecvStream(
- cricket::StreamParams::CreateLegacy(345)));
- EXPECT_TRUE(channel_->AddRecvStream(
- cricket::StreamParams::CreateLegacy(456)));
+ cricket::StreamParams::CreateLegacy(kSsrc2)));
int new_channel_num = voe_.GetLastChannel();
EXPECT_NE(channel_num, new_channel_num);
EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext));
@@ -298,7 +302,6 @@ class WebRtcVoiceEngineTestFake : public testing::Test {
cricket::AudioSendParameters send_parameters_;
cricket::AudioRecvParameters recv_parameters_;
- cricket::AudioOptions options_conference_;
cricket::AudioOptions options_adjust_agc_;
};
@@ -381,7 +384,6 @@ TEST_F(WebRtcVoiceEngineTestFake, FindCodec) {
// Test that we set our inbound codecs properly, including changing PT.
TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) {
EXPECT_TRUE(SetupEngine());
- int channel_num = voe_.GetLastChannel();
cricket::AudioRecvParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
@@ -389,6 +391,9 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) {
parameters.codecs[0].id = 106; // collide with existing telephone-event
parameters.codecs[2].id = 126;
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
+ EXPECT_TRUE(channel_->AddRecvStream(
+ cricket::StreamParams::CreateLegacy(kSsrc1)));
+ int channel_num = voe_.GetLastChannel();
webrtc::CodecInst gcodec;
rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
gcodec.plfreq = 16000;
@@ -433,7 +438,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) {
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
EXPECT_TRUE(channel_->AddRecvStream(
cricket::StreamParams::CreateLegacy(kSsrc1)));
- int channel_num2 = voe_.GetLastChannel();
+ int channel_num = voe_.GetLastChannel();
webrtc::CodecInst opus;
engine_.FindWebRtcCodec(kOpusCodec, &opus);
// Even without stereo parameters, recv codecs still specify channels = 2.
@@ -441,7 +446,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) {
EXPECT_EQ(111, opus.pltype);
EXPECT_STREQ("opus", opus.plname);
opus.pltype = 0;
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus));
+ EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, opus));
EXPECT_EQ(111, opus.pltype);
}
@@ -520,12 +525,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) {
}
TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithRecvStream());
cricket::AudioRecvParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs[0].id = 106; // collide with existing telephone-event
- EXPECT_TRUE(channel_->AddRecvStream(
- cricket::StreamParams::CreateLegacy(kSsrc1)));
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
int channel_num2 = voe_.GetLastChannel();
@@ -540,7 +543,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) {
// Test that we can apply the same set of codecs again while playing.
TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithRecvStream());
cricket::AudioRecvParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kCn16000Codec);
@@ -557,7 +560,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) {
// Test that we can add a codec while playing.
TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithRecvStream());
cricket::AudioRecvParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kCn16000Codec);
@@ -574,7 +577,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) {
}
TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
// Test that when autobw is enabled, bitrate is kept as the default
// value. autobw is enabled for the following tests because the target
@@ -591,7 +594,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) {
}
TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
// Test that the bitrate of a multi-rate codec is always the maximum.
@@ -605,7 +608,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) {
}
TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
// Test that we can only set a maximum bitrate for a fixed-rate codec
// if it's bigger than the fixed rate.
@@ -621,7 +624,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) {
}
TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) {
- EXPECT_TRUE(SetupEngineWithoutStream());
+ EXPECT_TRUE(SetupEngine());
const int kDesiredBitrate = 128000;
cricket::AudioSendParameters parameters;
parameters.codecs = engine_.codecs();
@@ -641,7 +644,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) {
// Bitrate is ignored if it is higher than the fixed bitrate.
// Bitrate less then the fixed bitrate is an error.
TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
// PCMU, default bitrate == 64000.
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
@@ -663,7 +666,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) {
// Test that we apply codecs properly.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
@@ -688,7 +691,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) {
// Test that VoE Channel doesn't call SetSendCodec again if same codec is tried
// to apply.
TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
@@ -705,7 +708,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) {
// Verify that G722 is set with 16000 samples per second to WebRTC.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kG722CodecSdp);
@@ -719,7 +722,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) {
// Test that if clockrate is not 48000 for opus, we fail.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
@@ -729,7 +732,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) {
// Test that if channels=0 for opus, we fail.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
@@ -739,7 +742,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) {
// Test that if channels=0 for opus, we fail.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
@@ -750,7 +753,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) {
// Test that if channel is 1 for opus and there's no stereo, we fail.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
@@ -760,7 +763,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) {
// Test that if channel is 1 for opus and stereo=0, we fail.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
@@ -771,7 +774,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) {
// Test that if channel is 1 for opus and stereo=1, we fail.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
parameters.codecs[0].bitrate = 0;
@@ -783,7 +786,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) {
// Test that with bitrate=0 and no stereo,
// channels and bitrate are 1 and 32000.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -799,7 +802,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) {
// Test that with bitrate=0 and stereo=0,
// channels and bitrate are 1 and 32000.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -816,7 +819,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) {
// Test that with bitrate=invalid and stereo=0,
// channels and bitrate are 1 and 32000.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -842,7 +845,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) {
// Test that with bitrate=0 and stereo=1,
// channels and bitrate are 2 and 64000.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -859,7 +862,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) {
// Test that with bitrate=invalid and stereo=1,
// channels and bitrate are 2 and 64000.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -885,7 +888,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) {
// Test that with bitrate=N and stereo unset,
// channels and bitrate are 1 and N.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -903,7 +906,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) {
// Test that with bitrate=N and stereo=0,
// channels and bitrate are 1 and N.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -920,7 +923,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) {
// Test that with bitrate=N and without any parameters,
// channels and bitrate are 1 and N.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -936,7 +939,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) {
// Test that with bitrate=N and stereo=1,
// channels and bitrate are 2 and N.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -954,7 +957,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) {
// Also test that the "maxaveragebitrate" can't be set to values outside the
// range of 6000 and 510000
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -981,7 +984,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) {
// Test that we can enable NACK with opus as caller.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -995,7 +998,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) {
// Test that we can enable NACK with opus as callee.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) {
- EXPECT_TRUE(SetupEngineWithoutStream());
+ EXPECT_TRUE(SetupEngine());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1013,7 +1016,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) {
// Test that we can enable NACK on receive streams.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num1 = voe_.GetLastChannel();
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
int channel_num2 = voe_.GetLastChannel();
@@ -1031,7 +1034,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) {
// Test that we can disable NACK.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1049,7 +1052,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) {
// Test that we can disable NACK on receive streams.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num1 = voe_.GetLastChannel();
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
int channel_num2 = voe_.GetLastChannel();
@@ -1071,7 +1074,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) {
// Test that NACK is enabled on a new receive stream.
TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
@@ -1092,7 +1095,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) {
// Test that without useinbandfec, Opus FEC is off.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1102,7 +1105,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) {
// Test that with useinbandfec=0, Opus FEC is off.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1119,7 +1122,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) {
// Test that with useinbandfec=1, Opus FEC is on.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1136,7 +1139,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) {
// Test that with useinbandfec=1, stereo=1, Opus FEC is on.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1154,7 +1157,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) {
// Test that with non-Opus, codec FEC is off.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
@@ -1164,7 +1167,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) {
// Test the with non-Opus, even if useinbandfec=1, FEC is off.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
@@ -1175,7 +1178,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) {
// Test that Opus FEC status can be changed.
TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1188,7 +1191,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) {
// Test maxplaybackrate <= 8000 triggers Opus narrow band mode.
TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1210,7 +1213,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) {
// Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode.
TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1232,7 +1235,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) {
// Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode.
TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1254,7 +1257,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) {
// Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode.
TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1276,7 +1279,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) {
// Test 24000 < maxplaybackrate triggers Opus full band mode.
TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1298,7 +1301,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) {
// Test Opus that without maxplaybackrate, default playback rate is used.
TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1309,7 +1312,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) {
// Test the with non-Opus, maxplaybackrate has no effect.
TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
@@ -1320,7 +1323,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) {
// Test maxplaybackrate can be set on two streams.
TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1343,7 +1346,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) {
// Test that with usedtx=0, Opus DTX is off.
TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1354,7 +1357,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) {
// Test that with usedtx=1, Opus DTX is on.
TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1366,7 +1369,7 @@ TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) {
// Test that usedtx=1 works with stereo Opus.
TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1379,7 +1382,7 @@ TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) {
// Test that usedtx=1 does not work with non Opus.
TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
@@ -1390,7 +1393,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) {
// Test that we can switch back and forth between Opus and ISAC with CN.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters opus_parameters;
opus_parameters.codecs.push_back(kOpusCodec);
@@ -1417,7 +1420,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) {
// Test that we handle various ways of specifying bitrate.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec); // bitrate == 32000
@@ -1467,7 +1470,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) {
// Test that we could set packet size specified in kCodecParamPTime.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kOpusCodec);
@@ -1502,7 +1505,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) {
// Test that we fail if no codecs are specified.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioSendParameters parameters;
EXPECT_FALSE(channel_->SetSendParameters(parameters));
}
@@ -1510,7 +1513,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) {
// Test that we can set send codecs even with telephone-event codec as the first
// one on the list.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kTelephoneEventCodec);
@@ -1529,7 +1532,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) {
// Test that we can set send codecs even with CN codec as the first
// one on the list.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kCn16000Codec);
@@ -1547,7 +1550,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) {
// Test that we set VAD and DTMF types correctly as caller.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
@@ -1608,7 +1611,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
// Test that we only apply VAD if we have a CN codec that matches the
// send codec clockrate.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
// Set ISAC(16K) and CN(16K). VAD should be activated.
@@ -1644,7 +1647,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) {
// Test that we perform case-insensitive matching of codec names.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
@@ -1671,7 +1674,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) {
// Test that we set up RED correctly as caller.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
@@ -1716,7 +1719,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) {
// Test that we set up RED correctly if params are omitted.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
@@ -1735,7 +1738,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) {
// Test that we ignore RED if the parameters aren't named the way we expect.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
@@ -1754,7 +1757,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) {
// Test that we ignore RED if it uses different primary/secondary encoding.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
@@ -1773,7 +1776,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) {
// Test that we ignore RED if it uses more than 2 encodings.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
@@ -1792,7 +1795,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) {
// Test that we ignore RED if it has bogus codec ids.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
@@ -1811,7 +1814,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) {
// Test that we ignore RED if it refers to a codec that is not present.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
@@ -1844,17 +1847,24 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) {
TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension);
}
-// Test that we can create a channel and start sending/playing out on it.
-TEST_F(WebRtcVoiceEngineTestFake, SendAndPlayout) {
- EXPECT_TRUE(SetupEngine());
+// Test that we can create a channel and start sending on it.
+TEST_F(WebRtcVoiceEngineTestFake, Send) {
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
EXPECT_TRUE(voe_.GetSend(channel_num));
- EXPECT_TRUE(channel_->SetPlayout(true));
- EXPECT_TRUE(voe_.GetPlayout(channel_num));
EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING));
EXPECT_FALSE(voe_.GetSend(channel_num));
+}
+
+// Test that we can create a channel and start playing out on it.
+TEST_F(WebRtcVoiceEngineTestFake, Playout) {
+ EXPECT_TRUE(SetupEngineWithRecvStream());
+ 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));
}
@@ -1998,12 +2008,21 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) {
EXPECT_EQ(cricket::kIntStatValue, info.senders[i].jitter_ms);
EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name);
}
-
EXPECT_EQ(0u, info.receivers.size());
+
+ // Registered stream's remote SSRC is kSsrc2. Send a packet with SSRC=1.
+ // We should drop the packet and no stats should be available.
DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
EXPECT_EQ(true, channel_->GetStats(&info));
+ EXPECT_EQ(0u, info.receivers.size());
+ // Remove the kSsrc2 stream and deliver a new packet - a default receive
+ // stream should be created and we should see stats.
+ EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2));
+ DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
+ EXPECT_EQ(true, channel_->GetStats(&info));
EXPECT_EQ(1u, info.receivers.size());
+
EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd);
EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd);
EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost);
@@ -2026,23 +2045,22 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) {
// Test that we can add and remove receive streams, and do proper send/playout.
// We can receive on multiple streams while sending one stream.
TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num1 = voe_.GetLastChannel();
- // Start playout on the default channel.
- send_parameters_.options = options_conference_;
+ // Start playout without a receive stream.
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_TRUE(channel_->SetPlayout(true));
- EXPECT_TRUE(voe_.GetPlayout(channel_num1));
+ EXPECT_FALSE(voe_.GetPlayout(channel_num1));
- // Adding another stream should disable playout on the default channel.
+ // Adding another stream should enable playout on the new stream only.
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
int channel_num2 = voe_.GetLastChannel();
EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
EXPECT_TRUE(voe_.GetSend(channel_num1));
EXPECT_FALSE(voe_.GetSend(channel_num2));
- // Make sure only the new channel is played out.
+ // Make sure only the new stream is played out.
EXPECT_FALSE(voe_.GetPlayout(channel_num1));
EXPECT_TRUE(voe_.GetPlayout(channel_num2));
@@ -2066,24 +2084,24 @@ TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) {
EXPECT_FALSE(voe_.GetPlayout(channel_num2));
EXPECT_FALSE(voe_.GetPlayout(channel_num3));
- // Restart playout and make sure the default channel still is not played out.
+ // 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));
- // Now remove the new streams and verify that the default channel is
- // played out again.
+ // Now remove the recv streams and verify that the send stream doesn't play.
EXPECT_TRUE(channel_->RemoveRecvStream(3));
EXPECT_TRUE(channel_->RemoveRecvStream(2));
-
- EXPECT_TRUE(voe_.GetPlayout(channel_num1));
+ EXPECT_FALSE(voe_.GetPlayout(channel_num1));
}
// Test that we can set the devices to use.
TEST_F(WebRtcVoiceEngineTestFake, SetDevices) {
- EXPECT_TRUE(SetupEngine());
- int channel_num = voe_.GetLastChannel();
+ EXPECT_TRUE(SetupEngineWithSendStream());
+ int send_channel = voe_.GetLastChannel();
+ EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
+ int recv_channel = voe_.GetLastChannel();
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
cricket::Device default_dev(cricket::kFakeDefaultDeviceName,
@@ -2097,38 +2115,40 @@ TEST_F(WebRtcVoiceEngineTestFake, SetDevices) {
// Test SetDevices() while sending and playing.
EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
EXPECT_TRUE(channel_->SetPlayout(true));
- EXPECT_TRUE(voe_.GetSend(channel_num));
- EXPECT_TRUE(voe_.GetPlayout(channel_num));
+ EXPECT_TRUE(voe_.GetSend(send_channel));
+ EXPECT_TRUE(voe_.GetPlayout(recv_channel));
EXPECT_TRUE(engine_.SetDevices(&dev, &dev));
- EXPECT_TRUE(voe_.GetSend(channel_num));
- EXPECT_TRUE(voe_.GetPlayout(channel_num));
+ EXPECT_TRUE(voe_.GetSend(send_channel));
+ EXPECT_TRUE(voe_.GetPlayout(recv_channel));
// Test that failure to open newly selected devices does not prevent opening
// ones after that.
- voe_.set_playout_fail_channel(channel_num);
- voe_.set_send_fail_channel(channel_num);
+ voe_.set_playout_fail_channel(recv_channel);
+ voe_.set_send_fail_channel(send_channel);
EXPECT_FALSE(engine_.SetDevices(&default_dev, &default_dev));
- EXPECT_FALSE(voe_.GetSend(channel_num));
- EXPECT_FALSE(voe_.GetPlayout(channel_num));
+ EXPECT_FALSE(voe_.GetSend(send_channel));
+ EXPECT_FALSE(voe_.GetPlayout(recv_channel));
voe_.set_playout_fail_channel(-1);
voe_.set_send_fail_channel(-1);
EXPECT_TRUE(engine_.SetDevices(&dev, &dev));
- EXPECT_TRUE(voe_.GetSend(channel_num));
- EXPECT_TRUE(voe_.GetPlayout(channel_num));
+ EXPECT_TRUE(voe_.GetSend(send_channel));
+ EXPECT_TRUE(voe_.GetPlayout(recv_channel));
}
// Test that we can set the devices to use even if we failed to
// open the initial ones.
TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) {
- EXPECT_TRUE(SetupEngine());
- int channel_num = voe_.GetLastChannel();
+ EXPECT_TRUE(SetupEngineWithSendStream());
+ int send_channel = voe_.GetLastChannel();
+ EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
+ int recv_channel = voe_.GetLastChannel();
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
cricket::Device default_dev(cricket::kFakeDefaultDeviceName,
@@ -2138,40 +2158,29 @@ TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) {
// Test that failure to open devices selected before starting
// send/play does not prevent opening newly selected ones after that.
- voe_.set_playout_fail_channel(channel_num);
- voe_.set_send_fail_channel(channel_num);
+ voe_.set_playout_fail_channel(recv_channel);
+ voe_.set_send_fail_channel(send_channel);
EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev));
EXPECT_FALSE(channel_->SetSend(cricket::SEND_MICROPHONE));
EXPECT_FALSE(channel_->SetPlayout(true));
- EXPECT_FALSE(voe_.GetSend(channel_num));
- EXPECT_FALSE(voe_.GetPlayout(channel_num));
+ EXPECT_FALSE(voe_.GetSend(send_channel));
+ EXPECT_FALSE(voe_.GetPlayout(recv_channel));
voe_.set_playout_fail_channel(-1);
voe_.set_send_fail_channel(-1);
EXPECT_TRUE(engine_.SetDevices(&dev, &dev));
- EXPECT_TRUE(voe_.GetSend(channel_num));
- EXPECT_TRUE(voe_.GetPlayout(channel_num));
-}
-
-// Test that we can create a channel configured for multi-point conferences,
-// and start sending/playing out on it.
-TEST_F(WebRtcVoiceEngineTestFake, ConferenceSendAndPlayout) {
- EXPECT_TRUE(SetupEngine());
- int channel_num = voe_.GetLastChannel();
- send_parameters_.options = options_conference_;
- EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
- EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
- EXPECT_TRUE(voe_.GetSend(channel_num));
+ EXPECT_TRUE(voe_.GetSend(send_channel));
+ EXPECT_TRUE(voe_.GetPlayout(recv_channel));
}
// Test that we can create a channel configured for Codian bridges,
-// and start sending/playing out on it.
-TEST_F(WebRtcVoiceEngineTestFake, CodianSendAndPlayout) {
- EXPECT_TRUE(SetupEngine());
+// and start sending on it.
+TEST_F(WebRtcVoiceEngineTestFake, CodianSend) {
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
webrtc::AgcConfig agc_config;
EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
@@ -2182,18 +2191,14 @@ TEST_F(WebRtcVoiceEngineTestFake, CodianSendAndPlayout) {
EXPECT_TRUE(voe_.GetSend(channel_num));
EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated
- EXPECT_TRUE(channel_->SetPlayout(true));
- EXPECT_TRUE(voe_.GetPlayout(channel_num));
EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING));
EXPECT_FALSE(voe_.GetSend(channel_num));
EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored
- EXPECT_TRUE(channel_->SetPlayout(false));
- EXPECT_FALSE(voe_.GetPlayout(channel_num));
}
TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
webrtc::AgcConfig agc_config;
EXPECT_EQ(0, voe_.GetAgcConfig(agc_config));
EXPECT_EQ(0, agc_config.targetLeveldBOv);
@@ -2220,7 +2225,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) {
}
TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioOptions options;
options.recording_sample_rate.Set(48000u);
options.playout_sample_rate.Set(44100u);
@@ -2234,7 +2239,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) {
}
TEST_F(WebRtcVoiceEngineTestFake, TraceFilterViaTraceOptions) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
engine_.SetLogging(rtc::LS_INFO, "");
EXPECT_EQ(
// Info:
@@ -2255,7 +2260,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TraceFilterViaTraceOptions) {
// Test that we can set the outgoing SSRC properly.
// SSRC is set in SetupEngine by calling AddSendStream.
TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num = voe_.GetLastChannel();
unsigned int send_ssrc;
EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc));
@@ -2266,9 +2271,9 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) {
TEST_F(WebRtcVoiceEngineTestFake, GetStats) {
// Setup. We need send codec to be set to get all stats.
- EXPECT_TRUE(SetupEngine());
- // SetupEngine adds a send stream with kSsrc1, so the receive stream has to
- // use a different SSRC.
+ EXPECT_TRUE(SetupEngineWithSendStream());
+ // SetupEngineWithSendStream adds a send stream with kSsrc1, so the receive
+ // stream has to use a different SSRC.
EXPECT_TRUE(channel_->AddRecvStream(
cricket::StreamParams::CreateLegacy(kSsrc2)));
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
@@ -2295,8 +2300,17 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStats) {
// EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_return_loss);
// EXPECT_EQ(cricket::kIntStatValue,
// info.senders[0].echo_return_loss_enhancement);
+ EXPECT_EQ(0u, info.receivers.size());
+ // Registered stream's remote SSRC is kSsrc2. Send a packet with SSRC=1.
+ // We should drop the packet and no stats should be available.
+ DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
+ EXPECT_EQ(true, channel_->GetStats(&info));
EXPECT_EQ(0u, info.receivers.size());
+
+ // Remove the kSsrc2 stream and deliver a new packet - a default receive
+ // stream should be created and we should see stats.
+ EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2));
DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
EXPECT_EQ(true, channel_->GetStats(&info));
EXPECT_EQ(1u, info.receivers.size());
@@ -2318,7 +2332,7 @@ TEST_F(WebRtcVoiceEngineTestFake, GetStats) {
// Test that we can set the outgoing SSRC properly with multiple streams.
// SSRC is set in SetupEngine by calling AddSendStream.
TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
int channel_num1 = voe_.GetLastChannel();
unsigned int send_ssrc;
EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc));
@@ -2353,16 +2367,15 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) {
// Test that we can properly receive packets.
TEST_F(WebRtcVoiceEngineTestFake, Recv) {
EXPECT_TRUE(SetupEngine());
- int channel_num = voe_.GetLastChannel();
DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
+ int channel_num = voe_.GetLastChannel();
EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame,
sizeof(kPcmuFrame)));
}
// Test that we can properly receive packets on multiple streams.
TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) {
- EXPECT_TRUE(SetupEngine());
- send_parameters_.options = options_conference_;
+ EXPECT_TRUE(SetupEngineWithSendStream());
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
int channel_num1 = voe_.GetLastChannel();
@@ -2405,30 +2418,24 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) {
// Test that we properly handle failures to add a stream.
TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
voe_.set_fail_create_channel(true);
- send_parameters_.options = options_conference_;
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
-
- // In 1:1 call, we should not try to create a new channel.
- send_parameters_.options.conference_mode.Set(false);
- EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
- EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
}
-// Test that AddRecvStream doesn't create new channel for 1:1 call.
-TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream1On1) {
- EXPECT_TRUE(SetupEngine());
+// Test that AddRecvStream creates new stream.
+TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream) {
+ EXPECT_TRUE(SetupEngineWithRecvStream());
int channel_num = voe_.GetLastChannel();
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
- EXPECT_EQ(channel_num, voe_.GetLastChannel());
+ EXPECT_NE(channel_num, voe_.GetLastChannel());
}
// Test that after adding a recv stream, we do not decode more codecs than
// those previously passed into SetRecvCodecs.
TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::AudioRecvParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
@@ -2446,8 +2453,7 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) {
// Test that we properly clean up any streams that were added, even if
// not explicitly removed.
TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) {
- EXPECT_TRUE(SetupEngine());
- send_parameters_.options = options_conference_;
+ EXPECT_TRUE(SetupEngineWithSendStream());
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
@@ -2458,23 +2464,22 @@ TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) {
}
TEST_F(WebRtcVoiceEngineTestFake, TestAddRecvStreamFailWithZeroSsrc) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0)));
}
TEST_F(WebRtcVoiceEngineTestFake, TestNoLeakingWhenAddRecvStreamFail) {
EXPECT_TRUE(SetupEngine());
- // Stream 1 reuses default channel.
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
- // Manually delete default channel to simulate a failure.
- int default_channel = voe_.GetLastChannel();
- EXPECT_EQ(0, voe_.DeleteChannel(default_channel));
- // Add recv stream 2 should fail because default channel is gone.
- EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
+ // Manually delete channel to simulate a failure.
+ int channel = voe_.GetLastChannel();
+ EXPECT_EQ(0, voe_.DeleteChannel(channel));
+ // Add recv stream 2 should work.
+ EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
int new_channel = voe_.GetLastChannel();
- EXPECT_NE(default_channel, new_channel);
- // The last created channel should have already been deleted.
- EXPECT_EQ(-1, voe_.DeleteChannel(new_channel));
+ EXPECT_NE(channel, new_channel);
+ // The last created channel is deleted too.
+ EXPECT_EQ(0, voe_.DeleteChannel(new_channel));
}
// Test the InsertDtmf on default send stream as caller.
@@ -2498,8 +2503,7 @@ TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) {
}
TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) {
- EXPECT_TRUE(SetupEngine());
- send_parameters_.options = options_conference_;
+ EXPECT_TRUE(SetupEngineWithSendStream());
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
@@ -2511,7 +2515,7 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) {
}
TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
bool ec_enabled;
webrtc::EcModes ec_mode;
@@ -2661,8 +2665,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) {
EXPECT_FALSE(typing_detection_enabled);
EXPECT_TRUE(stereo_swapping_enabled);
- // Turn on "conference mode" to ensure it has no impact.
- options.conference_mode.Set(true);
+ // Set options again to ensure it has no impact.
ASSERT_TRUE(engine_.SetOptions(options));
voe_.GetEcStatus(ec_enabled, ec_mode);
voe_.GetNsStatus(ns_enabled, ns_mode);
@@ -2673,7 +2676,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) {
}
TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
bool ec_enabled;
webrtc::EcModes ec_mode;
@@ -2718,7 +2721,7 @@ TEST_F(WebRtcVoiceEngineTestFake, InitDoesNotOverwriteDefaultAgcConfig) {
}
TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel1(
static_cast<cricket::WebRtcVoiceMediaChannel*>(
engine_.CreateChannel(&call_, cricket::AudioOptions())));
@@ -2831,7 +2834,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) {
// This test verifies DSCP settings are properly applied on voice media channel.
TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
rtc::scoped_ptr<cricket::VoiceMediaChannel> channel(
engine_.CreateChannel(&call_, cricket::AudioOptions()));
rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface(
@@ -2849,52 +2852,60 @@ TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
}
-// Test that GetReceiveChannelId returns the default channel for the first
-// recv stream in 1-1 calls.
-TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelIdIn1To1Calls) {
+TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelId) {
EXPECT_TRUE(SetupEngine());
cricket::WebRtcVoiceMediaChannel* media_channel =
static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
- // Test that GetChannelNum returns the default channel if the SSRC is unknown.
- EXPECT_EQ(media_channel->default_send_channel_id(),
- media_channel->GetReceiveChannelId(0));
- cricket::StreamParams stream;
- stream.ssrcs.push_back(kSsrc2);
- EXPECT_TRUE(channel_->AddRecvStream(stream));
- EXPECT_EQ(media_channel->default_send_channel_id(),
- media_channel->GetReceiveChannelId(kSsrc2));
+ EXPECT_EQ(-1, media_channel->GetReceiveChannelId(0));
+ EXPECT_TRUE(channel_->AddRecvStream(
+ cricket::StreamParams::CreateLegacy(kSsrc1)));
+ int channel_id = voe_.GetLastChannel();
+ EXPECT_EQ(channel_id, media_channel->GetReceiveChannelId(kSsrc1));
+ EXPECT_EQ(-1, media_channel->GetReceiveChannelId(kSsrc2));
+ EXPECT_TRUE(channel_->AddRecvStream(
+ cricket::StreamParams::CreateLegacy(kSsrc2)));
+ int channel_id2 = voe_.GetLastChannel();
+ EXPECT_EQ(channel_id2, media_channel->GetReceiveChannelId(kSsrc2));
}
-// Test that GetReceiveChannelId doesn't return the default channel for the
-// first recv stream in conference calls.
-TEST_F(WebRtcVoiceEngineTestFake, TestGetChannelNumInConferenceCalls) {
+TEST_F(WebRtcVoiceEngineTestFake, TestGetSendChannelId) {
EXPECT_TRUE(SetupEngine());
- send_parameters_.options = options_conference_;
- EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
- cricket::StreamParams stream;
- stream.ssrcs.push_back(kSsrc2);
- EXPECT_TRUE(channel_->AddRecvStream(stream));
cricket::WebRtcVoiceMediaChannel* media_channel =
- static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
- EXPECT_LT(media_channel->default_send_channel_id(),
- media_channel->GetReceiveChannelId(kSsrc2));
+ static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
+ EXPECT_EQ(-1, media_channel->GetSendChannelId(0));
+ EXPECT_TRUE(channel_->AddSendStream(
+ cricket::StreamParams::CreateLegacy(kSsrc1)));
+ int channel_id = voe_.GetLastChannel();
+ EXPECT_EQ(channel_id, media_channel->GetSendChannelId(kSsrc1));
+ EXPECT_EQ(-1, media_channel->GetSendChannelId(kSsrc2));
+ EXPECT_TRUE(channel_->AddSendStream(
+ cricket::StreamParams::CreateLegacy(kSsrc2)));
+ int channel_id2 = voe_.GetLastChannel();
+ EXPECT_EQ(channel_id2, media_channel->GetSendChannelId(kSsrc2));
}
TEST_F(WebRtcVoiceEngineTestFake, SetOutputVolume) {
EXPECT_TRUE(SetupEngine());
- float scale;
- EXPECT_TRUE(channel_->SetOutputVolume(0, 2));
- int channel_id = voe_.GetLastChannel();
- EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale));
- EXPECT_DOUBLE_EQ(2, scale);
-
EXPECT_FALSE(channel_->SetOutputVolume(kSsrc2, 0.5));
cricket::StreamParams stream;
stream.ssrcs.push_back(kSsrc2);
EXPECT_TRUE(channel_->AddRecvStream(stream));
-
+ int channel_id = voe_.GetLastChannel();
EXPECT_TRUE(channel_->SetOutputVolume(kSsrc2, 3));
- channel_id = voe_.GetLastChannel();
+ float scale = 0;
+ EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale));
+ EXPECT_DOUBLE_EQ(3, scale);
+}
+
+TEST_F(WebRtcVoiceEngineTestFake, SetOutputVolumeDefaultRecvStream) {
+ EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(channel_->SetOutputVolume(0, 2));
+ DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
+ int channel_id = voe_.GetLastChannel();
+ float scale = 0;
+ EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale));
+ EXPECT_DOUBLE_EQ(2, scale);
+ EXPECT_TRUE(channel_->SetOutputVolume(0, 3));
EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale));
EXPECT_DOUBLE_EQ(3, scale);
}
@@ -2903,7 +2914,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) {
const uint32_t kAudioSsrc = 123;
const std::string kSyncLabel = "AvSyncLabel";
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc);
sp.sync_label = kSyncLabel;
// Creating two channels to make sure that sync label is set properly for both
@@ -2928,7 +2939,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) {
ssrcs.push_back(223);
ssrcs.push_back(224);
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::WebRtcVoiceMediaChannel* media_channel =
static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
for (uint32_t ssrc : ssrcs) {
@@ -2968,7 +2979,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) {
TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) {
// Test that adding receive streams after enabling combined bandwidth
// estimation will correctly configure each channel.
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::WebRtcVoiceMediaChannel* media_channel =
static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
send_parameters_.options.combined_audio_video_bwe.Set(true);
@@ -2990,7 +3001,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
ssrcs.push_back(223);
ssrcs.push_back(224);
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::WebRtcVoiceMediaChannel* media_channel =
static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
send_parameters_.options.combined_audio_video_bwe.Set(true);
@@ -3049,7 +3060,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) {
};
rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp));
- EXPECT_TRUE(SetupEngine());
+ EXPECT_TRUE(SetupEngineWithSendStream());
cricket::WebRtcVoiceMediaChannel* media_channel =
static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_);
send_parameters_.options.combined_audio_video_bwe.Set(true);
@@ -3067,39 +3078,10 @@ TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) {
EXPECT_EQ(2, s->received_packets());
}
-// Associate channel should not set on 1:1 call, since the receive channel also
-// sends RTCP SR.
-TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelUnset1On1) {
- EXPECT_TRUE(SetupEngine());
- EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
- int recv_ch = voe_.GetLastChannel();
- EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1);
-}
-
-// This test is an extension of AssociateChannelUnset1On1. We create two receive
-// channels. The second should be associated with the default channel, since it
-// does not send RTCP SR.
-TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnSecondRecvChannel) {
- EXPECT_TRUE(SetupEngine());
- int default_channel = voe_.GetLastChannel();
- EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
- int recv_ch_1 = voe_.GetLastChannel();
- EXPECT_EQ(recv_ch_1, default_channel);
- EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
- int recv_ch_2 = voe_.GetLastChannel();
- EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1);
- EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel);
- // Add send stream, the association remains.
- EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3)));
- EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1);
- EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel);
-}
-
-// In conference mode, all receive channels should be associated with the
-// default channel, since they do not send RTCP SR.
+// All receive channels should be associated with the default send channel,
+// since they do not send RTCP SR.
TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) {
- EXPECT_TRUE(SetupEngine());
- send_parameters_.options = options_conference_;
+ EXPECT_TRUE(SetupEngineWithSendStream());
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
int default_channel = voe_.GetLastChannel();
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
@@ -3108,11 +3090,14 @@ TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) {
EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel);
EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2)));
EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel);
+ EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
+ recv_ch = voe_.GetLastChannel();
+ EXPECT_NE(recv_ch, default_channel);
+ EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel);
}
TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) {
- EXPECT_TRUE(SetupEngine());
- send_parameters_.options = options_conference_;
+ EXPECT_TRUE(SetupEngineWithSendStream());
EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
@@ -3265,7 +3250,6 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) {
while (num_channels > 0) {
delete channels[--num_channels];
}
-
engine.Terminate();
}
diff --git a/talk/session/media/channel.cc b/talk/session/media/channel.cc
index fb0f574211..c0f7f23f33 100644
--- a/talk/session/media/channel.cc
+++ b/talk/session/media/channel.cc
@@ -1497,9 +1497,6 @@ bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
AudioSendParameters send_params = last_send_params_;
RtpSendParametersFromMediaDescription(audio, &send_params);
- if (audio->conference_mode()) {
- send_params.options.conference_mode.Set(true);
- }
if (audio->agc_minus_10db()) {
send_params.options.adjust_agc_delta.Set(kAgcMinus10db);
}