Remove RED support from WebRtcVoiceEngine/MediaChannel

This CL was originally written by solenberg@webrtc.org:
https://codereview.webrtc.org/1928233003/

BUG=webrtc:4690, webrtc:5922

Review-Url: https://codereview.webrtc.org/2051073002
Cr-Commit-Position: refs/heads/master@{#13133}
This commit is contained in:
kwiberg 2016-06-14 08:04:47 -07:00 committed by Commit bot
parent b1963b403f
commit 6806136aec
7 changed files with 34 additions and 297 deletions

View File

@ -50,7 +50,6 @@ std::string AudioSendStream::Config::ToString() const {
ss << ", voe_channel_id: " << voe_channel_id;
// TODO(solenberg): Encoder config.
ss << ", cng_payload_type: " << cng_payload_type;
ss << ", red_payload_type: " << red_payload_type;
ss << '}';
return ss.str();
}

View File

@ -175,12 +175,10 @@ TEST(AudioSendStreamTest, ConfigToString) {
config.rtp.c_name = kCName;
config.voe_channel_id = kChannelId;
config.cng_payload_type = 42;
config.red_payload_type = 17;
EXPECT_EQ(
"{rtp: {ssrc: 1234, extensions: [{uri: "
"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 3}], "
"c_name: foo_name}, voe_channel_id: 1, cng_payload_type: 42, "
"red_payload_type: 17}",
"c_name: foo_name}, voe_channel_id: 1, cng_payload_type: 42}",
config.ToString());
}

View File

@ -85,7 +85,6 @@ class AudioSendStream {
// TODO(solenberg): Implement, once we configure codecs through the new API.
// std::unique_ptr<AudioEncoder> encoder;
int cng_payload_type = -1; // pt, or -1 to disable Comfort Noise Generator.
int red_payload_type = -1; // pt, or -1 to disable REDundant coding.
};
// Starts stream activity.

View File

@ -134,11 +134,9 @@ class FakeWebRtcVoiceEngine
bool codec_fec = false;
int max_encoding_bandwidth = 0;
bool opus_dtx = false;
bool red = false;
bool nack = false;
int cn8_type = 13;
int cn16_type = 105;
int red_type = 117;
int nack_max_packets = 0;
uint32_t send_ssrc = 0;
int associate_send_channel = -1;
@ -172,9 +170,6 @@ class FakeWebRtcVoiceEngine
bool GetOpusDtx(int channel) {
return channels_[channel]->opus_dtx;
}
bool GetRED(int channel) {
return channels_[channel]->red;
}
bool GetCodecFEC(int channel) {
return channels_[channel]->codec_fec;
}
@ -192,9 +187,6 @@ class FakeWebRtcVoiceEngine
channels_[channel]->cn16_type :
channels_[channel]->cn8_type;
}
int GetSendREDPayloadType(int channel) {
return channels_[channel]->red_type;
}
void set_playout_fail_channel(int channel) {
playout_fail_channel_ = channel;
}
@ -304,7 +296,7 @@ class FakeWebRtcVoiceEngine
if (_stricmp(codec.plname, "telephone-event") == 0 ||
_stricmp(codec.plname, "audio/telephone-event") == 0 ||
_stricmp(codec.plname, "CN") == 0 ||
_stricmp(codec.plname, "red") == 0 ) {
_stricmp(codec.plname, "red") == 0) {
return -1;
}
channels_[channel]->send_codec = codec;
@ -483,18 +475,8 @@ class FakeWebRtcVoiceEngine
unsigned int& maxJitterMs,
unsigned int& discardedPackets));
WEBRTC_STUB(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats));
WEBRTC_FUNC(SetREDStatus, (int channel, bool enable, int redPayloadtype)) {
WEBRTC_CHECK_CHANNEL(channel);
channels_[channel]->red = enable;
channels_[channel]->red_type = redPayloadtype;
return 0;
}
WEBRTC_FUNC(GetREDStatus, (int channel, bool& enable, int& redPayloadtype)) {
WEBRTC_CHECK_CHANNEL(channel);
enable = channels_[channel]->red;
redPayloadtype = channels_[channel]->red_type;
return 0;
}
WEBRTC_STUB(SetREDStatus, (int channel, bool enable, int redPayloadtype));
WEBRTC_STUB(GetREDStatus, (int channel, bool& enable, int& redPayloadtype));
WEBRTC_FUNC(SetNACKStatus, (int channel, bool enable, int maxNoPackets)) {
WEBRTC_CHECK_CHANNEL(channel);
channels_[channel]->nack = enable;

View File

@ -384,13 +384,10 @@ class WebRtcVoiceCodecs final {
static const AudioCodec* GetPreferredCodec(
const std::vector<AudioCodec>& codecs,
webrtc::CodecInst* out,
int* red_payload_type) {
webrtc::CodecInst* out) {
RTC_DCHECK(out);
RTC_DCHECK(red_payload_type);
// Select the preferred send codec (the first non-telephone-event/CN codec).
for (const AudioCodec& codec : codecs) {
*red_payload_type = -1;
if (IsCodec(codec, kDtmfCodecName) || IsCodec(codec, kCnCodecName)) {
// Skip telephone-event/CN codec, which will be handled later.
continue;
@ -398,27 +395,15 @@ class WebRtcVoiceCodecs final {
// We'll use the first codec in the list to actually send audio data.
// Be sure to use the payload type requested by the remote side.
// "red", for RED audio, is a special case where the actual codec to be
// used is specified in params.
const AudioCodec* found_codec = &codec;
if (IsCodec(*found_codec, kRedCodecName)) {
// Parse out the RED parameters. If we fail, just ignore RED;
// we don't support all possible params/usage scenarios.
*red_payload_type = codec.id;
found_codec = GetRedSendCodec(*found_codec, codecs);
if (!found_codec) {
continue;
}
}
// Ignore codecs we don't know about. The negotiation step should prevent
// this, but double-check to be sure.
webrtc::CodecInst voe_codec = {0};
if (!ToCodecInst(*found_codec, &voe_codec)) {
LOG(LS_WARNING) << "Unknown codec " << ToString(*found_codec);
if (!ToCodecInst(codec, &voe_codec)) {
LOG(LS_WARNING) << "Unknown codec " << ToString(codec);
continue;
}
*out = voe_codec;
return found_codec;
return &codec;
}
return nullptr;
}
@ -435,7 +420,7 @@ class WebRtcVoiceCodecs final {
int max_bitrate_bps;
};
// Note: keep the supported packet sizes in ascending order.
static const CodecPref kCodecPrefs[12];
static const CodecPref kCodecPrefs[11];
static int SelectPacketSize(const CodecPref& codec_pref, int ptime_ms) {
int selected_packet_size_ms = codec_pref.packet_sizes_ms[0];
@ -458,47 +443,9 @@ class WebRtcVoiceCodecs final {
voe_codec->plfreq = new_plfreq;
}
}
static const AudioCodec* GetRedSendCodec(
const AudioCodec& red_codec,
const std::vector<AudioCodec>& all_codecs) {
// Get the RED encodings from the parameter with no name. This may
// change based on what is discussed on the Jingle list.
// The encoding parameter is of the form "a/b"; we only support where
// a == b. Verify this and parse out the value into red_pt.
// If the parameter value is absent (as it will be until we wire up the
// signaling of this message), use the second codec specified (i.e. the
// one after "red") as the encoding parameter.
int red_pt = -1;
std::string red_params;
CodecParameterMap::const_iterator it = red_codec.params.find("");
if (it != red_codec.params.end()) {
red_params = it->second;
std::vector<std::string> red_pts;
if (rtc::split(red_params, '/', &red_pts) != 2 ||
red_pts[0] != red_pts[1] || !rtc::FromString(red_pts[0], &red_pt)) {
LOG(LS_WARNING) << "RED params " << red_params << " not supported.";
return nullptr;
}
} else if (red_codec.params.empty()) {
LOG(LS_WARNING) << "RED params not present, using defaults";
if (all_codecs.size() > 1) {
red_pt = all_codecs[1].id;
}
}
// Try to find red_pt in |codecs|.
for (const AudioCodec& codec : all_codecs) {
if (codec.id == red_pt) {
return &codec;
}
}
LOG(LS_WARNING) << "RED params " << red_params << " are invalid.";
return nullptr;
}
};
const WebRtcVoiceCodecs::CodecPref WebRtcVoiceCodecs::kCodecPrefs[12] = {
const WebRtcVoiceCodecs::CodecPref WebRtcVoiceCodecs::kCodecPrefs[11] = {
{kOpusCodecName, 48000, 2, 111, true, {10, 20, 40, 60}, kOpusMaxBitrate},
{kIsacCodecName, 16000, 1, 103, true, {30, 60}, kIsacMaxBitrate},
{kIsacCodecName, 32000, 1, 104, true, {30}, kIsacMaxBitrate},
@ -510,8 +457,7 @@ const WebRtcVoiceCodecs::CodecPref WebRtcVoiceCodecs::kCodecPrefs[12] = {
{kCnCodecName, 32000, 1, 106, false, {}},
{kCnCodecName, 16000, 1, 105, false, {}},
{kCnCodecName, 8000, 1, 13, false, {}},
{kRedCodecName, 8000, 1, 127, false, {}},
{kDtmfCodecName, 8000, 1, 126, false, {}},
{kDtmfCodecName, 8000, 1, 126, false, {}}
};
} // namespace {
@ -1670,46 +1616,41 @@ bool WebRtcVoiceMediaChannel::SetSendCodecs(
}
// Scan through the list to figure out the codec to use for sending, along
// with the proper configuration for VAD, CNG, RED, NACK and Opus-specific
// with the proper configuration for VAD, CNG, NACK and Opus-specific
// parameters.
// TODO(solenberg): Refactor this logic once we create AudioEncoders here.
{
SendCodecSpec send_codec_spec;
send_codec_spec.nack_enabled = send_codec_spec_.nack_enabled;
// Find send codec (the first non-telephone-event/CN codec).
const AudioCodec* codec = WebRtcVoiceCodecs::GetPreferredCodec(
codecs, &send_codec_spec.codec_inst, &send_codec_spec.red_payload_type);
codecs, &send_codec_spec.codec_inst);
if (!codec) {
LOG(LS_WARNING) << "Received empty list of codecs.";
return false;
}
send_codec_spec.transport_cc_enabled = HasTransportCc(*codec);
send_codec_spec.nack_enabled = HasNack(*codec);
// This condition is apparently here because Opus does not support RED and
// FEC simultaneously. However, DTX and max playback rate shouldn't have
// such limitations.
// TODO(solenberg): Refactor this logic once we create AudioEncoders here.
if (send_codec_spec.red_payload_type == -1) {
send_codec_spec.nack_enabled = HasNack(*codec);
// For Opus as the send codec, we are to determine inband FEC, maximum
// playback rate, and opus internal dtx.
if (IsCodec(*codec, kOpusCodecName)) {
GetOpusConfig(*codec, &send_codec_spec.codec_inst,
&send_codec_spec.enable_codec_fec,
&send_codec_spec.opus_max_playback_rate,
&send_codec_spec.enable_opus_dtx);
}
// For Opus as the send codec, we are to determine inband FEC, maximum
// playback rate, and opus internal dtx.
if (IsCodec(*codec, kOpusCodecName)) {
GetOpusConfig(*codec, &send_codec_spec.codec_inst,
&send_codec_spec.enable_codec_fec,
&send_codec_spec.opus_max_playback_rate,
&send_codec_spec.enable_opus_dtx);
}
// Set packet size if the AudioCodec param kCodecParamPTime is set.
int ptime_ms = 0;
if (codec->GetParam(kCodecParamPTime, &ptime_ms)) {
if (!WebRtcVoiceCodecs::SetPTimeAsPacketSize(
&send_codec_spec.codec_inst, ptime_ms)) {
LOG(LS_WARNING) << "Failed to set packet size for codec "
<< send_codec_spec.codec_inst.plname;
return false;
}
// Set packet size if the AudioCodec param kCodecParamPTime is set.
int ptime_ms = 0;
if (codec->GetParam(kCodecParamPTime, &ptime_ms)) {
if (!WebRtcVoiceCodecs::SetPTimeAsPacketSize(
&send_codec_spec.codec_inst, ptime_ms)) {
LOG(LS_WARNING) << "Failed to set packet size for codec "
<< send_codec_spec.codec_inst.plname;
return false;
}
}
@ -1781,24 +1722,11 @@ bool WebRtcVoiceMediaChannel::SetSendCodecs(
bool WebRtcVoiceMediaChannel::SetSendCodecs(
int channel,
const webrtc::RtpParameters& rtp_parameters) {
// Disable VAD, FEC, and RED unless we know the other side wants them.
// Disable VAD, NACK and FEC unless we know the other side wants them.
engine()->voe()->codec()->SetVADStatus(channel, false);
engine()->voe()->rtp()->SetNACKStatus(channel, false, 0);
engine()->voe()->rtp()->SetREDStatus(channel, false);
engine()->voe()->codec()->SetFECStatus(channel, false);
if (send_codec_spec_.red_payload_type != -1) {
// Enable redundant encoding of the specified codec. Treat any
// failure as a fatal internal error.
LOG(LS_INFO) << "Enabling RED on channel " << channel;
if (engine()->voe()->rtp()->SetREDStatus(channel, true,
send_codec_spec_.red_payload_type) == -1) {
LOG_RTCERR3(SetREDStatus, channel, true,
send_codec_spec_.red_payload_type);
return false;
}
}
SetNack(channel, send_codec_spec_.nack_enabled);
// Set the codec immediately, since SetVADStatus() depends on whether

View File

@ -295,7 +295,6 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel,
bool enable_codec_fec = false;
bool enable_opus_dtx = false;
int opus_max_playback_rate = 0;
int red_payload_type = -1;
int cng_payload_type = -1;
int cng_plfreq = -1;
webrtc::CodecInst codec_inst;

View File

@ -38,7 +38,6 @@ const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1);
const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2);
const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1);
const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1);
const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1);
const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1);
const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1);
const cricket::AudioCodec kTelephoneEventCodec(106,
@ -1045,7 +1044,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) {
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kCn8000Codec);
parameters.codecs[0].id = 96;
parameters.codecs[0].bitrate = 48000;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
@ -1057,7 +1056,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) {
EXPECT_EQ(48000, gcodec.rate);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_FALSE(voe_.GetVAD(channel_num));
EXPECT_FALSE(voe_.GetRED(channel_num));
EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true));
EXPECT_FALSE(channel_->CanInsertDtmf());
@ -1070,7 +1068,7 @@ TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) {
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kCn8000Codec);
parameters.codecs[0].id = 96;
parameters.codecs[0].bitrate = 48000;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
@ -1979,7 +1977,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) {
parameters.codecs.push_back(kCn16000Codec);
parameters.codecs.push_back(kCn8000Codec);
parameters.codecs.push_back(kTelephoneEventCodec);
parameters.codecs.push_back(kRedCodec);
parameters.codecs[0].id = 96;
parameters.codecs[2].id = 97; // wideband CN
parameters.codecs[4].id = 98; // DTMF
@ -1989,7 +1986,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) {
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_TRUE(voe_.GetVAD(channel_num));
EXPECT_FALSE(voe_.GetRED(channel_num));
EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
EXPECT_TRUE(channel_->CanInsertDtmf());
@ -2005,7 +2001,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
parameters.codecs.push_back(kCn16000Codec);
parameters.codecs.push_back(kCn8000Codec);
parameters.codecs.push_back(kTelephoneEventCodec);
parameters.codecs.push_back(kRedCodec);
parameters.codecs[0].id = 96;
parameters.codecs[2].id = 97; // wideband CN
parameters.codecs[4].id = 98; // DTMF
@ -2019,7 +2014,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_TRUE(voe_.GetVAD(channel_num));
EXPECT_FALSE(voe_.GetRED(channel_num));
EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
EXPECT_TRUE(channel_->CanInsertDtmf());
@ -2072,7 +2066,6 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) {
parameters.codecs.push_back(kCn16000Codec);
parameters.codecs.push_back(kCn8000Codec);
parameters.codecs.push_back(kTelephoneEventCodec);
parameters.codecs.push_back(kRedCodec);
parameters.codecs[0].name = "iSaC";
parameters.codecs[0].id = 96;
parameters.codecs[2].id = 97; // wideband CN
@ -2083,168 +2076,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) {
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_TRUE(voe_.GetVAD(channel_num));
EXPECT_FALSE(voe_.GetRED(channel_num));
EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
EXPECT_TRUE(channel_->CanInsertDtmf());
}
// Test that we set up RED correctly as caller.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) {
EXPECT_TRUE(SetupSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs[0].id = 127;
parameters.codecs[0].params[""] = "96/96";
parameters.codecs[1].id = 96;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
webrtc::CodecInst gcodec;
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_TRUE(voe_.GetRED(channel_num));
EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
}
// Test that we set up RED correctly as callee.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) {
EXPECT_TRUE(SetupChannel());
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs[0].id = 127;
parameters.codecs[0].params[""] = "96/96";
parameters.codecs[1].id = 96;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
EXPECT_TRUE(channel_->AddSendStream(
cricket::StreamParams::CreateLegacy(kSsrc1)));
int channel_num = voe_.GetLastChannel();
webrtc::CodecInst gcodec;
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_TRUE(voe_.GetRED(channel_num));
EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
}
// Test that we set up RED correctly if params are omitted.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) {
EXPECT_TRUE(SetupSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs[0].id = 127;
parameters.codecs[1].id = 96;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
webrtc::CodecInst gcodec;
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_TRUE(voe_.GetRED(channel_num));
EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
}
// Test that we ignore RED if the parameters aren't named the way we expect.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) {
EXPECT_TRUE(SetupSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs[0].id = 127;
parameters.codecs[0].params["ABC"] = "96/96";
parameters.codecs[1].id = 96;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
webrtc::CodecInst gcodec;
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_FALSE(voe_.GetRED(channel_num));
}
// Test that we ignore RED if it uses different primary/secondary encoding.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) {
EXPECT_TRUE(SetupSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs[0].id = 127;
parameters.codecs[0].params[""] = "96/0";
parameters.codecs[1].id = 96;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
webrtc::CodecInst gcodec;
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_FALSE(voe_.GetRED(channel_num));
}
// Test that we ignore RED if it uses more than 2 encodings.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) {
EXPECT_TRUE(SetupSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs[0].id = 127;
parameters.codecs[0].params[""] = "96/96/96";
parameters.codecs[1].id = 96;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
webrtc::CodecInst gcodec;
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_FALSE(voe_.GetRED(channel_num));
}
// Test that we ignore RED if it has bogus codec ids.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) {
EXPECT_TRUE(SetupSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs[0].id = 127;
parameters.codecs[0].params[""] = "ABC/ABC";
parameters.codecs[1].id = 96;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
webrtc::CodecInst gcodec;
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_FALSE(voe_.GetRED(channel_num));
}
// Test that we ignore RED if it refers to a codec that is not present.
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) {
EXPECT_TRUE(SetupSendStream());
int channel_num = voe_.GetLastChannel();
cricket::AudioSendParameters parameters;
parameters.codecs.push_back(kRedCodec);
parameters.codecs.push_back(kIsacCodec);
parameters.codecs.push_back(kPcmuCodec);
parameters.codecs[0].id = 127;
parameters.codecs[0].params[""] = "97/97";
parameters.codecs[1].id = 96;
EXPECT_TRUE(channel_->SetSendParameters(parameters));
webrtc::CodecInst gcodec;
EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
EXPECT_EQ(96, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
EXPECT_FALSE(voe_.GetRED(channel_num));
}
class WebRtcVoiceEngineWithSendSideBweTest : public WebRtcVoiceEngineTestFake {
public:
WebRtcVoiceEngineWithSendSideBweTest()
@ -3602,8 +3438,6 @@ TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) {
cricket::AudioCodec(96, "PCMA", 8000, 0, 1), nullptr));
EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
cricket::AudioCodec(96, "G722", 8000, 0, 1), nullptr));
EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
cricket::AudioCodec(96, "red", 8000, 0, 1), nullptr));
EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr));
EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
@ -3653,8 +3487,6 @@ TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) {
EXPECT_EQ(9, it->id);
} else if (it->name == "telephone-event") {
EXPECT_EQ(126, it->id);
} else if (it->name == "red") {
EXPECT_EQ(127, it->id);
} else if (it->name == "opus") {
EXPECT_EQ(111, it->id);
ASSERT_TRUE(it->params.find("minptime") != it->params.end());