Index: webrtc/media/engine/webrtcvoiceengine_unittest.cc |
diff --git a/webrtc/media/engine/webrtcvoiceengine_unittest.cc b/webrtc/media/engine/webrtcvoiceengine_unittest.cc |
index 75b632016697c9a179e7770df89f82457944e597..9635509364dfbf4a20dc09479b61f9e15fd09a48 100644 |
--- a/webrtc/media/engine/webrtcvoiceengine_unittest.cc |
+++ b/webrtc/media/engine/webrtcvoiceengine_unittest.cc |
@@ -41,7 +41,7 @@ constexpr uint32_t kMaxUnsignaledRecvStreams = 1; |
const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1); |
const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1); |
-const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2); |
+const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 32000, 2); |
const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1); |
const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1); |
const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1); |
@@ -362,34 +362,16 @@ class WebRtcVoiceEngineTestFake : public testing::Test { |
SetSendParameters(send_parameters); |
} |
- void CheckSendCodec(int32_t ssrc, |
- const char expected_name[], |
- int expected_channels, |
- int expected_bitrate) { |
- const auto& codec = GetSendStreamConfig(ssrc).send_codec_spec.codec_inst; |
- EXPECT_STREQ(expected_name, codec.plname); |
- EXPECT_EQ(expected_channels, codec.channels); |
- EXPECT_EQ(expected_bitrate, codec.rate); |
+ void CheckSendCodecBitrate(int32_t ssrc, |
+ const char expected_name[], |
+ int expected_bitrate) { |
+ const auto& spec = GetSendStreamConfig(ssrc).send_codec_spec; |
+ EXPECT_EQ(expected_name, spec->format.name); |
+ EXPECT_EQ(expected_bitrate, spec->target_bitrate_bps); |
} |
- int GetOpusMaxPlaybackRate(int32_t ssrc) { |
- return GetSendStreamConfig(ssrc).send_codec_spec.opus_max_playback_rate; |
- } |
- |
- bool GetOpusDtx(int32_t ssrc) { |
- return GetSendStreamConfig(ssrc).send_codec_spec.enable_opus_dtx; |
- } |
- |
- bool GetCodecFec(int32_t ssrc) { |
- return GetSendStreamConfig(ssrc).send_codec_spec.enable_codec_fec; |
- } |
- |
- int GetCodecBitrate(int32_t ssrc) { |
- return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.rate; |
- } |
- |
- int GetCodecPacSize(int32_t ssrc) { |
- return GetSendStreamConfig(ssrc).send_codec_spec.codec_inst.pacsize; |
+ rtc::Optional<int> GetCodecBitrate(int32_t ssrc) { |
+ return GetSendStreamConfig(ssrc).send_codec_spec->target_bitrate_bps; |
} |
const rtc::Optional<std::string>& GetAudioNetworkAdaptorConfig(int32_t ssrc) { |
@@ -718,19 +700,6 @@ TEST_F(WebRtcVoiceEngineTestFake, CreateRecvStream) { |
EXPECT_EQ("", config.sync_group); |
} |
-// Tests that the list of supported codecs is created properly and ordered |
-// correctly (such that opus appears first). |
-// TODO(ossu): This test should move into a separate builtin audio codecs |
-// module. |
-TEST_F(WebRtcVoiceEngineTestFake, CodecOrder) { |
- const std::vector<cricket::AudioCodec>& codecs = engine_->send_codecs(); |
- ASSERT_FALSE(codecs.empty()); |
- EXPECT_STRCASEEQ("opus", codecs[0].name.c_str()); |
- EXPECT_EQ(48000, codecs[0].clockrate); |
- EXPECT_EQ(2, codecs[0].channels); |
- EXPECT_EQ(64000, codecs[0].bitrate); |
-} |
- |
TEST_F(WebRtcVoiceEngineTestFake, OpusSupportsTransportCc) { |
const std::vector<cricket::AudioCodec>& codecs = engine_->send_codecs(); |
bool opus_found = false; |
@@ -743,46 +712,6 @@ TEST_F(WebRtcVoiceEngineTestFake, OpusSupportsTransportCc) { |
EXPECT_TRUE(opus_found); |
} |
-// Tests that we can find codecs by name or id, and that we interpret the |
-// clockrate and bitrate fields properly. |
-TEST_F(WebRtcVoiceEngineTestFake, FindCodec) { |
- cricket::AudioCodec codec; |
- webrtc::CodecInst codec_inst; |
- // Find PCMU with explicit clockrate and bitrate. |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kPcmuCodec, &codec_inst)); |
- // Find ISAC with explicit clockrate and 0 bitrate. |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kIsacCodec, &codec_inst)); |
- // Find telephone-event with explicit clockrate and 0 bitrate. |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kTelephoneEventCodec1, |
- &codec_inst)); |
- // Find telephone-event with explicit clockrate and 0 bitrate. |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kTelephoneEventCodec2, |
- &codec_inst)); |
- // Find ISAC with a different payload id. |
- codec = kIsacCodec; |
- codec.id = 127; |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); |
- EXPECT_EQ(codec.id, codec_inst.pltype); |
- // Find PCMU with a 0 clockrate. |
- codec = kPcmuCodec; |
- codec.clockrate = 0; |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); |
- EXPECT_EQ(codec.id, codec_inst.pltype); |
- EXPECT_EQ(8000, codec_inst.plfreq); |
- // Find PCMU with a 0 bitrate. |
- codec = kPcmuCodec; |
- codec.bitrate = 0; |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); |
- EXPECT_EQ(codec.id, codec_inst.pltype); |
- EXPECT_EQ(64000, codec_inst.rate); |
- // Find ISAC with an explicit bitrate. |
- codec = kIsacCodec; |
- codec.bitrate = 32000; |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); |
- EXPECT_EQ(codec.id, codec_inst.pltype); |
- EXPECT_EQ(32000, codec_inst.rate); |
-} |
- |
// Test that we set our inbound codecs properly, including changing PT. |
TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { |
EXPECT_TRUE(SetupChannel()); |
@@ -934,9 +863,6 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { |
parameters.codecs.push_back(kOpusCodec); |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
EXPECT_TRUE(GetRecvStream(kSsrcX).started()); |
- webrtc::CodecInst gcodec; |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &gcodec)); |
- EXPECT_EQ(kOpusCodec.id, gcodec.pltype); |
} |
TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { |
@@ -952,20 +878,17 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { |
// PCMU, default bitrate == 64000. |
TestMaxSendBandwidth(kPcmuCodec, -1, true, 64000); |
- // opus, default bitrate == 64000. |
- TestMaxSendBandwidth(kOpusCodec, -1, true, 64000); |
+ // opus, default bitrate == 32000 in mono. |
+ TestMaxSendBandwidth(kOpusCodec, -1, true, 32000); |
} |
TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { |
EXPECT_TRUE(SetupSendStream()); |
- // Test that the bitrate of a multi-rate codec is always the maximum. |
- |
// ISAC, default bitrate == 32000. |
- TestMaxSendBandwidth(kIsacCodec, 40000, true, 40000); |
TestMaxSendBandwidth(kIsacCodec, 16000, true, 16000); |
// Rates above the max (56000) should be capped. |
- TestMaxSendBandwidth(kIsacCodec, 100000, true, 56000); |
+ TestMaxSendBandwidth(kIsacCodec, 100000, true, 32000); |
// opus, default bitrate == 64000. |
TestMaxSendBandwidth(kOpusCodec, 96000, true, 96000); |
@@ -1028,8 +951,8 @@ TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { |
TEST_F(WebRtcVoiceEngineTestFake, SetMaxBitratePerStream) { |
EXPECT_TRUE(SetupSendStream()); |
- // opus, default bitrate == 64000. |
- SetAndExpectMaxBitrate(kOpusCodec, 0, 0, true, 64000); |
+ // opus, default bitrate == 32000. |
+ SetAndExpectMaxBitrate(kOpusCodec, 0, 0, true, 32000); |
SetAndExpectMaxBitrate(kOpusCodec, 48000, 0, true, 48000); |
SetAndExpectMaxBitrate(kOpusCodec, 48000, 64000, true, 48000); |
SetAndExpectMaxBitrate(kOpusCodec, 64000, 48000, true, 48000); |
@@ -1114,21 +1037,21 @@ TEST_F(WebRtcVoiceEngineTestFake, RtpParametersArePerStream) { |
// Configure one stream to be limited by the stream config, another to be |
// limited by the global max, and the third one with no per-stream limit |
// (still subject to the global limit). |
- SetGlobalMaxBitrate(kOpusCodec, 64000); |
- EXPECT_TRUE(SetMaxBitrateForStream(kSsrcs4[0], 48000)); |
- EXPECT_TRUE(SetMaxBitrateForStream(kSsrcs4[1], 96000)); |
+ SetGlobalMaxBitrate(kOpusCodec, 32000); |
+ EXPECT_TRUE(SetMaxBitrateForStream(kSsrcs4[0], 24000)); |
+ EXPECT_TRUE(SetMaxBitrateForStream(kSsrcs4[1], 48000)); |
EXPECT_TRUE(SetMaxBitrateForStream(kSsrcs4[2], -1)); |
- EXPECT_EQ(48000, GetCodecBitrate(kSsrcs4[0])); |
- EXPECT_EQ(64000, GetCodecBitrate(kSsrcs4[1])); |
- EXPECT_EQ(64000, GetCodecBitrate(kSsrcs4[2])); |
+ EXPECT_EQ(24000, GetCodecBitrate(kSsrcs4[0])); |
+ EXPECT_EQ(32000, GetCodecBitrate(kSsrcs4[1])); |
+ EXPECT_EQ(32000, GetCodecBitrate(kSsrcs4[2])); |
// Remove the global cap; the streams should switch to their respective |
// maximums (or remain unchanged if there was no other limit on them.) |
SetGlobalMaxBitrate(kOpusCodec, -1); |
- EXPECT_EQ(48000, GetCodecBitrate(kSsrcs4[0])); |
- EXPECT_EQ(96000, GetCodecBitrate(kSsrcs4[1])); |
- EXPECT_EQ(64000, GetCodecBitrate(kSsrcs4[2])); |
+ EXPECT_EQ(24000, GetCodecBitrate(kSsrcs4[0])); |
+ EXPECT_EQ(48000, GetCodecBitrate(kSsrcs4[1])); |
+ EXPECT_EQ(32000, GetCodecBitrate(kSsrcs4[2])); |
} |
// Test that GetRtpSendParameters returns the currently configured codecs. |
@@ -1283,22 +1206,20 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { |
parameters.codecs.push_back(kPcmuCodec); |
parameters.codecs.push_back(kCn8000Codec); |
parameters.codecs[0].id = 96; |
- parameters.codecs[0].bitrate = 48000; |
- const int initial_num = call_.GetNumCreatedSendStreams(); |
- SetSendParameters(parameters); |
- EXPECT_EQ(initial_num + 1, call_.GetNumCreatedSendStreams()); |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); |
- EXPECT_EQ(48000, send_codec_spec.codec_inst.rate); |
- EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
- EXPECT_NE(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
- EXPECT_EQ(-1, send_codec_spec.cng_payload_type); |
+ parameters.codecs[0].bitrate = 22000; |
+ SetSendParameters(parameters); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(96, send_codec_spec.payload_type); |
+ EXPECT_EQ(22000, send_codec_spec.target_bitrate_bps); |
+ EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); |
+ EXPECT_NE(send_codec_spec.format.clockrate_hz, 8000); |
+ EXPECT_EQ(rtc::Optional<int>(), send_codec_spec.cng_payload_type); |
EXPECT_FALSE(channel_->CanInsertDtmf()); |
} |
-// Test that VoE Channel doesn't call SetSendCodec again if same codec is tried |
-// to apply. |
-TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { |
+// Test that WebRtcVoiceEngine reconfigures, rather than recreates its |
+// AudioSendStream. |
+TEST_F(WebRtcVoiceEngineTestFake, DontRecreateSendStream) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
parameters.codecs.push_back(kIsacCodec); |
@@ -1308,24 +1229,15 @@ TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { |
parameters.codecs[0].bitrate = 48000; |
const int initial_num = call_.GetNumCreatedSendStreams(); |
SetSendParameters(parameters); |
- EXPECT_EQ(initial_num + 1, call_.GetNumCreatedSendStreams()); |
+ EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams()); |
// Calling SetSendCodec again with same codec which is already set. |
// In this case media channel shouldn't send codec to VoE. |
SetSendParameters(parameters); |
- EXPECT_EQ(initial_num + 1, call_.GetNumCreatedSendStreams()); |
+ EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams()); |
} |
-// Verify that G722 is set with 16000 samples per second to WebRTC. |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kG722CodecSdp); |
- SetSendParameters(parameters); |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_STREQ("G722", gcodec.plname); |
- EXPECT_EQ(1, gcodec.channels); |
- EXPECT_EQ(16000, gcodec.plfreq); |
-} |
+// TODO(ossu): Revisit if these tests need to be here, now that these kinds of |
+// tests should be available in AudioEncoderOpusTest. |
// Test that if clockrate is not 48000 for opus, we fail. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { |
@@ -1390,19 +1302,17 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { |
EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
} |
-// Test that with bitrate=0 and no stereo, |
-// channels and bitrate are 1 and 32000. |
+// Test that with bitrate=0 and no stereo, bitrate is 32000. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
parameters.codecs.push_back(kOpusCodec); |
parameters.codecs[0].bitrate = 0; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 1, 32000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 32000); |
} |
-// Test that with bitrate=0 and stereo=0, |
-// channels and bitrate are 1 and 32000. |
+// Test that with bitrate=0 and stereo=0, bitrate is 32000. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
@@ -1410,11 +1320,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { |
parameters.codecs[0].bitrate = 0; |
parameters.codecs[0].params["stereo"] = "0"; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 1, 32000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 32000); |
} |
-// Test that with bitrate=invalid and stereo=0, |
-// channels and bitrate are 1 and 32000. |
+// Test that with bitrate=invalid and stereo=0, bitrate is 32000. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
@@ -1423,15 +1332,14 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { |
// bitrate that's out of the range between 6000 and 510000 will be clamped. |
parameters.codecs[0].bitrate = 5999; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 1, 6000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 6000); |
parameters.codecs[0].bitrate = 510001; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 1, 510000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 510000); |
} |
-// Test that with bitrate=0 and stereo=1, |
-// channels and bitrate are 2 and 64000. |
+// Test that with bitrate=0 and stereo=1, bitrate is 64000. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
@@ -1439,11 +1347,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { |
parameters.codecs[0].bitrate = 0; |
parameters.codecs[0].params["stereo"] = "1"; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 2, 64000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 64000); |
} |
-// Test that with bitrate=invalid and stereo=1, |
-// channels and bitrate are 2 and 64000. |
+// Test that with bitrate=invalid and stereo=1, bitrate is 64000. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
@@ -1452,31 +1359,29 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { |
// bitrate that's out of the range between 6000 and 510000 will be clamped. |
parameters.codecs[0].bitrate = 5999; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 2, 6000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 6000); |
parameters.codecs[0].bitrate = 510001; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 2, 510000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 510000); |
} |
-// Test that with bitrate=N and stereo unset, |
-// channels and bitrate are 1 and N. |
+// Test that with bitrate=N and stereo unset, bitrate is N. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
parameters.codecs.push_back(kOpusCodec); |
parameters.codecs[0].bitrate = 96000; |
SetSendParameters(parameters); |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(111, gcodec.pltype); |
- EXPECT_EQ(96000, gcodec.rate); |
- EXPECT_STREQ("opus", gcodec.plname); |
- EXPECT_EQ(1, gcodec.channels); |
- EXPECT_EQ(48000, gcodec.plfreq); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(111, spec.payload_type); |
+ EXPECT_EQ(96000, spec.target_bitrate_bps); |
+ EXPECT_EQ("opus", spec.format.name); |
+ EXPECT_EQ(2, spec.format.num_channels); |
+ EXPECT_EQ(48000, spec.format.clockrate_hz); |
} |
-// Test that with bitrate=N and stereo=0, |
-// channels and bitrate are 1 and N. |
+// Test that with bitrate=N and stereo=0, bitrate is N. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
@@ -1484,22 +1389,20 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { |
parameters.codecs[0].bitrate = 30000; |
parameters.codecs[0].params["stereo"] = "0"; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 1, 30000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 30000); |
} |
-// Test that with bitrate=N and without any parameters, |
-// channels and bitrate are 1 and N. |
+// Test that with bitrate=N and without any parameters, bitrate is N. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
parameters.codecs.push_back(kOpusCodec); |
parameters.codecs[0].bitrate = 30000; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 1, 30000); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 30000); |
} |
-// Test that with bitrate=N and stereo=1, |
-// channels and bitrate are 2 and N. |
+// Test that with bitrate=N and stereo=1, bitrate is N. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { |
EXPECT_TRUE(SetupSendStream()); |
cricket::AudioSendParameters parameters; |
@@ -1507,30 +1410,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { |
parameters.codecs[0].bitrate = 30000; |
parameters.codecs[0].params["stereo"] = "1"; |
SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 2, 30000); |
-} |
- |
-// Test that bitrate will be overridden by the "maxaveragebitrate" parameter. |
-// Also test that the "maxaveragebitrate" can't be set to values outside the |
-// range of 6000 and 510000 |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 30000; |
- // Ignore if less than 6000. |
- parameters.codecs[0].params["maxaveragebitrate"] = "5999"; |
- SetSendParameters(parameters); |
- EXPECT_EQ(6000, GetCodecBitrate(kSsrcX)); |
- |
- // Ignore if larger than 510000. |
- parameters.codecs[0].params["maxaveragebitrate"] = "510001"; |
- SetSendParameters(parameters); |
- EXPECT_EQ(510000, GetCodecBitrate(kSsrcX)); |
- |
- parameters.codecs[0].params["maxaveragebitrate"] = "200000"; |
- SetSendParameters(parameters); |
- EXPECT_EQ(200000, GetCodecBitrate(kSsrcX)); |
+ CheckSendCodecBitrate(kSsrcX, "opus", 30000); |
} |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithBitrates) { |
@@ -1666,83 +1546,6 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { |
EXPECT_EQ(kRtpHistoryMs, GetRecvStreamConfig(kSsrcZ).rtp.nack.rtp_history_ms); |
} |
-// Test that without useinbandfec, Opus FEC is off. |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- SetSendParameters(parameters); |
- EXPECT_FALSE(GetCodecFec(kSsrcX)); |
-} |
- |
-// Test that with useinbandfec=0, Opus FEC is off. |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 0; |
- parameters.codecs[0].params["useinbandfec"] = "0"; |
- SetSendParameters(parameters); |
- CheckSendCodec(kSsrcX, "opus", 1, 32000); |
-} |
- |
-// Test that with useinbandfec=1, Opus FEC is on. |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 0; |
- parameters.codecs[0].params["useinbandfec"] = "1"; |
- SetSendParameters(parameters); |
- EXPECT_TRUE(GetCodecFec(kSsrcX)); |
- CheckSendCodec(kSsrcX, "opus", 1, 32000); |
-} |
- |
-// Test that with useinbandfec=1, stereo=1, Opus FEC is on. |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 0; |
- parameters.codecs[0].params["stereo"] = "1"; |
- parameters.codecs[0].params["useinbandfec"] = "1"; |
- SetSendParameters(parameters); |
- EXPECT_TRUE(GetCodecFec(kSsrcX)); |
- CheckSendCodec(kSsrcX, "opus", 2, 64000); |
-} |
- |
-// Test that with non-Opus, codec FEC is off. |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kIsacCodec); |
- SetSendParameters(parameters); |
- EXPECT_FALSE(GetCodecFec(kSsrcX)); |
-} |
- |
-// Test the with non-Opus, even if useinbandfec=1, FEC is off. |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kIsacCodec); |
- parameters.codecs[0].params["useinbandfec"] = "1"; |
- SetSendParameters(parameters); |
- EXPECT_FALSE(GetCodecFec(kSsrcX)); |
-} |
- |
-// Test that Opus FEC status can be changed. |
-TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- SetSendParameters(parameters); |
- EXPECT_FALSE(GetCodecFec(kSsrcX)); |
- |
- parameters.codecs[0].params["useinbandfec"] = "1"; |
- SetSendParameters(parameters); |
- EXPECT_TRUE(GetCodecFec(kSsrcX)); |
-} |
- |
TEST_F(WebRtcVoiceEngineTestFake, TransportCcCanBeEnabledAndDisabled) { |
EXPECT_TRUE(SetupChannel()); |
cricket::AudioSendParameters send_parameters; |
@@ -1765,162 +1568,6 @@ TEST_F(WebRtcVoiceEngineTestFake, TransportCcCanBeEnabledAndDisabled) { |
call_.GetAudioReceiveStream(kSsrcX)->GetConfig().rtp.transport_cc); |
} |
-// Test maxplaybackrate <= 8000 triggers Opus narrow band mode. |
-TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 0; |
- parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); |
- SetSendParameters(parameters); |
- EXPECT_EQ(8000, GetOpusMaxPlaybackRate(kSsrcX)); |
- EXPECT_EQ(12000, GetCodecBitrate(kSsrcX)); |
- |
- parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
- SetSendParameters(parameters); |
- EXPECT_EQ(24000, GetCodecBitrate(kSsrcX)); |
-} |
- |
-// Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode. |
-TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 0; |
- parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001); |
- SetSendParameters(parameters); |
- EXPECT_EQ(8001, GetOpusMaxPlaybackRate(kSsrcX)); |
- EXPECT_EQ(20000, GetCodecBitrate(kSsrcX)); |
- |
- parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
- SetSendParameters(parameters); |
- EXPECT_EQ(40000, GetCodecBitrate(kSsrcX)); |
-} |
- |
-// Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode. |
-TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 0; |
- parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001); |
- SetSendParameters(parameters); |
- EXPECT_EQ(12001, GetOpusMaxPlaybackRate(kSsrcX)); |
- EXPECT_EQ(20000, GetCodecBitrate(kSsrcX)); |
- |
- parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
- SetSendParameters(parameters); |
- EXPECT_EQ(40000, GetCodecBitrate(kSsrcX)); |
-} |
- |
-// Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode. |
-TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 0; |
- parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001); |
- SetSendParameters(parameters); |
- EXPECT_EQ(16001, GetOpusMaxPlaybackRate(kSsrcX)); |
- EXPECT_EQ(32000, GetCodecBitrate(kSsrcX)); |
- |
- parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
- SetSendParameters(parameters); |
- EXPECT_EQ(64000, GetCodecBitrate(kSsrcX)); |
-} |
- |
-// Test 24000 < maxplaybackrate triggers Opus full band mode. |
-TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].bitrate = 0; |
- parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001); |
- SetSendParameters(parameters); |
- EXPECT_EQ(24001, GetOpusMaxPlaybackRate(kSsrcX)); |
- EXPECT_EQ(32000, GetCodecBitrate(kSsrcX)); |
- |
- parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
- SetSendParameters(parameters); |
- EXPECT_EQ(64000, GetCodecBitrate(kSsrcX)); |
-} |
- |
-// Test Opus that without maxplaybackrate, default playback rate is used. |
-TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- SetSendParameters(parameters); |
- EXPECT_EQ(48000, GetOpusMaxPlaybackRate(kSsrcX)); |
-} |
- |
-// Test the with non-Opus, maxplaybackrate has no effect. |
-TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kIsacCodec); |
- parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000); |
- SetSendParameters(parameters); |
- EXPECT_EQ(0, GetOpusMaxPlaybackRate(kSsrcX)); |
-} |
- |
-// Test maxplaybackrate can be set on two streams. |
-TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- SetSendParameters(parameters); |
- EXPECT_EQ(48000, GetOpusMaxPlaybackRate(kSsrcX)); |
- |
- parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); |
- SetSendParameters(parameters); |
- EXPECT_EQ(8000, GetOpusMaxPlaybackRate(kSsrcX)); |
- |
- channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrcY)); |
- EXPECT_EQ(8000, GetOpusMaxPlaybackRate(kSsrcY)); |
-} |
- |
-// Test that with usedtx=0, Opus DTX is off. |
-TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].params["usedtx"] = "0"; |
- SetSendParameters(parameters); |
- EXPECT_FALSE(GetOpusDtx(kSsrcX)); |
-} |
- |
-// Test that with usedtx=1, Opus DTX is on. |
-TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].params["usedtx"] = "1"; |
- SetSendParameters(parameters); |
- EXPECT_TRUE(GetOpusDtx(kSsrcX)); |
-} |
- |
-// Test that usedtx=1 works with stereo Opus. |
-TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].params["usedtx"] = "1"; |
- parameters.codecs[0].params["stereo"] = "1"; |
- SetSendParameters(parameters); |
- EXPECT_TRUE(GetOpusDtx(kSsrcX)); |
-} |
- |
-// Test that usedtx=1 does not work with non Opus. |
-TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kIsacCodec); |
- parameters.codecs[0].params["usedtx"] = "1"; |
- SetSendParameters(parameters); |
- EXPECT_FALSE(GetOpusDtx(kSsrcX)); |
-} |
- |
// Test that we can switch back and forth between Opus and ISAC with CN. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { |
EXPECT_TRUE(SetupSendStream()); |
@@ -1929,9 +1576,9 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { |
opus_parameters.codecs.push_back(kOpusCodec); |
SetSendParameters(opus_parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(111, gcodec.pltype); |
- EXPECT_STREQ("opus", gcodec.plname); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(111, spec.payload_type); |
+ EXPECT_STRCASEEQ("opus", spec.format.name.c_str()); |
} |
cricket::AudioSendParameters isac_parameters; |
@@ -1940,16 +1587,16 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { |
isac_parameters.codecs.push_back(kOpusCodec); |
SetSendParameters(isac_parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(103, gcodec.pltype); |
- EXPECT_STREQ("ISAC", gcodec.plname); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(103, spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", spec.format.name.c_str()); |
} |
SetSendParameters(opus_parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(111, gcodec.pltype); |
- EXPECT_STREQ("opus", gcodec.plname); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(111, spec.payload_type); |
+ EXPECT_STRCASEEQ("opus", spec.format.name.c_str()); |
} |
} |
@@ -1960,88 +1607,58 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { |
parameters.codecs.push_back(kIsacCodec); // bitrate == 32000 |
SetSendParameters(parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(103, gcodec.pltype); |
- EXPECT_STREQ("ISAC", gcodec.plname); |
- EXPECT_EQ(32000, gcodec.rate); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(103, spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", spec.format.name.c_str()); |
+ EXPECT_EQ(32000, spec.target_bitrate_bps); |
} |
parameters.codecs[0].bitrate = 0; // bitrate == default |
SetSendParameters(parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(103, gcodec.pltype); |
- EXPECT_STREQ("ISAC", gcodec.plname); |
- EXPECT_EQ(32000, gcodec.rate); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(103, spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", spec.format.name.c_str()); |
+ EXPECT_EQ(32000, spec.target_bitrate_bps); |
} |
parameters.codecs[0].bitrate = 28000; // bitrate == 28000 |
SetSendParameters(parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(103, gcodec.pltype); |
- EXPECT_STREQ("ISAC", gcodec.plname); |
- EXPECT_EQ(28000, gcodec.rate); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(103, spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", spec.format.name.c_str()); |
+ EXPECT_EQ(28000, spec.target_bitrate_bps); |
} |
parameters.codecs[0] = kPcmuCodec; // bitrate == 64000 |
SetSendParameters(parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(0, gcodec.pltype); |
- EXPECT_STREQ("PCMU", gcodec.plname); |
- EXPECT_EQ(64000, gcodec.rate); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(0, spec.payload_type); |
+ EXPECT_STRCASEEQ("PCMU", spec.format.name.c_str()); |
+ EXPECT_EQ(64000, spec.target_bitrate_bps); |
} |
parameters.codecs[0].bitrate = 0; // bitrate == default |
SetSendParameters(parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(0, gcodec.pltype); |
- EXPECT_STREQ("PCMU", gcodec.plname); |
- EXPECT_EQ(64000, gcodec.rate); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(0, spec.payload_type); |
+ EXPECT_STREQ("PCMU", spec.format.name.c_str()); |
+ EXPECT_EQ(64000, spec.target_bitrate_bps); |
} |
parameters.codecs[0] = kOpusCodec; |
parameters.codecs[0].bitrate = 0; // bitrate == default |
SetSendParameters(parameters); |
{ |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(111, gcodec.pltype); |
- EXPECT_STREQ("opus", gcodec.plname); |
- EXPECT_EQ(32000, gcodec.rate); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(111, spec.payload_type); |
+ EXPECT_STREQ("opus", spec.format.name.c_str()); |
+ EXPECT_EQ(32000, spec.target_bitrate_bps); |
} |
} |
-// Test that we could set packet size specified in kCodecParamPTime. |
-TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { |
- EXPECT_TRUE(SetupSendStream()); |
- cricket::AudioSendParameters parameters; |
- parameters.codecs.push_back(kOpusCodec); |
- parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range. |
- SetSendParameters(parameters); |
- EXPECT_EQ(1920, GetCodecPacSize(kSsrcX)); // Opus gets 40ms. |
- |
- parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Below range. |
- SetSendParameters(parameters); |
- EXPECT_EQ(480, GetCodecPacSize(kSsrcX)); // Opus gets 10ms. |
- |
- parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 80); // Beyond range. |
- SetSendParameters(parameters); |
- EXPECT_EQ(2880, GetCodecPacSize(kSsrcX)); // Opus gets 60ms. |
- |
- parameters.codecs[0] = kIsacCodec; // Also try Isac, with unsupported size. |
- parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range. |
- SetSendParameters(parameters); |
- EXPECT_EQ(480, GetCodecPacSize( |
- kSsrcX)); // Isac gets 30ms as the next smallest value. |
- |
- parameters.codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP. |
- parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); |
- SetSendParameters(parameters); |
- EXPECT_EQ(640, GetCodecPacSize( |
- kSsrcX)); // G722 gets 40ms @16kHz as defined in VoE. |
-} |
- |
// Test that we fail if no codecs are specified. |
TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { |
EXPECT_TRUE(SetupSendStream()); |
@@ -2060,9 +1677,9 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { |
parameters.codecs[0].id = 98; // DTMF |
parameters.codecs[1].id = 96; |
SetSendParameters(parameters); |
- const auto& gcodec = GetSendStreamConfig(kSsrcX).send_codec_spec.codec_inst; |
- EXPECT_EQ(96, gcodec.pltype); |
- EXPECT_STREQ("ISAC", gcodec.plname); |
+ const auto& spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(96, spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", spec.format.name.c_str()); |
EXPECT_TRUE(channel_->CanInsertDtmf()); |
} |
@@ -2098,11 +1715,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { |
parameters.codecs[0].id = 98; // wideband CN |
parameters.codecs[1].id = 96; |
SetSendParameters(parameters); |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); |
- EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(96, send_codec_spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); |
EXPECT_EQ(98, send_codec_spec.cng_payload_type); |
- EXPECT_EQ(webrtc::kFreq16000Hz, send_codec_spec.cng_plfreq); |
} |
// Test that we set VAD and DTMF types correctly as caller. |
@@ -2119,13 +1735,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { |
parameters.codecs[2].id = 97; // wideband CN |
parameters.codecs[4].id = 98; // DTMF |
SetSendParameters(parameters); |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); |
- EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
- EXPECT_EQ(1, send_codec_spec.codec_inst.channels); |
- EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(96, send_codec_spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(1, send_codec_spec.format.num_channels); |
EXPECT_EQ(97, send_codec_spec.cng_payload_type); |
- EXPECT_EQ(webrtc::kFreq16000Hz, send_codec_spec.cng_plfreq); |
EXPECT_TRUE(channel_->CanInsertDtmf()); |
} |
@@ -2146,13 +1760,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { |
EXPECT_TRUE(channel_->AddSendStream( |
cricket::StreamParams::CreateLegacy(kSsrcX))); |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); |
- EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
- EXPECT_EQ(1, send_codec_spec.codec_inst.channels); |
- EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(96, send_codec_spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(1, send_codec_spec.format.num_channels); |
EXPECT_EQ(97, send_codec_spec.cng_payload_type); |
- EXPECT_EQ(webrtc::kFreq16000Hz, send_codec_spec.cng_plfreq); |
EXPECT_TRUE(channel_->CanInsertDtmf()); |
} |
@@ -2167,39 +1779,35 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { |
parameters.codecs[1].id = 97; |
SetSendParameters(parameters); |
{ |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
- EXPECT_EQ(1, send_codec_spec.codec_inst.channels); |
- EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(1, send_codec_spec.format.num_channels); |
EXPECT_EQ(97, send_codec_spec.cng_payload_type); |
- EXPECT_EQ(webrtc::kFreq16000Hz, send_codec_spec.cng_plfreq); |
} |
// Set PCMU(8K) and CN(16K). VAD should not be activated. |
parameters.codecs[0] = kPcmuCodec; |
SetSendParameters(parameters); |
{ |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_STREQ("PCMU", send_codec_spec.codec_inst.plname); |
- EXPECT_NE(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_STRCASEEQ("PCMU", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(rtc::Optional<int>(), send_codec_spec.cng_payload_type); |
} |
// Set PCMU(8K) and CN(8K). VAD should be activated. |
parameters.codecs[1] = kCn8000Codec; |
SetSendParameters(parameters); |
{ |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_STREQ("PCMU", send_codec_spec.codec_inst.plname); |
- EXPECT_EQ(1, send_codec_spec.codec_inst.channels); |
- EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_STRCASEEQ("PCMU", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(1, send_codec_spec.format.num_channels); |
EXPECT_EQ(13, send_codec_spec.cng_payload_type); |
- EXPECT_EQ(webrtc::kFreq8000Hz, send_codec_spec.cng_plfreq); |
} |
// Set ISAC(16K) and CN(8K). VAD should not be activated. |
parameters.codecs[0] = kIsacCodec; |
SetSendParameters(parameters); |
{ |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
- EXPECT_NE(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(rtc::Optional<int>(), send_codec_spec.cng_payload_type); |
} |
} |
@@ -2217,13 +1825,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { |
parameters.codecs[2].id = 97; // wideband CN |
parameters.codecs[4].id = 98; // DTMF |
SetSendParameters(parameters); |
- const auto& send_codec_spec = GetSendStreamConfig(kSsrcX).send_codec_spec; |
- EXPECT_EQ(96, send_codec_spec.codec_inst.pltype); |
- EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
- EXPECT_EQ(1, send_codec_spec.codec_inst.channels); |
- EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
+ const auto& send_codec_spec = *GetSendStreamConfig(kSsrcX).send_codec_spec; |
+ EXPECT_EQ(96, send_codec_spec.payload_type); |
+ EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(1, send_codec_spec.format.num_channels); |
EXPECT_EQ(97, send_codec_spec.cng_payload_type); |
- EXPECT_EQ(webrtc::kFreq16000Hz, send_codec_spec.cng_plfreq); |
EXPECT_TRUE(channel_->CanInsertDtmf()); |
} |
@@ -2381,12 +1987,10 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { |
for (uint32_t ssrc : kSsrcs4) { |
ASSERT_TRUE(call_.GetAudioSendStream(ssrc) != nullptr); |
const auto& send_codec_spec = |
- call_.GetAudioSendStream(ssrc)->GetConfig().send_codec_spec; |
- EXPECT_STREQ("ISAC", send_codec_spec.codec_inst.plname); |
- EXPECT_EQ(send_codec_spec.codec_inst.plfreq, send_codec_spec.cng_plfreq); |
- EXPECT_EQ(1, send_codec_spec.codec_inst.channels); |
+ *call_.GetAudioSendStream(ssrc)->GetConfig().send_codec_spec; |
+ EXPECT_STRCASEEQ("ISAC", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(1, send_codec_spec.format.num_channels); |
EXPECT_EQ(97, send_codec_spec.cng_payload_type); |
- EXPECT_EQ(webrtc::kFreq16000Hz, send_codec_spec.cng_plfreq); |
} |
// Change to PCMU(8K) and CN(16K). |
@@ -2395,9 +1999,9 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { |
for (uint32_t ssrc : kSsrcs4) { |
ASSERT_TRUE(call_.GetAudioSendStream(ssrc) != nullptr); |
const auto& send_codec_spec = |
- call_.GetAudioSendStream(ssrc)->GetConfig().send_codec_spec; |
- EXPECT_STREQ("PCMU", send_codec_spec.codec_inst.plname); |
- EXPECT_EQ(-1, send_codec_spec.cng_payload_type); |
+ *call_.GetAudioSendStream(ssrc)->GetConfig().send_codec_spec; |
+ EXPECT_STRCASEEQ("PCMU", send_codec_spec.format.name.c_str()); |
+ EXPECT_EQ(rtc::Optional<int>(), send_codec_spec.cng_payload_type); |
} |
} |
@@ -2593,12 +2197,9 @@ TEST_F(WebRtcVoiceEngineTestFake, AudioSendResetAudioNetworkAdaptor) { |
SetSendParameters(send_parameters_); |
EXPECT_EQ(send_parameters_.options.audio_network_adaptor_config, |
GetAudioNetworkAdaptorConfig(kSsrcX)); |
- const int initial_num = call_.GetNumCreatedSendStreams(); |
cricket::AudioOptions options; |
options.audio_network_adaptor = rtc::Optional<bool>(false); |
SetAudioSend(kSsrcX, true, nullptr, &options); |
- // AudioSendStream expected to be recreated. |
- EXPECT_EQ(initial_num + 1, call_.GetNumCreatedSendStreams()); |
EXPECT_EQ(rtc::Optional<std::string>(), GetAudioNetworkAdaptorConfig(kSsrcX)); |
} |
@@ -3671,95 +3272,39 @@ TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { |
} |
} |
-// Tests that the library is configured with the codecs we want. |
-TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { |
- // TODO(ossu): These tests should move into a future "builtin audio codecs" |
- // module. |
- |
- // Check codecs by name. |
-#ifdef WEBRTC_CODEC_OPUS |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "OPUS", 48000, 0, 2), nullptr)); |
-#endif |
-#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "ISAC", 16000, 0, 1), nullptr)); |
-#endif |
-#if (defined(WEBRTC_CODEC_ISAC)) |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "ISAC", 32000, 0, 1), nullptr)); |
-#endif |
-#ifdef WEBRTC_CODEC_ILBC |
- // Check that name matching is case-insensitive. |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "ILBC", 8000, 0, 1), nullptr)); |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "iLBC", 8000, 0, 1), nullptr)); |
-#endif |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr)); |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "CN", 16000, 0, 1), nullptr)); |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "telephone-event", 8000, 0, 1), nullptr)); |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "telephone-event", 16000, 0, 1), nullptr)); |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "telephone-event", 32000, 0, 1), nullptr)); |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(96, "telephone-event", 48000, 0, 1), nullptr)); |
- // Check codecs with an id by id. |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(0, "", 8000, 0, 1), nullptr)); // PCMU |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(8, "", 8000, 0, 1), nullptr)); // PCMA |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(9, "", 8000, 0, 1), nullptr)); // G722 |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(13, "", 8000, 0, 1), nullptr)); // CN |
- // Check sample/bitrate matching. |
- EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(0, "PCMU", 8000, 64000, 1), nullptr)); |
- // Check that bad codecs fail. |
- EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(99, "ABCD", 0, 0, 1), nullptr)); |
- EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(88, "", 0, 0, 1), nullptr)); |
- EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(0, "", 0, 0, 2), nullptr)); |
- EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(0, "", 5000, 0, 1), nullptr)); |
- EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
- cricket::AudioCodec(0, "", 0, 5000, 1), nullptr)); |
- |
- // Verify the payload id of common audio codecs, including CN, ISAC, and G722. |
+// Verify the payload id of common audio codecs, including CN, ISAC, and G722. |
+TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { |
// TODO(ossu): Why are the payload types of codecs with non-static payload |
// type assignments checked here? It shouldn't really matter. |
cricket::WebRtcVoiceEngine engine( |
nullptr, webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr); |
for (const cricket::AudioCodec& codec : engine.send_codecs()) { |
- if (codec.name == "CN" && codec.clockrate == 16000) { |
+ auto is_codec = [&codec](const char* name, int clockrate = 0) { |
+ return STR_CASE_CMP(codec.name.c_str(), name) == 0 && |
+ (clockrate == 0 || codec.clockrate == clockrate); |
+ }; |
+ if (is_codec("CN", 16000)) { |
EXPECT_EQ(105, codec.id); |
- } else if (codec.name == "CN" && codec.clockrate == 32000) { |
+ } else if (is_codec("CN", 32000)) { |
EXPECT_EQ(106, codec.id); |
- } else if (codec.name == "ISAC" && codec.clockrate == 16000) { |
+ } else if (is_codec("ISAC", 16000)) { |
EXPECT_EQ(103, codec.id); |
- } else if (codec.name == "ISAC" && codec.clockrate == 32000) { |
+ } else if (is_codec("ISAC", 32000)) { |
EXPECT_EQ(104, codec.id); |
- } else if (codec.name == "G722" && codec.clockrate == 8000) { |
+ } else if (is_codec("G722", 8000)) { |
EXPECT_EQ(9, codec.id); |
- } else if (codec.name == "telephone-event" && codec.clockrate == 8000) { |
+ } else if (is_codec("telephone-event", 8000)) { |
EXPECT_EQ(126, codec.id); |
// TODO(solenberg): 16k, 32k, 48k DTMF should be dynamically assigned. |
// Remove these checks once both send and receive side assigns payload types |
// dynamically. |
- } else if (codec.name == "telephone-event" && codec.clockrate == 16000) { |
+ } else if (is_codec("telephone-event", 16000)) { |
EXPECT_EQ(113, codec.id); |
- } else if (codec.name == "telephone-event" && codec.clockrate == 32000) { |
+ } else if (is_codec("telephone-event", 32000)) { |
EXPECT_EQ(112, codec.id); |
- } else if (codec.name == "telephone-event" && codec.clockrate == 48000) { |
+ } else if (is_codec("telephone-event", 48000)) { |
EXPECT_EQ(110, codec.id); |
- } else if (codec.name == "opus") { |
+ } else if (is_codec("opus")) { |
EXPECT_EQ(111, codec.id); |
ASSERT_TRUE(codec.params.find("minptime") != codec.params.end()); |
EXPECT_EQ("10", codec.params.find("minptime")->second); |