Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine_unittest.cc

Issue 1364643003: Remove the default send channel in WVoE. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@wvoe_default_receive_channel
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2008 Google Inc. 3 * Copyright 2008 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 bool SetupEngineWithSendStream() { 116 bool SetupEngineWithSendStream() {
117 if (!SetupEngine()) { 117 if (!SetupEngine()) {
118 return false; 118 return false;
119 } 119 }
120 return channel_->AddSendStream( 120 return channel_->AddSendStream(
121 cricket::StreamParams::CreateLegacy(kSsrc1)); 121 cricket::StreamParams::CreateLegacy(kSsrc1));
122 } 122 }
123 void SetupForMultiSendStream() { 123 void SetupForMultiSendStream() {
124 EXPECT_TRUE(SetupEngineWithSendStream()); 124 EXPECT_TRUE(SetupEngineWithSendStream());
125 // Remove stream added in Setup, which is corresponding to default channel. 125 // Remove stream added in Setup.
126 int default_channel_num = voe_.GetLastChannel(); 126 int default_channel_num = voe_.GetLastChannel();
127 uint32_t default_send_ssrc = 0u; 127 uint32_t default_send_ssrc = 0u;
128 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); 128 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc));
129 EXPECT_EQ(kSsrc1, default_send_ssrc); 129 EXPECT_EQ(kSsrc1, default_send_ssrc);
130 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc)); 130 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc));
131 131
132 // Verify the default channel still exists. 132 // Verify the channel does not exist.
133 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); 133 EXPECT_EQ(-1, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc));
134 } 134 }
135 void DeliverPacket(const void* data, int len) { 135 void DeliverPacket(const void* data, int len) {
136 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len); 136 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len);
137 channel_->OnPacketReceived(&packet, rtc::PacketTime()); 137 channel_->OnPacketReceived(&packet, rtc::PacketTime());
138 } 138 }
139 void TearDown() override { 139 void TearDown() override {
140 delete channel_; 140 delete channel_;
141 engine_.Terminate(); 141 engine_.Terminate();
142 } 142 }
143 143
144 void TestInsertDtmf(uint32_t ssrc, bool caller) { 144 void TestInsertDtmf(uint32_t ssrc, bool caller) {
145 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 145 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
146 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 146 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
147 EXPECT_TRUE(channel_ != nullptr); 147 EXPECT_TRUE(channel_ != nullptr);
148 if (caller) { 148 if (caller) {
149 // if this is a caller, local description will be applied and add the 149 // If this is a caller, local description will be applied and add the
150 // send stream. 150 // send stream.
151 EXPECT_TRUE(channel_->AddSendStream( 151 EXPECT_TRUE(channel_->AddSendStream(
152 cricket::StreamParams::CreateLegacy(kSsrc1))); 152 cricket::StreamParams::CreateLegacy(kSsrc1)));
153 } 153 }
154 int channel_id = voe_.GetLastChannel();
155 154
156 // Test we can only InsertDtmf when the other side supports telephone-event. 155 // Test we can only InsertDtmf when the other side supports telephone-event.
157 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 156 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
158 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); 157 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE));
159 EXPECT_FALSE(channel_->CanInsertDtmf()); 158 EXPECT_FALSE(channel_->CanInsertDtmf());
160 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111, cricket::DF_SEND)); 159 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 1, 111, cricket::DF_SEND));
161 send_parameters_.codecs.push_back(kTelephoneEventCodec); 160 send_parameters_.codecs.push_back(kTelephoneEventCodec);
162 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 161 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
163 EXPECT_TRUE(channel_->CanInsertDtmf()); 162 EXPECT_TRUE(channel_->CanInsertDtmf());
164 163
165 if (!caller) { 164 if (!caller) {
166 // There's no active send channel yet. 165 // If this is callee, there's no active send channel yet.
167 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123, cricket::DF_SEND)); 166 EXPECT_FALSE(channel_->InsertDtmf(ssrc, 2, 123, cricket::DF_SEND));
168 EXPECT_TRUE(channel_->AddSendStream( 167 EXPECT_TRUE(channel_->AddSendStream(
169 cricket::StreamParams::CreateLegacy(kSsrc1))); 168 cricket::StreamParams::CreateLegacy(kSsrc1)));
170 } 169 }
171 170
172 // Check we fail if the ssrc is invalid. 171 // Check we fail if the ssrc is invalid.
173 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111, cricket::DF_SEND)); 172 EXPECT_FALSE(channel_->InsertDtmf(-1, 1, 111, cricket::DF_SEND));
174 173
175 // Test send 174 // Test send
175 int channel_id = voe_.GetLastChannel();
176 EXPECT_FALSE(voe_.WasSendTelephoneEventCalled(channel_id, 2, 123)); 176 EXPECT_FALSE(voe_.WasSendTelephoneEventCalled(channel_id, 2, 123));
177 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123, cricket::DF_SEND)); 177 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 2, 123, cricket::DF_SEND));
178 EXPECT_TRUE(voe_.WasSendTelephoneEventCalled(channel_id, 2, 123)); 178 EXPECT_TRUE(voe_.WasSendTelephoneEventCalled(channel_id, 2, 123));
179 179
180 // Test play 180 // Test play
181 EXPECT_FALSE(voe_.WasPlayDtmfToneCalled(3, 134)); 181 EXPECT_FALSE(voe_.WasPlayDtmfToneCalled(3, 134));
182 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 3, 134, cricket::DF_PLAY)); 182 EXPECT_TRUE(channel_->InsertDtmf(ssrc, 3, 134, cricket::DF_PLAY));
183 EXPECT_TRUE(voe_.WasPlayDtmfToneCalled(3, 134)); 183 EXPECT_TRUE(voe_.WasPlayDtmfToneCalled(3, 134));
184 184
185 // Test send and play 185 // Test send and play
(...skipping 19 matching lines...) Expand all
205 parameters.max_bandwidth_bps = max_bitrate; 205 parameters.max_bandwidth_bps = max_bitrate;
206 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); 206 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters));
207 207
208 int channel_num = voe_.GetLastChannel(); 208 int channel_num = voe_.GetLastChannel();
209 webrtc::CodecInst temp_codec; 209 webrtc::CodecInst temp_codec;
210 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); 210 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec));
211 EXPECT_EQ(expected_bitrate, temp_codec.rate); 211 EXPECT_EQ(expected_bitrate, temp_codec.rate);
212 } 212 }
213 213
214 void TestSetSendRtpHeaderExtensions(const std::string& ext) { 214 void TestSetSendRtpHeaderExtensions(const std::string& ext) {
215 EXPECT_TRUE(SetupEngine()); 215 EXPECT_TRUE(SetupEngineWithSendStream());
216 int channel_num = voe_.GetLastChannel(); 216 int channel_num = voe_.GetLastChannel();
217 217
218 // Ensure extensions are off by default. 218 // Ensure extensions are off by default.
219 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); 219 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext));
220 220
221 // Ensure unknown extensions won't cause an error. 221 // Ensure unknown extensions won't cause an error.
222 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( 222 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension(
223 "urn:ietf:params:unknownextention", 1)); 223 "urn:ietf:params:unknownextention", 1));
224 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 224 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
225 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); 225 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext));
226 226
227 // Ensure extensions stay off with an empty list of headers. 227 // Ensure extensions stay off with an empty list of headers.
228 send_parameters_.extensions.clear(); 228 send_parameters_.extensions.clear();
229 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 229 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
230 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); 230 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext));
231 231
232 // Ensure extension is set properly. 232 // Ensure extension is set properly.
233 const int id = 1; 233 const int id = 1;
234 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension(ext, id)); 234 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension(ext, id));
235 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 235 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
236 EXPECT_EQ(id, voe_.GetSendRtpExtensionId(channel_num, ext)); 236 EXPECT_EQ(id, voe_.GetSendRtpExtensionId(channel_num, ext));
237 237
238 // Ensure extension is set properly on new channel. 238 // Ensure extension is set properly on new channels.
239 // The first stream to occupy the default channel.
240 EXPECT_TRUE(channel_->AddSendStream( 239 EXPECT_TRUE(channel_->AddSendStream(
241 cricket::StreamParams::CreateLegacy(123))); 240 cricket::StreamParams::CreateLegacy(kSsrc2)));
242 EXPECT_TRUE(channel_->AddSendStream(
243 cricket::StreamParams::CreateLegacy(234)));
244 int new_channel_num = voe_.GetLastChannel(); 241 int new_channel_num = voe_.GetLastChannel();
245 EXPECT_NE(channel_num, new_channel_num); 242 EXPECT_NE(channel_num, new_channel_num);
246 EXPECT_EQ(id, voe_.GetSendRtpExtensionId(new_channel_num, ext)); 243 EXPECT_EQ(id, voe_.GetSendRtpExtensionId(new_channel_num, ext));
247 244
248 // Ensure all extensions go back off with an empty list. 245 // Ensure all extensions go back off with an empty list.
249 send_parameters_.codecs.push_back(kPcmuCodec); 246 send_parameters_.codecs.push_back(kPcmuCodec);
250 send_parameters_.extensions.clear(); 247 send_parameters_.extensions.clear();
251 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 248 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
252 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); 249 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext));
253 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext)); 250 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 EXPECT_FALSE(voe_.IsInited()); 311 EXPECT_FALSE(voe_.IsInited());
315 } 312 }
316 313
317 // Tests that we can create and destroy a channel. 314 // Tests that we can create and destroy a channel.
318 TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) { 315 TEST_F(WebRtcVoiceEngineTestFake, CreateChannel) {
319 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 316 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
320 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 317 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
321 EXPECT_TRUE(channel_ != nullptr); 318 EXPECT_TRUE(channel_ != nullptr);
322 } 319 }
323 320
324 // Tests that we properly handle failures in CreateChannel.
325 TEST_F(WebRtcVoiceEngineTestFake, CreateChannelFail) {
326 voe_.set_fail_create_channel(true);
327 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
328 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
329 EXPECT_TRUE(channel_ == nullptr);
330 }
331
332 // Tests that the list of supported codecs is created properly and ordered 321 // Tests that the list of supported codecs is created properly and ordered
333 // correctly 322 // correctly
334 TEST_F(WebRtcVoiceEngineTestFake, CodecPreference) { 323 TEST_F(WebRtcVoiceEngineTestFake, CodecPreference) {
335 const std::vector<cricket::AudioCodec>& codecs = engine_.codecs(); 324 const std::vector<cricket::AudioCodec>& codecs = engine_.codecs();
336 ASSERT_FALSE(codecs.empty()); 325 ASSERT_FALSE(codecs.empty());
337 EXPECT_STRCASEEQ("opus", codecs[0].name.c_str()); 326 EXPECT_STRCASEEQ("opus", codecs[0].name.c_str());
338 EXPECT_EQ(48000, codecs[0].clockrate); 327 EXPECT_EQ(48000, codecs[0].clockrate);
339 EXPECT_EQ(2, codecs[0].channels); 328 EXPECT_EQ(2, codecs[0].channels);
340 EXPECT_EQ(64000, codecs[0].bitrate); 329 EXPECT_EQ(64000, codecs[0].bitrate);
341 int pref = codecs[0].preference; 330 int pref = codecs[0].preference;
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 parameters.codecs[0].AddFeedbackParam( 980 parameters.codecs[0].AddFeedbackParam(
992 cricket::FeedbackParam(cricket::kRtcpFbParamNack, 981 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
993 cricket::kParamValueEmpty)); 982 cricket::kParamValueEmpty));
994 EXPECT_FALSE(voe_.GetNACK(channel_num)); 983 EXPECT_FALSE(voe_.GetNACK(channel_num));
995 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 984 EXPECT_TRUE(channel_->SetSendParameters(parameters));
996 EXPECT_TRUE(voe_.GetNACK(channel_num)); 985 EXPECT_TRUE(voe_.GetNACK(channel_num));
997 } 986 }
998 987
999 // Test that we can enable NACK with opus as callee. 988 // Test that we can enable NACK with opus as callee.
1000 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { 989 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) {
1001 EXPECT_TRUE(SetupEngine()); 990 EXPECT_TRUE(SetupEngineWithRecvStream());
1002 int channel_num = voe_.GetLastChannel(); 991 int channel_num = voe_.GetLastChannel();
1003 cricket::AudioSendParameters parameters; 992 cricket::AudioSendParameters parameters;
1004 parameters.codecs.push_back(kOpusCodec); 993 parameters.codecs.push_back(kOpusCodec);
1005 parameters.codecs[0].AddFeedbackParam( 994 parameters.codecs[0].AddFeedbackParam(
1006 cricket::FeedbackParam(cricket::kRtcpFbParamNack, 995 cricket::FeedbackParam(cricket::kRtcpFbParamNack,
1007 cricket::kParamValueEmpty)); 996 cricket::kParamValueEmpty));
1008 EXPECT_FALSE(voe_.GetNACK(channel_num)); 997 EXPECT_FALSE(voe_.GetNACK(channel_num));
1009 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 998 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1010 EXPECT_FALSE(voe_.GetNACK(channel_num)); 999 EXPECT_FALSE(voe_.GetNACK(channel_num));
1011 1000
1012 EXPECT_TRUE(channel_->AddSendStream( 1001 EXPECT_TRUE(channel_->AddSendStream(
1013 cricket::StreamParams::CreateLegacy(kSsrc1))); 1002 cricket::StreamParams::CreateLegacy(kSsrc1)));
1014 EXPECT_TRUE(voe_.GetNACK(channel_num)); 1003 EXPECT_TRUE(voe_.GetNACK(voe_.GetLastChannel()));
1015 } 1004 }
1016 1005
1017 // Test that we can enable NACK on receive streams. 1006 // Test that we can enable NACK on receive streams.
1018 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { 1007 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) {
1019 EXPECT_TRUE(SetupEngineWithSendStream()); 1008 EXPECT_TRUE(SetupEngineWithSendStream());
1020 int channel_num1 = voe_.GetLastChannel(); 1009 int channel_num1 = voe_.GetLastChannel();
1021 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 1010 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
1022 int channel_num2 = voe_.GetLastChannel(); 1011 int channel_num2 = voe_.GetLastChannel();
1023 cricket::AudioSendParameters parameters; 1012 cricket::AudioSendParameters parameters;
1024 parameters.codecs.push_back(kOpusCodec); 1013 parameters.codecs.push_back(kOpusCodec);
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1563 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1575 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); 1564 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num));
1576 } 1565 }
1577 1566
1578 // Test that we set VAD and DTMF types correctly as callee. 1567 // Test that we set VAD and DTMF types correctly as callee.
1579 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) { 1568 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCallee) {
1580 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 1569 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
1581 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 1570 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
1582 EXPECT_TRUE(channel_ != nullptr); 1571 EXPECT_TRUE(channel_ != nullptr);
1583 1572
1584 int channel_num = voe_.GetLastChannel();
1585 cricket::AudioSendParameters parameters; 1573 cricket::AudioSendParameters parameters;
1586 parameters.codecs.push_back(kIsacCodec); 1574 parameters.codecs.push_back(kIsacCodec);
1587 parameters.codecs.push_back(kPcmuCodec); 1575 parameters.codecs.push_back(kPcmuCodec);
1588 // TODO(juberti): cn 32000 1576 // TODO(juberti): cn 32000
1589 parameters.codecs.push_back(kCn16000Codec); 1577 parameters.codecs.push_back(kCn16000Codec);
1590 parameters.codecs.push_back(kCn8000Codec); 1578 parameters.codecs.push_back(kCn8000Codec);
1591 parameters.codecs.push_back(kTelephoneEventCodec); 1579 parameters.codecs.push_back(kTelephoneEventCodec);
1592 parameters.codecs.push_back(kRedCodec); 1580 parameters.codecs.push_back(kRedCodec);
1593 parameters.codecs[0].id = 96; 1581 parameters.codecs[0].id = 96;
1594 parameters.codecs[2].id = 97; // wideband CN 1582 parameters.codecs[2].id = 97; // wideband CN
1595 parameters.codecs[4].id = 98; // DTMF 1583 parameters.codecs[4].id = 98; // DTMF
1596 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1584 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1597 EXPECT_TRUE(channel_->AddSendStream( 1585 EXPECT_TRUE(channel_->AddSendStream(
1598 cricket::StreamParams::CreateLegacy(kSsrc1))); 1586 cricket::StreamParams::CreateLegacy(kSsrc1)));
1587 int channel_num = voe_.GetLastChannel();
1599 1588
1600 webrtc::CodecInst gcodec; 1589 webrtc::CodecInst gcodec;
1601 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1590 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1602 EXPECT_EQ(96, gcodec.pltype); 1591 EXPECT_EQ(96, gcodec.pltype);
1603 EXPECT_STREQ("ISAC", gcodec.plname); 1592 EXPECT_STREQ("ISAC", gcodec.plname);
1604 EXPECT_TRUE(voe_.GetVAD(channel_num)); 1593 EXPECT_TRUE(voe_.GetVAD(channel_num));
1605 EXPECT_FALSE(voe_.GetRED(channel_num)); 1594 EXPECT_FALSE(voe_.GetRED(channel_num));
1606 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); 1595 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false));
1607 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); 1596 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true));
1608 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); 1597 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num));
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 EXPECT_TRUE(voe_.GetRED(channel_num)); 1680 EXPECT_TRUE(voe_.GetRED(channel_num));
1692 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); 1681 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
1693 } 1682 }
1694 1683
1695 // Test that we set up RED correctly as callee. 1684 // Test that we set up RED correctly as callee.
1696 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) { 1685 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCallee) {
1697 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); 1686 EXPECT_TRUE(engine_.Init(rtc::Thread::Current()));
1698 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); 1687 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions());
1699 EXPECT_TRUE(channel_ != nullptr); 1688 EXPECT_TRUE(channel_ != nullptr);
1700 1689
1701 int channel_num = voe_.GetLastChannel();
1702 cricket::AudioSendParameters parameters; 1690 cricket::AudioSendParameters parameters;
1703 parameters.codecs.push_back(kRedCodec); 1691 parameters.codecs.push_back(kRedCodec);
1704 parameters.codecs.push_back(kIsacCodec); 1692 parameters.codecs.push_back(kIsacCodec);
1705 parameters.codecs.push_back(kPcmuCodec); 1693 parameters.codecs.push_back(kPcmuCodec);
1706 parameters.codecs[0].id = 127; 1694 parameters.codecs[0].id = 127;
1707 parameters.codecs[0].params[""] = "96/96"; 1695 parameters.codecs[0].params[""] = "96/96";
1708 parameters.codecs[1].id = 96; 1696 parameters.codecs[1].id = 96;
1709 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1697 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1710 EXPECT_TRUE(channel_->AddSendStream( 1698 EXPECT_TRUE(channel_->AddSendStream(
1711 cricket::StreamParams::CreateLegacy(kSsrc1))); 1699 cricket::StreamParams::CreateLegacy(kSsrc1)));
1700 int channel_num = voe_.GetLastChannel();
1712 webrtc::CodecInst gcodec; 1701 webrtc::CodecInst gcodec;
1713 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); 1702 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec));
1714 EXPECT_EQ(96, gcodec.pltype); 1703 EXPECT_EQ(96, gcodec.pltype);
1715 EXPECT_STREQ("ISAC", gcodec.plname); 1704 EXPECT_STREQ("ISAC", gcodec.plname);
1716 EXPECT_TRUE(voe_.GetRED(channel_num)); 1705 EXPECT_TRUE(voe_.GetRED(channel_num));
1717 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); 1706 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num));
1718 } 1707 }
1719 1708
1720 // Test that we set up RED correctly if params are omitted. 1709 // Test that we set up RED correctly if params are omitted.
1721 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { 1710 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 // Verify that we are in a sending state for all the created streams. 1874 // Verify that we are in a sending state for all the created streams.
1886 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]); 1875 int channel_num = voe_.GetChannelFromLocalSsrc(kSsrcs4[i]);
1887 EXPECT_TRUE(voe_.GetSend(channel_num)); 1876 EXPECT_TRUE(voe_.GetSend(channel_num));
1888 } 1877 }
1889 1878
1890 // Remove the first send channel, which is the default channel. It will only 1879 // Remove the first send channel, which is the default channel. It will only
1891 // recycle the default channel but not delete it. 1880 // recycle the default channel but not delete it.
1892 EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs4[0])); 1881 EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs4[0]));
1893 // Stream should already be Removed from the send stream list. 1882 // Stream should already be Removed from the send stream list.
1894 EXPECT_FALSE(channel_->RemoveSendStream(kSsrcs4[0])); 1883 EXPECT_FALSE(channel_->RemoveSendStream(kSsrcs4[0]));
1895 // But the default still exists.
1896 EXPECT_EQ(0, voe_.GetChannelFromLocalSsrc(kSsrcs4[0]));
1897 1884
1898 // Delete the rest of send channel streams. 1885 // Delete the rest of send channel streams.
1899 for (unsigned int i = 1; i < ARRAY_SIZE(kSsrcs4); ++i) { 1886 for (unsigned int i = 1; i < ARRAY_SIZE(kSsrcs4); ++i) {
1900 EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs4[i])); 1887 EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs4[i]));
1901 // Stream should already be deleted. 1888 // Stream should already be deleted.
1902 EXPECT_FALSE(channel_->RemoveSendStream(kSsrcs4[i])); 1889 EXPECT_FALSE(channel_->RemoveSendStream(kSsrcs4[i]));
1903 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(kSsrcs4[i])); 1890 EXPECT_EQ(-1, voe_.GetChannelFromLocalSsrc(kSsrcs4[i]));
1904 } 1891 }
1905 } 1892 }
1906 1893
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 DeliverPacket(packets[3], sizeof(packets[3])); 2396 DeliverPacket(packets[3], sizeof(packets[3]));
2410 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); 2397 EXPECT_TRUE(voe_.CheckNoPacket(channel_num1));
2411 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); 2398 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2));
2412 EXPECT_TRUE(voe_.CheckPacket(channel_num3, packets[3], 2399 EXPECT_TRUE(voe_.CheckPacket(channel_num3, packets[3],
2413 sizeof(packets[3]))); 2400 sizeof(packets[3])));
2414 EXPECT_TRUE(channel_->RemoveRecvStream(3)); 2401 EXPECT_TRUE(channel_->RemoveRecvStream(3));
2415 EXPECT_TRUE(channel_->RemoveRecvStream(2)); 2402 EXPECT_TRUE(channel_->RemoveRecvStream(2));
2416 EXPECT_TRUE(channel_->RemoveRecvStream(1)); 2403 EXPECT_TRUE(channel_->RemoveRecvStream(1));
2417 } 2404 }
2418 2405
2419 // Test that we properly handle failures to add a stream. 2406 // Test that we properly handle failures to add a receive stream.
2420 TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) { 2407 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamFail) {
2421 EXPECT_TRUE(SetupEngineWithSendStream()); 2408 EXPECT_TRUE(SetupEngine());
2422 voe_.set_fail_create_channel(true); 2409 voe_.set_fail_create_channel(true);
2423 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2424 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); 2410 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2)));
2425 } 2411 }
2426 2412
2413 // Test that we properly handle failures to add a send stream.
2414 TEST_F(WebRtcVoiceEngineTestFake, AddSendStreamFail) {
2415 EXPECT_TRUE(SetupEngine());
2416 voe_.set_fail_create_channel(true);
2417 EXPECT_FALSE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2)));
2418 }
2419
2427 // Test that AddRecvStream creates new stream. 2420 // Test that AddRecvStream creates new stream.
2428 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream) { 2421 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream) {
2429 EXPECT_TRUE(SetupEngineWithRecvStream()); 2422 EXPECT_TRUE(SetupEngineWithRecvStream());
2430 int channel_num = voe_.GetLastChannel(); 2423 int channel_num = voe_.GetLastChannel();
2431 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 2424 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
2432 EXPECT_NE(channel_num, voe_.GetLastChannel()); 2425 EXPECT_NE(channel_num, voe_.GetLastChannel());
2433 } 2426 }
2434 2427
2435 // Test that after adding a recv stream, we do not decode more codecs than 2428 // Test that after adding a recv stream, we do not decode more codecs than
2436 // those previously passed into SetRecvCodecs. 2429 // those previously passed into SetRecvCodecs.
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size()); 3064 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size());
3072 const cricket::FakeAudioReceiveStream* s = 3065 const cricket::FakeAudioReceiveStream* s =
3073 call_.GetAudioReceiveStream(kAudioSsrc); 3066 call_.GetAudioReceiveStream(kAudioSsrc);
3074 EXPECT_EQ(0, s->received_packets()); 3067 EXPECT_EQ(0, s->received_packets());
3075 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); 3068 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime());
3076 EXPECT_EQ(1, s->received_packets()); 3069 EXPECT_EQ(1, s->received_packets());
3077 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); 3070 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime());
3078 EXPECT_EQ(2, s->received_packets()); 3071 EXPECT_EQ(2, s->received_packets());
3079 } 3072 }
3080 3073
3081 // All receive channels should be associated with the default send channel, 3074 // All receive channels should be associated with the first send channel,
3082 // since they do not send RTCP SR. 3075 // since they do not send RTCP SR.
3083 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { 3076 TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel) {
3084 EXPECT_TRUE(SetupEngineWithSendStream()); 3077 EXPECT_TRUE(SetupEngineWithSendStream());
3085 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3078 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3086 int default_channel = voe_.GetLastChannel(); 3079 int default_channel = voe_.GetLastChannel();
3087 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); 3080 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1)));
3088 int recv_ch = voe_.GetLastChannel(); 3081 int recv_ch = voe_.GetLastChannel();
3089 EXPECT_NE(recv_ch, default_channel); 3082 EXPECT_NE(recv_ch, default_channel);
3090 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); 3083 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel);
3091 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); 3084 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2)));
3092 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); 3085 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel);
3093 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); 3086 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3)));
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
3258 cricket::WebRtcVoiceEngine engine; 3251 cricket::WebRtcVoiceEngine engine;
3259 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); 3252 EXPECT_TRUE(engine.Init(rtc::Thread::Current()));
3260 rtc::scoped_ptr<webrtc::Call> call( 3253 rtc::scoped_ptr<webrtc::Call> call(
3261 webrtc::Call::Create(webrtc::Call::Config())); 3254 webrtc::Call::Create(webrtc::Call::Config()));
3262 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), 3255 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(),
3263 call.get()); 3256 call.get());
3264 cricket::AudioRecvParameters parameters; 3257 cricket::AudioRecvParameters parameters;
3265 parameters.codecs = engine.codecs(); 3258 parameters.codecs = engine.codecs();
3266 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3259 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3267 } 3260 }
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvoiceengine.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698