Index: webrtc/media/engine/webrtcvoiceengine_unittest.cc |
diff --git a/webrtc/media/engine/webrtcvoiceengine_unittest.cc b/webrtc/media/engine/webrtcvoiceengine_unittest.cc |
index 5809a08eaafa4ff2157db43f678bb718180ec2b7..e340a5e3cf5f52b655b6497c46ec07f6781e7f7b 100644 |
--- a/webrtc/media/engine/webrtcvoiceengine_unittest.cc |
+++ b/webrtc/media/engine/webrtcvoiceengine_unittest.cc |
@@ -31,6 +31,7 @@ |
#include "webrtc/test/gtest.h" |
#include "webrtc/voice_engine/transmit_mixer.h" |
+using testing::ContainerEq; |
using testing::Return; |
using testing::StrictMock; |
@@ -768,26 +769,12 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { |
parameters.codecs[2].id = 126; |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
EXPECT_TRUE(AddRecvStream(kSsrcX)); |
- int channel_num = voe_.GetLastChannel(); |
- |
- webrtc::CodecInst gcodec; |
- rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); |
- gcodec.plfreq = 16000; |
- gcodec.channels = 1; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); |
- EXPECT_EQ(106, gcodec.pltype); |
- EXPECT_STREQ("ISAC", gcodec.plname); |
- |
- rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event"); |
- gcodec.plfreq = 8000; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); |
- EXPECT_EQ(126, gcodec.pltype); |
- EXPECT_STREQ("telephone-event", gcodec.plname); |
- |
- gcodec.plfreq = 32000; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); |
- EXPECT_EQ(107, gcodec.pltype); |
- EXPECT_STREQ("telephone-event", gcodec.plname); |
+ EXPECT_THAT(GetRecvStreamConfig(kSsrcX).decoder_map, |
+ (ContainerEq<std::map<int, webrtc::SdpAudioFormat>>( |
+ {{0, {"PCMU", 8000, 1}}, |
+ {106, {"ISAC", 16000, 1}}, |
+ {126, {"telephone-event", 8000, 1}}, |
+ {107, {"telephone-event", 32000, 1}}}))); |
} |
// Test that we fail to set an unknown inbound codec. |
@@ -818,16 +805,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { |
parameters.codecs.push_back(kOpusCodec); |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
EXPECT_TRUE(AddRecvStream(kSsrcX)); |
- int channel_num = voe_.GetLastChannel(); |
- webrtc::CodecInst opus; |
- cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &opus); |
- // Even without stereo parameters, recv codecs still specify channels = 2. |
- EXPECT_EQ(2, opus.channels); |
- EXPECT_EQ(111, opus.pltype); |
- EXPECT_STREQ("opus", opus.plname); |
- opus.pltype = 0; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, opus)); |
- EXPECT_EQ(111, opus.pltype); |
+ EXPECT_THAT(GetRecvStreamConfig(kSsrcX).decoder_map, |
+ (ContainerEq<std::map<int, webrtc::SdpAudioFormat>>( |
+ {{0, {"PCMU", 8000, 1}}, |
+ {103, {"ISAC", 16000, 1}}, |
+ {111, {"opus", 48000, 2}}}))); |
} |
// Test that we can decode OPUS with stereo = 0. |
@@ -840,16 +822,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { |
parameters.codecs[2].params["stereo"] = "0"; |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
EXPECT_TRUE(AddRecvStream(kSsrcX)); |
- int channel_num2 = voe_.GetLastChannel(); |
- webrtc::CodecInst opus; |
- cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &opus); |
- // Even when stereo is off, recv codecs still specify channels = 2. |
- EXPECT_EQ(2, opus.channels); |
- EXPECT_EQ(111, opus.pltype); |
- EXPECT_STREQ("opus", opus.plname); |
- opus.pltype = 0; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); |
- EXPECT_EQ(111, opus.pltype); |
+ EXPECT_THAT(GetRecvStreamConfig(kSsrcX).decoder_map, |
+ (ContainerEq<std::map<int, webrtc::SdpAudioFormat>>( |
+ {{0, {"PCMU", 8000, 1}}, |
+ {103, {"ISAC", 16000, 1}}, |
+ {111, {"opus", 48000, 2, {{"stereo", "0"}}}}}))); |
} |
// Test that we can decode OPUS with stereo = 1. |
@@ -862,15 +839,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) { |
parameters.codecs[2].params["stereo"] = "1"; |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
EXPECT_TRUE(AddRecvStream(kSsrcX)); |
- int channel_num2 = voe_.GetLastChannel(); |
- webrtc::CodecInst opus; |
- cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &opus); |
- EXPECT_EQ(2, opus.channels); |
- EXPECT_EQ(111, opus.pltype); |
- EXPECT_STREQ("opus", opus.plname); |
- opus.pltype = 0; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); |
- EXPECT_EQ(111, opus.pltype); |
+ EXPECT_THAT(GetRecvStreamConfig(kSsrcX).decoder_map, |
+ (ContainerEq<std::map<int, webrtc::SdpAudioFormat>>( |
+ {{0, {"PCMU", 8000, 1}}, |
+ {103, {"ISAC", 16000, 1}}, |
+ {111, {"opus", 48000, 2, {{"stereo", "1"}}}}}))); |
} |
// Test that changes to recv codecs are applied to all streams. |
@@ -884,28 +857,15 @@ TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { |
parameters.codecs[0].id = 106; // collide with existing CN 32k |
parameters.codecs[2].id = 126; |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
- EXPECT_TRUE(AddRecvStream(kSsrcX)); |
- int channel_num2 = voe_.GetLastChannel(); |
- |
- webrtc::CodecInst gcodec; |
- rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); |
- gcodec.plfreq = 16000; |
- gcodec.channels = 1; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
- EXPECT_EQ(106, gcodec.pltype); |
- EXPECT_STREQ("ISAC", gcodec.plname); |
- |
- rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event"); |
- gcodec.plfreq = 8000; |
- gcodec.channels = 1; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
- EXPECT_EQ(126, gcodec.pltype); |
- EXPECT_STREQ("telephone-event", gcodec.plname); |
- |
- gcodec.plfreq = 32000; |
- EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
- EXPECT_EQ(107, gcodec.pltype); |
- EXPECT_STREQ("telephone-event", gcodec.plname); |
+ for (const auto& ssrc : {kSsrcX, kSsrcY}) { |
+ EXPECT_TRUE(AddRecvStream(ssrc)); |
+ EXPECT_THAT(GetRecvStreamConfig(ssrc).decoder_map, |
+ (ContainerEq<std::map<int, webrtc::SdpAudioFormat>>( |
+ {{0, {"PCMU", 8000, 1}}, |
+ {106, {"ISAC", 16000, 1}}, |
+ {126, {"telephone-event", 8000, 1}}, |
+ {107, {"telephone-event", 32000, 1}}}))); |
+ } |
} |
TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { |
@@ -2934,12 +2894,9 @@ TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { |
parameters.codecs.push_back(kPcmuCodec); |
EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
EXPECT_TRUE(AddRecvStream(kSsrcX)); |
- int channel_num2 = voe_.GetLastChannel(); |
- webrtc::CodecInst gcodec; |
- rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "opus"); |
- gcodec.plfreq = 48000; |
- gcodec.channels = 2; |
- EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); |
+ EXPECT_THAT(GetRecvStreamConfig(kSsrcX).decoder_map, |
+ (ContainerEq<std::map<int, webrtc::SdpAudioFormat>>( |
+ {{0, {"PCMU", 8000, 1}}, {103, {"ISAC", 16000, 1}}}))); |
} |
// Test that we properly clean up any streams that were added, even if |