OLD | NEW |
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 class WebRtcVoiceEngineTestFake : public testing::Test { | 90 class WebRtcVoiceEngineTestFake : public testing::Test { |
91 public: | 91 public: |
92 WebRtcVoiceEngineTestFake() | 92 WebRtcVoiceEngineTestFake() |
93 : call_(webrtc::Call::Config()), | 93 : call_(webrtc::Call::Config()), |
94 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), | 94 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), |
95 trace_wrapper_(new FakeVoETraceWrapper()), | 95 trace_wrapper_(new FakeVoETraceWrapper()), |
96 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), | 96 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), |
97 channel_(nullptr) { | 97 channel_(nullptr) { |
98 send_parameters_.codecs.push_back(kPcmuCodec); | 98 send_parameters_.codecs.push_back(kPcmuCodec); |
99 recv_parameters_.codecs.push_back(kPcmuCodec); | 99 recv_parameters_.codecs.push_back(kPcmuCodec); |
100 options_conference_.conference_mode.Set(true); | |
101 options_adjust_agc_.adjust_agc_delta.Set(-10); | 100 options_adjust_agc_.adjust_agc_delta.Set(-10); |
102 } | 101 } |
103 bool SetupEngineWithoutStream() { | 102 bool SetupEngine() { |
104 if (!engine_.Init(rtc::Thread::Current())) { | 103 if (!engine_.Init(rtc::Thread::Current())) { |
105 return false; | 104 return false; |
106 } | 105 } |
107 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); | 106 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); |
108 return (channel_ != nullptr); | 107 return (channel_ != nullptr); |
109 } | 108 } |
110 bool SetupEngine() { | 109 bool SetupEngineWithRecvStream() { |
111 if (!SetupEngineWithoutStream()) { | 110 if (!SetupEngine()) { |
| 111 return false; |
| 112 } |
| 113 return channel_->AddRecvStream( |
| 114 cricket::StreamParams::CreateLegacy(kSsrc1)); |
| 115 } |
| 116 bool SetupEngineWithSendStream() { |
| 117 if (!SetupEngine()) { |
112 return false; | 118 return false; |
113 } | 119 } |
114 return channel_->AddSendStream( | 120 return channel_->AddSendStream( |
115 cricket::StreamParams::CreateLegacy(kSsrc1)); | 121 cricket::StreamParams::CreateLegacy(kSsrc1)); |
116 } | 122 } |
117 void SetupForMultiSendStream() { | 123 void SetupForMultiSendStream() { |
118 EXPECT_TRUE(SetupEngine()); | 124 EXPECT_TRUE(SetupEngineWithSendStream()); |
119 // Remove stream added in Setup, which is corresponding to default channel. | 125 // Remove stream added in Setup, which is corresponding to default channel. |
120 int default_channel_num = voe_.GetLastChannel(); | 126 int default_channel_num = voe_.GetLastChannel(); |
121 uint32 default_send_ssrc = 0u; | 127 uint32 default_send_ssrc = 0u; |
122 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); | 128 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); |
123 EXPECT_EQ(kSsrc1, default_send_ssrc); | 129 EXPECT_EQ(kSsrc1, default_send_ssrc); |
124 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc)); | 130 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc)); |
125 | 131 |
126 // Verify the default channel still exists. | 132 // Verify the default channel still exists. |
127 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); | 133 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); |
128 } | 134 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 parameters.max_bandwidth_bps = max_bitrate; | 205 parameters.max_bandwidth_bps = max_bitrate; |
200 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); | 206 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); |
201 | 207 |
202 int channel_num = voe_.GetLastChannel(); | 208 int channel_num = voe_.GetLastChannel(); |
203 webrtc::CodecInst temp_codec; | 209 webrtc::CodecInst temp_codec; |
204 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); | 210 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); |
205 EXPECT_EQ(expected_bitrate, temp_codec.rate); | 211 EXPECT_EQ(expected_bitrate, temp_codec.rate); |
206 } | 212 } |
207 | 213 |
208 void TestSetSendRtpHeaderExtensions(const std::string& ext) { | 214 void TestSetSendRtpHeaderExtensions(const std::string& ext) { |
209 EXPECT_TRUE(SetupEngineWithoutStream()); | 215 EXPECT_TRUE(SetupEngine()); |
210 int channel_num = voe_.GetLastChannel(); | 216 int channel_num = voe_.GetLastChannel(); |
211 | 217 |
212 // Ensure extensions are off by default. | 218 // Ensure extensions are off by default. |
213 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); | 219 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); |
214 | 220 |
215 // Ensure unknown extensions won't cause an error. | 221 // Ensure unknown extensions won't cause an error. |
216 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( | 222 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
217 "urn:ietf:params:unknownextention", 1)); | 223 "urn:ietf:params:unknownextention", 1)); |
218 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 224 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
219 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); | 225 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); |
(...skipping 21 matching lines...) Expand all Loading... |
241 | 247 |
242 // Ensure all extensions go back off with an empty list. | 248 // Ensure all extensions go back off with an empty list. |
243 send_parameters_.codecs.push_back(kPcmuCodec); | 249 send_parameters_.codecs.push_back(kPcmuCodec); |
244 send_parameters_.extensions.clear(); | 250 send_parameters_.extensions.clear(); |
245 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 251 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
246 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); | 252 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); |
247 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext)); | 253 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext)); |
248 } | 254 } |
249 | 255 |
250 void TestSetRecvRtpHeaderExtensions(const std::string& ext) { | 256 void TestSetRecvRtpHeaderExtensions(const std::string& ext) { |
251 EXPECT_TRUE(SetupEngineWithoutStream()); | 257 EXPECT_TRUE(SetupEngineWithRecvStream()); |
252 int channel_num = voe_.GetLastChannel(); | 258 int channel_num = voe_.GetLastChannel(); |
253 | 259 |
254 // Ensure extensions are off by default. | 260 // Ensure extensions are off by default. |
255 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 261 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
256 | 262 |
257 cricket::AudioRecvParameters parameters; | 263 cricket::AudioRecvParameters parameters; |
258 // Ensure unknown extensions won't cause an error. | 264 // Ensure unknown extensions won't cause an error. |
259 parameters.extensions.push_back(cricket::RtpHeaderExtension( | 265 parameters.extensions.push_back(cricket::RtpHeaderExtension( |
260 "urn:ietf:params:unknownextention", 1)); | 266 "urn:ietf:params:unknownextention", 1)); |
261 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 267 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
262 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 268 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
263 | 269 |
264 // Ensure extensions stay off with an empty list of headers. | 270 // Ensure extensions stay off with an empty list of headers. |
265 parameters.extensions.clear(); | 271 parameters.extensions.clear(); |
266 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 272 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
267 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 273 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
268 | 274 |
269 // Ensure extension is set properly. | 275 // Ensure extension is set properly. |
270 const int id = 2; | 276 const int id = 2; |
271 parameters.extensions.push_back(cricket::RtpHeaderExtension(ext, id)); | 277 parameters.extensions.push_back(cricket::RtpHeaderExtension(ext, id)); |
272 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 278 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
273 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 279 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
274 | 280 |
275 // Ensure extension is set properly on new channel. | 281 // Ensure extension is set properly on new channel. |
276 // The first stream to occupy the default channel. | 282 // The first stream to occupy the default channel. |
277 EXPECT_TRUE(channel_->AddRecvStream( | 283 EXPECT_TRUE(channel_->AddRecvStream( |
278 cricket::StreamParams::CreateLegacy(345))); | 284 cricket::StreamParams::CreateLegacy(kSsrc2))); |
279 EXPECT_TRUE(channel_->AddRecvStream( | |
280 cricket::StreamParams::CreateLegacy(456))); | |
281 int new_channel_num = voe_.GetLastChannel(); | 285 int new_channel_num = voe_.GetLastChannel(); |
282 EXPECT_NE(channel_num, new_channel_num); | 286 EXPECT_NE(channel_num, new_channel_num); |
283 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); | 287 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); |
284 | 288 |
285 // Ensure all extensions go back off with an empty list. | 289 // Ensure all extensions go back off with an empty list. |
286 parameters.extensions.clear(); | 290 parameters.extensions.clear(); |
287 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 291 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
288 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 292 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
289 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); | 293 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); |
290 } | 294 } |
291 | 295 |
292 protected: | 296 protected: |
293 cricket::FakeCall call_; | 297 cricket::FakeCall call_; |
294 cricket::FakeWebRtcVoiceEngine voe_; | 298 cricket::FakeWebRtcVoiceEngine voe_; |
295 FakeVoETraceWrapper* trace_wrapper_; | 299 FakeVoETraceWrapper* trace_wrapper_; |
296 cricket::WebRtcVoiceEngine engine_; | 300 cricket::WebRtcVoiceEngine engine_; |
297 cricket::VoiceMediaChannel* channel_; | 301 cricket::VoiceMediaChannel* channel_; |
298 | 302 |
299 cricket::AudioSendParameters send_parameters_; | 303 cricket::AudioSendParameters send_parameters_; |
300 cricket::AudioRecvParameters recv_parameters_; | 304 cricket::AudioRecvParameters recv_parameters_; |
301 cricket::AudioOptions options_conference_; | |
302 cricket::AudioOptions options_adjust_agc_; | 305 cricket::AudioOptions options_adjust_agc_; |
303 }; | 306 }; |
304 | 307 |
305 // Tests that our stub library "works". | 308 // Tests that our stub library "works". |
306 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { | 309 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { |
307 EXPECT_FALSE(voe_.IsInited()); | 310 EXPECT_FALSE(voe_.IsInited()); |
308 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); | 311 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); |
309 EXPECT_TRUE(voe_.IsInited()); | 312 EXPECT_TRUE(voe_.IsInited()); |
310 engine_.Terminate(); | 313 engine_.Terminate(); |
311 EXPECT_FALSE(voe_.IsInited()); | 314 EXPECT_FALSE(voe_.IsInited()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 codec = kIsacCodec; | 377 codec = kIsacCodec; |
375 codec.bitrate = 32000; | 378 codec.bitrate = 32000; |
376 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); | 379 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); |
377 EXPECT_EQ(codec.id, codec_inst.pltype); | 380 EXPECT_EQ(codec.id, codec_inst.pltype); |
378 EXPECT_EQ(32000, codec_inst.rate); | 381 EXPECT_EQ(32000, codec_inst.rate); |
379 } | 382 } |
380 | 383 |
381 // Test that we set our inbound codecs properly, including changing PT. | 384 // Test that we set our inbound codecs properly, including changing PT. |
382 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { | 385 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { |
383 EXPECT_TRUE(SetupEngine()); | 386 EXPECT_TRUE(SetupEngine()); |
384 int channel_num = voe_.GetLastChannel(); | |
385 cricket::AudioRecvParameters parameters; | 387 cricket::AudioRecvParameters parameters; |
386 parameters.codecs.push_back(kIsacCodec); | 388 parameters.codecs.push_back(kIsacCodec); |
387 parameters.codecs.push_back(kPcmuCodec); | 389 parameters.codecs.push_back(kPcmuCodec); |
388 parameters.codecs.push_back(kTelephoneEventCodec); | 390 parameters.codecs.push_back(kTelephoneEventCodec); |
389 parameters.codecs[0].id = 106; // collide with existing telephone-event | 391 parameters.codecs[0].id = 106; // collide with existing telephone-event |
390 parameters.codecs[2].id = 126; | 392 parameters.codecs[2].id = 126; |
391 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 393 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 394 EXPECT_TRUE(channel_->AddRecvStream( |
| 395 cricket::StreamParams::CreateLegacy(kSsrc1))); |
| 396 int channel_num = voe_.GetLastChannel(); |
392 webrtc::CodecInst gcodec; | 397 webrtc::CodecInst gcodec; |
393 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); | 398 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); |
394 gcodec.plfreq = 16000; | 399 gcodec.plfreq = 16000; |
395 gcodec.channels = 1; | 400 gcodec.channels = 1; |
396 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); | 401 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); |
397 EXPECT_EQ(106, gcodec.pltype); | 402 EXPECT_EQ(106, gcodec.pltype); |
398 EXPECT_STREQ("ISAC", gcodec.plname); | 403 EXPECT_STREQ("ISAC", gcodec.plname); |
399 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), | 404 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), |
400 "telephone-event"); | 405 "telephone-event"); |
401 gcodec.plfreq = 8000; | 406 gcodec.plfreq = 8000; |
(...skipping 24 matching lines...) Expand all Loading... |
426 // Test that we can decode OPUS without stereo parameters. | 431 // Test that we can decode OPUS without stereo parameters. |
427 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { | 432 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { |
428 EXPECT_TRUE(SetupEngine()); | 433 EXPECT_TRUE(SetupEngine()); |
429 cricket::AudioRecvParameters parameters; | 434 cricket::AudioRecvParameters parameters; |
430 parameters.codecs.push_back(kIsacCodec); | 435 parameters.codecs.push_back(kIsacCodec); |
431 parameters.codecs.push_back(kPcmuCodec); | 436 parameters.codecs.push_back(kPcmuCodec); |
432 parameters.codecs.push_back(kOpusCodec); | 437 parameters.codecs.push_back(kOpusCodec); |
433 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 438 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
434 EXPECT_TRUE(channel_->AddRecvStream( | 439 EXPECT_TRUE(channel_->AddRecvStream( |
435 cricket::StreamParams::CreateLegacy(kSsrc1))); | 440 cricket::StreamParams::CreateLegacy(kSsrc1))); |
436 int channel_num2 = voe_.GetLastChannel(); | 441 int channel_num = voe_.GetLastChannel(); |
437 webrtc::CodecInst opus; | 442 webrtc::CodecInst opus; |
438 engine_.FindWebRtcCodec(kOpusCodec, &opus); | 443 engine_.FindWebRtcCodec(kOpusCodec, &opus); |
439 // Even without stereo parameters, recv codecs still specify channels = 2. | 444 // Even without stereo parameters, recv codecs still specify channels = 2. |
440 EXPECT_EQ(2, opus.channels); | 445 EXPECT_EQ(2, opus.channels); |
441 EXPECT_EQ(111, opus.pltype); | 446 EXPECT_EQ(111, opus.pltype); |
442 EXPECT_STREQ("opus", opus.plname); | 447 EXPECT_STREQ("opus", opus.plname); |
443 opus.pltype = 0; | 448 opus.pltype = 0; |
444 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); | 449 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, opus)); |
445 EXPECT_EQ(111, opus.pltype); | 450 EXPECT_EQ(111, opus.pltype); |
446 } | 451 } |
447 | 452 |
448 // Test that we can decode OPUS with stereo = 0. | 453 // Test that we can decode OPUS with stereo = 0. |
449 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { | 454 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { |
450 EXPECT_TRUE(SetupEngine()); | 455 EXPECT_TRUE(SetupEngine()); |
451 cricket::AudioRecvParameters parameters; | 456 cricket::AudioRecvParameters parameters; |
452 parameters.codecs.push_back(kIsacCodec); | 457 parameters.codecs.push_back(kIsacCodec); |
453 parameters.codecs.push_back(kPcmuCodec); | 458 parameters.codecs.push_back(kPcmuCodec); |
454 parameters.codecs.push_back(kOpusCodec); | 459 parameters.codecs.push_back(kOpusCodec); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), | 518 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), |
514 "telephone-event"); | 519 "telephone-event"); |
515 gcodec.plfreq = 8000; | 520 gcodec.plfreq = 8000; |
516 gcodec.channels = 1; | 521 gcodec.channels = 1; |
517 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); | 522 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
518 EXPECT_EQ(126, gcodec.pltype); | 523 EXPECT_EQ(126, gcodec.pltype); |
519 EXPECT_STREQ("telephone-event", gcodec.plname); | 524 EXPECT_STREQ("telephone-event", gcodec.plname); |
520 } | 525 } |
521 | 526 |
522 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { | 527 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { |
523 EXPECT_TRUE(SetupEngine()); | 528 EXPECT_TRUE(SetupEngineWithRecvStream()); |
524 cricket::AudioRecvParameters parameters; | 529 cricket::AudioRecvParameters parameters; |
525 parameters.codecs.push_back(kIsacCodec); | 530 parameters.codecs.push_back(kIsacCodec); |
526 parameters.codecs[0].id = 106; // collide with existing telephone-event | 531 parameters.codecs[0].id = 106; // collide with existing telephone-event |
527 EXPECT_TRUE(channel_->AddRecvStream( | |
528 cricket::StreamParams::CreateLegacy(kSsrc1))); | |
529 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 532 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
530 | 533 |
531 int channel_num2 = voe_.GetLastChannel(); | 534 int channel_num2 = voe_.GetLastChannel(); |
532 webrtc::CodecInst gcodec; | 535 webrtc::CodecInst gcodec; |
533 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); | 536 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); |
534 gcodec.plfreq = 16000; | 537 gcodec.plfreq = 16000; |
535 gcodec.channels = 1; | 538 gcodec.channels = 1; |
536 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); | 539 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
537 EXPECT_EQ(106, gcodec.pltype); | 540 EXPECT_EQ(106, gcodec.pltype); |
538 EXPECT_STREQ("ISAC", gcodec.plname); | 541 EXPECT_STREQ("ISAC", gcodec.plname); |
539 } | 542 } |
540 | 543 |
541 // Test that we can apply the same set of codecs again while playing. | 544 // Test that we can apply the same set of codecs again while playing. |
542 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { | 545 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { |
543 EXPECT_TRUE(SetupEngine()); | 546 EXPECT_TRUE(SetupEngineWithRecvStream()); |
544 cricket::AudioRecvParameters parameters; | 547 cricket::AudioRecvParameters parameters; |
545 parameters.codecs.push_back(kIsacCodec); | 548 parameters.codecs.push_back(kIsacCodec); |
546 parameters.codecs.push_back(kCn16000Codec); | 549 parameters.codecs.push_back(kCn16000Codec); |
547 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 550 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
548 EXPECT_TRUE(channel_->SetPlayout(true)); | 551 EXPECT_TRUE(channel_->SetPlayout(true)); |
549 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 552 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
550 | 553 |
551 // Changing the payload type of a codec should fail. | 554 // Changing the payload type of a codec should fail. |
552 parameters.codecs[0].id = 127; | 555 parameters.codecs[0].id = 127; |
553 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); | 556 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
554 int channel_num = voe_.GetLastChannel(); | 557 int channel_num = voe_.GetLastChannel(); |
555 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 558 EXPECT_TRUE(voe_.GetPlayout(channel_num)); |
556 } | 559 } |
557 | 560 |
558 // Test that we can add a codec while playing. | 561 // Test that we can add a codec while playing. |
559 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { | 562 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { |
560 EXPECT_TRUE(SetupEngine()); | 563 EXPECT_TRUE(SetupEngineWithRecvStream()); |
561 cricket::AudioRecvParameters parameters; | 564 cricket::AudioRecvParameters parameters; |
562 parameters.codecs.push_back(kIsacCodec); | 565 parameters.codecs.push_back(kIsacCodec); |
563 parameters.codecs.push_back(kCn16000Codec); | 566 parameters.codecs.push_back(kCn16000Codec); |
564 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 567 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
565 EXPECT_TRUE(channel_->SetPlayout(true)); | 568 EXPECT_TRUE(channel_->SetPlayout(true)); |
566 | 569 |
567 parameters.codecs.push_back(kOpusCodec); | 570 parameters.codecs.push_back(kOpusCodec); |
568 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 571 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
569 int channel_num = voe_.GetLastChannel(); | 572 int channel_num = voe_.GetLastChannel(); |
570 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 573 EXPECT_TRUE(voe_.GetPlayout(channel_num)); |
571 webrtc::CodecInst gcodec; | 574 webrtc::CodecInst gcodec; |
572 EXPECT_TRUE(engine_.FindWebRtcCodec(kOpusCodec, &gcodec)); | 575 EXPECT_TRUE(engine_.FindWebRtcCodec(kOpusCodec, &gcodec)); |
573 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); | 576 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); |
574 } | 577 } |
575 | 578 |
576 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { | 579 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { |
577 EXPECT_TRUE(SetupEngine()); | 580 EXPECT_TRUE(SetupEngineWithSendStream()); |
578 | 581 |
579 // Test that when autobw is enabled, bitrate is kept as the default | 582 // Test that when autobw is enabled, bitrate is kept as the default |
580 // value. autobw is enabled for the following tests because the target | 583 // value. autobw is enabled for the following tests because the target |
581 // bitrate is <= 0. | 584 // bitrate is <= 0. |
582 | 585 |
583 // ISAC, default bitrate == 32000. | 586 // ISAC, default bitrate == 32000. |
584 TestSendBandwidth(kIsacCodec, 0, true, 32000); | 587 TestSendBandwidth(kIsacCodec, 0, true, 32000); |
585 | 588 |
586 // PCMU, default bitrate == 64000. | 589 // PCMU, default bitrate == 64000. |
587 TestSendBandwidth(kPcmuCodec, -1, true, 64000); | 590 TestSendBandwidth(kPcmuCodec, -1, true, 64000); |
588 | 591 |
589 // opus, default bitrate == 64000. | 592 // opus, default bitrate == 64000. |
590 TestSendBandwidth(kOpusCodec, -1, true, 64000); | 593 TestSendBandwidth(kOpusCodec, -1, true, 64000); |
591 } | 594 } |
592 | 595 |
593 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { | 596 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { |
594 EXPECT_TRUE(SetupEngine()); | 597 EXPECT_TRUE(SetupEngineWithSendStream()); |
595 | 598 |
596 // Test that the bitrate of a multi-rate codec is always the maximum. | 599 // Test that the bitrate of a multi-rate codec is always the maximum. |
597 | 600 |
598 // ISAC, default bitrate == 32000. | 601 // ISAC, default bitrate == 32000. |
599 TestSendBandwidth(kIsacCodec, 128000, true, 128000); | 602 TestSendBandwidth(kIsacCodec, 128000, true, 128000); |
600 TestSendBandwidth(kIsacCodec, 16000, true, 16000); | 603 TestSendBandwidth(kIsacCodec, 16000, true, 16000); |
601 | 604 |
602 // opus, default bitrate == 64000. | 605 // opus, default bitrate == 64000. |
603 TestSendBandwidth(kOpusCodec, 96000, true, 96000); | 606 TestSendBandwidth(kOpusCodec, 96000, true, 96000); |
604 TestSendBandwidth(kOpusCodec, 48000, true, 48000); | 607 TestSendBandwidth(kOpusCodec, 48000, true, 48000); |
605 } | 608 } |
606 | 609 |
607 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { | 610 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { |
608 EXPECT_TRUE(SetupEngine()); | 611 EXPECT_TRUE(SetupEngineWithSendStream()); |
609 | 612 |
610 // Test that we can only set a maximum bitrate for a fixed-rate codec | 613 // Test that we can only set a maximum bitrate for a fixed-rate codec |
611 // if it's bigger than the fixed rate. | 614 // if it's bigger than the fixed rate. |
612 | 615 |
613 // PCMU, fixed bitrate == 64000. | 616 // PCMU, fixed bitrate == 64000. |
614 TestSendBandwidth(kPcmuCodec, 0, true, 64000); | 617 TestSendBandwidth(kPcmuCodec, 0, true, 64000); |
615 TestSendBandwidth(kPcmuCodec, 1, false, 64000); | 618 TestSendBandwidth(kPcmuCodec, 1, false, 64000); |
616 TestSendBandwidth(kPcmuCodec, 128000, true, 64000); | 619 TestSendBandwidth(kPcmuCodec, 128000, true, 64000); |
617 TestSendBandwidth(kPcmuCodec, 32000, false, 64000); | 620 TestSendBandwidth(kPcmuCodec, 32000, false, 64000); |
618 TestSendBandwidth(kPcmuCodec, 64000, true, 64000); | 621 TestSendBandwidth(kPcmuCodec, 64000, true, 64000); |
619 TestSendBandwidth(kPcmuCodec, 63999, false, 64000); | 622 TestSendBandwidth(kPcmuCodec, 63999, false, 64000); |
620 TestSendBandwidth(kPcmuCodec, 64001, true, 64000); | 623 TestSendBandwidth(kPcmuCodec, 64001, true, 64000); |
621 } | 624 } |
622 | 625 |
623 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { | 626 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { |
624 EXPECT_TRUE(SetupEngineWithoutStream()); | 627 EXPECT_TRUE(SetupEngine()); |
625 const int kDesiredBitrate = 128000; | 628 const int kDesiredBitrate = 128000; |
626 cricket::AudioSendParameters parameters; | 629 cricket::AudioSendParameters parameters; |
627 parameters.codecs = engine_.codecs(); | 630 parameters.codecs = engine_.codecs(); |
628 parameters.max_bandwidth_bps = kDesiredBitrate; | 631 parameters.max_bandwidth_bps = kDesiredBitrate; |
629 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 632 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
630 | 633 |
631 EXPECT_TRUE(channel_->AddSendStream( | 634 EXPECT_TRUE(channel_->AddSendStream( |
632 cricket::StreamParams::CreateLegacy(kSsrc1))); | 635 cricket::StreamParams::CreateLegacy(kSsrc1))); |
633 | 636 |
634 int channel_num = voe_.GetLastChannel(); | 637 int channel_num = voe_.GetLastChannel(); |
635 webrtc::CodecInst codec; | 638 webrtc::CodecInst codec; |
636 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 639 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
637 EXPECT_EQ(kDesiredBitrate, codec.rate); | 640 EXPECT_EQ(kDesiredBitrate, codec.rate); |
638 } | 641 } |
639 | 642 |
640 // Test that bitrate cannot be set for CBR codecs. | 643 // Test that bitrate cannot be set for CBR codecs. |
641 // Bitrate is ignored if it is higher than the fixed bitrate. | 644 // Bitrate is ignored if it is higher than the fixed bitrate. |
642 // Bitrate less then the fixed bitrate is an error. | 645 // Bitrate less then the fixed bitrate is an error. |
643 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { | 646 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { |
644 EXPECT_TRUE(SetupEngine()); | 647 EXPECT_TRUE(SetupEngineWithSendStream()); |
645 | 648 |
646 // PCMU, default bitrate == 64000. | 649 // PCMU, default bitrate == 64000. |
647 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 650 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
648 int channel_num = voe_.GetLastChannel(); | 651 int channel_num = voe_.GetLastChannel(); |
649 webrtc::CodecInst codec; | 652 webrtc::CodecInst codec; |
650 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 653 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
651 EXPECT_EQ(64000, codec.rate); | 654 EXPECT_EQ(64000, codec.rate); |
652 | 655 |
653 send_parameters_.max_bandwidth_bps = 128000; | 656 send_parameters_.max_bandwidth_bps = 128000; |
654 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 657 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
655 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 658 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
656 EXPECT_EQ(64000, codec.rate); | 659 EXPECT_EQ(64000, codec.rate); |
657 | 660 |
658 send_parameters_.max_bandwidth_bps = 128; | 661 send_parameters_.max_bandwidth_bps = 128; |
659 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); | 662 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
660 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 663 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
661 EXPECT_EQ(64000, codec.rate); | 664 EXPECT_EQ(64000, codec.rate); |
662 } | 665 } |
663 | 666 |
664 // Test that we apply codecs properly. | 667 // Test that we apply codecs properly. |
665 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { | 668 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { |
666 EXPECT_TRUE(SetupEngine()); | 669 EXPECT_TRUE(SetupEngineWithSendStream()); |
667 cricket::AudioSendParameters parameters; | 670 cricket::AudioSendParameters parameters; |
668 parameters.codecs.push_back(kIsacCodec); | 671 parameters.codecs.push_back(kIsacCodec); |
669 parameters.codecs.push_back(kPcmuCodec); | 672 parameters.codecs.push_back(kPcmuCodec); |
670 parameters.codecs.push_back(kRedCodec); | 673 parameters.codecs.push_back(kRedCodec); |
671 parameters.codecs[0].id = 96; | 674 parameters.codecs[0].id = 96; |
672 parameters.codecs[0].bitrate = 48000; | 675 parameters.codecs[0].bitrate = 48000; |
673 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 676 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
674 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); | 677 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); |
675 int channel_num = voe_.GetLastChannel(); | 678 int channel_num = voe_.GetLastChannel(); |
676 webrtc::CodecInst gcodec; | 679 webrtc::CodecInst gcodec; |
677 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 680 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
678 EXPECT_EQ(96, gcodec.pltype); | 681 EXPECT_EQ(96, gcodec.pltype); |
679 EXPECT_EQ(48000, gcodec.rate); | 682 EXPECT_EQ(48000, gcodec.rate); |
680 EXPECT_STREQ("ISAC", gcodec.plname); | 683 EXPECT_STREQ("ISAC", gcodec.plname); |
681 EXPECT_FALSE(voe_.GetVAD(channel_num)); | 684 EXPECT_FALSE(voe_.GetVAD(channel_num)); |
682 EXPECT_FALSE(voe_.GetRED(channel_num)); | 685 EXPECT_FALSE(voe_.GetRED(channel_num)); |
683 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); | 686 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); |
684 EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true)); | 687 EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true)); |
685 EXPECT_EQ(106, voe_.GetSendTelephoneEventPayloadType(channel_num)); | 688 EXPECT_EQ(106, voe_.GetSendTelephoneEventPayloadType(channel_num)); |
686 } | 689 } |
687 | 690 |
688 // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried | 691 // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried |
689 // to apply. | 692 // to apply. |
690 TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { | 693 TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { |
691 EXPECT_TRUE(SetupEngine()); | 694 EXPECT_TRUE(SetupEngineWithSendStream()); |
692 cricket::AudioSendParameters parameters; | 695 cricket::AudioSendParameters parameters; |
693 parameters.codecs.push_back(kIsacCodec); | 696 parameters.codecs.push_back(kIsacCodec); |
694 parameters.codecs.push_back(kPcmuCodec); | 697 parameters.codecs.push_back(kPcmuCodec); |
695 parameters.codecs.push_back(kRedCodec); | 698 parameters.codecs.push_back(kRedCodec); |
696 parameters.codecs[0].id = 96; | 699 parameters.codecs[0].id = 96; |
697 parameters.codecs[0].bitrate = 48000; | 700 parameters.codecs[0].bitrate = 48000; |
698 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 701 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
699 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); | 702 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); |
700 // Calling SetSendCodec again with same codec which is already set. | 703 // Calling SetSendCodec again with same codec which is already set. |
701 // In this case media channel shouldn't send codec to VoE. | 704 // In this case media channel shouldn't send codec to VoE. |
702 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 705 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
703 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); | 706 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); |
704 } | 707 } |
705 | 708 |
706 // Verify that G722 is set with 16000 samples per second to WebRTC. | 709 // Verify that G722 is set with 16000 samples per second to WebRTC. |
707 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { | 710 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { |
708 EXPECT_TRUE(SetupEngine()); | 711 EXPECT_TRUE(SetupEngineWithSendStream()); |
709 int channel_num = voe_.GetLastChannel(); | 712 int channel_num = voe_.GetLastChannel(); |
710 cricket::AudioSendParameters parameters; | 713 cricket::AudioSendParameters parameters; |
711 parameters.codecs.push_back(kG722CodecSdp); | 714 parameters.codecs.push_back(kG722CodecSdp); |
712 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 715 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
713 webrtc::CodecInst gcodec; | 716 webrtc::CodecInst gcodec; |
714 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 717 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
715 EXPECT_STREQ("G722", gcodec.plname); | 718 EXPECT_STREQ("G722", gcodec.plname); |
716 EXPECT_EQ(1, gcodec.channels); | 719 EXPECT_EQ(1, gcodec.channels); |
717 EXPECT_EQ(16000, gcodec.plfreq); | 720 EXPECT_EQ(16000, gcodec.plfreq); |
718 } | 721 } |
719 | 722 |
720 // Test that if clockrate is not 48000 for opus, we fail. | 723 // Test that if clockrate is not 48000 for opus, we fail. |
721 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { | 724 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { |
722 EXPECT_TRUE(SetupEngine()); | 725 EXPECT_TRUE(SetupEngineWithSendStream()); |
723 cricket::AudioSendParameters parameters; | 726 cricket::AudioSendParameters parameters; |
724 parameters.codecs.push_back(kOpusCodec); | 727 parameters.codecs.push_back(kOpusCodec); |
725 parameters.codecs[0].bitrate = 0; | 728 parameters.codecs[0].bitrate = 0; |
726 parameters.codecs[0].clockrate = 50000; | 729 parameters.codecs[0].clockrate = 50000; |
727 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 730 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
728 } | 731 } |
729 | 732 |
730 // Test that if channels=0 for opus, we fail. | 733 // Test that if channels=0 for opus, we fail. |
731 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { | 734 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { |
732 EXPECT_TRUE(SetupEngine()); | 735 EXPECT_TRUE(SetupEngineWithSendStream()); |
733 cricket::AudioSendParameters parameters; | 736 cricket::AudioSendParameters parameters; |
734 parameters.codecs.push_back(kOpusCodec); | 737 parameters.codecs.push_back(kOpusCodec); |
735 parameters.codecs[0].bitrate = 0; | 738 parameters.codecs[0].bitrate = 0; |
736 parameters.codecs[0].channels = 0; | 739 parameters.codecs[0].channels = 0; |
737 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 740 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
738 } | 741 } |
739 | 742 |
740 // Test that if channels=0 for opus, we fail. | 743 // Test that if channels=0 for opus, we fail. |
741 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { | 744 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { |
742 EXPECT_TRUE(SetupEngine()); | 745 EXPECT_TRUE(SetupEngineWithSendStream()); |
743 cricket::AudioSendParameters parameters; | 746 cricket::AudioSendParameters parameters; |
744 parameters.codecs.push_back(kOpusCodec); | 747 parameters.codecs.push_back(kOpusCodec); |
745 parameters.codecs[0].bitrate = 0; | 748 parameters.codecs[0].bitrate = 0; |
746 parameters.codecs[0].channels = 0; | 749 parameters.codecs[0].channels = 0; |
747 parameters.codecs[0].params["stereo"] = "1"; | 750 parameters.codecs[0].params["stereo"] = "1"; |
748 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 751 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
749 } | 752 } |
750 | 753 |
751 // Test that if channel is 1 for opus and there's no stereo, we fail. | 754 // Test that if channel is 1 for opus and there's no stereo, we fail. |
752 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { | 755 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { |
753 EXPECT_TRUE(SetupEngine()); | 756 EXPECT_TRUE(SetupEngineWithSendStream()); |
754 cricket::AudioSendParameters parameters; | 757 cricket::AudioSendParameters parameters; |
755 parameters.codecs.push_back(kOpusCodec); | 758 parameters.codecs.push_back(kOpusCodec); |
756 parameters.codecs[0].bitrate = 0; | 759 parameters.codecs[0].bitrate = 0; |
757 parameters.codecs[0].channels = 1; | 760 parameters.codecs[0].channels = 1; |
758 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 761 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
759 } | 762 } |
760 | 763 |
761 // Test that if channel is 1 for opus and stereo=0, we fail. | 764 // Test that if channel is 1 for opus and stereo=0, we fail. |
762 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { | 765 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { |
763 EXPECT_TRUE(SetupEngine()); | 766 EXPECT_TRUE(SetupEngineWithSendStream()); |
764 cricket::AudioSendParameters parameters; | 767 cricket::AudioSendParameters parameters; |
765 parameters.codecs.push_back(kOpusCodec); | 768 parameters.codecs.push_back(kOpusCodec); |
766 parameters.codecs[0].bitrate = 0; | 769 parameters.codecs[0].bitrate = 0; |
767 parameters.codecs[0].channels = 1; | 770 parameters.codecs[0].channels = 1; |
768 parameters.codecs[0].params["stereo"] = "0"; | 771 parameters.codecs[0].params["stereo"] = "0"; |
769 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 772 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
770 } | 773 } |
771 | 774 |
772 // Test that if channel is 1 for opus and stereo=1, we fail. | 775 // Test that if channel is 1 for opus and stereo=1, we fail. |
773 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { | 776 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { |
774 EXPECT_TRUE(SetupEngine()); | 777 EXPECT_TRUE(SetupEngineWithSendStream()); |
775 cricket::AudioSendParameters parameters; | 778 cricket::AudioSendParameters parameters; |
776 parameters.codecs.push_back(kOpusCodec); | 779 parameters.codecs.push_back(kOpusCodec); |
777 parameters.codecs[0].bitrate = 0; | 780 parameters.codecs[0].bitrate = 0; |
778 parameters.codecs[0].channels = 1; | 781 parameters.codecs[0].channels = 1; |
779 parameters.codecs[0].params["stereo"] = "1"; | 782 parameters.codecs[0].params["stereo"] = "1"; |
780 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 783 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
781 } | 784 } |
782 | 785 |
783 // Test that with bitrate=0 and no stereo, | 786 // Test that with bitrate=0 and no stereo, |
784 // channels and bitrate are 1 and 32000. | 787 // channels and bitrate are 1 and 32000. |
785 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { | 788 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { |
786 EXPECT_TRUE(SetupEngine()); | 789 EXPECT_TRUE(SetupEngineWithSendStream()); |
787 int channel_num = voe_.GetLastChannel(); | 790 int channel_num = voe_.GetLastChannel(); |
788 cricket::AudioSendParameters parameters; | 791 cricket::AudioSendParameters parameters; |
789 parameters.codecs.push_back(kOpusCodec); | 792 parameters.codecs.push_back(kOpusCodec); |
790 parameters.codecs[0].bitrate = 0; | 793 parameters.codecs[0].bitrate = 0; |
791 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 794 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
792 webrtc::CodecInst gcodec; | 795 webrtc::CodecInst gcodec; |
793 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 796 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
794 EXPECT_STREQ("opus", gcodec.plname); | 797 EXPECT_STREQ("opus", gcodec.plname); |
795 EXPECT_EQ(1, gcodec.channels); | 798 EXPECT_EQ(1, gcodec.channels); |
796 EXPECT_EQ(32000, gcodec.rate); | 799 EXPECT_EQ(32000, gcodec.rate); |
797 } | 800 } |
798 | 801 |
799 // Test that with bitrate=0 and stereo=0, | 802 // Test that with bitrate=0 and stereo=0, |
800 // channels and bitrate are 1 and 32000. | 803 // channels and bitrate are 1 and 32000. |
801 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { | 804 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { |
802 EXPECT_TRUE(SetupEngine()); | 805 EXPECT_TRUE(SetupEngineWithSendStream()); |
803 int channel_num = voe_.GetLastChannel(); | 806 int channel_num = voe_.GetLastChannel(); |
804 cricket::AudioSendParameters parameters; | 807 cricket::AudioSendParameters parameters; |
805 parameters.codecs.push_back(kOpusCodec); | 808 parameters.codecs.push_back(kOpusCodec); |
806 parameters.codecs[0].bitrate = 0; | 809 parameters.codecs[0].bitrate = 0; |
807 parameters.codecs[0].params["stereo"] = "0"; | 810 parameters.codecs[0].params["stereo"] = "0"; |
808 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 811 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
809 webrtc::CodecInst gcodec; | 812 webrtc::CodecInst gcodec; |
810 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 813 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
811 EXPECT_STREQ("opus", gcodec.plname); | 814 EXPECT_STREQ("opus", gcodec.plname); |
812 EXPECT_EQ(1, gcodec.channels); | 815 EXPECT_EQ(1, gcodec.channels); |
813 EXPECT_EQ(32000, gcodec.rate); | 816 EXPECT_EQ(32000, gcodec.rate); |
814 } | 817 } |
815 | 818 |
816 // Test that with bitrate=invalid and stereo=0, | 819 // Test that with bitrate=invalid and stereo=0, |
817 // channels and bitrate are 1 and 32000. | 820 // channels and bitrate are 1 and 32000. |
818 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { | 821 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { |
819 EXPECT_TRUE(SetupEngine()); | 822 EXPECT_TRUE(SetupEngineWithSendStream()); |
820 int channel_num = voe_.GetLastChannel(); | 823 int channel_num = voe_.GetLastChannel(); |
821 cricket::AudioSendParameters parameters; | 824 cricket::AudioSendParameters parameters; |
822 parameters.codecs.push_back(kOpusCodec); | 825 parameters.codecs.push_back(kOpusCodec); |
823 parameters.codecs[0].params["stereo"] = "0"; | 826 parameters.codecs[0].params["stereo"] = "0"; |
824 webrtc::CodecInst gcodec; | 827 webrtc::CodecInst gcodec; |
825 | 828 |
826 // bitrate that's out of the range between 6000 and 510000 will be clamped. | 829 // bitrate that's out of the range between 6000 and 510000 will be clamped. |
827 parameters.codecs[0].bitrate = 5999; | 830 parameters.codecs[0].bitrate = 5999; |
828 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 831 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
829 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 832 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
830 EXPECT_STREQ("opus", gcodec.plname); | 833 EXPECT_STREQ("opus", gcodec.plname); |
831 EXPECT_EQ(1, gcodec.channels); | 834 EXPECT_EQ(1, gcodec.channels); |
832 EXPECT_EQ(6000, gcodec.rate); | 835 EXPECT_EQ(6000, gcodec.rate); |
833 | 836 |
834 parameters.codecs[0].bitrate = 510001; | 837 parameters.codecs[0].bitrate = 510001; |
835 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 838 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
836 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 839 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
837 EXPECT_STREQ("opus", gcodec.plname); | 840 EXPECT_STREQ("opus", gcodec.plname); |
838 EXPECT_EQ(1, gcodec.channels); | 841 EXPECT_EQ(1, gcodec.channels); |
839 EXPECT_EQ(510000, gcodec.rate); | 842 EXPECT_EQ(510000, gcodec.rate); |
840 } | 843 } |
841 | 844 |
842 // Test that with bitrate=0 and stereo=1, | 845 // Test that with bitrate=0 and stereo=1, |
843 // channels and bitrate are 2 and 64000. | 846 // channels and bitrate are 2 and 64000. |
844 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { | 847 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { |
845 EXPECT_TRUE(SetupEngine()); | 848 EXPECT_TRUE(SetupEngineWithSendStream()); |
846 int channel_num = voe_.GetLastChannel(); | 849 int channel_num = voe_.GetLastChannel(); |
847 cricket::AudioSendParameters parameters; | 850 cricket::AudioSendParameters parameters; |
848 parameters.codecs.push_back(kOpusCodec); | 851 parameters.codecs.push_back(kOpusCodec); |
849 parameters.codecs[0].bitrate = 0; | 852 parameters.codecs[0].bitrate = 0; |
850 parameters.codecs[0].params["stereo"] = "1"; | 853 parameters.codecs[0].params["stereo"] = "1"; |
851 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 854 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
852 webrtc::CodecInst gcodec; | 855 webrtc::CodecInst gcodec; |
853 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 856 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
854 EXPECT_STREQ("opus", gcodec.plname); | 857 EXPECT_STREQ("opus", gcodec.plname); |
855 EXPECT_EQ(2, gcodec.channels); | 858 EXPECT_EQ(2, gcodec.channels); |
856 EXPECT_EQ(64000, gcodec.rate); | 859 EXPECT_EQ(64000, gcodec.rate); |
857 } | 860 } |
858 | 861 |
859 // Test that with bitrate=invalid and stereo=1, | 862 // Test that with bitrate=invalid and stereo=1, |
860 // channels and bitrate are 2 and 64000. | 863 // channels and bitrate are 2 and 64000. |
861 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { | 864 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { |
862 EXPECT_TRUE(SetupEngine()); | 865 EXPECT_TRUE(SetupEngineWithSendStream()); |
863 int channel_num = voe_.GetLastChannel(); | 866 int channel_num = voe_.GetLastChannel(); |
864 cricket::AudioSendParameters parameters; | 867 cricket::AudioSendParameters parameters; |
865 parameters.codecs.push_back(kOpusCodec); | 868 parameters.codecs.push_back(kOpusCodec); |
866 parameters.codecs[0].params["stereo"] = "1"; | 869 parameters.codecs[0].params["stereo"] = "1"; |
867 webrtc::CodecInst gcodec; | 870 webrtc::CodecInst gcodec; |
868 | 871 |
869 // bitrate that's out of the range between 6000 and 510000 will be clamped. | 872 // bitrate that's out of the range between 6000 and 510000 will be clamped. |
870 parameters.codecs[0].bitrate = 5999; | 873 parameters.codecs[0].bitrate = 5999; |
871 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 874 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
872 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 875 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
873 EXPECT_STREQ("opus", gcodec.plname); | 876 EXPECT_STREQ("opus", gcodec.plname); |
874 EXPECT_EQ(2, gcodec.channels); | 877 EXPECT_EQ(2, gcodec.channels); |
875 EXPECT_EQ(6000, gcodec.rate); | 878 EXPECT_EQ(6000, gcodec.rate); |
876 | 879 |
877 parameters.codecs[0].bitrate = 510001; | 880 parameters.codecs[0].bitrate = 510001; |
878 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 881 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
879 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 882 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
880 EXPECT_STREQ("opus", gcodec.plname); | 883 EXPECT_STREQ("opus", gcodec.plname); |
881 EXPECT_EQ(2, gcodec.channels); | 884 EXPECT_EQ(2, gcodec.channels); |
882 EXPECT_EQ(510000, gcodec.rate); | 885 EXPECT_EQ(510000, gcodec.rate); |
883 } | 886 } |
884 | 887 |
885 // Test that with bitrate=N and stereo unset, | 888 // Test that with bitrate=N and stereo unset, |
886 // channels and bitrate are 1 and N. | 889 // channels and bitrate are 1 and N. |
887 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { | 890 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { |
888 EXPECT_TRUE(SetupEngine()); | 891 EXPECT_TRUE(SetupEngineWithSendStream()); |
889 int channel_num = voe_.GetLastChannel(); | 892 int channel_num = voe_.GetLastChannel(); |
890 cricket::AudioSendParameters parameters; | 893 cricket::AudioSendParameters parameters; |
891 parameters.codecs.push_back(kOpusCodec); | 894 parameters.codecs.push_back(kOpusCodec); |
892 parameters.codecs[0].bitrate = 96000; | 895 parameters.codecs[0].bitrate = 96000; |
893 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 896 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
894 webrtc::CodecInst gcodec; | 897 webrtc::CodecInst gcodec; |
895 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 898 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
896 EXPECT_EQ(111, gcodec.pltype); | 899 EXPECT_EQ(111, gcodec.pltype); |
897 EXPECT_EQ(96000, gcodec.rate); | 900 EXPECT_EQ(96000, gcodec.rate); |
898 EXPECT_STREQ("opus", gcodec.plname); | 901 EXPECT_STREQ("opus", gcodec.plname); |
899 EXPECT_EQ(1, gcodec.channels); | 902 EXPECT_EQ(1, gcodec.channels); |
900 EXPECT_EQ(48000, gcodec.plfreq); | 903 EXPECT_EQ(48000, gcodec.plfreq); |
901 } | 904 } |
902 | 905 |
903 // Test that with bitrate=N and stereo=0, | 906 // Test that with bitrate=N and stereo=0, |
904 // channels and bitrate are 1 and N. | 907 // channels and bitrate are 1 and N. |
905 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { | 908 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { |
906 EXPECT_TRUE(SetupEngine()); | 909 EXPECT_TRUE(SetupEngineWithSendStream()); |
907 int channel_num = voe_.GetLastChannel(); | 910 int channel_num = voe_.GetLastChannel(); |
908 cricket::AudioSendParameters parameters; | 911 cricket::AudioSendParameters parameters; |
909 parameters.codecs.push_back(kOpusCodec); | 912 parameters.codecs.push_back(kOpusCodec); |
910 parameters.codecs[0].bitrate = 30000; | 913 parameters.codecs[0].bitrate = 30000; |
911 parameters.codecs[0].params["stereo"] = "0"; | 914 parameters.codecs[0].params["stereo"] = "0"; |
912 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 915 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
913 webrtc::CodecInst gcodec; | 916 webrtc::CodecInst gcodec; |
914 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 917 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
915 EXPECT_EQ(1, gcodec.channels); | 918 EXPECT_EQ(1, gcodec.channels); |
916 EXPECT_EQ(30000, gcodec.rate); | 919 EXPECT_EQ(30000, gcodec.rate); |
917 EXPECT_STREQ("opus", gcodec.plname); | 920 EXPECT_STREQ("opus", gcodec.plname); |
918 } | 921 } |
919 | 922 |
920 // Test that with bitrate=N and without any parameters, | 923 // Test that with bitrate=N and without any parameters, |
921 // channels and bitrate are 1 and N. | 924 // channels and bitrate are 1 and N. |
922 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { | 925 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { |
923 EXPECT_TRUE(SetupEngine()); | 926 EXPECT_TRUE(SetupEngineWithSendStream()); |
924 int channel_num = voe_.GetLastChannel(); | 927 int channel_num = voe_.GetLastChannel(); |
925 cricket::AudioSendParameters parameters; | 928 cricket::AudioSendParameters parameters; |
926 parameters.codecs.push_back(kOpusCodec); | 929 parameters.codecs.push_back(kOpusCodec); |
927 parameters.codecs[0].bitrate = 30000; | 930 parameters.codecs[0].bitrate = 30000; |
928 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 931 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
929 webrtc::CodecInst gcodec; | 932 webrtc::CodecInst gcodec; |
930 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 933 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
931 EXPECT_EQ(1, gcodec.channels); | 934 EXPECT_EQ(1, gcodec.channels); |
932 EXPECT_EQ(30000, gcodec.rate); | 935 EXPECT_EQ(30000, gcodec.rate); |
933 EXPECT_STREQ("opus", gcodec.plname); | 936 EXPECT_STREQ("opus", gcodec.plname); |
934 } | 937 } |
935 | 938 |
936 // Test that with bitrate=N and stereo=1, | 939 // Test that with bitrate=N and stereo=1, |
937 // channels and bitrate are 2 and N. | 940 // channels and bitrate are 2 and N. |
938 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { | 941 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { |
939 EXPECT_TRUE(SetupEngine()); | 942 EXPECT_TRUE(SetupEngineWithSendStream()); |
940 int channel_num = voe_.GetLastChannel(); | 943 int channel_num = voe_.GetLastChannel(); |
941 cricket::AudioSendParameters parameters; | 944 cricket::AudioSendParameters parameters; |
942 parameters.codecs.push_back(kOpusCodec); | 945 parameters.codecs.push_back(kOpusCodec); |
943 parameters.codecs[0].bitrate = 30000; | 946 parameters.codecs[0].bitrate = 30000; |
944 parameters.codecs[0].params["stereo"] = "1"; | 947 parameters.codecs[0].params["stereo"] = "1"; |
945 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 948 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
946 webrtc::CodecInst gcodec; | 949 webrtc::CodecInst gcodec; |
947 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 950 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
948 EXPECT_EQ(2, gcodec.channels); | 951 EXPECT_EQ(2, gcodec.channels); |
949 EXPECT_EQ(30000, gcodec.rate); | 952 EXPECT_EQ(30000, gcodec.rate); |
950 EXPECT_STREQ("opus", gcodec.plname); | 953 EXPECT_STREQ("opus", gcodec.plname); |
951 } | 954 } |
952 | 955 |
953 // Test that bitrate will be overridden by the "maxaveragebitrate" parameter. | 956 // Test that bitrate will be overridden by the "maxaveragebitrate" parameter. |
954 // Also test that the "maxaveragebitrate" can't be set to values outside the | 957 // Also test that the "maxaveragebitrate" can't be set to values outside the |
955 // range of 6000 and 510000 | 958 // range of 6000 and 510000 |
956 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { | 959 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { |
957 EXPECT_TRUE(SetupEngine()); | 960 EXPECT_TRUE(SetupEngineWithSendStream()); |
958 int channel_num = voe_.GetLastChannel(); | 961 int channel_num = voe_.GetLastChannel(); |
959 cricket::AudioSendParameters parameters; | 962 cricket::AudioSendParameters parameters; |
960 parameters.codecs.push_back(kOpusCodec); | 963 parameters.codecs.push_back(kOpusCodec); |
961 parameters.codecs[0].bitrate = 30000; | 964 parameters.codecs[0].bitrate = 30000; |
962 webrtc::CodecInst gcodec; | 965 webrtc::CodecInst gcodec; |
963 | 966 |
964 // Ignore if less than 6000. | 967 // Ignore if less than 6000. |
965 parameters.codecs[0].params["maxaveragebitrate"] = "5999"; | 968 parameters.codecs[0].params["maxaveragebitrate"] = "5999"; |
966 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 969 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
967 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 970 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
968 EXPECT_EQ(6000, gcodec.rate); | 971 EXPECT_EQ(6000, gcodec.rate); |
969 | 972 |
970 // Ignore if larger than 510000. | 973 // Ignore if larger than 510000. |
971 parameters.codecs[0].params["maxaveragebitrate"] = "510001"; | 974 parameters.codecs[0].params["maxaveragebitrate"] = "510001"; |
972 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 975 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
973 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 976 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
974 EXPECT_EQ(510000, gcodec.rate); | 977 EXPECT_EQ(510000, gcodec.rate); |
975 | 978 |
976 parameters.codecs[0].params["maxaveragebitrate"] = "200000"; | 979 parameters.codecs[0].params["maxaveragebitrate"] = "200000"; |
977 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 980 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
978 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 981 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
979 EXPECT_EQ(200000, gcodec.rate); | 982 EXPECT_EQ(200000, gcodec.rate); |
980 } | 983 } |
981 | 984 |
982 // Test that we can enable NACK with opus as caller. | 985 // Test that we can enable NACK with opus as caller. |
983 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { | 986 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { |
984 EXPECT_TRUE(SetupEngine()); | 987 EXPECT_TRUE(SetupEngineWithSendStream()); |
985 int channel_num = voe_.GetLastChannel(); | 988 int channel_num = voe_.GetLastChannel(); |
986 cricket::AudioSendParameters parameters; | 989 cricket::AudioSendParameters parameters; |
987 parameters.codecs.push_back(kOpusCodec); | 990 parameters.codecs.push_back(kOpusCodec); |
988 parameters.codecs[0].AddFeedbackParam( | 991 parameters.codecs[0].AddFeedbackParam( |
989 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 992 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
990 cricket::kParamValueEmpty)); | 993 cricket::kParamValueEmpty)); |
991 EXPECT_FALSE(voe_.GetNACK(channel_num)); | 994 EXPECT_FALSE(voe_.GetNACK(channel_num)); |
992 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 995 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
993 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 996 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
994 } | 997 } |
995 | 998 |
996 // Test that we can enable NACK with opus as callee. | 999 // Test that we can enable NACK with opus as callee. |
997 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { | 1000 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { |
998 EXPECT_TRUE(SetupEngineWithoutStream()); | 1001 EXPECT_TRUE(SetupEngine()); |
999 int channel_num = voe_.GetLastChannel(); | 1002 int channel_num = voe_.GetLastChannel(); |
1000 cricket::AudioSendParameters parameters; | 1003 cricket::AudioSendParameters parameters; |
1001 parameters.codecs.push_back(kOpusCodec); | 1004 parameters.codecs.push_back(kOpusCodec); |
1002 parameters.codecs[0].AddFeedbackParam( | 1005 parameters.codecs[0].AddFeedbackParam( |
1003 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1006 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1004 cricket::kParamValueEmpty)); | 1007 cricket::kParamValueEmpty)); |
1005 EXPECT_FALSE(voe_.GetNACK(channel_num)); | 1008 EXPECT_FALSE(voe_.GetNACK(channel_num)); |
1006 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1009 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1007 EXPECT_FALSE(voe_.GetNACK(channel_num)); | 1010 EXPECT_FALSE(voe_.GetNACK(channel_num)); |
1008 | 1011 |
1009 EXPECT_TRUE(channel_->AddSendStream( | 1012 EXPECT_TRUE(channel_->AddSendStream( |
1010 cricket::StreamParams::CreateLegacy(kSsrc1))); | 1013 cricket::StreamParams::CreateLegacy(kSsrc1))); |
1011 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1014 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1012 } | 1015 } |
1013 | 1016 |
1014 // Test that we can enable NACK on receive streams. | 1017 // Test that we can enable NACK on receive streams. |
1015 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { | 1018 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { |
1016 EXPECT_TRUE(SetupEngine()); | 1019 EXPECT_TRUE(SetupEngineWithSendStream()); |
1017 int channel_num1 = voe_.GetLastChannel(); | 1020 int channel_num1 = voe_.GetLastChannel(); |
1018 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 1021 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
1019 int channel_num2 = voe_.GetLastChannel(); | 1022 int channel_num2 = voe_.GetLastChannel(); |
1020 cricket::AudioSendParameters parameters; | 1023 cricket::AudioSendParameters parameters; |
1021 parameters.codecs.push_back(kOpusCodec); | 1024 parameters.codecs.push_back(kOpusCodec); |
1022 parameters.codecs[0].AddFeedbackParam( | 1025 parameters.codecs[0].AddFeedbackParam( |
1023 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1026 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1024 cricket::kParamValueEmpty)); | 1027 cricket::kParamValueEmpty)); |
1025 EXPECT_FALSE(voe_.GetNACK(channel_num1)); | 1028 EXPECT_FALSE(voe_.GetNACK(channel_num1)); |
1026 EXPECT_FALSE(voe_.GetNACK(channel_num2)); | 1029 EXPECT_FALSE(voe_.GetNACK(channel_num2)); |
1027 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1030 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1028 EXPECT_TRUE(voe_.GetNACK(channel_num1)); | 1031 EXPECT_TRUE(voe_.GetNACK(channel_num1)); |
1029 EXPECT_TRUE(voe_.GetNACK(channel_num2)); | 1032 EXPECT_TRUE(voe_.GetNACK(channel_num2)); |
1030 } | 1033 } |
1031 | 1034 |
1032 // Test that we can disable NACK. | 1035 // Test that we can disable NACK. |
1033 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { | 1036 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { |
1034 EXPECT_TRUE(SetupEngine()); | 1037 EXPECT_TRUE(SetupEngineWithSendStream()); |
1035 int channel_num = voe_.GetLastChannel(); | 1038 int channel_num = voe_.GetLastChannel(); |
1036 cricket::AudioSendParameters parameters; | 1039 cricket::AudioSendParameters parameters; |
1037 parameters.codecs.push_back(kOpusCodec); | 1040 parameters.codecs.push_back(kOpusCodec); |
1038 parameters.codecs[0].AddFeedbackParam( | 1041 parameters.codecs[0].AddFeedbackParam( |
1039 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1042 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1040 cricket::kParamValueEmpty)); | 1043 cricket::kParamValueEmpty)); |
1041 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1044 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1042 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1045 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1043 | 1046 |
1044 parameters.codecs.clear(); | 1047 parameters.codecs.clear(); |
1045 parameters.codecs.push_back(kOpusCodec); | 1048 parameters.codecs.push_back(kOpusCodec); |
1046 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1049 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1047 EXPECT_FALSE(voe_.GetNACK(channel_num)); | 1050 EXPECT_FALSE(voe_.GetNACK(channel_num)); |
1048 } | 1051 } |
1049 | 1052 |
1050 // Test that we can disable NACK on receive streams. | 1053 // Test that we can disable NACK on receive streams. |
1051 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { | 1054 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { |
1052 EXPECT_TRUE(SetupEngine()); | 1055 EXPECT_TRUE(SetupEngineWithSendStream()); |
1053 int channel_num1 = voe_.GetLastChannel(); | 1056 int channel_num1 = voe_.GetLastChannel(); |
1054 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 1057 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
1055 int channel_num2 = voe_.GetLastChannel(); | 1058 int channel_num2 = voe_.GetLastChannel(); |
1056 cricket::AudioSendParameters parameters; | 1059 cricket::AudioSendParameters parameters; |
1057 parameters.codecs.push_back(kOpusCodec); | 1060 parameters.codecs.push_back(kOpusCodec); |
1058 parameters.codecs[0].AddFeedbackParam( | 1061 parameters.codecs[0].AddFeedbackParam( |
1059 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1062 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1060 cricket::kParamValueEmpty)); | 1063 cricket::kParamValueEmpty)); |
1061 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1064 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1062 EXPECT_TRUE(voe_.GetNACK(channel_num1)); | 1065 EXPECT_TRUE(voe_.GetNACK(channel_num1)); |
1063 EXPECT_TRUE(voe_.GetNACK(channel_num2)); | 1066 EXPECT_TRUE(voe_.GetNACK(channel_num2)); |
1064 | 1067 |
1065 parameters.codecs.clear(); | 1068 parameters.codecs.clear(); |
1066 parameters.codecs.push_back(kOpusCodec); | 1069 parameters.codecs.push_back(kOpusCodec); |
1067 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1070 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1068 EXPECT_FALSE(voe_.GetNACK(channel_num1)); | 1071 EXPECT_FALSE(voe_.GetNACK(channel_num1)); |
1069 EXPECT_FALSE(voe_.GetNACK(channel_num2)); | 1072 EXPECT_FALSE(voe_.GetNACK(channel_num2)); |
1070 } | 1073 } |
1071 | 1074 |
1072 // Test that NACK is enabled on a new receive stream. | 1075 // Test that NACK is enabled on a new receive stream. |
1073 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { | 1076 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { |
1074 EXPECT_TRUE(SetupEngine()); | 1077 EXPECT_TRUE(SetupEngineWithSendStream()); |
1075 int channel_num = voe_.GetLastChannel(); | 1078 int channel_num = voe_.GetLastChannel(); |
1076 cricket::AudioSendParameters parameters; | 1079 cricket::AudioSendParameters parameters; |
1077 parameters.codecs.push_back(kIsacCodec); | 1080 parameters.codecs.push_back(kIsacCodec); |
1078 parameters.codecs.push_back(kCn16000Codec); | 1081 parameters.codecs.push_back(kCn16000Codec); |
1079 parameters.codecs[0].AddFeedbackParam( | 1082 parameters.codecs[0].AddFeedbackParam( |
1080 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1083 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1081 cricket::kParamValueEmpty)); | 1084 cricket::kParamValueEmpty)); |
1082 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1085 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1083 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1086 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1084 | 1087 |
1085 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 1088 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
1086 channel_num = voe_.GetLastChannel(); | 1089 channel_num = voe_.GetLastChannel(); |
1087 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1090 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1088 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 1091 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
1089 channel_num = voe_.GetLastChannel(); | 1092 channel_num = voe_.GetLastChannel(); |
1090 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1093 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1091 } | 1094 } |
1092 | 1095 |
1093 // Test that without useinbandfec, Opus FEC is off. | 1096 // Test that without useinbandfec, Opus FEC is off. |
1094 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { | 1097 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { |
1095 EXPECT_TRUE(SetupEngine()); | 1098 EXPECT_TRUE(SetupEngineWithSendStream()); |
1096 int channel_num = voe_.GetLastChannel(); | 1099 int channel_num = voe_.GetLastChannel(); |
1097 cricket::AudioSendParameters parameters; | 1100 cricket::AudioSendParameters parameters; |
1098 parameters.codecs.push_back(kOpusCodec); | 1101 parameters.codecs.push_back(kOpusCodec); |
1099 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1102 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1100 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1103 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1101 } | 1104 } |
1102 | 1105 |
1103 // Test that with useinbandfec=0, Opus FEC is off. | 1106 // Test that with useinbandfec=0, Opus FEC is off. |
1104 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { | 1107 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { |
1105 EXPECT_TRUE(SetupEngine()); | 1108 EXPECT_TRUE(SetupEngineWithSendStream()); |
1106 int channel_num = voe_.GetLastChannel(); | 1109 int channel_num = voe_.GetLastChannel(); |
1107 cricket::AudioSendParameters parameters; | 1110 cricket::AudioSendParameters parameters; |
1108 parameters.codecs.push_back(kOpusCodec); | 1111 parameters.codecs.push_back(kOpusCodec); |
1109 parameters.codecs[0].bitrate = 0; | 1112 parameters.codecs[0].bitrate = 0; |
1110 parameters.codecs[0].params["useinbandfec"] = "0"; | 1113 parameters.codecs[0].params["useinbandfec"] = "0"; |
1111 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1114 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1112 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1115 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1113 webrtc::CodecInst gcodec; | 1116 webrtc::CodecInst gcodec; |
1114 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1117 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1115 EXPECT_STREQ("opus", gcodec.plname); | 1118 EXPECT_STREQ("opus", gcodec.plname); |
1116 EXPECT_EQ(1, gcodec.channels); | 1119 EXPECT_EQ(1, gcodec.channels); |
1117 EXPECT_EQ(32000, gcodec.rate); | 1120 EXPECT_EQ(32000, gcodec.rate); |
1118 } | 1121 } |
1119 | 1122 |
1120 // Test that with useinbandfec=1, Opus FEC is on. | 1123 // Test that with useinbandfec=1, Opus FEC is on. |
1121 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { | 1124 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { |
1122 EXPECT_TRUE(SetupEngine()); | 1125 EXPECT_TRUE(SetupEngineWithSendStream()); |
1123 int channel_num = voe_.GetLastChannel(); | 1126 int channel_num = voe_.GetLastChannel(); |
1124 cricket::AudioSendParameters parameters; | 1127 cricket::AudioSendParameters parameters; |
1125 parameters.codecs.push_back(kOpusCodec); | 1128 parameters.codecs.push_back(kOpusCodec); |
1126 parameters.codecs[0].bitrate = 0; | 1129 parameters.codecs[0].bitrate = 0; |
1127 parameters.codecs[0].params["useinbandfec"] = "1"; | 1130 parameters.codecs[0].params["useinbandfec"] = "1"; |
1128 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1131 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1129 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); | 1132 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); |
1130 webrtc::CodecInst gcodec; | 1133 webrtc::CodecInst gcodec; |
1131 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1134 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1132 EXPECT_STREQ("opus", gcodec.plname); | 1135 EXPECT_STREQ("opus", gcodec.plname); |
1133 EXPECT_EQ(1, gcodec.channels); | 1136 EXPECT_EQ(1, gcodec.channels); |
1134 EXPECT_EQ(32000, gcodec.rate); | 1137 EXPECT_EQ(32000, gcodec.rate); |
1135 } | 1138 } |
1136 | 1139 |
1137 // Test that with useinbandfec=1, stereo=1, Opus FEC is on. | 1140 // Test that with useinbandfec=1, stereo=1, Opus FEC is on. |
1138 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { | 1141 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { |
1139 EXPECT_TRUE(SetupEngine()); | 1142 EXPECT_TRUE(SetupEngineWithSendStream()); |
1140 int channel_num = voe_.GetLastChannel(); | 1143 int channel_num = voe_.GetLastChannel(); |
1141 cricket::AudioSendParameters parameters; | 1144 cricket::AudioSendParameters parameters; |
1142 parameters.codecs.push_back(kOpusCodec); | 1145 parameters.codecs.push_back(kOpusCodec); |
1143 parameters.codecs[0].bitrate = 0; | 1146 parameters.codecs[0].bitrate = 0; |
1144 parameters.codecs[0].params["stereo"] = "1"; | 1147 parameters.codecs[0].params["stereo"] = "1"; |
1145 parameters.codecs[0].params["useinbandfec"] = "1"; | 1148 parameters.codecs[0].params["useinbandfec"] = "1"; |
1146 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1149 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1147 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); | 1150 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); |
1148 webrtc::CodecInst gcodec; | 1151 webrtc::CodecInst gcodec; |
1149 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1152 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1150 EXPECT_STREQ("opus", gcodec.plname); | 1153 EXPECT_STREQ("opus", gcodec.plname); |
1151 EXPECT_EQ(2, gcodec.channels); | 1154 EXPECT_EQ(2, gcodec.channels); |
1152 EXPECT_EQ(64000, gcodec.rate); | 1155 EXPECT_EQ(64000, gcodec.rate); |
1153 } | 1156 } |
1154 | 1157 |
1155 // Test that with non-Opus, codec FEC is off. | 1158 // Test that with non-Opus, codec FEC is off. |
1156 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { | 1159 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { |
1157 EXPECT_TRUE(SetupEngine()); | 1160 EXPECT_TRUE(SetupEngineWithSendStream()); |
1158 int channel_num = voe_.GetLastChannel(); | 1161 int channel_num = voe_.GetLastChannel(); |
1159 cricket::AudioSendParameters parameters; | 1162 cricket::AudioSendParameters parameters; |
1160 parameters.codecs.push_back(kIsacCodec); | 1163 parameters.codecs.push_back(kIsacCodec); |
1161 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1164 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1162 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1165 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1163 } | 1166 } |
1164 | 1167 |
1165 // Test the with non-Opus, even if useinbandfec=1, FEC is off. | 1168 // Test the with non-Opus, even if useinbandfec=1, FEC is off. |
1166 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { | 1169 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { |
1167 EXPECT_TRUE(SetupEngine()); | 1170 EXPECT_TRUE(SetupEngineWithSendStream()); |
1168 int channel_num = voe_.GetLastChannel(); | 1171 int channel_num = voe_.GetLastChannel(); |
1169 cricket::AudioSendParameters parameters; | 1172 cricket::AudioSendParameters parameters; |
1170 parameters.codecs.push_back(kIsacCodec); | 1173 parameters.codecs.push_back(kIsacCodec); |
1171 parameters.codecs[0].params["useinbandfec"] = "1"; | 1174 parameters.codecs[0].params["useinbandfec"] = "1"; |
1172 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1175 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1173 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1176 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1174 } | 1177 } |
1175 | 1178 |
1176 // Test that Opus FEC status can be changed. | 1179 // Test that Opus FEC status can be changed. |
1177 TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { | 1180 TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { |
1178 EXPECT_TRUE(SetupEngine()); | 1181 EXPECT_TRUE(SetupEngineWithSendStream()); |
1179 int channel_num = voe_.GetLastChannel(); | 1182 int channel_num = voe_.GetLastChannel(); |
1180 cricket::AudioSendParameters parameters; | 1183 cricket::AudioSendParameters parameters; |
1181 parameters.codecs.push_back(kOpusCodec); | 1184 parameters.codecs.push_back(kOpusCodec); |
1182 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1185 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1183 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1186 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1184 parameters.codecs[0].params["useinbandfec"] = "1"; | 1187 parameters.codecs[0].params["useinbandfec"] = "1"; |
1185 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1188 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1186 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); | 1189 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); |
1187 } | 1190 } |
1188 | 1191 |
1189 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. | 1192 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. |
1190 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { | 1193 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { |
1191 EXPECT_TRUE(SetupEngine()); | 1194 EXPECT_TRUE(SetupEngineWithSendStream()); |
1192 int channel_num = voe_.GetLastChannel(); | 1195 int channel_num = voe_.GetLastChannel(); |
1193 cricket::AudioSendParameters parameters; | 1196 cricket::AudioSendParameters parameters; |
1194 parameters.codecs.push_back(kOpusCodec); | 1197 parameters.codecs.push_back(kOpusCodec); |
1195 parameters.codecs[0].bitrate = 0; | 1198 parameters.codecs[0].bitrate = 0; |
1196 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); | 1199 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); |
1197 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1200 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1198 EXPECT_EQ(cricket::kOpusBandwidthNb, | 1201 EXPECT_EQ(cricket::kOpusBandwidthNb, |
1199 voe_.GetMaxEncodingBandwidth(channel_num)); | 1202 voe_.GetMaxEncodingBandwidth(channel_num)); |
1200 webrtc::CodecInst gcodec; | 1203 webrtc::CodecInst gcodec; |
1201 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1204 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1202 EXPECT_STREQ("opus", gcodec.plname); | 1205 EXPECT_STREQ("opus", gcodec.plname); |
1203 | 1206 |
1204 EXPECT_EQ(12000, gcodec.rate); | 1207 EXPECT_EQ(12000, gcodec.rate); |
1205 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1208 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1206 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1209 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1207 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1210 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1208 EXPECT_EQ(24000, gcodec.rate); | 1211 EXPECT_EQ(24000, gcodec.rate); |
1209 } | 1212 } |
1210 | 1213 |
1211 // Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode. | 1214 // Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode. |
1212 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { | 1215 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { |
1213 EXPECT_TRUE(SetupEngine()); | 1216 EXPECT_TRUE(SetupEngineWithSendStream()); |
1214 int channel_num = voe_.GetLastChannel(); | 1217 int channel_num = voe_.GetLastChannel(); |
1215 cricket::AudioSendParameters parameters; | 1218 cricket::AudioSendParameters parameters; |
1216 parameters.codecs.push_back(kOpusCodec); | 1219 parameters.codecs.push_back(kOpusCodec); |
1217 parameters.codecs[0].bitrate = 0; | 1220 parameters.codecs[0].bitrate = 0; |
1218 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001); | 1221 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001); |
1219 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1222 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1220 EXPECT_EQ(cricket::kOpusBandwidthMb, | 1223 EXPECT_EQ(cricket::kOpusBandwidthMb, |
1221 voe_.GetMaxEncodingBandwidth(channel_num)); | 1224 voe_.GetMaxEncodingBandwidth(channel_num)); |
1222 webrtc::CodecInst gcodec; | 1225 webrtc::CodecInst gcodec; |
1223 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1226 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1224 EXPECT_STREQ("opus", gcodec.plname); | 1227 EXPECT_STREQ("opus", gcodec.plname); |
1225 | 1228 |
1226 EXPECT_EQ(20000, gcodec.rate); | 1229 EXPECT_EQ(20000, gcodec.rate); |
1227 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1230 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1228 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1231 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1229 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1232 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1230 EXPECT_EQ(40000, gcodec.rate); | 1233 EXPECT_EQ(40000, gcodec.rate); |
1231 } | 1234 } |
1232 | 1235 |
1233 // Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode. | 1236 // Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode. |
1234 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { | 1237 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { |
1235 EXPECT_TRUE(SetupEngine()); | 1238 EXPECT_TRUE(SetupEngineWithSendStream()); |
1236 int channel_num = voe_.GetLastChannel(); | 1239 int channel_num = voe_.GetLastChannel(); |
1237 cricket::AudioSendParameters parameters; | 1240 cricket::AudioSendParameters parameters; |
1238 parameters.codecs.push_back(kOpusCodec); | 1241 parameters.codecs.push_back(kOpusCodec); |
1239 parameters.codecs[0].bitrate = 0; | 1242 parameters.codecs[0].bitrate = 0; |
1240 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001); | 1243 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001); |
1241 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1244 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1242 EXPECT_EQ(cricket::kOpusBandwidthWb, | 1245 EXPECT_EQ(cricket::kOpusBandwidthWb, |
1243 voe_.GetMaxEncodingBandwidth(channel_num)); | 1246 voe_.GetMaxEncodingBandwidth(channel_num)); |
1244 webrtc::CodecInst gcodec; | 1247 webrtc::CodecInst gcodec; |
1245 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1248 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1246 EXPECT_STREQ("opus", gcodec.plname); | 1249 EXPECT_STREQ("opus", gcodec.plname); |
1247 | 1250 |
1248 EXPECT_EQ(20000, gcodec.rate); | 1251 EXPECT_EQ(20000, gcodec.rate); |
1249 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1252 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1250 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1253 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1251 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1254 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1252 EXPECT_EQ(40000, gcodec.rate); | 1255 EXPECT_EQ(40000, gcodec.rate); |
1253 } | 1256 } |
1254 | 1257 |
1255 // Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode. | 1258 // Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode. |
1256 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { | 1259 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { |
1257 EXPECT_TRUE(SetupEngine()); | 1260 EXPECT_TRUE(SetupEngineWithSendStream()); |
1258 int channel_num = voe_.GetLastChannel(); | 1261 int channel_num = voe_.GetLastChannel(); |
1259 cricket::AudioSendParameters parameters; | 1262 cricket::AudioSendParameters parameters; |
1260 parameters.codecs.push_back(kOpusCodec); | 1263 parameters.codecs.push_back(kOpusCodec); |
1261 parameters.codecs[0].bitrate = 0; | 1264 parameters.codecs[0].bitrate = 0; |
1262 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001); | 1265 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001); |
1263 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1266 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1264 EXPECT_EQ(cricket::kOpusBandwidthSwb, | 1267 EXPECT_EQ(cricket::kOpusBandwidthSwb, |
1265 voe_.GetMaxEncodingBandwidth(channel_num)); | 1268 voe_.GetMaxEncodingBandwidth(channel_num)); |
1266 webrtc::CodecInst gcodec; | 1269 webrtc::CodecInst gcodec; |
1267 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1270 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1268 EXPECT_STREQ("opus", gcodec.plname); | 1271 EXPECT_STREQ("opus", gcodec.plname); |
1269 | 1272 |
1270 EXPECT_EQ(32000, gcodec.rate); | 1273 EXPECT_EQ(32000, gcodec.rate); |
1271 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1274 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1272 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1275 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1273 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1276 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1274 EXPECT_EQ(64000, gcodec.rate); | 1277 EXPECT_EQ(64000, gcodec.rate); |
1275 } | 1278 } |
1276 | 1279 |
1277 // Test 24000 < maxplaybackrate triggers Opus full band mode. | 1280 // Test 24000 < maxplaybackrate triggers Opus full band mode. |
1278 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { | 1281 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { |
1279 EXPECT_TRUE(SetupEngine()); | 1282 EXPECT_TRUE(SetupEngineWithSendStream()); |
1280 int channel_num = voe_.GetLastChannel(); | 1283 int channel_num = voe_.GetLastChannel(); |
1281 cricket::AudioSendParameters parameters; | 1284 cricket::AudioSendParameters parameters; |
1282 parameters.codecs.push_back(kOpusCodec); | 1285 parameters.codecs.push_back(kOpusCodec); |
1283 parameters.codecs[0].bitrate = 0; | 1286 parameters.codecs[0].bitrate = 0; |
1284 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001); | 1287 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001); |
1285 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1288 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1286 EXPECT_EQ(cricket::kOpusBandwidthFb, | 1289 EXPECT_EQ(cricket::kOpusBandwidthFb, |
1287 voe_.GetMaxEncodingBandwidth(channel_num)); | 1290 voe_.GetMaxEncodingBandwidth(channel_num)); |
1288 webrtc::CodecInst gcodec; | 1291 webrtc::CodecInst gcodec; |
1289 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1292 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1290 EXPECT_STREQ("opus", gcodec.plname); | 1293 EXPECT_STREQ("opus", gcodec.plname); |
1291 | 1294 |
1292 EXPECT_EQ(32000, gcodec.rate); | 1295 EXPECT_EQ(32000, gcodec.rate); |
1293 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1296 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1294 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1297 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1295 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1298 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1296 EXPECT_EQ(64000, gcodec.rate); | 1299 EXPECT_EQ(64000, gcodec.rate); |
1297 } | 1300 } |
1298 | 1301 |
1299 // Test Opus that without maxplaybackrate, default playback rate is used. | 1302 // Test Opus that without maxplaybackrate, default playback rate is used. |
1300 TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { | 1303 TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { |
1301 EXPECT_TRUE(SetupEngine()); | 1304 EXPECT_TRUE(SetupEngineWithSendStream()); |
1302 int channel_num = voe_.GetLastChannel(); | 1305 int channel_num = voe_.GetLastChannel(); |
1303 cricket::AudioSendParameters parameters; | 1306 cricket::AudioSendParameters parameters; |
1304 parameters.codecs.push_back(kOpusCodec); | 1307 parameters.codecs.push_back(kOpusCodec); |
1305 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1308 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1306 EXPECT_EQ(cricket::kOpusBandwidthFb, | 1309 EXPECT_EQ(cricket::kOpusBandwidthFb, |
1307 voe_.GetMaxEncodingBandwidth(channel_num)); | 1310 voe_.GetMaxEncodingBandwidth(channel_num)); |
1308 } | 1311 } |
1309 | 1312 |
1310 // Test the with non-Opus, maxplaybackrate has no effect. | 1313 // Test the with non-Opus, maxplaybackrate has no effect. |
1311 TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { | 1314 TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { |
1312 EXPECT_TRUE(SetupEngine()); | 1315 EXPECT_TRUE(SetupEngineWithSendStream()); |
1313 int channel_num = voe_.GetLastChannel(); | 1316 int channel_num = voe_.GetLastChannel(); |
1314 cricket::AudioSendParameters parameters; | 1317 cricket::AudioSendParameters parameters; |
1315 parameters.codecs.push_back(kIsacCodec); | 1318 parameters.codecs.push_back(kIsacCodec); |
1316 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000); | 1319 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000); |
1317 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1320 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1318 EXPECT_EQ(0, voe_.GetMaxEncodingBandwidth(channel_num)); | 1321 EXPECT_EQ(0, voe_.GetMaxEncodingBandwidth(channel_num)); |
1319 } | 1322 } |
1320 | 1323 |
1321 // Test maxplaybackrate can be set on two streams. | 1324 // Test maxplaybackrate can be set on two streams. |
1322 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { | 1325 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { |
1323 EXPECT_TRUE(SetupEngine()); | 1326 EXPECT_TRUE(SetupEngineWithSendStream()); |
1324 int channel_num = voe_.GetLastChannel(); | 1327 int channel_num = voe_.GetLastChannel(); |
1325 cricket::AudioSendParameters parameters; | 1328 cricket::AudioSendParameters parameters; |
1326 parameters.codecs.push_back(kOpusCodec); | 1329 parameters.codecs.push_back(kOpusCodec); |
1327 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1330 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1328 // Default bandwidth is 24000. | 1331 // Default bandwidth is 24000. |
1329 EXPECT_EQ(cricket::kOpusBandwidthFb, | 1332 EXPECT_EQ(cricket::kOpusBandwidthFb, |
1330 voe_.GetMaxEncodingBandwidth(channel_num)); | 1333 voe_.GetMaxEncodingBandwidth(channel_num)); |
1331 | 1334 |
1332 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); | 1335 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); |
1333 | 1336 |
1334 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1337 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1335 EXPECT_EQ(cricket::kOpusBandwidthNb, | 1338 EXPECT_EQ(cricket::kOpusBandwidthNb, |
1336 voe_.GetMaxEncodingBandwidth(channel_num)); | 1339 voe_.GetMaxEncodingBandwidth(channel_num)); |
1337 | 1340 |
1338 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc2)); | 1341 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc2)); |
1339 channel_num = voe_.GetLastChannel(); | 1342 channel_num = voe_.GetLastChannel(); |
1340 EXPECT_EQ(cricket::kOpusBandwidthNb, | 1343 EXPECT_EQ(cricket::kOpusBandwidthNb, |
1341 voe_.GetMaxEncodingBandwidth(channel_num)); | 1344 voe_.GetMaxEncodingBandwidth(channel_num)); |
1342 } | 1345 } |
1343 | 1346 |
1344 // Test that with usedtx=0, Opus DTX is off. | 1347 // Test that with usedtx=0, Opus DTX is off. |
1345 TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { | 1348 TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { |
1346 EXPECT_TRUE(SetupEngine()); | 1349 EXPECT_TRUE(SetupEngineWithSendStream()); |
1347 int channel_num = voe_.GetLastChannel(); | 1350 int channel_num = voe_.GetLastChannel(); |
1348 cricket::AudioSendParameters parameters; | 1351 cricket::AudioSendParameters parameters; |
1349 parameters.codecs.push_back(kOpusCodec); | 1352 parameters.codecs.push_back(kOpusCodec); |
1350 parameters.codecs[0].params["usedtx"] = "0"; | 1353 parameters.codecs[0].params["usedtx"] = "0"; |
1351 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1354 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1352 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); | 1355 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); |
1353 } | 1356 } |
1354 | 1357 |
1355 // Test that with usedtx=1, Opus DTX is on. | 1358 // Test that with usedtx=1, Opus DTX is on. |
1356 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { | 1359 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { |
1357 EXPECT_TRUE(SetupEngine()); | 1360 EXPECT_TRUE(SetupEngineWithSendStream()); |
1358 int channel_num = voe_.GetLastChannel(); | 1361 int channel_num = voe_.GetLastChannel(); |
1359 cricket::AudioSendParameters parameters; | 1362 cricket::AudioSendParameters parameters; |
1360 parameters.codecs.push_back(kOpusCodec); | 1363 parameters.codecs.push_back(kOpusCodec); |
1361 parameters.codecs[0].params["usedtx"] = "1"; | 1364 parameters.codecs[0].params["usedtx"] = "1"; |
1362 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1365 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1363 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); | 1366 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); |
1364 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. | 1367 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. |
1365 } | 1368 } |
1366 | 1369 |
1367 // Test that usedtx=1 works with stereo Opus. | 1370 // Test that usedtx=1 works with stereo Opus. |
1368 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { | 1371 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { |
1369 EXPECT_TRUE(SetupEngine()); | 1372 EXPECT_TRUE(SetupEngineWithSendStream()); |
1370 int channel_num = voe_.GetLastChannel(); | 1373 int channel_num = voe_.GetLastChannel(); |
1371 cricket::AudioSendParameters parameters; | 1374 cricket::AudioSendParameters parameters; |
1372 parameters.codecs.push_back(kOpusCodec); | 1375 parameters.codecs.push_back(kOpusCodec); |
1373 parameters.codecs[0].params["usedtx"] = "1"; | 1376 parameters.codecs[0].params["usedtx"] = "1"; |
1374 parameters.codecs[0].params["stereo"] = "1"; | 1377 parameters.codecs[0].params["stereo"] = "1"; |
1375 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1378 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1376 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); | 1379 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); |
1377 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. | 1380 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. |
1378 } | 1381 } |
1379 | 1382 |
1380 // Test that usedtx=1 does not work with non Opus. | 1383 // Test that usedtx=1 does not work with non Opus. |
1381 TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { | 1384 TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { |
1382 EXPECT_TRUE(SetupEngine()); | 1385 EXPECT_TRUE(SetupEngineWithSendStream()); |
1383 int channel_num = voe_.GetLastChannel(); | 1386 int channel_num = voe_.GetLastChannel(); |
1384 cricket::AudioSendParameters parameters; | 1387 cricket::AudioSendParameters parameters; |
1385 parameters.codecs.push_back(kIsacCodec); | 1388 parameters.codecs.push_back(kIsacCodec); |
1386 parameters.codecs[0].params["usedtx"] = "1"; | 1389 parameters.codecs[0].params["usedtx"] = "1"; |
1387 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1390 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1388 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); | 1391 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); |
1389 } | 1392 } |
1390 | 1393 |
1391 // Test that we can switch back and forth between Opus and ISAC with CN. | 1394 // Test that we can switch back and forth between Opus and ISAC with CN. |
1392 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { | 1395 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { |
1393 EXPECT_TRUE(SetupEngine()); | 1396 EXPECT_TRUE(SetupEngineWithSendStream()); |
1394 int channel_num = voe_.GetLastChannel(); | 1397 int channel_num = voe_.GetLastChannel(); |
1395 cricket::AudioSendParameters opus_parameters; | 1398 cricket::AudioSendParameters opus_parameters; |
1396 opus_parameters.codecs.push_back(kOpusCodec); | 1399 opus_parameters.codecs.push_back(kOpusCodec); |
1397 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); | 1400 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); |
1398 webrtc::CodecInst gcodec; | 1401 webrtc::CodecInst gcodec; |
1399 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1402 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1400 EXPECT_EQ(111, gcodec.pltype); | 1403 EXPECT_EQ(111, gcodec.pltype); |
1401 EXPECT_STREQ("opus", gcodec.plname); | 1404 EXPECT_STREQ("opus", gcodec.plname); |
1402 | 1405 |
1403 cricket::AudioSendParameters isac_parameters; | 1406 cricket::AudioSendParameters isac_parameters; |
1404 isac_parameters.codecs.push_back(kIsacCodec); | 1407 isac_parameters.codecs.push_back(kIsacCodec); |
1405 isac_parameters.codecs.push_back(kCn16000Codec); | 1408 isac_parameters.codecs.push_back(kCn16000Codec); |
1406 isac_parameters.codecs.push_back(kOpusCodec); | 1409 isac_parameters.codecs.push_back(kOpusCodec); |
1407 EXPECT_TRUE(channel_->SetSendParameters(isac_parameters)); | 1410 EXPECT_TRUE(channel_->SetSendParameters(isac_parameters)); |
1408 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1411 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1409 EXPECT_EQ(103, gcodec.pltype); | 1412 EXPECT_EQ(103, gcodec.pltype); |
1410 EXPECT_STREQ("ISAC", gcodec.plname); | 1413 EXPECT_STREQ("ISAC", gcodec.plname); |
1411 | 1414 |
1412 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); | 1415 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); |
1413 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1416 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1414 EXPECT_EQ(111, gcodec.pltype); | 1417 EXPECT_EQ(111, gcodec.pltype); |
1415 EXPECT_STREQ("opus", gcodec.plname); | 1418 EXPECT_STREQ("opus", gcodec.plname); |
1416 } | 1419 } |
1417 | 1420 |
1418 // Test that we handle various ways of specifying bitrate. | 1421 // Test that we handle various ways of specifying bitrate. |
1419 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { | 1422 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { |
1420 EXPECT_TRUE(SetupEngine()); | 1423 EXPECT_TRUE(SetupEngineWithSendStream()); |
1421 int channel_num = voe_.GetLastChannel(); | 1424 int channel_num = voe_.GetLastChannel(); |
1422 cricket::AudioSendParameters parameters; | 1425 cricket::AudioSendParameters parameters; |
1423 parameters.codecs.push_back(kIsacCodec); // bitrate == 32000 | 1426 parameters.codecs.push_back(kIsacCodec); // bitrate == 32000 |
1424 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1427 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1425 webrtc::CodecInst gcodec; | 1428 webrtc::CodecInst gcodec; |
1426 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1429 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1427 EXPECT_EQ(103, gcodec.pltype); | 1430 EXPECT_EQ(103, gcodec.pltype); |
1428 EXPECT_STREQ("ISAC", gcodec.plname); | 1431 EXPECT_STREQ("ISAC", gcodec.plname); |
1429 EXPECT_EQ(32000, gcodec.rate); | 1432 EXPECT_EQ(32000, gcodec.rate); |
1430 | 1433 |
(...skipping 29 matching lines...) Expand all Loading... |
1460 parameters.codecs[0].bitrate = 0; // bitrate == default | 1463 parameters.codecs[0].bitrate = 0; // bitrate == default |
1461 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1464 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1462 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1465 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1463 EXPECT_EQ(111, gcodec.pltype); | 1466 EXPECT_EQ(111, gcodec.pltype); |
1464 EXPECT_STREQ("opus", gcodec.plname); | 1467 EXPECT_STREQ("opus", gcodec.plname); |
1465 EXPECT_EQ(32000, gcodec.rate); | 1468 EXPECT_EQ(32000, gcodec.rate); |
1466 } | 1469 } |
1467 | 1470 |
1468 // Test that we could set packet size specified in kCodecParamPTime. | 1471 // Test that we could set packet size specified in kCodecParamPTime. |
1469 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { | 1472 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { |
1470 EXPECT_TRUE(SetupEngine()); | 1473 EXPECT_TRUE(SetupEngineWithSendStream()); |
1471 int channel_num = voe_.GetLastChannel(); | 1474 int channel_num = voe_.GetLastChannel(); |
1472 cricket::AudioSendParameters parameters; | 1475 cricket::AudioSendParameters parameters; |
1473 parameters.codecs.push_back(kOpusCodec); | 1476 parameters.codecs.push_back(kOpusCodec); |
1474 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range. | 1477 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range. |
1475 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1478 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1476 webrtc::CodecInst gcodec; | 1479 webrtc::CodecInst gcodec; |
1477 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1480 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1478 EXPECT_EQ(1920, gcodec.pacsize); // Opus gets 40ms. | 1481 EXPECT_EQ(1920, gcodec.pacsize); // Opus gets 40ms. |
1479 | 1482 |
1480 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Below range. | 1483 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Below range. |
(...skipping 14 matching lines...) Expand all Loading... |
1495 | 1498 |
1496 parameters.codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP. | 1499 parameters.codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP. |
1497 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); | 1500 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); |
1498 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1501 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1499 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1502 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1500 EXPECT_EQ(640, gcodec.pacsize); // G722 gets 40ms @16kHz as defined in VoE. | 1503 EXPECT_EQ(640, gcodec.pacsize); // G722 gets 40ms @16kHz as defined in VoE. |
1501 } | 1504 } |
1502 | 1505 |
1503 // Test that we fail if no codecs are specified. | 1506 // Test that we fail if no codecs are specified. |
1504 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { | 1507 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { |
1505 EXPECT_TRUE(SetupEngine()); | 1508 EXPECT_TRUE(SetupEngineWithSendStream()); |
1506 cricket::AudioSendParameters parameters; | 1509 cricket::AudioSendParameters parameters; |
1507 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 1510 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
1508 } | 1511 } |
1509 | 1512 |
1510 // Test that we can set send codecs even with telephone-event codec as the first | 1513 // Test that we can set send codecs even with telephone-event codec as the first |
1511 // one on the list. | 1514 // one on the list. |
1512 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { | 1515 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { |
1513 EXPECT_TRUE(SetupEngine()); | 1516 EXPECT_TRUE(SetupEngineWithSendStream()); |
1514 int channel_num = voe_.GetLastChannel(); | 1517 int channel_num = voe_.GetLastChannel(); |
1515 cricket::AudioSendParameters parameters; | 1518 cricket::AudioSendParameters parameters; |
1516 parameters.codecs.push_back(kTelephoneEventCodec); | 1519 parameters.codecs.push_back(kTelephoneEventCodec); |
1517 parameters.codecs.push_back(kIsacCodec); | 1520 parameters.codecs.push_back(kIsacCodec); |
1518 parameters.codecs.push_back(kPcmuCodec); | 1521 parameters.codecs.push_back(kPcmuCodec); |
1519 parameters.codecs[0].id = 98; // DTMF | 1522 parameters.codecs[0].id = 98; // DTMF |
1520 parameters.codecs[1].id = 96; | 1523 parameters.codecs[1].id = 96; |
1521 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1524 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1522 webrtc::CodecInst gcodec; | 1525 webrtc::CodecInst gcodec; |
1523 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1526 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1524 EXPECT_EQ(96, gcodec.pltype); | 1527 EXPECT_EQ(96, gcodec.pltype); |
1525 EXPECT_STREQ("ISAC", gcodec.plname); | 1528 EXPECT_STREQ("ISAC", gcodec.plname); |
1526 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); | 1529 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); |
1527 } | 1530 } |
1528 | 1531 |
1529 // Test that we can set send codecs even with CN codec as the first | 1532 // Test that we can set send codecs even with CN codec as the first |
1530 // one on the list. | 1533 // one on the list. |
1531 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { | 1534 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { |
1532 EXPECT_TRUE(SetupEngine()); | 1535 EXPECT_TRUE(SetupEngineWithSendStream()); |
1533 int channel_num = voe_.GetLastChannel(); | 1536 int channel_num = voe_.GetLastChannel(); |
1534 cricket::AudioSendParameters parameters; | 1537 cricket::AudioSendParameters parameters; |
1535 parameters.codecs.push_back(kCn16000Codec); | 1538 parameters.codecs.push_back(kCn16000Codec); |
1536 parameters.codecs.push_back(kIsacCodec); | 1539 parameters.codecs.push_back(kIsacCodec); |
1537 parameters.codecs.push_back(kPcmuCodec); | 1540 parameters.codecs.push_back(kPcmuCodec); |
1538 parameters.codecs[0].id = 98; // wideband CN | 1541 parameters.codecs[0].id = 98; // wideband CN |
1539 parameters.codecs[1].id = 96; | 1542 parameters.codecs[1].id = 96; |
1540 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1543 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1541 webrtc::CodecInst gcodec; | 1544 webrtc::CodecInst gcodec; |
1542 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1545 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1543 EXPECT_EQ(96, gcodec.pltype); | 1546 EXPECT_EQ(96, gcodec.pltype); |
1544 EXPECT_STREQ("ISAC", gcodec.plname); | 1547 EXPECT_STREQ("ISAC", gcodec.plname); |
1545 EXPECT_EQ(98, voe_.GetSendCNPayloadType(channel_num, true)); | 1548 EXPECT_EQ(98, voe_.GetSendCNPayloadType(channel_num, true)); |
1546 } | 1549 } |
1547 | 1550 |
1548 // Test that we set VAD and DTMF types correctly as caller. | 1551 // Test that we set VAD and DTMF types correctly as caller. |
1549 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { | 1552 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { |
1550 EXPECT_TRUE(SetupEngine()); | 1553 EXPECT_TRUE(SetupEngineWithSendStream()); |
1551 int channel_num = voe_.GetLastChannel(); | 1554 int channel_num = voe_.GetLastChannel(); |
1552 cricket::AudioSendParameters parameters; | 1555 cricket::AudioSendParameters parameters; |
1553 parameters.codecs.push_back(kIsacCodec); | 1556 parameters.codecs.push_back(kIsacCodec); |
1554 parameters.codecs.push_back(kPcmuCodec); | 1557 parameters.codecs.push_back(kPcmuCodec); |
1555 // TODO(juberti): cn 32000 | 1558 // TODO(juberti): cn 32000 |
1556 parameters.codecs.push_back(kCn16000Codec); | 1559 parameters.codecs.push_back(kCn16000Codec); |
1557 parameters.codecs.push_back(kCn8000Codec); | 1560 parameters.codecs.push_back(kCn8000Codec); |
1558 parameters.codecs.push_back(kTelephoneEventCodec); | 1561 parameters.codecs.push_back(kTelephoneEventCodec); |
1559 parameters.codecs.push_back(kRedCodec); | 1562 parameters.codecs.push_back(kRedCodec); |
1560 parameters.codecs[0].id = 96; | 1563 parameters.codecs[0].id = 96; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 EXPECT_TRUE(voe_.GetVAD(channel_num)); | 1604 EXPECT_TRUE(voe_.GetVAD(channel_num)); |
1602 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1605 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1603 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); | 1606 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); |
1604 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); | 1607 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); |
1605 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); | 1608 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); |
1606 } | 1609 } |
1607 | 1610 |
1608 // Test that we only apply VAD if we have a CN codec that matches the | 1611 // Test that we only apply VAD if we have a CN codec that matches the |
1609 // send codec clockrate. | 1612 // send codec clockrate. |
1610 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { | 1613 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { |
1611 EXPECT_TRUE(SetupEngine()); | 1614 EXPECT_TRUE(SetupEngineWithSendStream()); |
1612 int channel_num = voe_.GetLastChannel(); | 1615 int channel_num = voe_.GetLastChannel(); |
1613 cricket::AudioSendParameters parameters; | 1616 cricket::AudioSendParameters parameters; |
1614 // Set ISAC(16K) and CN(16K). VAD should be activated. | 1617 // Set ISAC(16K) and CN(16K). VAD should be activated. |
1615 parameters.codecs.push_back(kIsacCodec); | 1618 parameters.codecs.push_back(kIsacCodec); |
1616 parameters.codecs.push_back(kCn16000Codec); | 1619 parameters.codecs.push_back(kCn16000Codec); |
1617 parameters.codecs[1].id = 97; | 1620 parameters.codecs[1].id = 97; |
1618 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1621 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1619 webrtc::CodecInst gcodec; | 1622 webrtc::CodecInst gcodec; |
1620 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1623 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1621 EXPECT_STREQ("ISAC", gcodec.plname); | 1624 EXPECT_STREQ("ISAC", gcodec.plname); |
(...skipping 15 matching lines...) Expand all Loading... |
1637 // Set ISAC(16K) and CN(8K). VAD should not be activated. | 1640 // Set ISAC(16K) and CN(8K). VAD should not be activated. |
1638 parameters.codecs[0] = kIsacCodec; | 1641 parameters.codecs[0] = kIsacCodec; |
1639 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1642 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1640 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1643 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1641 EXPECT_STREQ("ISAC", gcodec.plname); | 1644 EXPECT_STREQ("ISAC", gcodec.plname); |
1642 EXPECT_FALSE(voe_.GetVAD(channel_num)); | 1645 EXPECT_FALSE(voe_.GetVAD(channel_num)); |
1643 } | 1646 } |
1644 | 1647 |
1645 // Test that we perform case-insensitive matching of codec names. | 1648 // Test that we perform case-insensitive matching of codec names. |
1646 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { | 1649 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { |
1647 EXPECT_TRUE(SetupEngine()); | 1650 EXPECT_TRUE(SetupEngineWithSendStream()); |
1648 int channel_num = voe_.GetLastChannel(); | 1651 int channel_num = voe_.GetLastChannel(); |
1649 cricket::AudioSendParameters parameters; | 1652 cricket::AudioSendParameters parameters; |
1650 parameters.codecs.push_back(kIsacCodec); | 1653 parameters.codecs.push_back(kIsacCodec); |
1651 parameters.codecs.push_back(kPcmuCodec); | 1654 parameters.codecs.push_back(kPcmuCodec); |
1652 parameters.codecs.push_back(kCn16000Codec); | 1655 parameters.codecs.push_back(kCn16000Codec); |
1653 parameters.codecs.push_back(kCn8000Codec); | 1656 parameters.codecs.push_back(kCn8000Codec); |
1654 parameters.codecs.push_back(kTelephoneEventCodec); | 1657 parameters.codecs.push_back(kTelephoneEventCodec); |
1655 parameters.codecs.push_back(kRedCodec); | 1658 parameters.codecs.push_back(kRedCodec); |
1656 parameters.codecs[0].name = "iSaC"; | 1659 parameters.codecs[0].name = "iSaC"; |
1657 parameters.codecs[0].id = 96; | 1660 parameters.codecs[0].id = 96; |
1658 parameters.codecs[2].id = 97; // wideband CN | 1661 parameters.codecs[2].id = 97; // wideband CN |
1659 parameters.codecs[4].id = 98; // DTMF | 1662 parameters.codecs[4].id = 98; // DTMF |
1660 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1663 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1661 webrtc::CodecInst gcodec; | 1664 webrtc::CodecInst gcodec; |
1662 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1665 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1663 EXPECT_EQ(96, gcodec.pltype); | 1666 EXPECT_EQ(96, gcodec.pltype); |
1664 EXPECT_STREQ("ISAC", gcodec.plname); | 1667 EXPECT_STREQ("ISAC", gcodec.plname); |
1665 EXPECT_TRUE(voe_.GetVAD(channel_num)); | 1668 EXPECT_TRUE(voe_.GetVAD(channel_num)); |
1666 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1669 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1667 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); | 1670 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); |
1668 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); | 1671 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); |
1669 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); | 1672 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); |
1670 } | 1673 } |
1671 | 1674 |
1672 // Test that we set up RED correctly as caller. | 1675 // Test that we set up RED correctly as caller. |
1673 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) { | 1676 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) { |
1674 EXPECT_TRUE(SetupEngine()); | 1677 EXPECT_TRUE(SetupEngineWithSendStream()); |
1675 int channel_num = voe_.GetLastChannel(); | 1678 int channel_num = voe_.GetLastChannel(); |
1676 cricket::AudioSendParameters parameters; | 1679 cricket::AudioSendParameters parameters; |
1677 parameters.codecs.push_back(kRedCodec); | 1680 parameters.codecs.push_back(kRedCodec); |
1678 parameters.codecs.push_back(kIsacCodec); | 1681 parameters.codecs.push_back(kIsacCodec); |
1679 parameters.codecs.push_back(kPcmuCodec); | 1682 parameters.codecs.push_back(kPcmuCodec); |
1680 parameters.codecs[0].id = 127; | 1683 parameters.codecs[0].id = 127; |
1681 parameters.codecs[0].params[""] = "96/96"; | 1684 parameters.codecs[0].params[""] = "96/96"; |
1682 parameters.codecs[1].id = 96; | 1685 parameters.codecs[1].id = 96; |
1683 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1686 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1684 webrtc::CodecInst gcodec; | 1687 webrtc::CodecInst gcodec; |
(...skipping 24 matching lines...) Expand all Loading... |
1709 webrtc::CodecInst gcodec; | 1712 webrtc::CodecInst gcodec; |
1710 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1713 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1711 EXPECT_EQ(96, gcodec.pltype); | 1714 EXPECT_EQ(96, gcodec.pltype); |
1712 EXPECT_STREQ("ISAC", gcodec.plname); | 1715 EXPECT_STREQ("ISAC", gcodec.plname); |
1713 EXPECT_TRUE(voe_.GetRED(channel_num)); | 1716 EXPECT_TRUE(voe_.GetRED(channel_num)); |
1714 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); | 1717 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); |
1715 } | 1718 } |
1716 | 1719 |
1717 // Test that we set up RED correctly if params are omitted. | 1720 // Test that we set up RED correctly if params are omitted. |
1718 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { | 1721 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { |
1719 EXPECT_TRUE(SetupEngine()); | 1722 EXPECT_TRUE(SetupEngineWithSendStream()); |
1720 int channel_num = voe_.GetLastChannel(); | 1723 int channel_num = voe_.GetLastChannel(); |
1721 cricket::AudioSendParameters parameters; | 1724 cricket::AudioSendParameters parameters; |
1722 parameters.codecs.push_back(kRedCodec); | 1725 parameters.codecs.push_back(kRedCodec); |
1723 parameters.codecs.push_back(kIsacCodec); | 1726 parameters.codecs.push_back(kIsacCodec); |
1724 parameters.codecs.push_back(kPcmuCodec); | 1727 parameters.codecs.push_back(kPcmuCodec); |
1725 parameters.codecs[0].id = 127; | 1728 parameters.codecs[0].id = 127; |
1726 parameters.codecs[1].id = 96; | 1729 parameters.codecs[1].id = 96; |
1727 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1730 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1728 webrtc::CodecInst gcodec; | 1731 webrtc::CodecInst gcodec; |
1729 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1732 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1730 EXPECT_EQ(96, gcodec.pltype); | 1733 EXPECT_EQ(96, gcodec.pltype); |
1731 EXPECT_STREQ("ISAC", gcodec.plname); | 1734 EXPECT_STREQ("ISAC", gcodec.plname); |
1732 EXPECT_TRUE(voe_.GetRED(channel_num)); | 1735 EXPECT_TRUE(voe_.GetRED(channel_num)); |
1733 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); | 1736 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); |
1734 } | 1737 } |
1735 | 1738 |
1736 // Test that we ignore RED if the parameters aren't named the way we expect. | 1739 // Test that we ignore RED if the parameters aren't named the way we expect. |
1737 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { | 1740 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { |
1738 EXPECT_TRUE(SetupEngine()); | 1741 EXPECT_TRUE(SetupEngineWithSendStream()); |
1739 int channel_num = voe_.GetLastChannel(); | 1742 int channel_num = voe_.GetLastChannel(); |
1740 cricket::AudioSendParameters parameters; | 1743 cricket::AudioSendParameters parameters; |
1741 parameters.codecs.push_back(kRedCodec); | 1744 parameters.codecs.push_back(kRedCodec); |
1742 parameters.codecs.push_back(kIsacCodec); | 1745 parameters.codecs.push_back(kIsacCodec); |
1743 parameters.codecs.push_back(kPcmuCodec); | 1746 parameters.codecs.push_back(kPcmuCodec); |
1744 parameters.codecs[0].id = 127; | 1747 parameters.codecs[0].id = 127; |
1745 parameters.codecs[0].params["ABC"] = "96/96"; | 1748 parameters.codecs[0].params["ABC"] = "96/96"; |
1746 parameters.codecs[1].id = 96; | 1749 parameters.codecs[1].id = 96; |
1747 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1750 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1748 webrtc::CodecInst gcodec; | 1751 webrtc::CodecInst gcodec; |
1749 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1752 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1750 EXPECT_EQ(96, gcodec.pltype); | 1753 EXPECT_EQ(96, gcodec.pltype); |
1751 EXPECT_STREQ("ISAC", gcodec.plname); | 1754 EXPECT_STREQ("ISAC", gcodec.plname); |
1752 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1755 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1753 } | 1756 } |
1754 | 1757 |
1755 // Test that we ignore RED if it uses different primary/secondary encoding. | 1758 // Test that we ignore RED if it uses different primary/secondary encoding. |
1756 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { | 1759 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { |
1757 EXPECT_TRUE(SetupEngine()); | 1760 EXPECT_TRUE(SetupEngineWithSendStream()); |
1758 int channel_num = voe_.GetLastChannel(); | 1761 int channel_num = voe_.GetLastChannel(); |
1759 cricket::AudioSendParameters parameters; | 1762 cricket::AudioSendParameters parameters; |
1760 parameters.codecs.push_back(kRedCodec); | 1763 parameters.codecs.push_back(kRedCodec); |
1761 parameters.codecs.push_back(kIsacCodec); | 1764 parameters.codecs.push_back(kIsacCodec); |
1762 parameters.codecs.push_back(kPcmuCodec); | 1765 parameters.codecs.push_back(kPcmuCodec); |
1763 parameters.codecs[0].id = 127; | 1766 parameters.codecs[0].id = 127; |
1764 parameters.codecs[0].params[""] = "96/0"; | 1767 parameters.codecs[0].params[""] = "96/0"; |
1765 parameters.codecs[1].id = 96; | 1768 parameters.codecs[1].id = 96; |
1766 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1769 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1767 webrtc::CodecInst gcodec; | 1770 webrtc::CodecInst gcodec; |
1768 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1771 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1769 EXPECT_EQ(96, gcodec.pltype); | 1772 EXPECT_EQ(96, gcodec.pltype); |
1770 EXPECT_STREQ("ISAC", gcodec.plname); | 1773 EXPECT_STREQ("ISAC", gcodec.plname); |
1771 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1774 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1772 } | 1775 } |
1773 | 1776 |
1774 // Test that we ignore RED if it uses more than 2 encodings. | 1777 // Test that we ignore RED if it uses more than 2 encodings. |
1775 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { | 1778 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { |
1776 EXPECT_TRUE(SetupEngine()); | 1779 EXPECT_TRUE(SetupEngineWithSendStream()); |
1777 int channel_num = voe_.GetLastChannel(); | 1780 int channel_num = voe_.GetLastChannel(); |
1778 cricket::AudioSendParameters parameters; | 1781 cricket::AudioSendParameters parameters; |
1779 parameters.codecs.push_back(kRedCodec); | 1782 parameters.codecs.push_back(kRedCodec); |
1780 parameters.codecs.push_back(kIsacCodec); | 1783 parameters.codecs.push_back(kIsacCodec); |
1781 parameters.codecs.push_back(kPcmuCodec); | 1784 parameters.codecs.push_back(kPcmuCodec); |
1782 parameters.codecs[0].id = 127; | 1785 parameters.codecs[0].id = 127; |
1783 parameters.codecs[0].params[""] = "96/96/96"; | 1786 parameters.codecs[0].params[""] = "96/96/96"; |
1784 parameters.codecs[1].id = 96; | 1787 parameters.codecs[1].id = 96; |
1785 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1788 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1786 webrtc::CodecInst gcodec; | 1789 webrtc::CodecInst gcodec; |
1787 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1790 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1788 EXPECT_EQ(96, gcodec.pltype); | 1791 EXPECT_EQ(96, gcodec.pltype); |
1789 EXPECT_STREQ("ISAC", gcodec.plname); | 1792 EXPECT_STREQ("ISAC", gcodec.plname); |
1790 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1793 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1791 } | 1794 } |
1792 | 1795 |
1793 // Test that we ignore RED if it has bogus codec ids. | 1796 // Test that we ignore RED if it has bogus codec ids. |
1794 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { | 1797 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { |
1795 EXPECT_TRUE(SetupEngine()); | 1798 EXPECT_TRUE(SetupEngineWithSendStream()); |
1796 int channel_num = voe_.GetLastChannel(); | 1799 int channel_num = voe_.GetLastChannel(); |
1797 cricket::AudioSendParameters parameters; | 1800 cricket::AudioSendParameters parameters; |
1798 parameters.codecs.push_back(kRedCodec); | 1801 parameters.codecs.push_back(kRedCodec); |
1799 parameters.codecs.push_back(kIsacCodec); | 1802 parameters.codecs.push_back(kIsacCodec); |
1800 parameters.codecs.push_back(kPcmuCodec); | 1803 parameters.codecs.push_back(kPcmuCodec); |
1801 parameters.codecs[0].id = 127; | 1804 parameters.codecs[0].id = 127; |
1802 parameters.codecs[0].params[""] = "ABC/ABC"; | 1805 parameters.codecs[0].params[""] = "ABC/ABC"; |
1803 parameters.codecs[1].id = 96; | 1806 parameters.codecs[1].id = 96; |
1804 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1807 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1805 webrtc::CodecInst gcodec; | 1808 webrtc::CodecInst gcodec; |
1806 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1809 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1807 EXPECT_EQ(96, gcodec.pltype); | 1810 EXPECT_EQ(96, gcodec.pltype); |
1808 EXPECT_STREQ("ISAC", gcodec.plname); | 1811 EXPECT_STREQ("ISAC", gcodec.plname); |
1809 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1812 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1810 } | 1813 } |
1811 | 1814 |
1812 // Test that we ignore RED if it refers to a codec that is not present. | 1815 // Test that we ignore RED if it refers to a codec that is not present. |
1813 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) { | 1816 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) { |
1814 EXPECT_TRUE(SetupEngine()); | 1817 EXPECT_TRUE(SetupEngineWithSendStream()); |
1815 int channel_num = voe_.GetLastChannel(); | 1818 int channel_num = voe_.GetLastChannel(); |
1816 cricket::AudioSendParameters parameters; | 1819 cricket::AudioSendParameters parameters; |
1817 parameters.codecs.push_back(kRedCodec); | 1820 parameters.codecs.push_back(kRedCodec); |
1818 parameters.codecs.push_back(kIsacCodec); | 1821 parameters.codecs.push_back(kIsacCodec); |
1819 parameters.codecs.push_back(kPcmuCodec); | 1822 parameters.codecs.push_back(kPcmuCodec); |
1820 parameters.codecs[0].id = 127; | 1823 parameters.codecs[0].id = 127; |
1821 parameters.codecs[0].params[""] = "97/97"; | 1824 parameters.codecs[0].params[""] = "97/97"; |
1822 parameters.codecs[1].id = 96; | 1825 parameters.codecs[1].id = 96; |
1823 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1826 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1824 webrtc::CodecInst gcodec; | 1827 webrtc::CodecInst gcodec; |
(...skipping 12 matching lines...) Expand all Loading... |
1837 } | 1840 } |
1838 | 1841 |
1839 // Test support for absolute send time header extension. | 1842 // Test support for absolute send time header extension. |
1840 TEST_F(WebRtcVoiceEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) { | 1843 TEST_F(WebRtcVoiceEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) { |
1841 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); | 1844 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); |
1842 } | 1845 } |
1843 TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { | 1846 TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { |
1844 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); | 1847 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); |
1845 } | 1848 } |
1846 | 1849 |
1847 // Test that we can create a channel and start sending/playing out on it. | 1850 // Test that we can create a channel and start sending on it. |
1848 TEST_F(WebRtcVoiceEngineTestFake, SendAndPlayout) { | 1851 TEST_F(WebRtcVoiceEngineTestFake, Send) { |
1849 EXPECT_TRUE(SetupEngine()); | 1852 EXPECT_TRUE(SetupEngineWithSendStream()); |
1850 int channel_num = voe_.GetLastChannel(); | 1853 int channel_num = voe_.GetLastChannel(); |
1851 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 1854 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1852 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 1855 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
1853 EXPECT_TRUE(voe_.GetSend(channel_num)); | 1856 EXPECT_TRUE(voe_.GetSend(channel_num)); |
| 1857 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); |
| 1858 EXPECT_FALSE(voe_.GetSend(channel_num)); |
| 1859 } |
| 1860 |
| 1861 // Test that we can create a channel and start playing out on it. |
| 1862 TEST_F(WebRtcVoiceEngineTestFake, Playout) { |
| 1863 EXPECT_TRUE(SetupEngineWithRecvStream()); |
| 1864 int channel_num = voe_.GetLastChannel(); |
| 1865 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
1854 EXPECT_TRUE(channel_->SetPlayout(true)); | 1866 EXPECT_TRUE(channel_->SetPlayout(true)); |
1855 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 1867 EXPECT_TRUE(voe_.GetPlayout(channel_num)); |
1856 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); | |
1857 EXPECT_FALSE(voe_.GetSend(channel_num)); | |
1858 EXPECT_TRUE(channel_->SetPlayout(false)); | 1868 EXPECT_TRUE(channel_->SetPlayout(false)); |
1859 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | 1869 EXPECT_FALSE(voe_.GetPlayout(channel_num)); |
1860 } | 1870 } |
1861 | 1871 |
1862 // Test that we can add and remove send streams. | 1872 // Test that we can add and remove send streams. |
1863 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { | 1873 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { |
1864 SetupForMultiSendStream(); | 1874 SetupForMultiSendStream(); |
1865 | 1875 |
1866 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; | 1876 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; |
1867 | 1877 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); | 2001 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); |
1992 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent); | 2002 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent); |
1993 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_sent); | 2003 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_sent); |
1994 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_lost); | 2004 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_lost); |
1995 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[i].fraction_lost); | 2005 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[i].fraction_lost); |
1996 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].ext_seqnum); | 2006 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].ext_seqnum); |
1997 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].rtt_ms); | 2007 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].rtt_ms); |
1998 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].jitter_ms); | 2008 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].jitter_ms); |
1999 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); | 2009 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); |
2000 } | 2010 } |
| 2011 EXPECT_EQ(0u, info.receivers.size()); |
2001 | 2012 |
2002 EXPECT_EQ(0u, info.receivers.size()); | 2013 // Registered stream's remote SSRC is kSsrc2. Send a packet with SSRC=1. |
| 2014 // We should drop the packet and no stats should be available. |
2003 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2015 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
2004 EXPECT_EQ(true, channel_->GetStats(&info)); | 2016 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2017 EXPECT_EQ(0u, info.receivers.size()); |
2005 | 2018 |
| 2019 // Remove the kSsrc2 stream and deliver a new packet - a default receive |
| 2020 // stream should be created and we should see stats. |
| 2021 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); |
| 2022 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2023 EXPECT_EQ(true, channel_->GetStats(&info)); |
2006 EXPECT_EQ(1u, info.receivers.size()); | 2024 EXPECT_EQ(1u, info.receivers.size()); |
| 2025 |
2007 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); | 2026 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); |
2008 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); | 2027 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); |
2009 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); | 2028 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); |
2010 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); | 2029 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); |
2011 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); | 2030 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); |
2012 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / | 2031 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / |
2013 (1 << 14), info.receivers[0].expand_rate); | 2032 (1 << 14), info.receivers[0].expand_rate); |
2014 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / | 2033 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / |
2015 (1 << 14), info.receivers[0].speech_expand_rate); | 2034 (1 << 14), info.receivers[0].speech_expand_rate); |
2016 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / | 2035 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / |
2017 (1 << 14), info.receivers[0].secondary_decoded_rate); | 2036 (1 << 14), info.receivers[0].secondary_decoded_rate); |
2018 EXPECT_EQ( | 2037 EXPECT_EQ( |
2019 static_cast<float>(cricket::kNetStats.currentAccelerateRate) / (1 << 14), | 2038 static_cast<float>(cricket::kNetStats.currentAccelerateRate) / (1 << 14), |
2020 info.receivers[0].accelerate_rate); | 2039 info.receivers[0].accelerate_rate); |
2021 EXPECT_EQ( | 2040 EXPECT_EQ( |
2022 static_cast<float>(cricket::kNetStats.currentPreemptiveRate) / (1 << 14), | 2041 static_cast<float>(cricket::kNetStats.currentPreemptiveRate) / (1 << 14), |
2023 info.receivers[0].preemptive_expand_rate); | 2042 info.receivers[0].preemptive_expand_rate); |
2024 } | 2043 } |
2025 | 2044 |
2026 // Test that we can add and remove receive streams, and do proper send/playout. | 2045 // Test that we can add and remove receive streams, and do proper send/playout. |
2027 // We can receive on multiple streams while sending one stream. | 2046 // We can receive on multiple streams while sending one stream. |
2028 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { | 2047 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { |
2029 EXPECT_TRUE(SetupEngine()); | 2048 EXPECT_TRUE(SetupEngineWithSendStream()); |
2030 int channel_num1 = voe_.GetLastChannel(); | 2049 int channel_num1 = voe_.GetLastChannel(); |
2031 | 2050 |
2032 // Start playout on the default channel. | 2051 // Start playout without a receive stream. |
2033 send_parameters_.options = options_conference_; | |
2034 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2052 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2035 EXPECT_TRUE(channel_->SetPlayout(true)); | 2053 EXPECT_TRUE(channel_->SetPlayout(true)); |
2036 EXPECT_TRUE(voe_.GetPlayout(channel_num1)); | 2054 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2037 | 2055 |
2038 // Adding another stream should disable playout on the default channel. | 2056 // Adding another stream should enable playout on the new stream only. |
2039 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2057 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2040 int channel_num2 = voe_.GetLastChannel(); | 2058 int channel_num2 = voe_.GetLastChannel(); |
2041 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2059 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2042 EXPECT_TRUE(voe_.GetSend(channel_num1)); | 2060 EXPECT_TRUE(voe_.GetSend(channel_num1)); |
2043 EXPECT_FALSE(voe_.GetSend(channel_num2)); | 2061 EXPECT_FALSE(voe_.GetSend(channel_num2)); |
2044 | 2062 |
2045 // Make sure only the new channel is played out. | 2063 // Make sure only the new stream is played out. |
2046 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2064 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2047 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | 2065 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); |
2048 | 2066 |
2049 // Adding yet another stream should have stream 2 and 3 enabled for playout. | 2067 // Adding yet another stream should have stream 2 and 3 enabled for playout. |
2050 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 2068 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
2051 int channel_num3 = voe_.GetLastChannel(); | 2069 int channel_num3 = voe_.GetLastChannel(); |
2052 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2070 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2053 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | 2071 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); |
2054 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); | 2072 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); |
2055 EXPECT_FALSE(voe_.GetSend(channel_num3)); | 2073 EXPECT_FALSE(voe_.GetSend(channel_num3)); |
2056 | 2074 |
2057 // Stop sending. | 2075 // Stop sending. |
2058 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); | 2076 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); |
2059 EXPECT_FALSE(voe_.GetSend(channel_num1)); | 2077 EXPECT_FALSE(voe_.GetSend(channel_num1)); |
2060 EXPECT_FALSE(voe_.GetSend(channel_num2)); | 2078 EXPECT_FALSE(voe_.GetSend(channel_num2)); |
2061 EXPECT_FALSE(voe_.GetSend(channel_num3)); | 2079 EXPECT_FALSE(voe_.GetSend(channel_num3)); |
2062 | 2080 |
2063 // Stop playout. | 2081 // Stop playout. |
2064 EXPECT_TRUE(channel_->SetPlayout(false)); | 2082 EXPECT_TRUE(channel_->SetPlayout(false)); |
2065 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2083 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2066 EXPECT_FALSE(voe_.GetPlayout(channel_num2)); | 2084 EXPECT_FALSE(voe_.GetPlayout(channel_num2)); |
2067 EXPECT_FALSE(voe_.GetPlayout(channel_num3)); | 2085 EXPECT_FALSE(voe_.GetPlayout(channel_num3)); |
2068 | 2086 |
2069 // Restart playout and make sure the default channel still is not played out. | 2087 // Restart playout and make sure only recv streams are played out. |
2070 EXPECT_TRUE(channel_->SetPlayout(true)); | 2088 EXPECT_TRUE(channel_->SetPlayout(true)); |
2071 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2089 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2072 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | 2090 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); |
2073 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); | 2091 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); |
2074 | 2092 |
2075 // Now remove the new streams and verify that the default channel is | 2093 // Now remove the recv streams and verify that the send stream doesn't play. |
2076 // played out again. | |
2077 EXPECT_TRUE(channel_->RemoveRecvStream(3)); | 2094 EXPECT_TRUE(channel_->RemoveRecvStream(3)); |
2078 EXPECT_TRUE(channel_->RemoveRecvStream(2)); | 2095 EXPECT_TRUE(channel_->RemoveRecvStream(2)); |
2079 | 2096 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2080 EXPECT_TRUE(voe_.GetPlayout(channel_num1)); | |
2081 } | 2097 } |
2082 | 2098 |
2083 // Test that we can set the devices to use. | 2099 // Test that we can set the devices to use. |
2084 TEST_F(WebRtcVoiceEngineTestFake, SetDevices) { | 2100 TEST_F(WebRtcVoiceEngineTestFake, SetDevices) { |
2085 EXPECT_TRUE(SetupEngine()); | 2101 EXPECT_TRUE(SetupEngineWithSendStream()); |
2086 int channel_num = voe_.GetLastChannel(); | 2102 int send_channel = voe_.GetLastChannel(); |
| 2103 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2104 int recv_channel = voe_.GetLastChannel(); |
2087 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2105 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2088 | 2106 |
2089 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, | 2107 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, |
2090 cricket::kFakeDefaultDeviceId); | 2108 cricket::kFakeDefaultDeviceId); |
2091 cricket::Device dev(cricket::kFakeDeviceName, | 2109 cricket::Device dev(cricket::kFakeDeviceName, |
2092 cricket::kFakeDeviceId); | 2110 cricket::kFakeDeviceId); |
2093 | 2111 |
2094 // Test SetDevices() while not sending or playing. | 2112 // Test SetDevices() while not sending or playing. |
2095 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); | 2113 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); |
2096 | 2114 |
2097 // Test SetDevices() while sending and playing. | 2115 // Test SetDevices() while sending and playing. |
2098 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2116 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2099 EXPECT_TRUE(channel_->SetPlayout(true)); | 2117 EXPECT_TRUE(channel_->SetPlayout(true)); |
2100 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2118 EXPECT_TRUE(voe_.GetSend(send_channel)); |
2101 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2119 EXPECT_TRUE(voe_.GetPlayout(recv_channel)); |
2102 | 2120 |
2103 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); | 2121 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); |
2104 | 2122 |
2105 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2123 EXPECT_TRUE(voe_.GetSend(send_channel)); |
2106 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2124 EXPECT_TRUE(voe_.GetPlayout(recv_channel)); |
2107 | 2125 |
2108 // Test that failure to open newly selected devices does not prevent opening | 2126 // Test that failure to open newly selected devices does not prevent opening |
2109 // ones after that. | 2127 // ones after that. |
2110 voe_.set_playout_fail_channel(channel_num); | 2128 voe_.set_playout_fail_channel(recv_channel); |
2111 voe_.set_send_fail_channel(channel_num); | 2129 voe_.set_send_fail_channel(send_channel); |
2112 | 2130 |
2113 EXPECT_FALSE(engine_.SetDevices(&default_dev, &default_dev)); | 2131 EXPECT_FALSE(engine_.SetDevices(&default_dev, &default_dev)); |
2114 | 2132 |
2115 EXPECT_FALSE(voe_.GetSend(channel_num)); | 2133 EXPECT_FALSE(voe_.GetSend(send_channel)); |
2116 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | 2134 EXPECT_FALSE(voe_.GetPlayout(recv_channel)); |
2117 | 2135 |
2118 voe_.set_playout_fail_channel(-1); | 2136 voe_.set_playout_fail_channel(-1); |
2119 voe_.set_send_fail_channel(-1); | 2137 voe_.set_send_fail_channel(-1); |
2120 | 2138 |
2121 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); | 2139 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); |
2122 | 2140 |
2123 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2141 EXPECT_TRUE(voe_.GetSend(send_channel)); |
2124 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2142 EXPECT_TRUE(voe_.GetPlayout(recv_channel)); |
2125 } | 2143 } |
2126 | 2144 |
2127 // Test that we can set the devices to use even if we failed to | 2145 // Test that we can set the devices to use even if we failed to |
2128 // open the initial ones. | 2146 // open the initial ones. |
2129 TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) { | 2147 TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) { |
2130 EXPECT_TRUE(SetupEngine()); | 2148 EXPECT_TRUE(SetupEngineWithSendStream()); |
2131 int channel_num = voe_.GetLastChannel(); | 2149 int send_channel = voe_.GetLastChannel(); |
| 2150 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2151 int recv_channel = voe_.GetLastChannel(); |
2132 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2152 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2133 | 2153 |
2134 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, | 2154 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, |
2135 cricket::kFakeDefaultDeviceId); | 2155 cricket::kFakeDefaultDeviceId); |
2136 cricket::Device dev(cricket::kFakeDeviceName, | 2156 cricket::Device dev(cricket::kFakeDeviceName, |
2137 cricket::kFakeDeviceId); | 2157 cricket::kFakeDeviceId); |
2138 | 2158 |
2139 // Test that failure to open devices selected before starting | 2159 // Test that failure to open devices selected before starting |
2140 // send/play does not prevent opening newly selected ones after that. | 2160 // send/play does not prevent opening newly selected ones after that. |
2141 voe_.set_playout_fail_channel(channel_num); | 2161 voe_.set_playout_fail_channel(recv_channel); |
2142 voe_.set_send_fail_channel(channel_num); | 2162 voe_.set_send_fail_channel(send_channel); |
2143 | 2163 |
2144 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); | 2164 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); |
2145 | 2165 |
2146 EXPECT_FALSE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2166 EXPECT_FALSE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2147 EXPECT_FALSE(channel_->SetPlayout(true)); | 2167 EXPECT_FALSE(channel_->SetPlayout(true)); |
2148 EXPECT_FALSE(voe_.GetSend(channel_num)); | 2168 EXPECT_FALSE(voe_.GetSend(send_channel)); |
2149 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | 2169 EXPECT_FALSE(voe_.GetPlayout(recv_channel)); |
2150 | 2170 |
2151 voe_.set_playout_fail_channel(-1); | 2171 voe_.set_playout_fail_channel(-1); |
2152 voe_.set_send_fail_channel(-1); | 2172 voe_.set_send_fail_channel(-1); |
2153 | 2173 |
2154 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); | 2174 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); |
2155 | 2175 |
2156 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2176 EXPECT_TRUE(voe_.GetSend(send_channel)); |
2157 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2177 EXPECT_TRUE(voe_.GetPlayout(recv_channel)); |
2158 } | |
2159 | |
2160 // Test that we can create a channel configured for multi-point conferences, | |
2161 // and start sending/playing out on it. | |
2162 TEST_F(WebRtcVoiceEngineTestFake, ConferenceSendAndPlayout) { | |
2163 EXPECT_TRUE(SetupEngine()); | |
2164 int channel_num = voe_.GetLastChannel(); | |
2165 send_parameters_.options = options_conference_; | |
2166 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
2167 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | |
2168 EXPECT_TRUE(voe_.GetSend(channel_num)); | |
2169 } | 2178 } |
2170 | 2179 |
2171 // Test that we can create a channel configured for Codian bridges, | 2180 // Test that we can create a channel configured for Codian bridges, |
2172 // and start sending/playing out on it. | 2181 // and start sending on it. |
2173 TEST_F(WebRtcVoiceEngineTestFake, CodianSendAndPlayout) { | 2182 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { |
2174 EXPECT_TRUE(SetupEngine()); | 2183 EXPECT_TRUE(SetupEngineWithSendStream()); |
2175 int channel_num = voe_.GetLastChannel(); | 2184 int channel_num = voe_.GetLastChannel(); |
2176 webrtc::AgcConfig agc_config; | 2185 webrtc::AgcConfig agc_config; |
2177 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2186 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2178 EXPECT_EQ(0, agc_config.targetLeveldBOv); | 2187 EXPECT_EQ(0, agc_config.targetLeveldBOv); |
2179 send_parameters_.options = options_adjust_agc_; | 2188 send_parameters_.options = options_adjust_agc_; |
2180 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2189 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2181 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2190 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2182 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2191 EXPECT_TRUE(voe_.GetSend(channel_num)); |
2183 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2192 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2184 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated | 2193 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated |
2185 EXPECT_TRUE(channel_->SetPlayout(true)); | |
2186 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | |
2187 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); | 2194 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); |
2188 EXPECT_FALSE(voe_.GetSend(channel_num)); | 2195 EXPECT_FALSE(voe_.GetSend(channel_num)); |
2189 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2196 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2190 EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored | 2197 EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored |
2191 EXPECT_TRUE(channel_->SetPlayout(false)); | |
2192 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | |
2193 } | 2198 } |
2194 | 2199 |
2195 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { | 2200 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { |
2196 EXPECT_TRUE(SetupEngine()); | 2201 EXPECT_TRUE(SetupEngineWithSendStream()); |
2197 webrtc::AgcConfig agc_config; | 2202 webrtc::AgcConfig agc_config; |
2198 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2203 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2199 EXPECT_EQ(0, agc_config.targetLeveldBOv); | 2204 EXPECT_EQ(0, agc_config.targetLeveldBOv); |
2200 | 2205 |
2201 cricket::AudioOptions options; | 2206 cricket::AudioOptions options; |
2202 options.tx_agc_target_dbov.Set(3); | 2207 options.tx_agc_target_dbov.Set(3); |
2203 options.tx_agc_digital_compression_gain.Set(9); | 2208 options.tx_agc_digital_compression_gain.Set(9); |
2204 options.tx_agc_limiter.Set(true); | 2209 options.tx_agc_limiter.Set(true); |
2205 options.auto_gain_control.Set(true); | 2210 options.auto_gain_control.Set(true); |
2206 EXPECT_TRUE(engine_.SetOptions(options)); | 2211 EXPECT_TRUE(engine_.SetOptions(options)); |
2207 | 2212 |
2208 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2213 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2209 EXPECT_EQ(3, agc_config.targetLeveldBOv); | 2214 EXPECT_EQ(3, agc_config.targetLeveldBOv); |
2210 EXPECT_EQ(9, agc_config.digitalCompressionGaindB); | 2215 EXPECT_EQ(9, agc_config.digitalCompressionGaindB); |
2211 EXPECT_TRUE(agc_config.limiterEnable); | 2216 EXPECT_TRUE(agc_config.limiterEnable); |
2212 | 2217 |
2213 // Check interaction with adjust_agc_delta. Both should be respected, for | 2218 // Check interaction with adjust_agc_delta. Both should be respected, for |
2214 // backwards compatibility. | 2219 // backwards compatibility. |
2215 options.adjust_agc_delta.Set(-10); | 2220 options.adjust_agc_delta.Set(-10); |
2216 EXPECT_TRUE(engine_.SetOptions(options)); | 2221 EXPECT_TRUE(engine_.SetOptions(options)); |
2217 | 2222 |
2218 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2223 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2219 EXPECT_EQ(13, agc_config.targetLeveldBOv); | 2224 EXPECT_EQ(13, agc_config.targetLeveldBOv); |
2220 } | 2225 } |
2221 | 2226 |
2222 TEST_F(WebRtcVoiceEngineTestFake, RxAgcConfigViaOptions) { | 2227 TEST_F(WebRtcVoiceEngineTestFake, RxAgcConfigViaOptions) { |
2223 EXPECT_TRUE(SetupEngine()); | 2228 EXPECT_TRUE(SetupEngineWithSendStream()); |
2224 int channel_num = voe_.GetLastChannel(); | |
2225 send_parameters_.options.rx_agc_target_dbov.Set(6); | 2229 send_parameters_.options.rx_agc_target_dbov.Set(6); |
2226 send_parameters_.options.rx_agc_digital_compression_gain.Set(0); | 2230 send_parameters_.options.rx_agc_digital_compression_gain.Set(0); |
2227 send_parameters_.options.rx_agc_limiter.Set(true); | 2231 send_parameters_.options.rx_agc_limiter.Set(true); |
2228 send_parameters_.options.rx_auto_gain_control.Set(true); | 2232 send_parameters_.options.rx_auto_gain_control.Set(true); |
2229 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2233 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2234 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2235 int channel_num = voe_.GetLastChannel(); |
2230 | 2236 |
2231 webrtc::AgcConfig agc_config; | 2237 webrtc::AgcConfig agc_config; |
2232 EXPECT_EQ(0, engine_.voe()->processing()->GetRxAgcConfig( | 2238 EXPECT_EQ(0, engine_.voe()->processing()->GetRxAgcConfig( |
2233 channel_num, agc_config)); | 2239 channel_num, agc_config)); |
2234 EXPECT_EQ(6, agc_config.targetLeveldBOv); | 2240 EXPECT_EQ(6, agc_config.targetLeveldBOv); |
2235 EXPECT_EQ(0, agc_config.digitalCompressionGaindB); | 2241 EXPECT_EQ(0, agc_config.digitalCompressionGaindB); |
2236 EXPECT_TRUE(agc_config.limiterEnable); | 2242 EXPECT_TRUE(agc_config.limiterEnable); |
2237 } | 2243 } |
2238 | 2244 |
2239 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { | 2245 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { |
2240 EXPECT_TRUE(SetupEngine()); | 2246 EXPECT_TRUE(SetupEngineWithSendStream()); |
2241 cricket::AudioOptions options; | 2247 cricket::AudioOptions options; |
2242 options.recording_sample_rate.Set(48000u); | 2248 options.recording_sample_rate.Set(48000u); |
2243 options.playout_sample_rate.Set(44100u); | 2249 options.playout_sample_rate.Set(44100u); |
2244 EXPECT_TRUE(engine_.SetOptions(options)); | 2250 EXPECT_TRUE(engine_.SetOptions(options)); |
2245 | 2251 |
2246 unsigned int recording_sample_rate, playout_sample_rate; | 2252 unsigned int recording_sample_rate, playout_sample_rate; |
2247 EXPECT_EQ(0, voe_.RecordingSampleRate(&recording_sample_rate)); | 2253 EXPECT_EQ(0, voe_.RecordingSampleRate(&recording_sample_rate)); |
2248 EXPECT_EQ(0, voe_.PlayoutSampleRate(&playout_sample_rate)); | 2254 EXPECT_EQ(0, voe_.PlayoutSampleRate(&playout_sample_rate)); |
2249 EXPECT_EQ(48000u, recording_sample_rate); | 2255 EXPECT_EQ(48000u, recording_sample_rate); |
2250 EXPECT_EQ(44100u, playout_sample_rate); | 2256 EXPECT_EQ(44100u, playout_sample_rate); |
2251 } | 2257 } |
2252 | 2258 |
2253 TEST_F(WebRtcVoiceEngineTestFake, TraceFilterViaTraceOptions) { | 2259 TEST_F(WebRtcVoiceEngineTestFake, TraceFilterViaTraceOptions) { |
2254 EXPECT_TRUE(SetupEngine()); | 2260 EXPECT_TRUE(SetupEngineWithSendStream()); |
2255 engine_.SetLogging(rtc::LS_INFO, ""); | 2261 engine_.SetLogging(rtc::LS_INFO, ""); |
2256 EXPECT_EQ( | 2262 EXPECT_EQ( |
2257 // Info: | 2263 // Info: |
2258 webrtc::kTraceStateInfo | webrtc::kTraceInfo | | 2264 webrtc::kTraceStateInfo | webrtc::kTraceInfo | |
2259 // Warning: | 2265 // Warning: |
2260 webrtc::kTraceTerseInfo | webrtc::kTraceWarning | | 2266 webrtc::kTraceTerseInfo | webrtc::kTraceWarning | |
2261 // Error: | 2267 // Error: |
2262 webrtc::kTraceError | webrtc::kTraceCritical, | 2268 webrtc::kTraceError | webrtc::kTraceCritical, |
2263 static_cast<int>(trace_wrapper_->filter_)); | 2269 static_cast<int>(trace_wrapper_->filter_)); |
2264 // Now set it explicitly | 2270 // Now set it explicitly |
2265 std::string filter = | 2271 std::string filter = |
2266 "tracefilter " + rtc::ToString(webrtc::kTraceDefault); | 2272 "tracefilter " + rtc::ToString(webrtc::kTraceDefault); |
2267 engine_.SetLogging(rtc::LS_VERBOSE, filter.c_str()); | 2273 engine_.SetLogging(rtc::LS_VERBOSE, filter.c_str()); |
2268 EXPECT_EQ(static_cast<unsigned int>(webrtc::kTraceDefault), | 2274 EXPECT_EQ(static_cast<unsigned int>(webrtc::kTraceDefault), |
2269 trace_wrapper_->filter_); | 2275 trace_wrapper_->filter_); |
2270 } | 2276 } |
2271 | 2277 |
2272 // Test that we can set the outgoing SSRC properly. | 2278 // Test that we can set the outgoing SSRC properly. |
2273 // SSRC is set in SetupEngine by calling AddSendStream. | 2279 // SSRC is set in SetupEngine by calling AddSendStream. |
2274 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { | 2280 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { |
2275 EXPECT_TRUE(SetupEngine()); | 2281 EXPECT_TRUE(SetupEngineWithSendStream()); |
2276 int channel_num = voe_.GetLastChannel(); | 2282 int channel_num = voe_.GetLastChannel(); |
2277 unsigned int send_ssrc; | 2283 unsigned int send_ssrc; |
2278 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); | 2284 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); |
2279 EXPECT_NE(0U, send_ssrc); | 2285 EXPECT_NE(0U, send_ssrc); |
2280 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); | 2286 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); |
2281 EXPECT_EQ(kSsrc1, send_ssrc); | 2287 EXPECT_EQ(kSsrc1, send_ssrc); |
2282 } | 2288 } |
2283 | 2289 |
2284 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { | 2290 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { |
2285 // Setup. We need send codec to be set to get all stats. | 2291 // Setup. We need send codec to be set to get all stats. |
2286 EXPECT_TRUE(SetupEngine()); | 2292 EXPECT_TRUE(SetupEngineWithSendStream()); |
2287 // SetupEngine adds a send stream with kSsrc1, so the receive stream has to | 2293 // SetupEngineWithSendStream adds a send stream with kSsrc1, so the receive |
2288 // use a different SSRC. | 2294 // stream has to use a different SSRC. |
2289 EXPECT_TRUE(channel_->AddRecvStream( | 2295 EXPECT_TRUE(channel_->AddRecvStream( |
2290 cricket::StreamParams::CreateLegacy(kSsrc2))); | 2296 cricket::StreamParams::CreateLegacy(kSsrc2))); |
2291 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2297 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2292 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | 2298 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
2293 | 2299 |
2294 cricket::VoiceMediaInfo info; | 2300 cricket::VoiceMediaInfo info; |
2295 EXPECT_EQ(true, channel_->GetStats(&info)); | 2301 EXPECT_EQ(true, channel_->GetStats(&info)); |
2296 EXPECT_EQ(1u, info.senders.size()); | 2302 EXPECT_EQ(1u, info.senders.size()); |
2297 EXPECT_EQ(kSsrc1, info.senders[0].ssrc()); | 2303 EXPECT_EQ(kSsrc1, info.senders[0].ssrc()); |
2298 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); | 2304 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); |
2299 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].bytes_sent); | 2305 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].bytes_sent); |
2300 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_sent); | 2306 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_sent); |
2301 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_lost); | 2307 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_lost); |
2302 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[0].fraction_lost); | 2308 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[0].fraction_lost); |
2303 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].ext_seqnum); | 2309 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].ext_seqnum); |
2304 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].rtt_ms); | 2310 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].rtt_ms); |
2305 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].jitter_ms); | 2311 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].jitter_ms); |
2306 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); | 2312 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); |
2307 // TODO(sriniv): Add testing for more fields. These are not populated | 2313 // TODO(sriniv): Add testing for more fields. These are not populated |
2308 // in FakeWebrtcVoiceEngine yet. | 2314 // in FakeWebrtcVoiceEngine yet. |
2309 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].audio_level); | 2315 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].audio_level); |
2310 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_median_ms); | 2316 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_median_ms); |
2311 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_std_ms); | 2317 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_std_ms); |
2312 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_return_loss); | 2318 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_return_loss); |
2313 // EXPECT_EQ(cricket::kIntStatValue, | 2319 // EXPECT_EQ(cricket::kIntStatValue, |
2314 // info.senders[0].echo_return_loss_enhancement); | 2320 // info.senders[0].echo_return_loss_enhancement); |
| 2321 EXPECT_EQ(0u, info.receivers.size()); |
2315 | 2322 |
| 2323 // Registered stream's remote SSRC is kSsrc2. Send a packet with SSRC=1. |
| 2324 // We should drop the packet and no stats should be available. |
| 2325 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2326 EXPECT_EQ(true, channel_->GetStats(&info)); |
2316 EXPECT_EQ(0u, info.receivers.size()); | 2327 EXPECT_EQ(0u, info.receivers.size()); |
| 2328 |
| 2329 // Remove the kSsrc2 stream and deliver a new packet - a default receive |
| 2330 // stream should be created and we should see stats. |
| 2331 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); |
2317 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2332 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
2318 EXPECT_EQ(true, channel_->GetStats(&info)); | 2333 EXPECT_EQ(true, channel_->GetStats(&info)); |
2319 EXPECT_EQ(1u, info.receivers.size()); | 2334 EXPECT_EQ(1u, info.receivers.size()); |
2320 | 2335 |
2321 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); | 2336 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); |
2322 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); | 2337 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); |
2323 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); | 2338 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); |
2324 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); | 2339 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); |
2325 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); | 2340 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); |
2326 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / | 2341 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / |
2327 (1 << 14), info.receivers[0].expand_rate); | 2342 (1 << 14), info.receivers[0].expand_rate); |
2328 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / | 2343 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / |
2329 (1 << 14), info.receivers[0].speech_expand_rate); | 2344 (1 << 14), info.receivers[0].speech_expand_rate); |
2330 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / | 2345 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / |
2331 (1 << 14), info.receivers[0].secondary_decoded_rate); | 2346 (1 << 14), info.receivers[0].secondary_decoded_rate); |
2332 // TODO(sriniv): Add testing for more receiver fields. | 2347 // TODO(sriniv): Add testing for more receiver fields. |
2333 } | 2348 } |
2334 | 2349 |
2335 // Test that we can set the outgoing SSRC properly with multiple streams. | 2350 // Test that we can set the outgoing SSRC properly with multiple streams. |
2336 // SSRC is set in SetupEngine by calling AddSendStream. | 2351 // SSRC is set in SetupEngine by calling AddSendStream. |
2337 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { | 2352 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { |
2338 EXPECT_TRUE(SetupEngine()); | 2353 EXPECT_TRUE(SetupEngineWithSendStream()); |
2339 int channel_num1 = voe_.GetLastChannel(); | 2354 int channel_num1 = voe_.GetLastChannel(); |
2340 unsigned int send_ssrc; | 2355 unsigned int send_ssrc; |
2341 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); | 2356 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); |
2342 EXPECT_EQ(kSsrc1, send_ssrc); | 2357 EXPECT_EQ(kSsrc1, send_ssrc); |
2343 | 2358 |
2344 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2359 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2345 int channel_num2 = voe_.GetLastChannel(); | 2360 int channel_num2 = voe_.GetLastChannel(); |
2346 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc)); | 2361 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc)); |
2347 EXPECT_EQ(kSsrc1, send_ssrc); | 2362 EXPECT_EQ(kSsrc1, send_ssrc); |
2348 } | 2363 } |
(...skipping 14 matching lines...) Expand all Loading... |
2363 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc)); | 2378 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc)); |
2364 EXPECT_EQ(1234U, ssrc); | 2379 EXPECT_EQ(1234U, ssrc); |
2365 ssrc = 0; | 2380 ssrc = 0; |
2366 EXPECT_EQ(0, voe_.GetLocalSSRC(receive_channel_num, ssrc)); | 2381 EXPECT_EQ(0, voe_.GetLocalSSRC(receive_channel_num, ssrc)); |
2367 EXPECT_EQ(1234U, ssrc); | 2382 EXPECT_EQ(1234U, ssrc); |
2368 } | 2383 } |
2369 | 2384 |
2370 // Test that we can properly receive packets. | 2385 // Test that we can properly receive packets. |
2371 TEST_F(WebRtcVoiceEngineTestFake, Recv) { | 2386 TEST_F(WebRtcVoiceEngineTestFake, Recv) { |
2372 EXPECT_TRUE(SetupEngine()); | 2387 EXPECT_TRUE(SetupEngine()); |
| 2388 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
2373 int channel_num = voe_.GetLastChannel(); | 2389 int channel_num = voe_.GetLastChannel(); |
2374 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | |
2375 EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame, | 2390 EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame, |
2376 sizeof(kPcmuFrame))); | 2391 sizeof(kPcmuFrame))); |
2377 } | 2392 } |
2378 | 2393 |
2379 // Test that we can properly receive packets on multiple streams. | 2394 // Test that we can properly receive packets on multiple streams. |
2380 TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { | 2395 TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { |
2381 EXPECT_TRUE(SetupEngine()); | 2396 EXPECT_TRUE(SetupEngineWithSendStream()); |
2382 send_parameters_.options = options_conference_; | |
2383 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2397 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2384 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2398 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
2385 int channel_num1 = voe_.GetLastChannel(); | 2399 int channel_num1 = voe_.GetLastChannel(); |
2386 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2400 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2387 int channel_num2 = voe_.GetLastChannel(); | 2401 int channel_num2 = voe_.GetLastChannel(); |
2388 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 2402 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
2389 int channel_num3 = voe_.GetLastChannel(); | 2403 int channel_num3 = voe_.GetLastChannel(); |
2390 // Create packets with the right SSRCs. | 2404 // Create packets with the right SSRCs. |
2391 char packets[4][sizeof(kPcmuFrame)]; | 2405 char packets[4][sizeof(kPcmuFrame)]; |
2392 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { | 2406 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { |
(...skipping 22 matching lines...) Expand all Loading... |
2415 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); | 2429 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); |
2416 EXPECT_TRUE(voe_.CheckPacket(channel_num3, packets[3], | 2430 EXPECT_TRUE(voe_.CheckPacket(channel_num3, packets[3], |
2417 sizeof(packets[3]))); | 2431 sizeof(packets[3]))); |
2418 EXPECT_TRUE(channel_->RemoveRecvStream(3)); | 2432 EXPECT_TRUE(channel_->RemoveRecvStream(3)); |
2419 EXPECT_TRUE(channel_->RemoveRecvStream(2)); | 2433 EXPECT_TRUE(channel_->RemoveRecvStream(2)); |
2420 EXPECT_TRUE(channel_->RemoveRecvStream(1)); | 2434 EXPECT_TRUE(channel_->RemoveRecvStream(1)); |
2421 } | 2435 } |
2422 | 2436 |
2423 // Test that we properly handle failures to add a stream. | 2437 // Test that we properly handle failures to add a stream. |
2424 TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) { | 2438 TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) { |
2425 EXPECT_TRUE(SetupEngine()); | 2439 EXPECT_TRUE(SetupEngineWithSendStream()); |
2426 voe_.set_fail_create_channel(true); | 2440 voe_.set_fail_create_channel(true); |
2427 send_parameters_.options = options_conference_; | |
2428 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2441 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2429 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2442 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2430 | |
2431 // In 1:1 call, we should not try to create a new channel. | |
2432 send_parameters_.options.conference_mode.Set(false); | |
2433 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
2434 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | |
2435 } | 2443 } |
2436 | 2444 |
2437 // Test that AddRecvStream doesn't create new channel for 1:1 call. | 2445 // Test that AddRecvStream creates new stream. |
2438 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream1On1) { | 2446 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream) { |
2439 EXPECT_TRUE(SetupEngine()); | 2447 EXPECT_TRUE(SetupEngineWithRecvStream()); |
2440 int channel_num = voe_.GetLastChannel(); | 2448 int channel_num = voe_.GetLastChannel(); |
2441 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2449 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
2442 EXPECT_EQ(channel_num, voe_.GetLastChannel()); | 2450 EXPECT_NE(channel_num, voe_.GetLastChannel()); |
2443 } | 2451 } |
2444 | 2452 |
2445 // Test that after adding a recv stream, we do not decode more codecs than | 2453 // Test that after adding a recv stream, we do not decode more codecs than |
2446 // those previously passed into SetRecvCodecs. | 2454 // those previously passed into SetRecvCodecs. |
2447 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { | 2455 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { |
2448 EXPECT_TRUE(SetupEngine()); | 2456 EXPECT_TRUE(SetupEngineWithSendStream()); |
2449 cricket::AudioRecvParameters parameters; | 2457 cricket::AudioRecvParameters parameters; |
2450 parameters.codecs.push_back(kIsacCodec); | 2458 parameters.codecs.push_back(kIsacCodec); |
2451 parameters.codecs.push_back(kPcmuCodec); | 2459 parameters.codecs.push_back(kPcmuCodec); |
2452 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2460 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2453 EXPECT_TRUE(channel_->AddRecvStream( | 2461 EXPECT_TRUE(channel_->AddRecvStream( |
2454 cricket::StreamParams::CreateLegacy(kSsrc1))); | 2462 cricket::StreamParams::CreateLegacy(kSsrc1))); |
2455 int channel_num2 = voe_.GetLastChannel(); | 2463 int channel_num2 = voe_.GetLastChannel(); |
2456 webrtc::CodecInst gcodec; | 2464 webrtc::CodecInst gcodec; |
2457 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus"); | 2465 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus"); |
2458 gcodec.plfreq = 48000; | 2466 gcodec.plfreq = 48000; |
2459 gcodec.channels = 2; | 2467 gcodec.channels = 2; |
2460 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); | 2468 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); |
2461 } | 2469 } |
2462 | 2470 |
2463 // Test that we properly clean up any streams that were added, even if | 2471 // Test that we properly clean up any streams that were added, even if |
2464 // not explicitly removed. | 2472 // not explicitly removed. |
2465 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { | 2473 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { |
2466 EXPECT_TRUE(SetupEngine()); | 2474 EXPECT_TRUE(SetupEngineWithSendStream()); |
2467 send_parameters_.options = options_conference_; | |
2468 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2475 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2469 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2476 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
2470 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2477 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2471 EXPECT_EQ(3, voe_.GetNumChannels()); // default channel + 2 added | 2478 EXPECT_EQ(3, voe_.GetNumChannels()); // default channel + 2 added |
2472 delete channel_; | 2479 delete channel_; |
2473 channel_ = NULL; | 2480 channel_ = NULL; |
2474 EXPECT_EQ(0, voe_.GetNumChannels()); | 2481 EXPECT_EQ(0, voe_.GetNumChannels()); |
2475 } | 2482 } |
2476 | 2483 |
2477 TEST_F(WebRtcVoiceEngineTestFake, TestAddRecvStreamFailWithZeroSsrc) { | 2484 TEST_F(WebRtcVoiceEngineTestFake, TestAddRecvStreamFailWithZeroSsrc) { |
2478 EXPECT_TRUE(SetupEngine()); | 2485 EXPECT_TRUE(SetupEngineWithSendStream()); |
2479 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0))); | 2486 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0))); |
2480 } | 2487 } |
2481 | 2488 |
2482 TEST_F(WebRtcVoiceEngineTestFake, TestNoLeakingWhenAddRecvStreamFail) { | 2489 TEST_F(WebRtcVoiceEngineTestFake, TestNoLeakingWhenAddRecvStreamFail) { |
2483 EXPECT_TRUE(SetupEngine()); | 2490 EXPECT_TRUE(SetupEngine()); |
2484 // Stream 1 reuses default channel. | |
2485 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2491 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
2486 // Manually delete default channel to simulate a failure. | 2492 // Manually delete channel to simulate a failure. |
2487 int default_channel = voe_.GetLastChannel(); | 2493 int channel = voe_.GetLastChannel(); |
2488 EXPECT_EQ(0, voe_.DeleteChannel(default_channel)); | 2494 EXPECT_EQ(0, voe_.DeleteChannel(channel)); |
2489 // Add recv stream 2 should fail because default channel is gone. | 2495 // Add recv stream 2 should work. |
2490 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2496 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2491 int new_channel = voe_.GetLastChannel(); | 2497 int new_channel = voe_.GetLastChannel(); |
2492 EXPECT_NE(default_channel, new_channel); | 2498 EXPECT_NE(channel, new_channel); |
2493 // The last created channel should have already been deleted. | 2499 // The last created channel is deleted too. |
2494 EXPECT_EQ(-1, voe_.DeleteChannel(new_channel)); | 2500 EXPECT_EQ(0, voe_.DeleteChannel(new_channel)); |
2495 } | 2501 } |
2496 | 2502 |
2497 // Test the InsertDtmf on default send stream as caller. | 2503 // Test the InsertDtmf on default send stream as caller. |
2498 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { | 2504 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { |
2499 TestInsertDtmf(0, true); | 2505 TestInsertDtmf(0, true); |
2500 } | 2506 } |
2501 | 2507 |
2502 // Test the InsertDtmf on default send stream as callee | 2508 // Test the InsertDtmf on default send stream as callee |
2503 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { | 2509 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { |
2504 TestInsertDtmf(0, false); | 2510 TestInsertDtmf(0, false); |
2505 } | 2511 } |
2506 | 2512 |
2507 // Test the InsertDtmf on specified send stream as caller. | 2513 // Test the InsertDtmf on specified send stream as caller. |
2508 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { | 2514 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { |
2509 TestInsertDtmf(kSsrc1, true); | 2515 TestInsertDtmf(kSsrc1, true); |
2510 } | 2516 } |
2511 | 2517 |
2512 // Test the InsertDtmf on specified send stream as callee. | 2518 // Test the InsertDtmf on specified send stream as callee. |
2513 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { | 2519 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { |
2514 TestInsertDtmf(kSsrc1, false); | 2520 TestInsertDtmf(kSsrc1, false); |
2515 } | 2521 } |
2516 | 2522 |
2517 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { | 2523 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { |
2518 EXPECT_TRUE(SetupEngine()); | 2524 EXPECT_TRUE(SetupEngineWithSendStream()); |
2519 send_parameters_.options = options_conference_; | |
2520 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2525 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2521 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2526 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2522 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2527 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2523 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 2528 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
2524 EXPECT_TRUE(channel_->SetPlayout(true)); | 2529 EXPECT_TRUE(channel_->SetPlayout(true)); |
2525 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); | 2530 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); |
2526 EXPECT_TRUE(channel_->SetPlayout(false)); | 2531 EXPECT_TRUE(channel_->SetPlayout(false)); |
2527 EXPECT_FALSE(channel_->SetPlayout(true)); | 2532 EXPECT_FALSE(channel_->SetPlayout(true)); |
2528 } | 2533 } |
2529 | 2534 |
2530 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { | 2535 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
2531 EXPECT_TRUE(SetupEngine()); | 2536 EXPECT_TRUE(SetupEngineWithSendStream()); |
2532 | 2537 |
2533 bool ec_enabled; | 2538 bool ec_enabled; |
2534 webrtc::EcModes ec_mode; | 2539 webrtc::EcModes ec_mode; |
2535 bool ec_metrics_enabled; | 2540 bool ec_metrics_enabled; |
2536 webrtc::AecmModes aecm_mode; | 2541 webrtc::AecmModes aecm_mode; |
2537 bool cng_enabled; | 2542 bool cng_enabled; |
2538 bool agc_enabled; | 2543 bool agc_enabled; |
2539 webrtc::AgcModes agc_mode; | 2544 webrtc::AgcModes agc_mode; |
2540 webrtc::AgcConfig agc_config; | 2545 webrtc::AgcConfig agc_config; |
2541 bool ns_enabled; | 2546 bool ns_enabled; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2671 ASSERT_TRUE(engine_.SetOptions(options)); | 2676 ASSERT_TRUE(engine_.SetOptions(options)); |
2672 voe_.GetNsStatus(ns_enabled, ns_mode); | 2677 voe_.GetNsStatus(ns_enabled, ns_mode); |
2673 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); | 2678 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); |
2674 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | 2679 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); |
2675 voe_.GetTypingDetectionStatus(typing_detection_enabled); | 2680 voe_.GetTypingDetectionStatus(typing_detection_enabled); |
2676 EXPECT_FALSE(ns_enabled); | 2681 EXPECT_FALSE(ns_enabled); |
2677 EXPECT_FALSE(highpass_filter_enabled); | 2682 EXPECT_FALSE(highpass_filter_enabled); |
2678 EXPECT_FALSE(typing_detection_enabled); | 2683 EXPECT_FALSE(typing_detection_enabled); |
2679 EXPECT_TRUE(stereo_swapping_enabled); | 2684 EXPECT_TRUE(stereo_swapping_enabled); |
2680 | 2685 |
2681 // Turn on "conference mode" to ensure it has no impact. | 2686 // Set options again to ensure it has no impact. |
2682 options.conference_mode.Set(true); | |
2683 ASSERT_TRUE(engine_.SetOptions(options)); | 2687 ASSERT_TRUE(engine_.SetOptions(options)); |
2684 voe_.GetEcStatus(ec_enabled, ec_mode); | 2688 voe_.GetEcStatus(ec_enabled, ec_mode); |
2685 voe_.GetNsStatus(ns_enabled, ns_mode); | 2689 voe_.GetNsStatus(ns_enabled, ns_mode); |
2686 EXPECT_TRUE(ec_enabled); | 2690 EXPECT_TRUE(ec_enabled); |
2687 EXPECT_EQ(webrtc::kEcConference, ec_mode); | 2691 EXPECT_EQ(webrtc::kEcConference, ec_mode); |
2688 EXPECT_FALSE(ns_enabled); | 2692 EXPECT_FALSE(ns_enabled); |
2689 EXPECT_EQ(webrtc::kNsHighSuppression, ns_mode); | 2693 EXPECT_EQ(webrtc::kNsHighSuppression, ns_mode); |
2690 } | 2694 } |
2691 | 2695 |
2692 TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) { | 2696 TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) { |
2693 EXPECT_TRUE(SetupEngine()); | 2697 EXPECT_TRUE(SetupEngineWithSendStream()); |
2694 | 2698 |
2695 bool ec_enabled; | 2699 bool ec_enabled; |
2696 webrtc::EcModes ec_mode; | 2700 webrtc::EcModes ec_mode; |
2697 bool ec_metrics_enabled; | 2701 bool ec_metrics_enabled; |
2698 bool agc_enabled; | 2702 bool agc_enabled; |
2699 webrtc::AgcModes agc_mode; | 2703 webrtc::AgcModes agc_mode; |
2700 bool ns_enabled; | 2704 bool ns_enabled; |
2701 webrtc::NsModes ns_mode; | 2705 webrtc::NsModes ns_mode; |
2702 bool highpass_filter_enabled; | 2706 bool highpass_filter_enabled; |
2703 bool stereo_swapping_enabled; | 2707 bool stereo_swapping_enabled; |
(...skipping 24 matching lines...) Expand all Loading... |
2728 | 2732 |
2729 webrtc::AgcConfig config = {0}; | 2733 webrtc::AgcConfig config = {0}; |
2730 EXPECT_EQ(0, voe_.GetAgcConfig(config)); | 2734 EXPECT_EQ(0, voe_.GetAgcConfig(config)); |
2731 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv); | 2735 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv); |
2732 EXPECT_EQ(set_config.digitalCompressionGaindB, | 2736 EXPECT_EQ(set_config.digitalCompressionGaindB, |
2733 config.digitalCompressionGaindB); | 2737 config.digitalCompressionGaindB); |
2734 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable); | 2738 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable); |
2735 } | 2739 } |
2736 | 2740 |
2737 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { | 2741 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { |
2738 EXPECT_TRUE(SetupEngine()); | 2742 EXPECT_TRUE(SetupEngineWithSendStream()); |
2739 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel1( | 2743 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel1( |
2740 static_cast<cricket::WebRtcVoiceMediaChannel*>( | 2744 static_cast<cricket::WebRtcVoiceMediaChannel*>( |
2741 engine_.CreateChannel(&call_, cricket::AudioOptions()))); | 2745 engine_.CreateChannel(&call_, cricket::AudioOptions()))); |
2742 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel2( | 2746 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel2( |
2743 static_cast<cricket::WebRtcVoiceMediaChannel*>( | 2747 static_cast<cricket::WebRtcVoiceMediaChannel*>( |
2744 engine_.CreateChannel(&call_, cricket::AudioOptions()))); | 2748 engine_.CreateChannel(&call_, cricket::AudioOptions()))); |
2745 | 2749 |
2746 // Have to add a stream to make SetSend work. | 2750 // Have to add a stream to make SetSend work. |
2747 cricket::StreamParams stream1; | 2751 cricket::StreamParams stream1; |
2748 stream1.ssrcs.push_back(1); | 2752 stream1.ssrcs.push_back(1); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2841 voe_.GetEcStatus(ec_enabled, ec_mode); | 2845 voe_.GetEcStatus(ec_enabled, ec_mode); |
2842 voe_.GetAgcStatus(agc_enabled, agc_mode); | 2846 voe_.GetAgcStatus(agc_enabled, agc_mode); |
2843 voe_.GetNsStatus(ns_enabled, ns_mode); | 2847 voe_.GetNsStatus(ns_enabled, ns_mode); |
2844 EXPECT_TRUE(ec_enabled); | 2848 EXPECT_TRUE(ec_enabled); |
2845 EXPECT_FALSE(agc_enabled); | 2849 EXPECT_FALSE(agc_enabled); |
2846 EXPECT_FALSE(ns_enabled); | 2850 EXPECT_FALSE(ns_enabled); |
2847 } | 2851 } |
2848 | 2852 |
2849 // This test verifies DSCP settings are properly applied on voice media channel. | 2853 // This test verifies DSCP settings are properly applied on voice media channel. |
2850 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { | 2854 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { |
2851 EXPECT_TRUE(SetupEngine()); | 2855 EXPECT_TRUE(SetupEngineWithSendStream()); |
2852 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel( | 2856 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel( |
2853 engine_.CreateChannel(&call_, cricket::AudioOptions())); | 2857 engine_.CreateChannel(&call_, cricket::AudioOptions())); |
2854 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( | 2858 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( |
2855 new cricket::FakeNetworkInterface); | 2859 new cricket::FakeNetworkInterface); |
2856 channel->SetInterface(network_interface.get()); | 2860 channel->SetInterface(network_interface.get()); |
2857 cricket::AudioSendParameters parameters = send_parameters_; | 2861 cricket::AudioSendParameters parameters = send_parameters_; |
2858 parameters.options.dscp.Set(true); | 2862 parameters.options.dscp.Set(true); |
2859 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 2863 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
2860 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); | 2864 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); |
2861 // Verify previous value is not modified if dscp option is not set. | 2865 // Verify previous value is not modified if dscp option is not set. |
2862 EXPECT_TRUE(channel->SetSendParameters(send_parameters_)); | 2866 EXPECT_TRUE(channel->SetSendParameters(send_parameters_)); |
2863 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); | 2867 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); |
2864 parameters.options.dscp.Set(false); | 2868 parameters.options.dscp.Set(false); |
2865 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 2869 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
2866 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); | 2870 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); |
2867 } | 2871 } |
2868 | 2872 |
2869 // Test that GetReceiveChannelNum returns the default channel for the first | 2873 // Test that GetReceiveChannelNum returns the default channel for the first |
2870 // recv stream in 1-1 calls. | 2874 // recv stream in 1-1 calls. |
2871 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNumIn1To1Calls) { | 2875 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNum) { |
2872 EXPECT_TRUE(SetupEngine()); | 2876 EXPECT_TRUE(SetupEngine()); |
2873 cricket::WebRtcVoiceMediaChannel* media_channel = | 2877 cricket::WebRtcVoiceMediaChannel* media_channel = |
2874 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 2878 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
2875 // Test that GetChannelNum returns the default channel if the SSRC is unknown. | 2879 EXPECT_EQ(-1, media_channel->GetReceiveChannelNum(0)); |
2876 EXPECT_EQ(media_channel->voe_channel(), | 2880 EXPECT_TRUE(channel_->AddRecvStream( |
2877 media_channel->GetReceiveChannelNum(0)); | 2881 cricket::StreamParams::CreateLegacy(kSsrc1))); |
2878 cricket::StreamParams stream; | 2882 int channel_id = voe_.GetLastChannel(); |
2879 stream.ssrcs.push_back(kSsrc2); | 2883 EXPECT_EQ(channel_id, media_channel->GetReceiveChannelNum(kSsrc1)); |
2880 EXPECT_TRUE(channel_->AddRecvStream(stream)); | 2884 EXPECT_EQ(-1, media_channel->GetReceiveChannelNum(kSsrc2)); |
2881 EXPECT_EQ(media_channel->voe_channel(), | 2885 EXPECT_TRUE(channel_->AddRecvStream( |
2882 media_channel->GetReceiveChannelNum(kSsrc2)); | 2886 cricket::StreamParams::CreateLegacy(kSsrc2))); |
2883 } | 2887 int channel_id2 = voe_.GetLastChannel(); |
2884 | 2888 EXPECT_EQ(channel_id2, media_channel->GetReceiveChannelNum(kSsrc2)); |
2885 // Test that GetReceiveChannelNum doesn't return the default channel for the | |
2886 // first recv stream in conference calls. | |
2887 TEST_F(WebRtcVoiceEngineTestFake, TestGetChannelNumInConferenceCalls) { | |
2888 EXPECT_TRUE(SetupEngine()); | |
2889 send_parameters_.options = options_conference_; | |
2890 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
2891 cricket::StreamParams stream; | |
2892 stream.ssrcs.push_back(kSsrc2); | |
2893 EXPECT_TRUE(channel_->AddRecvStream(stream)); | |
2894 cricket::WebRtcVoiceMediaChannel* media_channel = | |
2895 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
2896 EXPECT_LT(media_channel->voe_channel(), | |
2897 media_channel->GetReceiveChannelNum(kSsrc2)); | |
2898 } | 2889 } |
2899 | 2890 |
2900 TEST_F(WebRtcVoiceEngineTestFake, SetOutputScaling) { | 2891 TEST_F(WebRtcVoiceEngineTestFake, SetOutputScaling) { |
2901 EXPECT_TRUE(SetupEngine()); | 2892 EXPECT_TRUE(SetupEngineWithRecvStream()); |
2902 float scale, left, right; | 2893 float scale, left, right; |
2903 EXPECT_TRUE(channel_->SetOutputScaling(0, 1, 2)); | 2894 EXPECT_TRUE(channel_->SetOutputScaling(0, 1, 2)); |
2904 int channel_id = voe_.GetLastChannel(); | 2895 int channel_id = voe_.GetLastChannel(); |
2905 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); | 2896 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); |
2906 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); | 2897 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); |
2907 EXPECT_DOUBLE_EQ(1, left * scale); | 2898 EXPECT_DOUBLE_EQ(1, left * scale); |
2908 EXPECT_DOUBLE_EQ(2, right * scale); | 2899 EXPECT_DOUBLE_EQ(2, right * scale); |
2909 | 2900 |
2910 EXPECT_FALSE(channel_->SetOutputScaling(kSsrc2, 1, 2)); | 2901 EXPECT_FALSE(channel_->SetOutputScaling(kSsrc2, 1, 2)); |
2911 cricket::StreamParams stream; | 2902 cricket::StreamParams stream; |
2912 stream.ssrcs.push_back(kSsrc2); | 2903 stream.ssrcs.push_back(kSsrc2); |
2913 EXPECT_TRUE(channel_->AddRecvStream(stream)); | 2904 EXPECT_TRUE(channel_->AddRecvStream(stream)); |
2914 | 2905 |
2915 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1)); | 2906 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1)); |
2916 channel_id = voe_.GetLastChannel(); | 2907 channel_id = voe_.GetLastChannel(); |
2917 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); | 2908 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); |
2918 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); | 2909 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); |
2919 EXPECT_DOUBLE_EQ(2, left * scale); | 2910 EXPECT_DOUBLE_EQ(2, left * scale); |
2920 EXPECT_DOUBLE_EQ(1, right * scale); | 2911 EXPECT_DOUBLE_EQ(1, right * scale); |
2921 } | 2912 } |
2922 | 2913 |
2923 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { | 2914 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { |
2924 const uint32 kAudioSsrc = 123; | 2915 const uint32 kAudioSsrc = 123; |
2925 const std::string kSyncLabel = "AvSyncLabel"; | 2916 const std::string kSyncLabel = "AvSyncLabel"; |
2926 | 2917 |
2927 EXPECT_TRUE(SetupEngine()); | 2918 EXPECT_TRUE(SetupEngineWithSendStream()); |
2928 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); | 2919 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); |
2929 sp.sync_label = kSyncLabel; | 2920 sp.sync_label = kSyncLabel; |
2930 // Creating two channels to make sure that sync label is set properly for both | 2921 // Creating two channels to make sure that sync label is set properly for both |
2931 // the default voice channel and following ones. | 2922 // the default voice channel and following ones. |
2932 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 2923 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
2933 sp.ssrcs[0] += 1; | 2924 sp.ssrcs[0] += 1; |
2934 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 2925 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
2935 | 2926 |
2936 ASSERT_EQ(2, call_.GetAudioReceiveStreams().size()); | 2927 ASSERT_EQ(2, call_.GetAudioReceiveStreams().size()); |
2937 EXPECT_EQ(kSyncLabel, | 2928 EXPECT_EQ(kSyncLabel, |
2938 call_.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) | 2929 call_.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) |
2939 << "SyncGroup should be set based on sync_label"; | 2930 << "SyncGroup should be set based on sync_label"; |
2940 EXPECT_EQ(kSyncLabel, | 2931 EXPECT_EQ(kSyncLabel, |
2941 call_.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) | 2932 call_.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) |
2942 << "SyncGroup should be set based on sync_label"; | 2933 << "SyncGroup should be set based on sync_label"; |
2943 } | 2934 } |
2944 | 2935 |
2945 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { | 2936 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { |
2946 // Test that changing the combined_audio_video_bwe option results in the | 2937 // Test that changing the combined_audio_video_bwe option results in the |
2947 // expected state changes on an associated Call. | 2938 // expected state changes on an associated Call. |
2948 std::vector<uint32> ssrcs; | 2939 std::vector<uint32> ssrcs; |
2949 ssrcs.push_back(223); | 2940 ssrcs.push_back(223); |
2950 ssrcs.push_back(224); | 2941 ssrcs.push_back(224); |
2951 | 2942 |
2952 EXPECT_TRUE(SetupEngine()); | 2943 EXPECT_TRUE(SetupEngineWithSendStream()); |
2953 cricket::WebRtcVoiceMediaChannel* media_channel = | 2944 cricket::WebRtcVoiceMediaChannel* media_channel = |
2954 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 2945 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
2955 for (uint32 ssrc : ssrcs) { | 2946 for (uint32 ssrc : ssrcs) { |
2956 EXPECT_TRUE(media_channel->AddRecvStream( | 2947 EXPECT_TRUE(media_channel->AddRecvStream( |
2957 cricket::StreamParams::CreateLegacy(ssrc))); | 2948 cricket::StreamParams::CreateLegacy(ssrc))); |
2958 } | 2949 } |
2959 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); | 2950 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); |
2960 | 2951 |
2961 // Combined BWE should be disabled. | 2952 // Combined BWE should be disabled. |
2962 for (uint32 ssrc : ssrcs) { | 2953 for (uint32 ssrc : ssrcs) { |
(...skipping 19 matching lines...) Expand all Loading... |
2982 EXPECT_NE(nullptr, s); | 2973 EXPECT_NE(nullptr, s); |
2983 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); | 2974 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); |
2984 } | 2975 } |
2985 | 2976 |
2986 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); | 2977 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); |
2987 } | 2978 } |
2988 | 2979 |
2989 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { | 2980 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { |
2990 // Test that adding receive streams after enabling combined bandwidth | 2981 // Test that adding receive streams after enabling combined bandwidth |
2991 // estimation will correctly configure each channel. | 2982 // estimation will correctly configure each channel. |
2992 EXPECT_TRUE(SetupEngine()); | 2983 EXPECT_TRUE(SetupEngineWithSendStream()); |
2993 cricket::WebRtcVoiceMediaChannel* media_channel = | 2984 cricket::WebRtcVoiceMediaChannel* media_channel = |
2994 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 2985 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
2995 send_parameters_.options.combined_audio_video_bwe.Set(true); | 2986 send_parameters_.options.combined_audio_video_bwe.Set(true); |
2996 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); | 2987 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); |
2997 | 2988 |
2998 static const uint32 kSsrcs[] = {1, 2, 3, 4}; | 2989 static const uint32 kSsrcs[] = {1, 2, 3, 4}; |
2999 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { | 2990 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { |
3000 EXPECT_TRUE(media_channel->AddRecvStream( | 2991 EXPECT_TRUE(media_channel->AddRecvStream( |
3001 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); | 2992 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); |
3002 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); | 2993 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); |
3003 } | 2994 } |
3004 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); | 2995 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); |
3005 } | 2996 } |
3006 | 2997 |
3007 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { | 2998 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { |
3008 // Test that setting the header extensions results in the expected state | 2999 // Test that setting the header extensions results in the expected state |
3009 // changes on an associated Call. | 3000 // changes on an associated Call. |
3010 std::vector<uint32> ssrcs; | 3001 std::vector<uint32> ssrcs; |
3011 ssrcs.push_back(223); | 3002 ssrcs.push_back(223); |
3012 ssrcs.push_back(224); | 3003 ssrcs.push_back(224); |
3013 | 3004 |
3014 EXPECT_TRUE(SetupEngine()); | 3005 EXPECT_TRUE(SetupEngineWithSendStream()); |
3015 cricket::WebRtcVoiceMediaChannel* media_channel = | 3006 cricket::WebRtcVoiceMediaChannel* media_channel = |
3016 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3007 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3017 send_parameters_.options.combined_audio_video_bwe.Set(true); | 3008 send_parameters_.options.combined_audio_video_bwe.Set(true); |
3018 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); | 3009 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); |
3019 for (uint32 ssrc : ssrcs) { | 3010 for (uint32 ssrc : ssrcs) { |
3020 EXPECT_TRUE(media_channel->AddRecvStream( | 3011 EXPECT_TRUE(media_channel->AddRecvStream( |
3021 cricket::StreamParams::CreateLegacy(ssrc))); | 3012 cricket::StreamParams::CreateLegacy(ssrc))); |
3022 } | 3013 } |
3023 | 3014 |
3024 // Combined BWE should be set up, but with no configured extensions. | 3015 // Combined BWE should be set up, but with no configured extensions. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3063 const uint32 kAudioSsrc = 1; | 3054 const uint32 kAudioSsrc = 1; |
3064 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 3055 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
3065 static const unsigned char kRtcp[] = { | 3056 static const unsigned char kRtcp[] = { |
3066 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, | 3057 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, |
3067 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, | 3058 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, |
3068 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3059 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
3069 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 3060 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
3070 }; | 3061 }; |
3071 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); | 3062 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); |
3072 | 3063 |
3073 EXPECT_TRUE(SetupEngine()); | 3064 EXPECT_TRUE(SetupEngineWithSendStream()); |
3074 cricket::WebRtcVoiceMediaChannel* media_channel = | 3065 cricket::WebRtcVoiceMediaChannel* media_channel = |
3075 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3066 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3076 send_parameters_.options.combined_audio_video_bwe.Set(true); | 3067 send_parameters_.options.combined_audio_video_bwe.Set(true); |
3077 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 3068 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
3078 EXPECT_TRUE(media_channel->AddRecvStream( | 3069 EXPECT_TRUE(media_channel->AddRecvStream( |
3079 cricket::StreamParams::CreateLegacy(kAudioSsrc))); | 3070 cricket::StreamParams::CreateLegacy(kAudioSsrc))); |
3080 | 3071 |
3081 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size()); | 3072 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size()); |
3082 const cricket::FakeAudioReceiveStream* s = | 3073 const cricket::FakeAudioReceiveStream* s = |
3083 call_.GetAudioReceiveStream(kAudioSsrc); | 3074 call_.GetAudioReceiveStream(kAudioSsrc); |
3084 EXPECT_EQ(0, s->received_packets()); | 3075 EXPECT_EQ(0, s->received_packets()); |
3085 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); | 3076 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); |
3086 EXPECT_EQ(1, s->received_packets()); | 3077 EXPECT_EQ(1, s->received_packets()); |
3087 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); | 3078 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); |
3088 EXPECT_EQ(2, s->received_packets()); | 3079 EXPECT_EQ(2, s->received_packets()); |
3089 } | 3080 } |
3090 | 3081 |
3091 // Associate channel should not set on 1:1 call, since the receive channel also | 3082 // All receive channels should be associated with the default send channel, |
3092 // sends RTCP SR. | 3083 // since they do not send RTCP SR. |
3093 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelUnset1On1) { | |
3094 EXPECT_TRUE(SetupEngine()); | |
3095 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
3096 int recv_ch = voe_.GetLastChannel(); | |
3097 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); | |
3098 } | |
3099 | |
3100 // This test is an extension of AssociateChannelUnset1On1. We create two receive | |
3101 // channels. The second should be associated with the default channel, since it | |
3102 // does not send RTCP SR. | |
3103 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnSecondRecvChannel) { | |
3104 EXPECT_TRUE(SetupEngine()); | |
3105 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3106 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3107 int default_channel = media_channel->voe_channel(); | |
3108 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
3109 int recv_ch_1 = voe_.GetLastChannel(); | |
3110 EXPECT_EQ(recv_ch_1, default_channel); | |
3111 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | |
3112 int recv_ch_2 = voe_.GetLastChannel(); | |
3113 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); | |
3114 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); | |
3115 // Add send stream, the association remains. | |
3116 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); | |
3117 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); | |
3118 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); | |
3119 } | |
3120 | |
3121 // In conference mode, all receive channels should be associated with the | |
3122 // default channel, since they do not send RTCP SR. | |
3123 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { | 3084 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { |
3124 EXPECT_TRUE(SetupEngine()); | 3085 EXPECT_TRUE(SetupEngineWithSendStream()); |
3125 send_parameters_.options = options_conference_; | |
3126 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 3086 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
3127 cricket::WebRtcVoiceMediaChannel* media_channel = | 3087 cricket::WebRtcVoiceMediaChannel* media_channel = |
3128 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3088 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3129 int default_channel = media_channel->voe_channel(); | 3089 int default_channel = media_channel->voe_channel(); |
3130 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 3090 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
3131 int recv_ch = voe_.GetLastChannel(); | 3091 int recv_ch = voe_.GetLastChannel(); |
3132 EXPECT_NE(recv_ch, default_channel); | 3092 EXPECT_NE(recv_ch, default_channel); |
3133 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | 3093 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); |
3134 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); | 3094 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); |
3135 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | 3095 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); |
| 3096 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
| 3097 recv_ch = voe_.GetLastChannel(); |
| 3098 EXPECT_NE(recv_ch, default_channel); |
| 3099 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); |
3136 } | 3100 } |
3137 | 3101 |
3138 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { | 3102 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { |
3139 EXPECT_TRUE(SetupEngine()); | 3103 EXPECT_TRUE(SetupEngineWithSendStream()); |
3140 send_parameters_.options = options_conference_; | |
3141 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 3104 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
3142 | 3105 |
3143 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 3106 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
3144 int recv_ch = voe_.GetLastChannel(); | 3107 int recv_ch = voe_.GetLastChannel(); |
3145 | 3108 |
3146 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); | 3109 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); |
3147 int send_ch = voe_.GetLastChannel(); | 3110 int send_ch = voe_.GetLastChannel(); |
3148 | 3111 |
3149 // Manually associate |recv_ch| to |send_ch|. This test is to verify a | 3112 // Manually associate |recv_ch| to |send_ch|. This test is to verify a |
3150 // deleting logic, i.e., deleting |send_ch| will reset the associate send | 3113 // deleting logic, i.e., deleting |send_ch| will reset the associate send |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3283 break; | 3246 break; |
3284 channels[num_channels++] = channel; | 3247 channels[num_channels++] = channel; |
3285 } | 3248 } |
3286 | 3249 |
3287 int expected = ARRAY_SIZE(channels); | 3250 int expected = ARRAY_SIZE(channels); |
3288 EXPECT_EQ(expected, num_channels); | 3251 EXPECT_EQ(expected, num_channels); |
3289 | 3252 |
3290 while (num_channels > 0) { | 3253 while (num_channels > 0) { |
3291 delete channels[--num_channels]; | 3254 delete channels[--num_channels]; |
3292 } | 3255 } |
3293 | |
3294 engine.Terminate(); | 3256 engine.Terminate(); |
3295 } | 3257 } |
3296 | 3258 |
3297 // Test that we set our preferred codecs properly. | 3259 // Test that we set our preferred codecs properly. |
3298 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3260 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
3299 cricket::WebRtcVoiceEngine engine; | 3261 cricket::WebRtcVoiceEngine engine; |
3300 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3262 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3301 rtc::scoped_ptr<webrtc::Call> call( | 3263 rtc::scoped_ptr<webrtc::Call> call( |
3302 webrtc::Call::Create(webrtc::Call::Config())); | 3264 webrtc::Call::Create(webrtc::Call::Config())); |
3303 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), | 3265 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), |
3304 call.get()); | 3266 call.get()); |
3305 cricket::AudioRecvParameters parameters; | 3267 cricket::AudioRecvParameters parameters; |
3306 parameters.codecs = engine.codecs(); | 3268 parameters.codecs = engine.codecs(); |
3307 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3269 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3308 } | 3270 } |
OLD | NEW |