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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 }; | 119 }; |
120 | 120 |
121 WebRtcVoiceEngineTestFake() | 121 WebRtcVoiceEngineTestFake() |
122 : call_(webrtc::Call::Config()), | 122 : call_(webrtc::Call::Config()), |
123 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), | 123 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), |
124 trace_wrapper_(new FakeVoETraceWrapper()), | 124 trace_wrapper_(new FakeVoETraceWrapper()), |
125 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), | 125 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), |
126 channel_(nullptr) { | 126 channel_(nullptr) { |
127 send_parameters_.codecs.push_back(kPcmuCodec); | 127 send_parameters_.codecs.push_back(kPcmuCodec); |
128 recv_parameters_.codecs.push_back(kPcmuCodec); | 128 recv_parameters_.codecs.push_back(kPcmuCodec); |
129 options_conference_.conference_mode.Set(true); | |
130 options_adjust_agc_.adjust_agc_delta.Set(-10); | 129 options_adjust_agc_.adjust_agc_delta.Set(-10); |
131 } | 130 } |
132 bool SetupEngineWithoutStream() { | 131 bool SetupEngine() { |
133 if (!engine_.Init(rtc::Thread::Current())) { | 132 if (!engine_.Init(rtc::Thread::Current())) { |
134 return false; | 133 return false; |
135 } | 134 } |
136 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); | 135 channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); |
137 return (channel_ != nullptr); | 136 return (channel_ != nullptr); |
138 } | 137 } |
139 bool SetupEngine() { | 138 bool SetupEngineWithRecvStream() { |
140 if (!SetupEngineWithoutStream()) { | 139 if (!SetupEngine()) { |
| 140 return false; |
| 141 } |
| 142 return channel_->AddRecvStream( |
| 143 cricket::StreamParams::CreateLegacy(kSsrc1)); |
| 144 } |
| 145 bool SetupEngineWithSendStream() { |
| 146 if (!SetupEngine()) { |
141 return false; | 147 return false; |
142 } | 148 } |
143 return channel_->AddSendStream( | 149 return channel_->AddSendStream( |
144 cricket::StreamParams::CreateLegacy(kSsrc1)); | 150 cricket::StreamParams::CreateLegacy(kSsrc1)); |
145 } | 151 } |
146 void SetupForMultiSendStream() { | 152 void SetupForMultiSendStream() { |
147 EXPECT_TRUE(SetupEngine()); | 153 EXPECT_TRUE(SetupEngineWithSendStream()); |
148 // Remove stream added in Setup, which is corresponding to default channel. | 154 // Remove stream added in Setup, which is corresponding to default channel. |
149 int default_channel_num = voe_.GetLastChannel(); | 155 int default_channel_num = voe_.GetLastChannel(); |
150 uint32 default_send_ssrc = 0u; | 156 uint32 default_send_ssrc = 0u; |
151 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); | 157 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); |
152 EXPECT_EQ(kSsrc1, default_send_ssrc); | 158 EXPECT_EQ(kSsrc1, default_send_ssrc); |
153 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc)); | 159 EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc)); |
154 | 160 |
155 // Verify the default channel still exists. | 161 // Verify the default channel still exists. |
156 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); | 162 EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); |
157 } | 163 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 parameters.max_bandwidth_bps = max_bitrate; | 234 parameters.max_bandwidth_bps = max_bitrate; |
229 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); | 235 EXPECT_EQ(expected_result, channel_->SetSendParameters(parameters)); |
230 | 236 |
231 int channel_num = voe_.GetLastChannel(); | 237 int channel_num = voe_.GetLastChannel(); |
232 webrtc::CodecInst temp_codec; | 238 webrtc::CodecInst temp_codec; |
233 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); | 239 EXPECT_FALSE(voe_.GetSendCodec(channel_num, temp_codec)); |
234 EXPECT_EQ(expected_bitrate, temp_codec.rate); | 240 EXPECT_EQ(expected_bitrate, temp_codec.rate); |
235 } | 241 } |
236 | 242 |
237 void TestSetSendRtpHeaderExtensions(const std::string& ext) { | 243 void TestSetSendRtpHeaderExtensions(const std::string& ext) { |
238 EXPECT_TRUE(SetupEngineWithoutStream()); | 244 EXPECT_TRUE(SetupEngine()); |
239 int channel_num = voe_.GetLastChannel(); | 245 int channel_num = voe_.GetLastChannel(); |
240 | 246 |
241 // Ensure extensions are off by default. | 247 // Ensure extensions are off by default. |
242 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); | 248 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); |
243 | 249 |
244 // Ensure unknown extensions won't cause an error. | 250 // Ensure unknown extensions won't cause an error. |
245 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( | 251 send_parameters_.extensions.push_back(cricket::RtpHeaderExtension( |
246 "urn:ietf:params:unknownextention", 1)); | 252 "urn:ietf:params:unknownextention", 1)); |
247 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 253 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
248 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); | 254 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); |
(...skipping 21 matching lines...) Expand all Loading... |
270 | 276 |
271 // Ensure all extensions go back off with an empty list. | 277 // Ensure all extensions go back off with an empty list. |
272 send_parameters_.codecs.push_back(kPcmuCodec); | 278 send_parameters_.codecs.push_back(kPcmuCodec); |
273 send_parameters_.extensions.clear(); | 279 send_parameters_.extensions.clear(); |
274 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 280 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
275 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); | 281 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(channel_num, ext)); |
276 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext)); | 282 EXPECT_EQ(-1, voe_.GetSendRtpExtensionId(new_channel_num, ext)); |
277 } | 283 } |
278 | 284 |
279 void TestSetRecvRtpHeaderExtensions(const std::string& ext) { | 285 void TestSetRecvRtpHeaderExtensions(const std::string& ext) { |
280 EXPECT_TRUE(SetupEngineWithoutStream()); | 286 EXPECT_TRUE(SetupEngineWithRecvStream()); |
281 int channel_num = voe_.GetLastChannel(); | 287 int channel_num = voe_.GetLastChannel(); |
282 | 288 |
283 // Ensure extensions are off by default. | 289 // Ensure extensions are off by default. |
284 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 290 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
285 | 291 |
286 cricket::AudioRecvParameters parameters; | 292 cricket::AudioRecvParameters parameters; |
287 // Ensure unknown extensions won't cause an error. | 293 // Ensure unknown extensions won't cause an error. |
288 parameters.extensions.push_back(cricket::RtpHeaderExtension( | 294 parameters.extensions.push_back(cricket::RtpHeaderExtension( |
289 "urn:ietf:params:unknownextention", 1)); | 295 "urn:ietf:params:unknownextention", 1)); |
290 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 296 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
291 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 297 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
292 | 298 |
293 // Ensure extensions stay off with an empty list of headers. | 299 // Ensure extensions stay off with an empty list of headers. |
294 parameters.extensions.clear(); | 300 parameters.extensions.clear(); |
295 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 301 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
296 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 302 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
297 | 303 |
298 // Ensure extension is set properly. | 304 // Ensure extension is set properly. |
299 const int id = 2; | 305 const int id = 2; |
300 parameters.extensions.push_back(cricket::RtpHeaderExtension(ext, id)); | 306 parameters.extensions.push_back(cricket::RtpHeaderExtension(ext, id)); |
301 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 307 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
302 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 308 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
303 | 309 |
304 // Ensure extension is set properly on new channel. | 310 // Ensure extension is set properly on new channel. |
305 // The first stream to occupy the default channel. | 311 // The first stream to occupy the default channel. |
306 EXPECT_TRUE(channel_->AddRecvStream( | 312 EXPECT_TRUE(channel_->AddRecvStream( |
307 cricket::StreamParams::CreateLegacy(345))); | 313 cricket::StreamParams::CreateLegacy(kSsrc2))); |
308 EXPECT_TRUE(channel_->AddRecvStream( | |
309 cricket::StreamParams::CreateLegacy(456))); | |
310 int new_channel_num = voe_.GetLastChannel(); | 314 int new_channel_num = voe_.GetLastChannel(); |
311 EXPECT_NE(channel_num, new_channel_num); | 315 EXPECT_NE(channel_num, new_channel_num); |
312 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); | 316 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); |
313 | 317 |
314 // Ensure all extensions go back off with an empty list. | 318 // Ensure all extensions go back off with an empty list. |
315 parameters.extensions.clear(); | 319 parameters.extensions.clear(); |
316 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 320 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
317 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 321 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
318 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); | 322 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); |
319 } | 323 } |
320 | 324 |
321 protected: | 325 protected: |
322 cricket::FakeCall call_; | 326 cricket::FakeCall call_; |
323 cricket::FakeWebRtcVoiceEngine voe_; | 327 cricket::FakeWebRtcVoiceEngine voe_; |
324 FakeVoETraceWrapper* trace_wrapper_; | 328 FakeVoETraceWrapper* trace_wrapper_; |
325 cricket::WebRtcVoiceEngine engine_; | 329 cricket::WebRtcVoiceEngine engine_; |
326 cricket::VoiceMediaChannel* channel_; | 330 cricket::VoiceMediaChannel* channel_; |
327 | 331 |
328 cricket::AudioSendParameters send_parameters_; | 332 cricket::AudioSendParameters send_parameters_; |
329 cricket::AudioRecvParameters recv_parameters_; | 333 cricket::AudioRecvParameters recv_parameters_; |
330 cricket::AudioOptions options_conference_; | |
331 cricket::AudioOptions options_adjust_agc_; | 334 cricket::AudioOptions options_adjust_agc_; |
332 }; | 335 }; |
333 | 336 |
334 // Tests that our stub library "works". | 337 // Tests that our stub library "works". |
335 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { | 338 TEST_F(WebRtcVoiceEngineTestFake, StartupShutdown) { |
336 EXPECT_FALSE(voe_.IsInited()); | 339 EXPECT_FALSE(voe_.IsInited()); |
337 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); | 340 EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); |
338 EXPECT_TRUE(voe_.IsInited()); | 341 EXPECT_TRUE(voe_.IsInited()); |
339 engine_.Terminate(); | 342 engine_.Terminate(); |
340 EXPECT_FALSE(voe_.IsInited()); | 343 EXPECT_FALSE(voe_.IsInited()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 codec = kIsacCodec; | 406 codec = kIsacCodec; |
404 codec.bitrate = 32000; | 407 codec.bitrate = 32000; |
405 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); | 408 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); |
406 EXPECT_EQ(codec.id, codec_inst.pltype); | 409 EXPECT_EQ(codec.id, codec_inst.pltype); |
407 EXPECT_EQ(32000, codec_inst.rate); | 410 EXPECT_EQ(32000, codec_inst.rate); |
408 } | 411 } |
409 | 412 |
410 // Test that we set our inbound codecs properly, including changing PT. | 413 // Test that we set our inbound codecs properly, including changing PT. |
411 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { | 414 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { |
412 EXPECT_TRUE(SetupEngine()); | 415 EXPECT_TRUE(SetupEngine()); |
413 int channel_num = voe_.GetLastChannel(); | |
414 cricket::AudioRecvParameters parameters; | 416 cricket::AudioRecvParameters parameters; |
415 parameters.codecs.push_back(kIsacCodec); | 417 parameters.codecs.push_back(kIsacCodec); |
416 parameters.codecs.push_back(kPcmuCodec); | 418 parameters.codecs.push_back(kPcmuCodec); |
417 parameters.codecs.push_back(kTelephoneEventCodec); | 419 parameters.codecs.push_back(kTelephoneEventCodec); |
418 parameters.codecs[0].id = 106; // collide with existing telephone-event | 420 parameters.codecs[0].id = 106; // collide with existing telephone-event |
419 parameters.codecs[2].id = 126; | 421 parameters.codecs[2].id = 126; |
420 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 422 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 423 EXPECT_TRUE(channel_->AddRecvStream( |
| 424 cricket::StreamParams::CreateLegacy(kSsrc1))); |
| 425 int channel_num = voe_.GetLastChannel(); |
421 webrtc::CodecInst gcodec; | 426 webrtc::CodecInst gcodec; |
422 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); | 427 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); |
423 gcodec.plfreq = 16000; | 428 gcodec.plfreq = 16000; |
424 gcodec.channels = 1; | 429 gcodec.channels = 1; |
425 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); | 430 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec)); |
426 EXPECT_EQ(106, gcodec.pltype); | 431 EXPECT_EQ(106, gcodec.pltype); |
427 EXPECT_STREQ("ISAC", gcodec.plname); | 432 EXPECT_STREQ("ISAC", gcodec.plname); |
428 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), | 433 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), |
429 "telephone-event"); | 434 "telephone-event"); |
430 gcodec.plfreq = 8000; | 435 gcodec.plfreq = 8000; |
(...skipping 24 matching lines...) Expand all Loading... |
455 // Test that we can decode OPUS without stereo parameters. | 460 // Test that we can decode OPUS without stereo parameters. |
456 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { | 461 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpusNoStereo) { |
457 EXPECT_TRUE(SetupEngine()); | 462 EXPECT_TRUE(SetupEngine()); |
458 cricket::AudioRecvParameters parameters; | 463 cricket::AudioRecvParameters parameters; |
459 parameters.codecs.push_back(kIsacCodec); | 464 parameters.codecs.push_back(kIsacCodec); |
460 parameters.codecs.push_back(kPcmuCodec); | 465 parameters.codecs.push_back(kPcmuCodec); |
461 parameters.codecs.push_back(kOpusCodec); | 466 parameters.codecs.push_back(kOpusCodec); |
462 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 467 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
463 EXPECT_TRUE(channel_->AddRecvStream( | 468 EXPECT_TRUE(channel_->AddRecvStream( |
464 cricket::StreamParams::CreateLegacy(kSsrc1))); | 469 cricket::StreamParams::CreateLegacy(kSsrc1))); |
465 int channel_num2 = voe_.GetLastChannel(); | 470 int channel_num = voe_.GetLastChannel(); |
466 webrtc::CodecInst opus; | 471 webrtc::CodecInst opus; |
467 engine_.FindWebRtcCodec(kOpusCodec, &opus); | 472 engine_.FindWebRtcCodec(kOpusCodec, &opus); |
468 // Even without stereo parameters, recv codecs still specify channels = 2. | 473 // Even without stereo parameters, recv codecs still specify channels = 2. |
469 EXPECT_EQ(2, opus.channels); | 474 EXPECT_EQ(2, opus.channels); |
470 EXPECT_EQ(111, opus.pltype); | 475 EXPECT_EQ(111, opus.pltype); |
471 EXPECT_STREQ("opus", opus.plname); | 476 EXPECT_STREQ("opus", opus.plname); |
472 opus.pltype = 0; | 477 opus.pltype = 0; |
473 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); | 478 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, opus)); |
474 EXPECT_EQ(111, opus.pltype); | 479 EXPECT_EQ(111, opus.pltype); |
475 } | 480 } |
476 | 481 |
477 // Test that we can decode OPUS with stereo = 0. | 482 // Test that we can decode OPUS with stereo = 0. |
478 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { | 483 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { |
479 EXPECT_TRUE(SetupEngine()); | 484 EXPECT_TRUE(SetupEngine()); |
480 cricket::AudioRecvParameters parameters; | 485 cricket::AudioRecvParameters parameters; |
481 parameters.codecs.push_back(kIsacCodec); | 486 parameters.codecs.push_back(kIsacCodec); |
482 parameters.codecs.push_back(kPcmuCodec); | 487 parameters.codecs.push_back(kPcmuCodec); |
483 parameters.codecs.push_back(kOpusCodec); | 488 parameters.codecs.push_back(kOpusCodec); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), | 547 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), |
543 "telephone-event"); | 548 "telephone-event"); |
544 gcodec.plfreq = 8000; | 549 gcodec.plfreq = 8000; |
545 gcodec.channels = 1; | 550 gcodec.channels = 1; |
546 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); | 551 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
547 EXPECT_EQ(126, gcodec.pltype); | 552 EXPECT_EQ(126, gcodec.pltype); |
548 EXPECT_STREQ("telephone-event", gcodec.plname); | 553 EXPECT_STREQ("telephone-event", gcodec.plname); |
549 } | 554 } |
550 | 555 |
551 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { | 556 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { |
552 EXPECT_TRUE(SetupEngine()); | 557 EXPECT_TRUE(SetupEngineWithRecvStream()); |
553 cricket::AudioRecvParameters parameters; | 558 cricket::AudioRecvParameters parameters; |
554 parameters.codecs.push_back(kIsacCodec); | 559 parameters.codecs.push_back(kIsacCodec); |
555 parameters.codecs[0].id = 106; // collide with existing telephone-event | 560 parameters.codecs[0].id = 106; // collide with existing telephone-event |
556 EXPECT_TRUE(channel_->AddRecvStream( | |
557 cricket::StreamParams::CreateLegacy(kSsrc1))); | |
558 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 561 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
559 | 562 |
560 int channel_num2 = voe_.GetLastChannel(); | 563 int channel_num2 = voe_.GetLastChannel(); |
561 webrtc::CodecInst gcodec; | 564 webrtc::CodecInst gcodec; |
562 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); | 565 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC"); |
563 gcodec.plfreq = 16000; | 566 gcodec.plfreq = 16000; |
564 gcodec.channels = 1; | 567 gcodec.channels = 1; |
565 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); | 568 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec)); |
566 EXPECT_EQ(106, gcodec.pltype); | 569 EXPECT_EQ(106, gcodec.pltype); |
567 EXPECT_STREQ("ISAC", gcodec.plname); | 570 EXPECT_STREQ("ISAC", gcodec.plname); |
568 } | 571 } |
569 | 572 |
570 // Test that we can apply the same set of codecs again while playing. | 573 // Test that we can apply the same set of codecs again while playing. |
571 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { | 574 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { |
572 EXPECT_TRUE(SetupEngine()); | 575 EXPECT_TRUE(SetupEngineWithRecvStream()); |
573 cricket::AudioRecvParameters parameters; | 576 cricket::AudioRecvParameters parameters; |
574 parameters.codecs.push_back(kIsacCodec); | 577 parameters.codecs.push_back(kIsacCodec); |
575 parameters.codecs.push_back(kCn16000Codec); | 578 parameters.codecs.push_back(kCn16000Codec); |
576 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 579 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
577 EXPECT_TRUE(channel_->SetPlayout(true)); | 580 EXPECT_TRUE(channel_->SetPlayout(true)); |
578 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 581 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
579 | 582 |
580 // Changing the payload type of a codec should fail. | 583 // Changing the payload type of a codec should fail. |
581 parameters.codecs[0].id = 127; | 584 parameters.codecs[0].id = 127; |
582 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); | 585 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
583 int channel_num = voe_.GetLastChannel(); | 586 int channel_num = voe_.GetLastChannel(); |
584 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 587 EXPECT_TRUE(voe_.GetPlayout(channel_num)); |
585 } | 588 } |
586 | 589 |
587 // Test that we can add a codec while playing. | 590 // Test that we can add a codec while playing. |
588 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { | 591 TEST_F(WebRtcVoiceEngineTestFake, AddRecvCodecsWhilePlaying) { |
589 EXPECT_TRUE(SetupEngine()); | 592 EXPECT_TRUE(SetupEngineWithRecvStream()); |
590 cricket::AudioRecvParameters parameters; | 593 cricket::AudioRecvParameters parameters; |
591 parameters.codecs.push_back(kIsacCodec); | 594 parameters.codecs.push_back(kIsacCodec); |
592 parameters.codecs.push_back(kCn16000Codec); | 595 parameters.codecs.push_back(kCn16000Codec); |
593 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 596 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
594 EXPECT_TRUE(channel_->SetPlayout(true)); | 597 EXPECT_TRUE(channel_->SetPlayout(true)); |
595 | 598 |
596 parameters.codecs.push_back(kOpusCodec); | 599 parameters.codecs.push_back(kOpusCodec); |
597 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 600 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
598 int channel_num = voe_.GetLastChannel(); | 601 int channel_num = voe_.GetLastChannel(); |
599 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 602 EXPECT_TRUE(voe_.GetPlayout(channel_num)); |
600 webrtc::CodecInst gcodec; | 603 webrtc::CodecInst gcodec; |
601 EXPECT_TRUE(engine_.FindWebRtcCodec(kOpusCodec, &gcodec)); | 604 EXPECT_TRUE(engine_.FindWebRtcCodec(kOpusCodec, &gcodec)); |
602 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); | 605 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); |
603 } | 606 } |
604 | 607 |
605 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { | 608 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { |
606 EXPECT_TRUE(SetupEngine()); | 609 EXPECT_TRUE(SetupEngineWithSendStream()); |
607 | 610 |
608 // Test that when autobw is enabled, bitrate is kept as the default | 611 // Test that when autobw is enabled, bitrate is kept as the default |
609 // value. autobw is enabled for the following tests because the target | 612 // value. autobw is enabled for the following tests because the target |
610 // bitrate is <= 0. | 613 // bitrate is <= 0. |
611 | 614 |
612 // ISAC, default bitrate == 32000. | 615 // ISAC, default bitrate == 32000. |
613 TestSendBandwidth(kIsacCodec, 0, true, 32000); | 616 TestSendBandwidth(kIsacCodec, 0, true, 32000); |
614 | 617 |
615 // PCMU, default bitrate == 64000. | 618 // PCMU, default bitrate == 64000. |
616 TestSendBandwidth(kPcmuCodec, -1, true, 64000); | 619 TestSendBandwidth(kPcmuCodec, -1, true, 64000); |
617 | 620 |
618 // opus, default bitrate == 64000. | 621 // opus, default bitrate == 64000. |
619 TestSendBandwidth(kOpusCodec, -1, true, 64000); | 622 TestSendBandwidth(kOpusCodec, -1, true, 64000); |
620 } | 623 } |
621 | 624 |
622 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { | 625 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCaller) { |
623 EXPECT_TRUE(SetupEngine()); | 626 EXPECT_TRUE(SetupEngineWithSendStream()); |
624 | 627 |
625 // Test that the bitrate of a multi-rate codec is always the maximum. | 628 // Test that the bitrate of a multi-rate codec is always the maximum. |
626 | 629 |
627 // ISAC, default bitrate == 32000. | 630 // ISAC, default bitrate == 32000. |
628 TestSendBandwidth(kIsacCodec, 128000, true, 128000); | 631 TestSendBandwidth(kIsacCodec, 128000, true, 128000); |
629 TestSendBandwidth(kIsacCodec, 16000, true, 16000); | 632 TestSendBandwidth(kIsacCodec, 16000, true, 16000); |
630 | 633 |
631 // opus, default bitrate == 64000. | 634 // opus, default bitrate == 64000. |
632 TestSendBandwidth(kOpusCodec, 96000, true, 96000); | 635 TestSendBandwidth(kOpusCodec, 96000, true, 96000); |
633 TestSendBandwidth(kOpusCodec, 48000, true, 48000); | 636 TestSendBandwidth(kOpusCodec, 48000, true, 48000); |
634 } | 637 } |
635 | 638 |
636 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { | 639 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthFixedRateAsCaller) { |
637 EXPECT_TRUE(SetupEngine()); | 640 EXPECT_TRUE(SetupEngineWithSendStream()); |
638 | 641 |
639 // Test that we can only set a maximum bitrate for a fixed-rate codec | 642 // Test that we can only set a maximum bitrate for a fixed-rate codec |
640 // if it's bigger than the fixed rate. | 643 // if it's bigger than the fixed rate. |
641 | 644 |
642 // PCMU, fixed bitrate == 64000. | 645 // PCMU, fixed bitrate == 64000. |
643 TestSendBandwidth(kPcmuCodec, 0, true, 64000); | 646 TestSendBandwidth(kPcmuCodec, 0, true, 64000); |
644 TestSendBandwidth(kPcmuCodec, 1, false, 64000); | 647 TestSendBandwidth(kPcmuCodec, 1, false, 64000); |
645 TestSendBandwidth(kPcmuCodec, 128000, true, 64000); | 648 TestSendBandwidth(kPcmuCodec, 128000, true, 64000); |
646 TestSendBandwidth(kPcmuCodec, 32000, false, 64000); | 649 TestSendBandwidth(kPcmuCodec, 32000, false, 64000); |
647 TestSendBandwidth(kPcmuCodec, 64000, true, 64000); | 650 TestSendBandwidth(kPcmuCodec, 64000, true, 64000); |
648 TestSendBandwidth(kPcmuCodec, 63999, false, 64000); | 651 TestSendBandwidth(kPcmuCodec, 63999, false, 64000); |
649 TestSendBandwidth(kPcmuCodec, 64001, true, 64000); | 652 TestSendBandwidth(kPcmuCodec, 64001, true, 64000); |
650 } | 653 } |
651 | 654 |
652 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { | 655 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { |
653 EXPECT_TRUE(SetupEngineWithoutStream()); | 656 EXPECT_TRUE(SetupEngine()); |
654 const int kDesiredBitrate = 128000; | 657 const int kDesiredBitrate = 128000; |
655 cricket::AudioSendParameters parameters; | 658 cricket::AudioSendParameters parameters; |
656 parameters.codecs = engine_.codecs(); | 659 parameters.codecs = engine_.codecs(); |
657 parameters.max_bandwidth_bps = kDesiredBitrate; | 660 parameters.max_bandwidth_bps = kDesiredBitrate; |
658 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 661 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
659 | 662 |
660 EXPECT_TRUE(channel_->AddSendStream( | 663 EXPECT_TRUE(channel_->AddSendStream( |
661 cricket::StreamParams::CreateLegacy(kSsrc1))); | 664 cricket::StreamParams::CreateLegacy(kSsrc1))); |
662 | 665 |
663 int channel_num = voe_.GetLastChannel(); | 666 int channel_num = voe_.GetLastChannel(); |
664 webrtc::CodecInst codec; | 667 webrtc::CodecInst codec; |
665 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 668 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
666 EXPECT_EQ(kDesiredBitrate, codec.rate); | 669 EXPECT_EQ(kDesiredBitrate, codec.rate); |
667 } | 670 } |
668 | 671 |
669 // Test that bitrate cannot be set for CBR codecs. | 672 // Test that bitrate cannot be set for CBR codecs. |
670 // Bitrate is ignored if it is higher than the fixed bitrate. | 673 // Bitrate is ignored if it is higher than the fixed bitrate. |
671 // Bitrate less then the fixed bitrate is an error. | 674 // Bitrate less then the fixed bitrate is an error. |
672 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { | 675 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthCbr) { |
673 EXPECT_TRUE(SetupEngine()); | 676 EXPECT_TRUE(SetupEngineWithSendStream()); |
674 | 677 |
675 // PCMU, default bitrate == 64000. | 678 // PCMU, default bitrate == 64000. |
676 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 679 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
677 int channel_num = voe_.GetLastChannel(); | 680 int channel_num = voe_.GetLastChannel(); |
678 webrtc::CodecInst codec; | 681 webrtc::CodecInst codec; |
679 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 682 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
680 EXPECT_EQ(64000, codec.rate); | 683 EXPECT_EQ(64000, codec.rate); |
681 | 684 |
682 send_parameters_.max_bandwidth_bps = 128000; | 685 send_parameters_.max_bandwidth_bps = 128000; |
683 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 686 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
684 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 687 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
685 EXPECT_EQ(64000, codec.rate); | 688 EXPECT_EQ(64000, codec.rate); |
686 | 689 |
687 send_parameters_.max_bandwidth_bps = 128; | 690 send_parameters_.max_bandwidth_bps = 128; |
688 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); | 691 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
689 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 692 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
690 EXPECT_EQ(64000, codec.rate); | 693 EXPECT_EQ(64000, codec.rate); |
691 } | 694 } |
692 | 695 |
693 // Test that we apply codecs properly. | 696 // Test that we apply codecs properly. |
694 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { | 697 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecs) { |
695 EXPECT_TRUE(SetupEngine()); | 698 EXPECT_TRUE(SetupEngineWithSendStream()); |
696 cricket::AudioSendParameters parameters; | 699 cricket::AudioSendParameters parameters; |
697 parameters.codecs.push_back(kIsacCodec); | 700 parameters.codecs.push_back(kIsacCodec); |
698 parameters.codecs.push_back(kPcmuCodec); | 701 parameters.codecs.push_back(kPcmuCodec); |
699 parameters.codecs.push_back(kRedCodec); | 702 parameters.codecs.push_back(kRedCodec); |
700 parameters.codecs[0].id = 96; | 703 parameters.codecs[0].id = 96; |
701 parameters.codecs[0].bitrate = 48000; | 704 parameters.codecs[0].bitrate = 48000; |
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 int channel_num = voe_.GetLastChannel(); | 707 int channel_num = voe_.GetLastChannel(); |
705 webrtc::CodecInst gcodec; | 708 webrtc::CodecInst gcodec; |
706 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 709 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
707 EXPECT_EQ(96, gcodec.pltype); | 710 EXPECT_EQ(96, gcodec.pltype); |
708 EXPECT_EQ(48000, gcodec.rate); | 711 EXPECT_EQ(48000, gcodec.rate); |
709 EXPECT_STREQ("ISAC", gcodec.plname); | 712 EXPECT_STREQ("ISAC", gcodec.plname); |
710 EXPECT_FALSE(voe_.GetVAD(channel_num)); | 713 EXPECT_FALSE(voe_.GetVAD(channel_num)); |
711 EXPECT_FALSE(voe_.GetRED(channel_num)); | 714 EXPECT_FALSE(voe_.GetRED(channel_num)); |
712 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); | 715 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); |
713 EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true)); | 716 EXPECT_EQ(105, voe_.GetSendCNPayloadType(channel_num, true)); |
714 EXPECT_EQ(106, voe_.GetSendTelephoneEventPayloadType(channel_num)); | 717 EXPECT_EQ(106, voe_.GetSendTelephoneEventPayloadType(channel_num)); |
715 } | 718 } |
716 | 719 |
717 // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried | 720 // Test that VoE Channel doesn't call SetSendCodec again if same codec is tried |
718 // to apply. | 721 // to apply. |
719 TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { | 722 TEST_F(WebRtcVoiceEngineTestFake, DontResetSetSendCodec) { |
720 EXPECT_TRUE(SetupEngine()); | 723 EXPECT_TRUE(SetupEngineWithSendStream()); |
721 cricket::AudioSendParameters parameters; | 724 cricket::AudioSendParameters parameters; |
722 parameters.codecs.push_back(kIsacCodec); | 725 parameters.codecs.push_back(kIsacCodec); |
723 parameters.codecs.push_back(kPcmuCodec); | 726 parameters.codecs.push_back(kPcmuCodec); |
724 parameters.codecs.push_back(kRedCodec); | 727 parameters.codecs.push_back(kRedCodec); |
725 parameters.codecs[0].id = 96; | 728 parameters.codecs[0].id = 96; |
726 parameters.codecs[0].bitrate = 48000; | 729 parameters.codecs[0].bitrate = 48000; |
727 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 730 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
728 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); | 731 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); |
729 // Calling SetSendCodec again with same codec which is already set. | 732 // Calling SetSendCodec again with same codec which is already set. |
730 // In this case media channel shouldn't send codec to VoE. | 733 // In this case media channel shouldn't send codec to VoE. |
731 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 734 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
732 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); | 735 EXPECT_EQ(1, voe_.GetNumSetSendCodecs()); |
733 } | 736 } |
734 | 737 |
735 // Verify that G722 is set with 16000 samples per second to WebRTC. | 738 // Verify that G722 is set with 16000 samples per second to WebRTC. |
736 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { | 739 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecG722) { |
737 EXPECT_TRUE(SetupEngine()); | 740 EXPECT_TRUE(SetupEngineWithSendStream()); |
738 int channel_num = voe_.GetLastChannel(); | 741 int channel_num = voe_.GetLastChannel(); |
739 cricket::AudioSendParameters parameters; | 742 cricket::AudioSendParameters parameters; |
740 parameters.codecs.push_back(kG722CodecSdp); | 743 parameters.codecs.push_back(kG722CodecSdp); |
741 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 744 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
742 webrtc::CodecInst gcodec; | 745 webrtc::CodecInst gcodec; |
743 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 746 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
744 EXPECT_STREQ("G722", gcodec.plname); | 747 EXPECT_STREQ("G722", gcodec.plname); |
745 EXPECT_EQ(1, gcodec.channels); | 748 EXPECT_EQ(1, gcodec.channels); |
746 EXPECT_EQ(16000, gcodec.plfreq); | 749 EXPECT_EQ(16000, gcodec.plfreq); |
747 } | 750 } |
748 | 751 |
749 // Test that if clockrate is not 48000 for opus, we fail. | 752 // Test that if clockrate is not 48000 for opus, we fail. |
750 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { | 753 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBadClockrate) { |
751 EXPECT_TRUE(SetupEngine()); | 754 EXPECT_TRUE(SetupEngineWithSendStream()); |
752 cricket::AudioSendParameters parameters; | 755 cricket::AudioSendParameters parameters; |
753 parameters.codecs.push_back(kOpusCodec); | 756 parameters.codecs.push_back(kOpusCodec); |
754 parameters.codecs[0].bitrate = 0; | 757 parameters.codecs[0].bitrate = 0; |
755 parameters.codecs[0].clockrate = 50000; | 758 parameters.codecs[0].clockrate = 50000; |
756 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 759 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
757 } | 760 } |
758 | 761 |
759 // Test that if channels=0 for opus, we fail. | 762 // Test that if channels=0 for opus, we fail. |
760 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { | 763 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0ChannelsNoStereo) { |
761 EXPECT_TRUE(SetupEngine()); | 764 EXPECT_TRUE(SetupEngineWithSendStream()); |
762 cricket::AudioSendParameters parameters; | 765 cricket::AudioSendParameters parameters; |
763 parameters.codecs.push_back(kOpusCodec); | 766 parameters.codecs.push_back(kOpusCodec); |
764 parameters.codecs[0].bitrate = 0; | 767 parameters.codecs[0].bitrate = 0; |
765 parameters.codecs[0].channels = 0; | 768 parameters.codecs[0].channels = 0; |
766 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 769 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
767 } | 770 } |
768 | 771 |
769 // Test that if channels=0 for opus, we fail. | 772 // Test that if channels=0 for opus, we fail. |
770 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { | 773 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad0Channels1Stereo) { |
771 EXPECT_TRUE(SetupEngine()); | 774 EXPECT_TRUE(SetupEngineWithSendStream()); |
772 cricket::AudioSendParameters parameters; | 775 cricket::AudioSendParameters parameters; |
773 parameters.codecs.push_back(kOpusCodec); | 776 parameters.codecs.push_back(kOpusCodec); |
774 parameters.codecs[0].bitrate = 0; | 777 parameters.codecs[0].bitrate = 0; |
775 parameters.codecs[0].channels = 0; | 778 parameters.codecs[0].channels = 0; |
776 parameters.codecs[0].params["stereo"] = "1"; | 779 parameters.codecs[0].params["stereo"] = "1"; |
777 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 780 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
778 } | 781 } |
779 | 782 |
780 // Test that if channel is 1 for opus and there's no stereo, we fail. | 783 // Test that if channel is 1 for opus and there's no stereo, we fail. |
781 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { | 784 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpus1ChannelNoStereo) { |
782 EXPECT_TRUE(SetupEngine()); | 785 EXPECT_TRUE(SetupEngineWithSendStream()); |
783 cricket::AudioSendParameters parameters; | 786 cricket::AudioSendParameters parameters; |
784 parameters.codecs.push_back(kOpusCodec); | 787 parameters.codecs.push_back(kOpusCodec); |
785 parameters.codecs[0].bitrate = 0; | 788 parameters.codecs[0].bitrate = 0; |
786 parameters.codecs[0].channels = 1; | 789 parameters.codecs[0].channels = 1; |
787 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 790 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
788 } | 791 } |
789 | 792 |
790 // Test that if channel is 1 for opus and stereo=0, we fail. | 793 // Test that if channel is 1 for opus and stereo=0, we fail. |
791 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { | 794 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel0Stereo) { |
792 EXPECT_TRUE(SetupEngine()); | 795 EXPECT_TRUE(SetupEngineWithSendStream()); |
793 cricket::AudioSendParameters parameters; | 796 cricket::AudioSendParameters parameters; |
794 parameters.codecs.push_back(kOpusCodec); | 797 parameters.codecs.push_back(kOpusCodec); |
795 parameters.codecs[0].bitrate = 0; | 798 parameters.codecs[0].bitrate = 0; |
796 parameters.codecs[0].channels = 1; | 799 parameters.codecs[0].channels = 1; |
797 parameters.codecs[0].params["stereo"] = "0"; | 800 parameters.codecs[0].params["stereo"] = "0"; |
798 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 801 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
799 } | 802 } |
800 | 803 |
801 // Test that if channel is 1 for opus and stereo=1, we fail. | 804 // Test that if channel is 1 for opus and stereo=1, we fail. |
802 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { | 805 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusBad1Channel1Stereo) { |
803 EXPECT_TRUE(SetupEngine()); | 806 EXPECT_TRUE(SetupEngineWithSendStream()); |
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].channels = 1; | 810 parameters.codecs[0].channels = 1; |
808 parameters.codecs[0].params["stereo"] = "1"; | 811 parameters.codecs[0].params["stereo"] = "1"; |
809 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 812 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
810 } | 813 } |
811 | 814 |
812 // Test that with bitrate=0 and no stereo, | 815 // Test that with bitrate=0 and no stereo, |
813 // channels and bitrate are 1 and 32000. | 816 // channels and bitrate are 1 and 32000. |
814 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { | 817 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0BitrateNoStereo) { |
815 EXPECT_TRUE(SetupEngine()); | 818 EXPECT_TRUE(SetupEngineWithSendStream()); |
816 int channel_num = voe_.GetLastChannel(); | 819 int channel_num = voe_.GetLastChannel(); |
817 cricket::AudioSendParameters parameters; | 820 cricket::AudioSendParameters parameters; |
818 parameters.codecs.push_back(kOpusCodec); | 821 parameters.codecs.push_back(kOpusCodec); |
819 parameters.codecs[0].bitrate = 0; | 822 parameters.codecs[0].bitrate = 0; |
820 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 823 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
821 webrtc::CodecInst gcodec; | 824 webrtc::CodecInst gcodec; |
822 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 825 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
823 EXPECT_STREQ("opus", gcodec.plname); | 826 EXPECT_STREQ("opus", gcodec.plname); |
824 EXPECT_EQ(1, gcodec.channels); | 827 EXPECT_EQ(1, gcodec.channels); |
825 EXPECT_EQ(32000, gcodec.rate); | 828 EXPECT_EQ(32000, gcodec.rate); |
826 } | 829 } |
827 | 830 |
828 // Test that with bitrate=0 and stereo=0, | 831 // Test that with bitrate=0 and stereo=0, |
829 // channels and bitrate are 1 and 32000. | 832 // channels and bitrate are 1 and 32000. |
830 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { | 833 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate0Stereo) { |
831 EXPECT_TRUE(SetupEngine()); | 834 EXPECT_TRUE(SetupEngineWithSendStream()); |
832 int channel_num = voe_.GetLastChannel(); | 835 int channel_num = voe_.GetLastChannel(); |
833 cricket::AudioSendParameters parameters; | 836 cricket::AudioSendParameters parameters; |
834 parameters.codecs.push_back(kOpusCodec); | 837 parameters.codecs.push_back(kOpusCodec); |
835 parameters.codecs[0].bitrate = 0; | 838 parameters.codecs[0].bitrate = 0; |
836 parameters.codecs[0].params["stereo"] = "0"; | 839 parameters.codecs[0].params["stereo"] = "0"; |
837 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 840 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
838 webrtc::CodecInst gcodec; | 841 webrtc::CodecInst gcodec; |
839 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 842 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
840 EXPECT_STREQ("opus", gcodec.plname); | 843 EXPECT_STREQ("opus", gcodec.plname); |
841 EXPECT_EQ(1, gcodec.channels); | 844 EXPECT_EQ(1, gcodec.channels); |
842 EXPECT_EQ(32000, gcodec.rate); | 845 EXPECT_EQ(32000, gcodec.rate); |
843 } | 846 } |
844 | 847 |
845 // Test that with bitrate=invalid and stereo=0, | 848 // Test that with bitrate=invalid and stereo=0, |
846 // channels and bitrate are 1 and 32000. | 849 // channels and bitrate are 1 and 32000. |
847 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { | 850 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate0Stereo) { |
848 EXPECT_TRUE(SetupEngine()); | 851 EXPECT_TRUE(SetupEngineWithSendStream()); |
849 int channel_num = voe_.GetLastChannel(); | 852 int channel_num = voe_.GetLastChannel(); |
850 cricket::AudioSendParameters parameters; | 853 cricket::AudioSendParameters parameters; |
851 parameters.codecs.push_back(kOpusCodec); | 854 parameters.codecs.push_back(kOpusCodec); |
852 parameters.codecs[0].params["stereo"] = "0"; | 855 parameters.codecs[0].params["stereo"] = "0"; |
853 webrtc::CodecInst gcodec; | 856 webrtc::CodecInst gcodec; |
854 | 857 |
855 // bitrate that's out of the range between 6000 and 510000 will be clamped. | 858 // bitrate that's out of the range between 6000 and 510000 will be clamped. |
856 parameters.codecs[0].bitrate = 5999; | 859 parameters.codecs[0].bitrate = 5999; |
857 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 860 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
858 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 861 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
859 EXPECT_STREQ("opus", gcodec.plname); | 862 EXPECT_STREQ("opus", gcodec.plname); |
860 EXPECT_EQ(1, gcodec.channels); | 863 EXPECT_EQ(1, gcodec.channels); |
861 EXPECT_EQ(6000, gcodec.rate); | 864 EXPECT_EQ(6000, gcodec.rate); |
862 | 865 |
863 parameters.codecs[0].bitrate = 510001; | 866 parameters.codecs[0].bitrate = 510001; |
864 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 867 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
865 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 868 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
866 EXPECT_STREQ("opus", gcodec.plname); | 869 EXPECT_STREQ("opus", gcodec.plname); |
867 EXPECT_EQ(1, gcodec.channels); | 870 EXPECT_EQ(1, gcodec.channels); |
868 EXPECT_EQ(510000, gcodec.rate); | 871 EXPECT_EQ(510000, gcodec.rate); |
869 } | 872 } |
870 | 873 |
871 // Test that with bitrate=0 and stereo=1, | 874 // Test that with bitrate=0 and stereo=1, |
872 // channels and bitrate are 2 and 64000. | 875 // channels and bitrate are 2 and 64000. |
873 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { | 876 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGood0Bitrate1Stereo) { |
874 EXPECT_TRUE(SetupEngine()); | 877 EXPECT_TRUE(SetupEngineWithSendStream()); |
875 int channel_num = voe_.GetLastChannel(); | 878 int channel_num = voe_.GetLastChannel(); |
876 cricket::AudioSendParameters parameters; | 879 cricket::AudioSendParameters parameters; |
877 parameters.codecs.push_back(kOpusCodec); | 880 parameters.codecs.push_back(kOpusCodec); |
878 parameters.codecs[0].bitrate = 0; | 881 parameters.codecs[0].bitrate = 0; |
879 parameters.codecs[0].params["stereo"] = "1"; | 882 parameters.codecs[0].params["stereo"] = "1"; |
880 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 883 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
881 webrtc::CodecInst gcodec; | 884 webrtc::CodecInst gcodec; |
882 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 885 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
883 EXPECT_STREQ("opus", gcodec.plname); | 886 EXPECT_STREQ("opus", gcodec.plname); |
884 EXPECT_EQ(2, gcodec.channels); | 887 EXPECT_EQ(2, gcodec.channels); |
885 EXPECT_EQ(64000, gcodec.rate); | 888 EXPECT_EQ(64000, gcodec.rate); |
886 } | 889 } |
887 | 890 |
888 // Test that with bitrate=invalid and stereo=1, | 891 // Test that with bitrate=invalid and stereo=1, |
889 // channels and bitrate are 2 and 64000. | 892 // channels and bitrate are 2 and 64000. |
890 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { | 893 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodXBitrate1Stereo) { |
891 EXPECT_TRUE(SetupEngine()); | 894 EXPECT_TRUE(SetupEngineWithSendStream()); |
892 int channel_num = voe_.GetLastChannel(); | 895 int channel_num = voe_.GetLastChannel(); |
893 cricket::AudioSendParameters parameters; | 896 cricket::AudioSendParameters parameters; |
894 parameters.codecs.push_back(kOpusCodec); | 897 parameters.codecs.push_back(kOpusCodec); |
895 parameters.codecs[0].params["stereo"] = "1"; | 898 parameters.codecs[0].params["stereo"] = "1"; |
896 webrtc::CodecInst gcodec; | 899 webrtc::CodecInst gcodec; |
897 | 900 |
898 // bitrate that's out of the range between 6000 and 510000 will be clamped. | 901 // bitrate that's out of the range between 6000 and 510000 will be clamped. |
899 parameters.codecs[0].bitrate = 5999; | 902 parameters.codecs[0].bitrate = 5999; |
900 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 903 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
901 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 904 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
902 EXPECT_STREQ("opus", gcodec.plname); | 905 EXPECT_STREQ("opus", gcodec.plname); |
903 EXPECT_EQ(2, gcodec.channels); | 906 EXPECT_EQ(2, gcodec.channels); |
904 EXPECT_EQ(6000, gcodec.rate); | 907 EXPECT_EQ(6000, gcodec.rate); |
905 | 908 |
906 parameters.codecs[0].bitrate = 510001; | 909 parameters.codecs[0].bitrate = 510001; |
907 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 910 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
908 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 911 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
909 EXPECT_STREQ("opus", gcodec.plname); | 912 EXPECT_STREQ("opus", gcodec.plname); |
910 EXPECT_EQ(2, gcodec.channels); | 913 EXPECT_EQ(2, gcodec.channels); |
911 EXPECT_EQ(510000, gcodec.rate); | 914 EXPECT_EQ(510000, gcodec.rate); |
912 } | 915 } |
913 | 916 |
914 // Test that with bitrate=N and stereo unset, | 917 // Test that with bitrate=N and stereo unset, |
915 // channels and bitrate are 1 and N. | 918 // channels and bitrate are 1 and N. |
916 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { | 919 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoStereo) { |
917 EXPECT_TRUE(SetupEngine()); | 920 EXPECT_TRUE(SetupEngineWithSendStream()); |
918 int channel_num = voe_.GetLastChannel(); | 921 int channel_num = voe_.GetLastChannel(); |
919 cricket::AudioSendParameters parameters; | 922 cricket::AudioSendParameters parameters; |
920 parameters.codecs.push_back(kOpusCodec); | 923 parameters.codecs.push_back(kOpusCodec); |
921 parameters.codecs[0].bitrate = 96000; | 924 parameters.codecs[0].bitrate = 96000; |
922 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 925 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
923 webrtc::CodecInst gcodec; | 926 webrtc::CodecInst gcodec; |
924 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 927 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
925 EXPECT_EQ(111, gcodec.pltype); | 928 EXPECT_EQ(111, gcodec.pltype); |
926 EXPECT_EQ(96000, gcodec.rate); | 929 EXPECT_EQ(96000, gcodec.rate); |
927 EXPECT_STREQ("opus", gcodec.plname); | 930 EXPECT_STREQ("opus", gcodec.plname); |
928 EXPECT_EQ(1, gcodec.channels); | 931 EXPECT_EQ(1, gcodec.channels); |
929 EXPECT_EQ(48000, gcodec.plfreq); | 932 EXPECT_EQ(48000, gcodec.plfreq); |
930 } | 933 } |
931 | 934 |
932 // Test that with bitrate=N and stereo=0, | 935 // Test that with bitrate=N and stereo=0, |
933 // channels and bitrate are 1 and N. | 936 // channels and bitrate are 1 and N. |
934 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { | 937 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate0Stereo) { |
935 EXPECT_TRUE(SetupEngine()); | 938 EXPECT_TRUE(SetupEngineWithSendStream()); |
936 int channel_num = voe_.GetLastChannel(); | 939 int channel_num = voe_.GetLastChannel(); |
937 cricket::AudioSendParameters parameters; | 940 cricket::AudioSendParameters parameters; |
938 parameters.codecs.push_back(kOpusCodec); | 941 parameters.codecs.push_back(kOpusCodec); |
939 parameters.codecs[0].bitrate = 30000; | 942 parameters.codecs[0].bitrate = 30000; |
940 parameters.codecs[0].params["stereo"] = "0"; | 943 parameters.codecs[0].params["stereo"] = "0"; |
941 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 944 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
942 webrtc::CodecInst gcodec; | 945 webrtc::CodecInst gcodec; |
943 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 946 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
944 EXPECT_EQ(1, gcodec.channels); | 947 EXPECT_EQ(1, gcodec.channels); |
945 EXPECT_EQ(30000, gcodec.rate); | 948 EXPECT_EQ(30000, gcodec.rate); |
946 EXPECT_STREQ("opus", gcodec.plname); | 949 EXPECT_STREQ("opus", gcodec.plname); |
947 } | 950 } |
948 | 951 |
949 // Test that with bitrate=N and without any parameters, | 952 // Test that with bitrate=N and without any parameters, |
950 // channels and bitrate are 1 and N. | 953 // channels and bitrate are 1 and N. |
951 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { | 954 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrateNoParameters) { |
952 EXPECT_TRUE(SetupEngine()); | 955 EXPECT_TRUE(SetupEngineWithSendStream()); |
953 int channel_num = voe_.GetLastChannel(); | 956 int channel_num = voe_.GetLastChannel(); |
954 cricket::AudioSendParameters parameters; | 957 cricket::AudioSendParameters parameters; |
955 parameters.codecs.push_back(kOpusCodec); | 958 parameters.codecs.push_back(kOpusCodec); |
956 parameters.codecs[0].bitrate = 30000; | 959 parameters.codecs[0].bitrate = 30000; |
957 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 960 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
958 webrtc::CodecInst gcodec; | 961 webrtc::CodecInst gcodec; |
959 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 962 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
960 EXPECT_EQ(1, gcodec.channels); | 963 EXPECT_EQ(1, gcodec.channels); |
961 EXPECT_EQ(30000, gcodec.rate); | 964 EXPECT_EQ(30000, gcodec.rate); |
962 EXPECT_STREQ("opus", gcodec.plname); | 965 EXPECT_STREQ("opus", gcodec.plname); |
963 } | 966 } |
964 | 967 |
965 // Test that with bitrate=N and stereo=1, | 968 // Test that with bitrate=N and stereo=1, |
966 // channels and bitrate are 2 and N. | 969 // channels and bitrate are 2 and N. |
967 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { | 970 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusGoodNBitrate1Stereo) { |
968 EXPECT_TRUE(SetupEngine()); | 971 EXPECT_TRUE(SetupEngineWithSendStream()); |
969 int channel_num = voe_.GetLastChannel(); | 972 int channel_num = voe_.GetLastChannel(); |
970 cricket::AudioSendParameters parameters; | 973 cricket::AudioSendParameters parameters; |
971 parameters.codecs.push_back(kOpusCodec); | 974 parameters.codecs.push_back(kOpusCodec); |
972 parameters.codecs[0].bitrate = 30000; | 975 parameters.codecs[0].bitrate = 30000; |
973 parameters.codecs[0].params["stereo"] = "1"; | 976 parameters.codecs[0].params["stereo"] = "1"; |
974 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 977 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
975 webrtc::CodecInst gcodec; | 978 webrtc::CodecInst gcodec; |
976 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 979 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
977 EXPECT_EQ(2, gcodec.channels); | 980 EXPECT_EQ(2, gcodec.channels); |
978 EXPECT_EQ(30000, gcodec.rate); | 981 EXPECT_EQ(30000, gcodec.rate); |
979 EXPECT_STREQ("opus", gcodec.plname); | 982 EXPECT_STREQ("opus", gcodec.plname); |
980 } | 983 } |
981 | 984 |
982 // Test that bitrate will be overridden by the "maxaveragebitrate" parameter. | 985 // Test that bitrate will be overridden by the "maxaveragebitrate" parameter. |
983 // Also test that the "maxaveragebitrate" can't be set to values outside the | 986 // Also test that the "maxaveragebitrate" can't be set to values outside the |
984 // range of 6000 and 510000 | 987 // range of 6000 and 510000 |
985 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { | 988 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusMaxAverageBitrate) { |
986 EXPECT_TRUE(SetupEngine()); | 989 EXPECT_TRUE(SetupEngineWithSendStream()); |
987 int channel_num = voe_.GetLastChannel(); | 990 int channel_num = voe_.GetLastChannel(); |
988 cricket::AudioSendParameters parameters; | 991 cricket::AudioSendParameters parameters; |
989 parameters.codecs.push_back(kOpusCodec); | 992 parameters.codecs.push_back(kOpusCodec); |
990 parameters.codecs[0].bitrate = 30000; | 993 parameters.codecs[0].bitrate = 30000; |
991 webrtc::CodecInst gcodec; | 994 webrtc::CodecInst gcodec; |
992 | 995 |
993 // Ignore if less than 6000. | 996 // Ignore if less than 6000. |
994 parameters.codecs[0].params["maxaveragebitrate"] = "5999"; | 997 parameters.codecs[0].params["maxaveragebitrate"] = "5999"; |
995 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 998 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
996 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 999 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
997 EXPECT_EQ(6000, gcodec.rate); | 1000 EXPECT_EQ(6000, gcodec.rate); |
998 | 1001 |
999 // Ignore if larger than 510000. | 1002 // Ignore if larger than 510000. |
1000 parameters.codecs[0].params["maxaveragebitrate"] = "510001"; | 1003 parameters.codecs[0].params["maxaveragebitrate"] = "510001"; |
1001 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1004 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1002 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1005 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1003 EXPECT_EQ(510000, gcodec.rate); | 1006 EXPECT_EQ(510000, gcodec.rate); |
1004 | 1007 |
1005 parameters.codecs[0].params["maxaveragebitrate"] = "200000"; | 1008 parameters.codecs[0].params["maxaveragebitrate"] = "200000"; |
1006 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1009 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1007 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1010 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1008 EXPECT_EQ(200000, gcodec.rate); | 1011 EXPECT_EQ(200000, gcodec.rate); |
1009 } | 1012 } |
1010 | 1013 |
1011 // Test that we can enable NACK with opus as caller. | 1014 // Test that we can enable NACK with opus as caller. |
1012 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { | 1015 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCaller) { |
1013 EXPECT_TRUE(SetupEngine()); | 1016 EXPECT_TRUE(SetupEngineWithSendStream()); |
1014 int channel_num = voe_.GetLastChannel(); | 1017 int channel_num = voe_.GetLastChannel(); |
1015 cricket::AudioSendParameters parameters; | 1018 cricket::AudioSendParameters parameters; |
1016 parameters.codecs.push_back(kOpusCodec); | 1019 parameters.codecs.push_back(kOpusCodec); |
1017 parameters.codecs[0].AddFeedbackParam( | 1020 parameters.codecs[0].AddFeedbackParam( |
1018 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1021 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1019 cricket::kParamValueEmpty)); | 1022 cricket::kParamValueEmpty)); |
1020 EXPECT_FALSE(voe_.GetNACK(channel_num)); | 1023 EXPECT_FALSE(voe_.GetNACK(channel_num)); |
1021 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1024 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1022 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1025 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1023 } | 1026 } |
1024 | 1027 |
1025 // Test that we can enable NACK with opus as callee. | 1028 // Test that we can enable NACK with opus as callee. |
1026 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { | 1029 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackAsCallee) { |
1027 EXPECT_TRUE(SetupEngineWithoutStream()); | 1030 EXPECT_TRUE(SetupEngine()); |
1028 int channel_num = voe_.GetLastChannel(); | 1031 int channel_num = voe_.GetLastChannel(); |
1029 cricket::AudioSendParameters parameters; | 1032 cricket::AudioSendParameters parameters; |
1030 parameters.codecs.push_back(kOpusCodec); | 1033 parameters.codecs.push_back(kOpusCodec); |
1031 parameters.codecs[0].AddFeedbackParam( | 1034 parameters.codecs[0].AddFeedbackParam( |
1032 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1035 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1033 cricket::kParamValueEmpty)); | 1036 cricket::kParamValueEmpty)); |
1034 EXPECT_FALSE(voe_.GetNACK(channel_num)); | 1037 EXPECT_FALSE(voe_.GetNACK(channel_num)); |
1035 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1038 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1036 EXPECT_FALSE(voe_.GetNACK(channel_num)); | 1039 EXPECT_FALSE(voe_.GetNACK(channel_num)); |
1037 | 1040 |
1038 EXPECT_TRUE(channel_->AddSendStream( | 1041 EXPECT_TRUE(channel_->AddSendStream( |
1039 cricket::StreamParams::CreateLegacy(kSsrc1))); | 1042 cricket::StreamParams::CreateLegacy(kSsrc1))); |
1040 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1043 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1041 } | 1044 } |
1042 | 1045 |
1043 // Test that we can enable NACK on receive streams. | 1046 // Test that we can enable NACK on receive streams. |
1044 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { | 1047 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecEnableNackRecvStreams) { |
1045 EXPECT_TRUE(SetupEngine()); | 1048 EXPECT_TRUE(SetupEngineWithSendStream()); |
1046 int channel_num1 = voe_.GetLastChannel(); | 1049 int channel_num1 = voe_.GetLastChannel(); |
1047 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 1050 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
1048 int channel_num2 = voe_.GetLastChannel(); | 1051 int channel_num2 = voe_.GetLastChannel(); |
1049 cricket::AudioSendParameters parameters; | 1052 cricket::AudioSendParameters parameters; |
1050 parameters.codecs.push_back(kOpusCodec); | 1053 parameters.codecs.push_back(kOpusCodec); |
1051 parameters.codecs[0].AddFeedbackParam( | 1054 parameters.codecs[0].AddFeedbackParam( |
1052 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1055 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1053 cricket::kParamValueEmpty)); | 1056 cricket::kParamValueEmpty)); |
1054 EXPECT_FALSE(voe_.GetNACK(channel_num1)); | 1057 EXPECT_FALSE(voe_.GetNACK(channel_num1)); |
1055 EXPECT_FALSE(voe_.GetNACK(channel_num2)); | 1058 EXPECT_FALSE(voe_.GetNACK(channel_num2)); |
1056 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1059 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1057 EXPECT_TRUE(voe_.GetNACK(channel_num1)); | 1060 EXPECT_TRUE(voe_.GetNACK(channel_num1)); |
1058 EXPECT_TRUE(voe_.GetNACK(channel_num2)); | 1061 EXPECT_TRUE(voe_.GetNACK(channel_num2)); |
1059 } | 1062 } |
1060 | 1063 |
1061 // Test that we can disable NACK. | 1064 // Test that we can disable NACK. |
1062 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { | 1065 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNack) { |
1063 EXPECT_TRUE(SetupEngine()); | 1066 EXPECT_TRUE(SetupEngineWithSendStream()); |
1064 int channel_num = voe_.GetLastChannel(); | 1067 int channel_num = voe_.GetLastChannel(); |
1065 cricket::AudioSendParameters parameters; | 1068 cricket::AudioSendParameters parameters; |
1066 parameters.codecs.push_back(kOpusCodec); | 1069 parameters.codecs.push_back(kOpusCodec); |
1067 parameters.codecs[0].AddFeedbackParam( | 1070 parameters.codecs[0].AddFeedbackParam( |
1068 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1071 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1069 cricket::kParamValueEmpty)); | 1072 cricket::kParamValueEmpty)); |
1070 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1073 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1071 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1074 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1072 | 1075 |
1073 parameters.codecs.clear(); | 1076 parameters.codecs.clear(); |
1074 parameters.codecs.push_back(kOpusCodec); | 1077 parameters.codecs.push_back(kOpusCodec); |
1075 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1078 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1076 EXPECT_FALSE(voe_.GetNACK(channel_num)); | 1079 EXPECT_FALSE(voe_.GetNACK(channel_num)); |
1077 } | 1080 } |
1078 | 1081 |
1079 // Test that we can disable NACK on receive streams. | 1082 // Test that we can disable NACK on receive streams. |
1080 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { | 1083 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecDisableNackRecvStreams) { |
1081 EXPECT_TRUE(SetupEngine()); | 1084 EXPECT_TRUE(SetupEngineWithSendStream()); |
1082 int channel_num1 = voe_.GetLastChannel(); | 1085 int channel_num1 = voe_.GetLastChannel(); |
1083 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 1086 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
1084 int channel_num2 = voe_.GetLastChannel(); | 1087 int channel_num2 = voe_.GetLastChannel(); |
1085 cricket::AudioSendParameters parameters; | 1088 cricket::AudioSendParameters parameters; |
1086 parameters.codecs.push_back(kOpusCodec); | 1089 parameters.codecs.push_back(kOpusCodec); |
1087 parameters.codecs[0].AddFeedbackParam( | 1090 parameters.codecs[0].AddFeedbackParam( |
1088 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1091 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1089 cricket::kParamValueEmpty)); | 1092 cricket::kParamValueEmpty)); |
1090 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1093 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1091 EXPECT_TRUE(voe_.GetNACK(channel_num1)); | 1094 EXPECT_TRUE(voe_.GetNACK(channel_num1)); |
1092 EXPECT_TRUE(voe_.GetNACK(channel_num2)); | 1095 EXPECT_TRUE(voe_.GetNACK(channel_num2)); |
1093 | 1096 |
1094 parameters.codecs.clear(); | 1097 parameters.codecs.clear(); |
1095 parameters.codecs.push_back(kOpusCodec); | 1098 parameters.codecs.push_back(kOpusCodec); |
1096 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1099 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1097 EXPECT_FALSE(voe_.GetNACK(channel_num1)); | 1100 EXPECT_FALSE(voe_.GetNACK(channel_num1)); |
1098 EXPECT_FALSE(voe_.GetNACK(channel_num2)); | 1101 EXPECT_FALSE(voe_.GetNACK(channel_num2)); |
1099 } | 1102 } |
1100 | 1103 |
1101 // Test that NACK is enabled on a new receive stream. | 1104 // Test that NACK is enabled on a new receive stream. |
1102 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { | 1105 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamEnableNack) { |
1103 EXPECT_TRUE(SetupEngine()); | 1106 EXPECT_TRUE(SetupEngineWithSendStream()); |
1104 int channel_num = voe_.GetLastChannel(); | 1107 int channel_num = voe_.GetLastChannel(); |
1105 cricket::AudioSendParameters parameters; | 1108 cricket::AudioSendParameters parameters; |
1106 parameters.codecs.push_back(kIsacCodec); | 1109 parameters.codecs.push_back(kIsacCodec); |
1107 parameters.codecs.push_back(kCn16000Codec); | 1110 parameters.codecs.push_back(kCn16000Codec); |
1108 parameters.codecs[0].AddFeedbackParam( | 1111 parameters.codecs[0].AddFeedbackParam( |
1109 cricket::FeedbackParam(cricket::kRtcpFbParamNack, | 1112 cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
1110 cricket::kParamValueEmpty)); | 1113 cricket::kParamValueEmpty)); |
1111 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1114 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1112 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1115 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1113 | 1116 |
1114 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 1117 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
1115 channel_num = voe_.GetLastChannel(); | 1118 channel_num = voe_.GetLastChannel(); |
1116 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1119 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1117 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 1120 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
1118 channel_num = voe_.GetLastChannel(); | 1121 channel_num = voe_.GetLastChannel(); |
1119 EXPECT_TRUE(voe_.GetNACK(channel_num)); | 1122 EXPECT_TRUE(voe_.GetNACK(channel_num)); |
1120 } | 1123 } |
1121 | 1124 |
1122 // Test that without useinbandfec, Opus FEC is off. | 1125 // Test that without useinbandfec, Opus FEC is off. |
1123 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { | 1126 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecNoOpusFec) { |
1124 EXPECT_TRUE(SetupEngine()); | 1127 EXPECT_TRUE(SetupEngineWithSendStream()); |
1125 int channel_num = voe_.GetLastChannel(); | 1128 int channel_num = voe_.GetLastChannel(); |
1126 cricket::AudioSendParameters parameters; | 1129 cricket::AudioSendParameters parameters; |
1127 parameters.codecs.push_back(kOpusCodec); | 1130 parameters.codecs.push_back(kOpusCodec); |
1128 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1131 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1129 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1132 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1130 } | 1133 } |
1131 | 1134 |
1132 // Test that with useinbandfec=0, Opus FEC is off. | 1135 // Test that with useinbandfec=0, Opus FEC is off. |
1133 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { | 1136 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusDisableFec) { |
1134 EXPECT_TRUE(SetupEngine()); | 1137 EXPECT_TRUE(SetupEngineWithSendStream()); |
1135 int channel_num = voe_.GetLastChannel(); | 1138 int channel_num = voe_.GetLastChannel(); |
1136 cricket::AudioSendParameters parameters; | 1139 cricket::AudioSendParameters parameters; |
1137 parameters.codecs.push_back(kOpusCodec); | 1140 parameters.codecs.push_back(kOpusCodec); |
1138 parameters.codecs[0].bitrate = 0; | 1141 parameters.codecs[0].bitrate = 0; |
1139 parameters.codecs[0].params["useinbandfec"] = "0"; | 1142 parameters.codecs[0].params["useinbandfec"] = "0"; |
1140 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1143 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1141 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1144 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1142 webrtc::CodecInst gcodec; | 1145 webrtc::CodecInst gcodec; |
1143 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1146 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1144 EXPECT_STREQ("opus", gcodec.plname); | 1147 EXPECT_STREQ("opus", gcodec.plname); |
1145 EXPECT_EQ(1, gcodec.channels); | 1148 EXPECT_EQ(1, gcodec.channels); |
1146 EXPECT_EQ(32000, gcodec.rate); | 1149 EXPECT_EQ(32000, gcodec.rate); |
1147 } | 1150 } |
1148 | 1151 |
1149 // Test that with useinbandfec=1, Opus FEC is on. | 1152 // Test that with useinbandfec=1, Opus FEC is on. |
1150 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { | 1153 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFec) { |
1151 EXPECT_TRUE(SetupEngine()); | 1154 EXPECT_TRUE(SetupEngineWithSendStream()); |
1152 int channel_num = voe_.GetLastChannel(); | 1155 int channel_num = voe_.GetLastChannel(); |
1153 cricket::AudioSendParameters parameters; | 1156 cricket::AudioSendParameters parameters; |
1154 parameters.codecs.push_back(kOpusCodec); | 1157 parameters.codecs.push_back(kOpusCodec); |
1155 parameters.codecs[0].bitrate = 0; | 1158 parameters.codecs[0].bitrate = 0; |
1156 parameters.codecs[0].params["useinbandfec"] = "1"; | 1159 parameters.codecs[0].params["useinbandfec"] = "1"; |
1157 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1160 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1158 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); | 1161 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); |
1159 webrtc::CodecInst gcodec; | 1162 webrtc::CodecInst gcodec; |
1160 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1163 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1161 EXPECT_STREQ("opus", gcodec.plname); | 1164 EXPECT_STREQ("opus", gcodec.plname); |
1162 EXPECT_EQ(1, gcodec.channels); | 1165 EXPECT_EQ(1, gcodec.channels); |
1163 EXPECT_EQ(32000, gcodec.rate); | 1166 EXPECT_EQ(32000, gcodec.rate); |
1164 } | 1167 } |
1165 | 1168 |
1166 // Test that with useinbandfec=1, stereo=1, Opus FEC is on. | 1169 // Test that with useinbandfec=1, stereo=1, Opus FEC is on. |
1167 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { | 1170 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecOpusEnableFecStereo) { |
1168 EXPECT_TRUE(SetupEngine()); | 1171 EXPECT_TRUE(SetupEngineWithSendStream()); |
1169 int channel_num = voe_.GetLastChannel(); | 1172 int channel_num = voe_.GetLastChannel(); |
1170 cricket::AudioSendParameters parameters; | 1173 cricket::AudioSendParameters parameters; |
1171 parameters.codecs.push_back(kOpusCodec); | 1174 parameters.codecs.push_back(kOpusCodec); |
1172 parameters.codecs[0].bitrate = 0; | 1175 parameters.codecs[0].bitrate = 0; |
1173 parameters.codecs[0].params["stereo"] = "1"; | 1176 parameters.codecs[0].params["stereo"] = "1"; |
1174 parameters.codecs[0].params["useinbandfec"] = "1"; | 1177 parameters.codecs[0].params["useinbandfec"] = "1"; |
1175 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1178 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1176 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); | 1179 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); |
1177 webrtc::CodecInst gcodec; | 1180 webrtc::CodecInst gcodec; |
1178 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1181 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1179 EXPECT_STREQ("opus", gcodec.plname); | 1182 EXPECT_STREQ("opus", gcodec.plname); |
1180 EXPECT_EQ(2, gcodec.channels); | 1183 EXPECT_EQ(2, gcodec.channels); |
1181 EXPECT_EQ(64000, gcodec.rate); | 1184 EXPECT_EQ(64000, gcodec.rate); |
1182 } | 1185 } |
1183 | 1186 |
1184 // Test that with non-Opus, codec FEC is off. | 1187 // Test that with non-Opus, codec FEC is off. |
1185 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { | 1188 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacNoFec) { |
1186 EXPECT_TRUE(SetupEngine()); | 1189 EXPECT_TRUE(SetupEngineWithSendStream()); |
1187 int channel_num = voe_.GetLastChannel(); | 1190 int channel_num = voe_.GetLastChannel(); |
1188 cricket::AudioSendParameters parameters; | 1191 cricket::AudioSendParameters parameters; |
1189 parameters.codecs.push_back(kIsacCodec); | 1192 parameters.codecs.push_back(kIsacCodec); |
1190 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1193 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1191 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1194 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1192 } | 1195 } |
1193 | 1196 |
1194 // Test the with non-Opus, even if useinbandfec=1, FEC is off. | 1197 // Test the with non-Opus, even if useinbandfec=1, FEC is off. |
1195 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { | 1198 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecIsacWithParamNoFec) { |
1196 EXPECT_TRUE(SetupEngine()); | 1199 EXPECT_TRUE(SetupEngineWithSendStream()); |
1197 int channel_num = voe_.GetLastChannel(); | 1200 int channel_num = voe_.GetLastChannel(); |
1198 cricket::AudioSendParameters parameters; | 1201 cricket::AudioSendParameters parameters; |
1199 parameters.codecs.push_back(kIsacCodec); | 1202 parameters.codecs.push_back(kIsacCodec); |
1200 parameters.codecs[0].params["useinbandfec"] = "1"; | 1203 parameters.codecs[0].params["useinbandfec"] = "1"; |
1201 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1204 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1202 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1205 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1203 } | 1206 } |
1204 | 1207 |
1205 // Test that Opus FEC status can be changed. | 1208 // Test that Opus FEC status can be changed. |
1206 TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { | 1209 TEST_F(WebRtcVoiceEngineTestFake, ChangeOpusFecStatus) { |
1207 EXPECT_TRUE(SetupEngine()); | 1210 EXPECT_TRUE(SetupEngineWithSendStream()); |
1208 int channel_num = voe_.GetLastChannel(); | 1211 int channel_num = voe_.GetLastChannel(); |
1209 cricket::AudioSendParameters parameters; | 1212 cricket::AudioSendParameters parameters; |
1210 parameters.codecs.push_back(kOpusCodec); | 1213 parameters.codecs.push_back(kOpusCodec); |
1211 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1214 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1212 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); | 1215 EXPECT_FALSE(voe_.GetCodecFEC(channel_num)); |
1213 parameters.codecs[0].params["useinbandfec"] = "1"; | 1216 parameters.codecs[0].params["useinbandfec"] = "1"; |
1214 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1217 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1215 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); | 1218 EXPECT_TRUE(voe_.GetCodecFEC(channel_num)); |
1216 } | 1219 } |
1217 | 1220 |
1218 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. | 1221 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. |
1219 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { | 1222 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { |
1220 EXPECT_TRUE(SetupEngine()); | 1223 EXPECT_TRUE(SetupEngineWithSendStream()); |
1221 int channel_num = voe_.GetLastChannel(); | 1224 int channel_num = voe_.GetLastChannel(); |
1222 cricket::AudioSendParameters parameters; | 1225 cricket::AudioSendParameters parameters; |
1223 parameters.codecs.push_back(kOpusCodec); | 1226 parameters.codecs.push_back(kOpusCodec); |
1224 parameters.codecs[0].bitrate = 0; | 1227 parameters.codecs[0].bitrate = 0; |
1225 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); | 1228 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); |
1226 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1229 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1227 EXPECT_EQ(cricket::kOpusBandwidthNb, | 1230 EXPECT_EQ(cricket::kOpusBandwidthNb, |
1228 voe_.GetMaxEncodingBandwidth(channel_num)); | 1231 voe_.GetMaxEncodingBandwidth(channel_num)); |
1229 webrtc::CodecInst gcodec; | 1232 webrtc::CodecInst gcodec; |
1230 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1233 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1231 EXPECT_STREQ("opus", gcodec.plname); | 1234 EXPECT_STREQ("opus", gcodec.plname); |
1232 | 1235 |
1233 EXPECT_EQ(12000, gcodec.rate); | 1236 EXPECT_EQ(12000, gcodec.rate); |
1234 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1237 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1235 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1238 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1236 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1239 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1237 EXPECT_EQ(24000, gcodec.rate); | 1240 EXPECT_EQ(24000, gcodec.rate); |
1238 } | 1241 } |
1239 | 1242 |
1240 // Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode. | 1243 // Test 8000 < maxplaybackrate <= 12000 triggers Opus medium band mode. |
1241 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { | 1244 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateMb) { |
1242 EXPECT_TRUE(SetupEngine()); | 1245 EXPECT_TRUE(SetupEngineWithSendStream()); |
1243 int channel_num = voe_.GetLastChannel(); | 1246 int channel_num = voe_.GetLastChannel(); |
1244 cricket::AudioSendParameters parameters; | 1247 cricket::AudioSendParameters parameters; |
1245 parameters.codecs.push_back(kOpusCodec); | 1248 parameters.codecs.push_back(kOpusCodec); |
1246 parameters.codecs[0].bitrate = 0; | 1249 parameters.codecs[0].bitrate = 0; |
1247 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001); | 1250 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8001); |
1248 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1251 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1249 EXPECT_EQ(cricket::kOpusBandwidthMb, | 1252 EXPECT_EQ(cricket::kOpusBandwidthMb, |
1250 voe_.GetMaxEncodingBandwidth(channel_num)); | 1253 voe_.GetMaxEncodingBandwidth(channel_num)); |
1251 webrtc::CodecInst gcodec; | 1254 webrtc::CodecInst gcodec; |
1252 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1255 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1253 EXPECT_STREQ("opus", gcodec.plname); | 1256 EXPECT_STREQ("opus", gcodec.plname); |
1254 | 1257 |
1255 EXPECT_EQ(20000, gcodec.rate); | 1258 EXPECT_EQ(20000, gcodec.rate); |
1256 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1259 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1257 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1260 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1258 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1261 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1259 EXPECT_EQ(40000, gcodec.rate); | 1262 EXPECT_EQ(40000, gcodec.rate); |
1260 } | 1263 } |
1261 | 1264 |
1262 // Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode. | 1265 // Test 12000 < maxplaybackrate <= 16000 triggers Opus wide band mode. |
1263 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { | 1266 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateWb) { |
1264 EXPECT_TRUE(SetupEngine()); | 1267 EXPECT_TRUE(SetupEngineWithSendStream()); |
1265 int channel_num = voe_.GetLastChannel(); | 1268 int channel_num = voe_.GetLastChannel(); |
1266 cricket::AudioSendParameters parameters; | 1269 cricket::AudioSendParameters parameters; |
1267 parameters.codecs.push_back(kOpusCodec); | 1270 parameters.codecs.push_back(kOpusCodec); |
1268 parameters.codecs[0].bitrate = 0; | 1271 parameters.codecs[0].bitrate = 0; |
1269 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001); | 1272 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 12001); |
1270 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1273 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1271 EXPECT_EQ(cricket::kOpusBandwidthWb, | 1274 EXPECT_EQ(cricket::kOpusBandwidthWb, |
1272 voe_.GetMaxEncodingBandwidth(channel_num)); | 1275 voe_.GetMaxEncodingBandwidth(channel_num)); |
1273 webrtc::CodecInst gcodec; | 1276 webrtc::CodecInst gcodec; |
1274 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1277 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1275 EXPECT_STREQ("opus", gcodec.plname); | 1278 EXPECT_STREQ("opus", gcodec.plname); |
1276 | 1279 |
1277 EXPECT_EQ(20000, gcodec.rate); | 1280 EXPECT_EQ(20000, gcodec.rate); |
1278 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1281 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1279 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1282 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1280 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1283 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1281 EXPECT_EQ(40000, gcodec.rate); | 1284 EXPECT_EQ(40000, gcodec.rate); |
1282 } | 1285 } |
1283 | 1286 |
1284 // Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode. | 1287 // Test 16000 < maxplaybackrate <= 24000 triggers Opus super wide band mode. |
1285 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { | 1288 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateSwb) { |
1286 EXPECT_TRUE(SetupEngine()); | 1289 EXPECT_TRUE(SetupEngineWithSendStream()); |
1287 int channel_num = voe_.GetLastChannel(); | 1290 int channel_num = voe_.GetLastChannel(); |
1288 cricket::AudioSendParameters parameters; | 1291 cricket::AudioSendParameters parameters; |
1289 parameters.codecs.push_back(kOpusCodec); | 1292 parameters.codecs.push_back(kOpusCodec); |
1290 parameters.codecs[0].bitrate = 0; | 1293 parameters.codecs[0].bitrate = 0; |
1291 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001); | 1294 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 16001); |
1292 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1295 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1293 EXPECT_EQ(cricket::kOpusBandwidthSwb, | 1296 EXPECT_EQ(cricket::kOpusBandwidthSwb, |
1294 voe_.GetMaxEncodingBandwidth(channel_num)); | 1297 voe_.GetMaxEncodingBandwidth(channel_num)); |
1295 webrtc::CodecInst gcodec; | 1298 webrtc::CodecInst gcodec; |
1296 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1299 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1297 EXPECT_STREQ("opus", gcodec.plname); | 1300 EXPECT_STREQ("opus", gcodec.plname); |
1298 | 1301 |
1299 EXPECT_EQ(32000, gcodec.rate); | 1302 EXPECT_EQ(32000, gcodec.rate); |
1300 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1303 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1301 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1304 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1302 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1305 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1303 EXPECT_EQ(64000, gcodec.rate); | 1306 EXPECT_EQ(64000, gcodec.rate); |
1304 } | 1307 } |
1305 | 1308 |
1306 // Test 24000 < maxplaybackrate triggers Opus full band mode. | 1309 // Test 24000 < maxplaybackrate triggers Opus full band mode. |
1307 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { | 1310 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateFb) { |
1308 EXPECT_TRUE(SetupEngine()); | 1311 EXPECT_TRUE(SetupEngineWithSendStream()); |
1309 int channel_num = voe_.GetLastChannel(); | 1312 int channel_num = voe_.GetLastChannel(); |
1310 cricket::AudioSendParameters parameters; | 1313 cricket::AudioSendParameters parameters; |
1311 parameters.codecs.push_back(kOpusCodec); | 1314 parameters.codecs.push_back(kOpusCodec); |
1312 parameters.codecs[0].bitrate = 0; | 1315 parameters.codecs[0].bitrate = 0; |
1313 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001); | 1316 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 24001); |
1314 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1317 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1315 EXPECT_EQ(cricket::kOpusBandwidthFb, | 1318 EXPECT_EQ(cricket::kOpusBandwidthFb, |
1316 voe_.GetMaxEncodingBandwidth(channel_num)); | 1319 voe_.GetMaxEncodingBandwidth(channel_num)); |
1317 webrtc::CodecInst gcodec; | 1320 webrtc::CodecInst gcodec; |
1318 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1321 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1319 EXPECT_STREQ("opus", gcodec.plname); | 1322 EXPECT_STREQ("opus", gcodec.plname); |
1320 | 1323 |
1321 EXPECT_EQ(32000, gcodec.rate); | 1324 EXPECT_EQ(32000, gcodec.rate); |
1322 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); | 1325 parameters.codecs[0].SetParam(cricket::kCodecParamStereo, "1"); |
1323 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1326 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1324 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1327 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1325 EXPECT_EQ(64000, gcodec.rate); | 1328 EXPECT_EQ(64000, gcodec.rate); |
1326 } | 1329 } |
1327 | 1330 |
1328 // Test Opus that without maxplaybackrate, default playback rate is used. | 1331 // Test Opus that without maxplaybackrate, default playback rate is used. |
1329 TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { | 1332 TEST_F(WebRtcVoiceEngineTestFake, DefaultOpusMaxPlaybackRate) { |
1330 EXPECT_TRUE(SetupEngine()); | 1333 EXPECT_TRUE(SetupEngineWithSendStream()); |
1331 int channel_num = voe_.GetLastChannel(); | 1334 int channel_num = voe_.GetLastChannel(); |
1332 cricket::AudioSendParameters parameters; | 1335 cricket::AudioSendParameters parameters; |
1333 parameters.codecs.push_back(kOpusCodec); | 1336 parameters.codecs.push_back(kOpusCodec); |
1334 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1337 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1335 EXPECT_EQ(cricket::kOpusBandwidthFb, | 1338 EXPECT_EQ(cricket::kOpusBandwidthFb, |
1336 voe_.GetMaxEncodingBandwidth(channel_num)); | 1339 voe_.GetMaxEncodingBandwidth(channel_num)); |
1337 } | 1340 } |
1338 | 1341 |
1339 // Test the with non-Opus, maxplaybackrate has no effect. | 1342 // Test the with non-Opus, maxplaybackrate has no effect. |
1340 TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { | 1343 TEST_F(WebRtcVoiceEngineTestFake, SetNonOpusMaxPlaybackRate) { |
1341 EXPECT_TRUE(SetupEngine()); | 1344 EXPECT_TRUE(SetupEngineWithSendStream()); |
1342 int channel_num = voe_.GetLastChannel(); | 1345 int channel_num = voe_.GetLastChannel(); |
1343 cricket::AudioSendParameters parameters; | 1346 cricket::AudioSendParameters parameters; |
1344 parameters.codecs.push_back(kIsacCodec); | 1347 parameters.codecs.push_back(kIsacCodec); |
1345 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000); | 1348 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 32000); |
1346 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1349 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1347 EXPECT_EQ(0, voe_.GetMaxEncodingBandwidth(channel_num)); | 1350 EXPECT_EQ(0, voe_.GetMaxEncodingBandwidth(channel_num)); |
1348 } | 1351 } |
1349 | 1352 |
1350 // Test maxplaybackrate can be set on two streams. | 1353 // Test maxplaybackrate can be set on two streams. |
1351 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { | 1354 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateOnTwoStreams) { |
1352 EXPECT_TRUE(SetupEngine()); | 1355 EXPECT_TRUE(SetupEngineWithSendStream()); |
1353 int channel_num = voe_.GetLastChannel(); | 1356 int channel_num = voe_.GetLastChannel(); |
1354 cricket::AudioSendParameters parameters; | 1357 cricket::AudioSendParameters parameters; |
1355 parameters.codecs.push_back(kOpusCodec); | 1358 parameters.codecs.push_back(kOpusCodec); |
1356 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1359 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1357 // Default bandwidth is 24000. | 1360 // Default bandwidth is 24000. |
1358 EXPECT_EQ(cricket::kOpusBandwidthFb, | 1361 EXPECT_EQ(cricket::kOpusBandwidthFb, |
1359 voe_.GetMaxEncodingBandwidth(channel_num)); | 1362 voe_.GetMaxEncodingBandwidth(channel_num)); |
1360 | 1363 |
1361 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); | 1364 parameters.codecs[0].SetParam(cricket::kCodecParamMaxPlaybackRate, 8000); |
1362 | 1365 |
1363 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1366 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1364 EXPECT_EQ(cricket::kOpusBandwidthNb, | 1367 EXPECT_EQ(cricket::kOpusBandwidthNb, |
1365 voe_.GetMaxEncodingBandwidth(channel_num)); | 1368 voe_.GetMaxEncodingBandwidth(channel_num)); |
1366 | 1369 |
1367 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc2)); | 1370 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc2)); |
1368 channel_num = voe_.GetLastChannel(); | 1371 channel_num = voe_.GetLastChannel(); |
1369 EXPECT_EQ(cricket::kOpusBandwidthNb, | 1372 EXPECT_EQ(cricket::kOpusBandwidthNb, |
1370 voe_.GetMaxEncodingBandwidth(channel_num)); | 1373 voe_.GetMaxEncodingBandwidth(channel_num)); |
1371 } | 1374 } |
1372 | 1375 |
1373 // Test that with usedtx=0, Opus DTX is off. | 1376 // Test that with usedtx=0, Opus DTX is off. |
1374 TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { | 1377 TEST_F(WebRtcVoiceEngineTestFake, DisableOpusDtxOnOpus) { |
1375 EXPECT_TRUE(SetupEngine()); | 1378 EXPECT_TRUE(SetupEngineWithSendStream()); |
1376 int channel_num = voe_.GetLastChannel(); | 1379 int channel_num = voe_.GetLastChannel(); |
1377 cricket::AudioSendParameters parameters; | 1380 cricket::AudioSendParameters parameters; |
1378 parameters.codecs.push_back(kOpusCodec); | 1381 parameters.codecs.push_back(kOpusCodec); |
1379 parameters.codecs[0].params["usedtx"] = "0"; | 1382 parameters.codecs[0].params["usedtx"] = "0"; |
1380 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1383 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1381 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); | 1384 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); |
1382 } | 1385 } |
1383 | 1386 |
1384 // Test that with usedtx=1, Opus DTX is on. | 1387 // Test that with usedtx=1, Opus DTX is on. |
1385 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { | 1388 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpus) { |
1386 EXPECT_TRUE(SetupEngine()); | 1389 EXPECT_TRUE(SetupEngineWithSendStream()); |
1387 int channel_num = voe_.GetLastChannel(); | 1390 int channel_num = voe_.GetLastChannel(); |
1388 cricket::AudioSendParameters parameters; | 1391 cricket::AudioSendParameters parameters; |
1389 parameters.codecs.push_back(kOpusCodec); | 1392 parameters.codecs.push_back(kOpusCodec); |
1390 parameters.codecs[0].params["usedtx"] = "1"; | 1393 parameters.codecs[0].params["usedtx"] = "1"; |
1391 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1394 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1392 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); | 1395 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); |
1393 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. | 1396 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. |
1394 } | 1397 } |
1395 | 1398 |
1396 // Test that usedtx=1 works with stereo Opus. | 1399 // Test that usedtx=1 works with stereo Opus. |
1397 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { | 1400 TEST_F(WebRtcVoiceEngineTestFake, EnableOpusDtxOnOpusStereo) { |
1398 EXPECT_TRUE(SetupEngine()); | 1401 EXPECT_TRUE(SetupEngineWithSendStream()); |
1399 int channel_num = voe_.GetLastChannel(); | 1402 int channel_num = voe_.GetLastChannel(); |
1400 cricket::AudioSendParameters parameters; | 1403 cricket::AudioSendParameters parameters; |
1401 parameters.codecs.push_back(kOpusCodec); | 1404 parameters.codecs.push_back(kOpusCodec); |
1402 parameters.codecs[0].params["usedtx"] = "1"; | 1405 parameters.codecs[0].params["usedtx"] = "1"; |
1403 parameters.codecs[0].params["stereo"] = "1"; | 1406 parameters.codecs[0].params["stereo"] = "1"; |
1404 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1407 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1405 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); | 1408 EXPECT_TRUE(voe_.GetOpusDtx(channel_num)); |
1406 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. | 1409 EXPECT_FALSE(voe_.GetVAD(channel_num)); // Opus DTX should not affect VAD. |
1407 } | 1410 } |
1408 | 1411 |
1409 // Test that usedtx=1 does not work with non Opus. | 1412 // Test that usedtx=1 does not work with non Opus. |
1410 TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { | 1413 TEST_F(WebRtcVoiceEngineTestFake, CannotEnableOpusDtxOnNonOpus) { |
1411 EXPECT_TRUE(SetupEngine()); | 1414 EXPECT_TRUE(SetupEngineWithSendStream()); |
1412 int channel_num = voe_.GetLastChannel(); | 1415 int channel_num = voe_.GetLastChannel(); |
1413 cricket::AudioSendParameters parameters; | 1416 cricket::AudioSendParameters parameters; |
1414 parameters.codecs.push_back(kIsacCodec); | 1417 parameters.codecs.push_back(kIsacCodec); |
1415 parameters.codecs[0].params["usedtx"] = "1"; | 1418 parameters.codecs[0].params["usedtx"] = "1"; |
1416 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1419 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1417 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); | 1420 EXPECT_FALSE(voe_.GetOpusDtx(channel_num)); |
1418 } | 1421 } |
1419 | 1422 |
1420 // Test that we can switch back and forth between Opus and ISAC with CN. | 1423 // Test that we can switch back and forth between Opus and ISAC with CN. |
1421 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { | 1424 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsIsacOpusSwitching) { |
1422 EXPECT_TRUE(SetupEngine()); | 1425 EXPECT_TRUE(SetupEngineWithSendStream()); |
1423 int channel_num = voe_.GetLastChannel(); | 1426 int channel_num = voe_.GetLastChannel(); |
1424 cricket::AudioSendParameters opus_parameters; | 1427 cricket::AudioSendParameters opus_parameters; |
1425 opus_parameters.codecs.push_back(kOpusCodec); | 1428 opus_parameters.codecs.push_back(kOpusCodec); |
1426 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); | 1429 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); |
1427 webrtc::CodecInst gcodec; | 1430 webrtc::CodecInst gcodec; |
1428 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1431 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1429 EXPECT_EQ(111, gcodec.pltype); | 1432 EXPECT_EQ(111, gcodec.pltype); |
1430 EXPECT_STREQ("opus", gcodec.plname); | 1433 EXPECT_STREQ("opus", gcodec.plname); |
1431 | 1434 |
1432 cricket::AudioSendParameters isac_parameters; | 1435 cricket::AudioSendParameters isac_parameters; |
1433 isac_parameters.codecs.push_back(kIsacCodec); | 1436 isac_parameters.codecs.push_back(kIsacCodec); |
1434 isac_parameters.codecs.push_back(kCn16000Codec); | 1437 isac_parameters.codecs.push_back(kCn16000Codec); |
1435 isac_parameters.codecs.push_back(kOpusCodec); | 1438 isac_parameters.codecs.push_back(kOpusCodec); |
1436 EXPECT_TRUE(channel_->SetSendParameters(isac_parameters)); | 1439 EXPECT_TRUE(channel_->SetSendParameters(isac_parameters)); |
1437 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1440 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1438 EXPECT_EQ(103, gcodec.pltype); | 1441 EXPECT_EQ(103, gcodec.pltype); |
1439 EXPECT_STREQ("ISAC", gcodec.plname); | 1442 EXPECT_STREQ("ISAC", gcodec.plname); |
1440 | 1443 |
1441 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); | 1444 EXPECT_TRUE(channel_->SetSendParameters(opus_parameters)); |
1442 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1445 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1443 EXPECT_EQ(111, gcodec.pltype); | 1446 EXPECT_EQ(111, gcodec.pltype); |
1444 EXPECT_STREQ("opus", gcodec.plname); | 1447 EXPECT_STREQ("opus", gcodec.plname); |
1445 } | 1448 } |
1446 | 1449 |
1447 // Test that we handle various ways of specifying bitrate. | 1450 // Test that we handle various ways of specifying bitrate. |
1448 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { | 1451 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBitrate) { |
1449 EXPECT_TRUE(SetupEngine()); | 1452 EXPECT_TRUE(SetupEngineWithSendStream()); |
1450 int channel_num = voe_.GetLastChannel(); | 1453 int channel_num = voe_.GetLastChannel(); |
1451 cricket::AudioSendParameters parameters; | 1454 cricket::AudioSendParameters parameters; |
1452 parameters.codecs.push_back(kIsacCodec); // bitrate == 32000 | 1455 parameters.codecs.push_back(kIsacCodec); // bitrate == 32000 |
1453 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1456 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1454 webrtc::CodecInst gcodec; | 1457 webrtc::CodecInst gcodec; |
1455 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1458 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1456 EXPECT_EQ(103, gcodec.pltype); | 1459 EXPECT_EQ(103, gcodec.pltype); |
1457 EXPECT_STREQ("ISAC", gcodec.plname); | 1460 EXPECT_STREQ("ISAC", gcodec.plname); |
1458 EXPECT_EQ(32000, gcodec.rate); | 1461 EXPECT_EQ(32000, gcodec.rate); |
1459 | 1462 |
(...skipping 29 matching lines...) Expand all Loading... |
1489 parameters.codecs[0].bitrate = 0; // bitrate == default | 1492 parameters.codecs[0].bitrate = 0; // bitrate == default |
1490 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1493 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1491 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1494 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1492 EXPECT_EQ(111, gcodec.pltype); | 1495 EXPECT_EQ(111, gcodec.pltype); |
1493 EXPECT_STREQ("opus", gcodec.plname); | 1496 EXPECT_STREQ("opus", gcodec.plname); |
1494 EXPECT_EQ(32000, gcodec.rate); | 1497 EXPECT_EQ(32000, gcodec.rate); |
1495 } | 1498 } |
1496 | 1499 |
1497 // Test that we could set packet size specified in kCodecParamPTime. | 1500 // Test that we could set packet size specified in kCodecParamPTime. |
1498 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { | 1501 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsPTimeAsPacketSize) { |
1499 EXPECT_TRUE(SetupEngine()); | 1502 EXPECT_TRUE(SetupEngineWithSendStream()); |
1500 int channel_num = voe_.GetLastChannel(); | 1503 int channel_num = voe_.GetLastChannel(); |
1501 cricket::AudioSendParameters parameters; | 1504 cricket::AudioSendParameters parameters; |
1502 parameters.codecs.push_back(kOpusCodec); | 1505 parameters.codecs.push_back(kOpusCodec); |
1503 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range. | 1506 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); // Within range. |
1504 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1507 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1505 webrtc::CodecInst gcodec; | 1508 webrtc::CodecInst gcodec; |
1506 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1509 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1507 EXPECT_EQ(1920, gcodec.pacsize); // Opus gets 40ms. | 1510 EXPECT_EQ(1920, gcodec.pacsize); // Opus gets 40ms. |
1508 | 1511 |
1509 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Below range. | 1512 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 5); // Below range. |
(...skipping 14 matching lines...) Expand all Loading... |
1524 | 1527 |
1525 parameters.codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP. | 1528 parameters.codecs[0] = kG722CodecSdp; // Try G722 @8kHz as negotiated in SDP. |
1526 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); | 1529 parameters.codecs[0].SetParam(cricket::kCodecParamPTime, 40); |
1527 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1530 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1528 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1531 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1529 EXPECT_EQ(640, gcodec.pacsize); // G722 gets 40ms @16kHz as defined in VoE. | 1532 EXPECT_EQ(640, gcodec.pacsize); // G722 gets 40ms @16kHz as defined in VoE. |
1530 } | 1533 } |
1531 | 1534 |
1532 // Test that we fail if no codecs are specified. | 1535 // Test that we fail if no codecs are specified. |
1533 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { | 1536 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsNoCodecs) { |
1534 EXPECT_TRUE(SetupEngine()); | 1537 EXPECT_TRUE(SetupEngineWithSendStream()); |
1535 cricket::AudioSendParameters parameters; | 1538 cricket::AudioSendParameters parameters; |
1536 EXPECT_FALSE(channel_->SetSendParameters(parameters)); | 1539 EXPECT_FALSE(channel_->SetSendParameters(parameters)); |
1537 } | 1540 } |
1538 | 1541 |
1539 // Test that we can set send codecs even with telephone-event codec as the first | 1542 // Test that we can set send codecs even with telephone-event codec as the first |
1540 // one on the list. | 1543 // one on the list. |
1541 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { | 1544 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsDTMFOnTop) { |
1542 EXPECT_TRUE(SetupEngine()); | 1545 EXPECT_TRUE(SetupEngineWithSendStream()); |
1543 int channel_num = voe_.GetLastChannel(); | 1546 int channel_num = voe_.GetLastChannel(); |
1544 cricket::AudioSendParameters parameters; | 1547 cricket::AudioSendParameters parameters; |
1545 parameters.codecs.push_back(kTelephoneEventCodec); | 1548 parameters.codecs.push_back(kTelephoneEventCodec); |
1546 parameters.codecs.push_back(kIsacCodec); | 1549 parameters.codecs.push_back(kIsacCodec); |
1547 parameters.codecs.push_back(kPcmuCodec); | 1550 parameters.codecs.push_back(kPcmuCodec); |
1548 parameters.codecs[0].id = 98; // DTMF | 1551 parameters.codecs[0].id = 98; // DTMF |
1549 parameters.codecs[1].id = 96; | 1552 parameters.codecs[1].id = 96; |
1550 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1553 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1551 webrtc::CodecInst gcodec; | 1554 webrtc::CodecInst gcodec; |
1552 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1555 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1553 EXPECT_EQ(96, gcodec.pltype); | 1556 EXPECT_EQ(96, gcodec.pltype); |
1554 EXPECT_STREQ("ISAC", gcodec.plname); | 1557 EXPECT_STREQ("ISAC", gcodec.plname); |
1555 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); | 1558 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); |
1556 } | 1559 } |
1557 | 1560 |
1558 // Test that we can set send codecs even with CN codec as the first | 1561 // Test that we can set send codecs even with CN codec as the first |
1559 // one on the list. | 1562 // one on the list. |
1560 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { | 1563 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNOnTop) { |
1561 EXPECT_TRUE(SetupEngine()); | 1564 EXPECT_TRUE(SetupEngineWithSendStream()); |
1562 int channel_num = voe_.GetLastChannel(); | 1565 int channel_num = voe_.GetLastChannel(); |
1563 cricket::AudioSendParameters parameters; | 1566 cricket::AudioSendParameters parameters; |
1564 parameters.codecs.push_back(kCn16000Codec); | 1567 parameters.codecs.push_back(kCn16000Codec); |
1565 parameters.codecs.push_back(kIsacCodec); | 1568 parameters.codecs.push_back(kIsacCodec); |
1566 parameters.codecs.push_back(kPcmuCodec); | 1569 parameters.codecs.push_back(kPcmuCodec); |
1567 parameters.codecs[0].id = 98; // wideband CN | 1570 parameters.codecs[0].id = 98; // wideband CN |
1568 parameters.codecs[1].id = 96; | 1571 parameters.codecs[1].id = 96; |
1569 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1572 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1570 webrtc::CodecInst gcodec; | 1573 webrtc::CodecInst gcodec; |
1571 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1574 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1572 EXPECT_EQ(96, gcodec.pltype); | 1575 EXPECT_EQ(96, gcodec.pltype); |
1573 EXPECT_STREQ("ISAC", gcodec.plname); | 1576 EXPECT_STREQ("ISAC", gcodec.plname); |
1574 EXPECT_EQ(98, voe_.GetSendCNPayloadType(channel_num, true)); | 1577 EXPECT_EQ(98, voe_.GetSendCNPayloadType(channel_num, true)); |
1575 } | 1578 } |
1576 | 1579 |
1577 // Test that we set VAD and DTMF types correctly as caller. | 1580 // Test that we set VAD and DTMF types correctly as caller. |
1578 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { | 1581 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNandDTMFAsCaller) { |
1579 EXPECT_TRUE(SetupEngine()); | 1582 EXPECT_TRUE(SetupEngineWithSendStream()); |
1580 int channel_num = voe_.GetLastChannel(); | 1583 int channel_num = voe_.GetLastChannel(); |
1581 cricket::AudioSendParameters parameters; | 1584 cricket::AudioSendParameters parameters; |
1582 parameters.codecs.push_back(kIsacCodec); | 1585 parameters.codecs.push_back(kIsacCodec); |
1583 parameters.codecs.push_back(kPcmuCodec); | 1586 parameters.codecs.push_back(kPcmuCodec); |
1584 // TODO(juberti): cn 32000 | 1587 // TODO(juberti): cn 32000 |
1585 parameters.codecs.push_back(kCn16000Codec); | 1588 parameters.codecs.push_back(kCn16000Codec); |
1586 parameters.codecs.push_back(kCn8000Codec); | 1589 parameters.codecs.push_back(kCn8000Codec); |
1587 parameters.codecs.push_back(kTelephoneEventCodec); | 1590 parameters.codecs.push_back(kTelephoneEventCodec); |
1588 parameters.codecs.push_back(kRedCodec); | 1591 parameters.codecs.push_back(kRedCodec); |
1589 parameters.codecs[0].id = 96; | 1592 parameters.codecs[0].id = 96; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 EXPECT_TRUE(voe_.GetVAD(channel_num)); | 1633 EXPECT_TRUE(voe_.GetVAD(channel_num)); |
1631 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1634 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1632 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); | 1635 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); |
1633 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); | 1636 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); |
1634 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); | 1637 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); |
1635 } | 1638 } |
1636 | 1639 |
1637 // Test that we only apply VAD if we have a CN codec that matches the | 1640 // Test that we only apply VAD if we have a CN codec that matches the |
1638 // send codec clockrate. | 1641 // send codec clockrate. |
1639 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { | 1642 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCNNoMatch) { |
1640 EXPECT_TRUE(SetupEngine()); | 1643 EXPECT_TRUE(SetupEngineWithSendStream()); |
1641 int channel_num = voe_.GetLastChannel(); | 1644 int channel_num = voe_.GetLastChannel(); |
1642 cricket::AudioSendParameters parameters; | 1645 cricket::AudioSendParameters parameters; |
1643 // Set ISAC(16K) and CN(16K). VAD should be activated. | 1646 // Set ISAC(16K) and CN(16K). VAD should be activated. |
1644 parameters.codecs.push_back(kIsacCodec); | 1647 parameters.codecs.push_back(kIsacCodec); |
1645 parameters.codecs.push_back(kCn16000Codec); | 1648 parameters.codecs.push_back(kCn16000Codec); |
1646 parameters.codecs[1].id = 97; | 1649 parameters.codecs[1].id = 97; |
1647 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1650 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1648 webrtc::CodecInst gcodec; | 1651 webrtc::CodecInst gcodec; |
1649 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1652 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1650 EXPECT_STREQ("ISAC", gcodec.plname); | 1653 EXPECT_STREQ("ISAC", gcodec.plname); |
(...skipping 15 matching lines...) Expand all Loading... |
1666 // Set ISAC(16K) and CN(8K). VAD should not be activated. | 1669 // Set ISAC(16K) and CN(8K). VAD should not be activated. |
1667 parameters.codecs[0] = kIsacCodec; | 1670 parameters.codecs[0] = kIsacCodec; |
1668 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1671 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1669 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1672 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1670 EXPECT_STREQ("ISAC", gcodec.plname); | 1673 EXPECT_STREQ("ISAC", gcodec.plname); |
1671 EXPECT_FALSE(voe_.GetVAD(channel_num)); | 1674 EXPECT_FALSE(voe_.GetVAD(channel_num)); |
1672 } | 1675 } |
1673 | 1676 |
1674 // Test that we perform case-insensitive matching of codec names. | 1677 // Test that we perform case-insensitive matching of codec names. |
1675 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { | 1678 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsCaseInsensitive) { |
1676 EXPECT_TRUE(SetupEngine()); | 1679 EXPECT_TRUE(SetupEngineWithSendStream()); |
1677 int channel_num = voe_.GetLastChannel(); | 1680 int channel_num = voe_.GetLastChannel(); |
1678 cricket::AudioSendParameters parameters; | 1681 cricket::AudioSendParameters parameters; |
1679 parameters.codecs.push_back(kIsacCodec); | 1682 parameters.codecs.push_back(kIsacCodec); |
1680 parameters.codecs.push_back(kPcmuCodec); | 1683 parameters.codecs.push_back(kPcmuCodec); |
1681 parameters.codecs.push_back(kCn16000Codec); | 1684 parameters.codecs.push_back(kCn16000Codec); |
1682 parameters.codecs.push_back(kCn8000Codec); | 1685 parameters.codecs.push_back(kCn8000Codec); |
1683 parameters.codecs.push_back(kTelephoneEventCodec); | 1686 parameters.codecs.push_back(kTelephoneEventCodec); |
1684 parameters.codecs.push_back(kRedCodec); | 1687 parameters.codecs.push_back(kRedCodec); |
1685 parameters.codecs[0].name = "iSaC"; | 1688 parameters.codecs[0].name = "iSaC"; |
1686 parameters.codecs[0].id = 96; | 1689 parameters.codecs[0].id = 96; |
1687 parameters.codecs[2].id = 97; // wideband CN | 1690 parameters.codecs[2].id = 97; // wideband CN |
1688 parameters.codecs[4].id = 98; // DTMF | 1691 parameters.codecs[4].id = 98; // DTMF |
1689 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1692 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1690 webrtc::CodecInst gcodec; | 1693 webrtc::CodecInst gcodec; |
1691 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1694 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1692 EXPECT_EQ(96, gcodec.pltype); | 1695 EXPECT_EQ(96, gcodec.pltype); |
1693 EXPECT_STREQ("ISAC", gcodec.plname); | 1696 EXPECT_STREQ("ISAC", gcodec.plname); |
1694 EXPECT_TRUE(voe_.GetVAD(channel_num)); | 1697 EXPECT_TRUE(voe_.GetVAD(channel_num)); |
1695 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1698 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1696 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); | 1699 EXPECT_EQ(13, voe_.GetSendCNPayloadType(channel_num, false)); |
1697 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); | 1700 EXPECT_EQ(97, voe_.GetSendCNPayloadType(channel_num, true)); |
1698 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); | 1701 EXPECT_EQ(98, voe_.GetSendTelephoneEventPayloadType(channel_num)); |
1699 } | 1702 } |
1700 | 1703 |
1701 // Test that we set up RED correctly as caller. | 1704 // Test that we set up RED correctly as caller. |
1702 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) { | 1705 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDAsCaller) { |
1703 EXPECT_TRUE(SetupEngine()); | 1706 EXPECT_TRUE(SetupEngineWithSendStream()); |
1704 int channel_num = voe_.GetLastChannel(); | 1707 int channel_num = voe_.GetLastChannel(); |
1705 cricket::AudioSendParameters parameters; | 1708 cricket::AudioSendParameters parameters; |
1706 parameters.codecs.push_back(kRedCodec); | 1709 parameters.codecs.push_back(kRedCodec); |
1707 parameters.codecs.push_back(kIsacCodec); | 1710 parameters.codecs.push_back(kIsacCodec); |
1708 parameters.codecs.push_back(kPcmuCodec); | 1711 parameters.codecs.push_back(kPcmuCodec); |
1709 parameters.codecs[0].id = 127; | 1712 parameters.codecs[0].id = 127; |
1710 parameters.codecs[0].params[""] = "96/96"; | 1713 parameters.codecs[0].params[""] = "96/96"; |
1711 parameters.codecs[1].id = 96; | 1714 parameters.codecs[1].id = 96; |
1712 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1715 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1713 webrtc::CodecInst gcodec; | 1716 webrtc::CodecInst gcodec; |
(...skipping 24 matching lines...) Expand all Loading... |
1738 webrtc::CodecInst gcodec; | 1741 webrtc::CodecInst gcodec; |
1739 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1742 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1740 EXPECT_EQ(96, gcodec.pltype); | 1743 EXPECT_EQ(96, gcodec.pltype); |
1741 EXPECT_STREQ("ISAC", gcodec.plname); | 1744 EXPECT_STREQ("ISAC", gcodec.plname); |
1742 EXPECT_TRUE(voe_.GetRED(channel_num)); | 1745 EXPECT_TRUE(voe_.GetRED(channel_num)); |
1743 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); | 1746 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); |
1744 } | 1747 } |
1745 | 1748 |
1746 // Test that we set up RED correctly if params are omitted. | 1749 // Test that we set up RED correctly if params are omitted. |
1747 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { | 1750 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsREDNoParams) { |
1748 EXPECT_TRUE(SetupEngine()); | 1751 EXPECT_TRUE(SetupEngineWithSendStream()); |
1749 int channel_num = voe_.GetLastChannel(); | 1752 int channel_num = voe_.GetLastChannel(); |
1750 cricket::AudioSendParameters parameters; | 1753 cricket::AudioSendParameters parameters; |
1751 parameters.codecs.push_back(kRedCodec); | 1754 parameters.codecs.push_back(kRedCodec); |
1752 parameters.codecs.push_back(kIsacCodec); | 1755 parameters.codecs.push_back(kIsacCodec); |
1753 parameters.codecs.push_back(kPcmuCodec); | 1756 parameters.codecs.push_back(kPcmuCodec); |
1754 parameters.codecs[0].id = 127; | 1757 parameters.codecs[0].id = 127; |
1755 parameters.codecs[1].id = 96; | 1758 parameters.codecs[1].id = 96; |
1756 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1759 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1757 webrtc::CodecInst gcodec; | 1760 webrtc::CodecInst gcodec; |
1758 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1761 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1759 EXPECT_EQ(96, gcodec.pltype); | 1762 EXPECT_EQ(96, gcodec.pltype); |
1760 EXPECT_STREQ("ISAC", gcodec.plname); | 1763 EXPECT_STREQ("ISAC", gcodec.plname); |
1761 EXPECT_TRUE(voe_.GetRED(channel_num)); | 1764 EXPECT_TRUE(voe_.GetRED(channel_num)); |
1762 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); | 1765 EXPECT_EQ(127, voe_.GetSendREDPayloadType(channel_num)); |
1763 } | 1766 } |
1764 | 1767 |
1765 // Test that we ignore RED if the parameters aren't named the way we expect. | 1768 // Test that we ignore RED if the parameters aren't named the way we expect. |
1766 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { | 1769 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED1) { |
1767 EXPECT_TRUE(SetupEngine()); | 1770 EXPECT_TRUE(SetupEngineWithSendStream()); |
1768 int channel_num = voe_.GetLastChannel(); | 1771 int channel_num = voe_.GetLastChannel(); |
1769 cricket::AudioSendParameters parameters; | 1772 cricket::AudioSendParameters parameters; |
1770 parameters.codecs.push_back(kRedCodec); | 1773 parameters.codecs.push_back(kRedCodec); |
1771 parameters.codecs.push_back(kIsacCodec); | 1774 parameters.codecs.push_back(kIsacCodec); |
1772 parameters.codecs.push_back(kPcmuCodec); | 1775 parameters.codecs.push_back(kPcmuCodec); |
1773 parameters.codecs[0].id = 127; | 1776 parameters.codecs[0].id = 127; |
1774 parameters.codecs[0].params["ABC"] = "96/96"; | 1777 parameters.codecs[0].params["ABC"] = "96/96"; |
1775 parameters.codecs[1].id = 96; | 1778 parameters.codecs[1].id = 96; |
1776 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1779 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1777 webrtc::CodecInst gcodec; | 1780 webrtc::CodecInst gcodec; |
1778 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1781 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1779 EXPECT_EQ(96, gcodec.pltype); | 1782 EXPECT_EQ(96, gcodec.pltype); |
1780 EXPECT_STREQ("ISAC", gcodec.plname); | 1783 EXPECT_STREQ("ISAC", gcodec.plname); |
1781 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1784 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1782 } | 1785 } |
1783 | 1786 |
1784 // Test that we ignore RED if it uses different primary/secondary encoding. | 1787 // Test that we ignore RED if it uses different primary/secondary encoding. |
1785 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { | 1788 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED2) { |
1786 EXPECT_TRUE(SetupEngine()); | 1789 EXPECT_TRUE(SetupEngineWithSendStream()); |
1787 int channel_num = voe_.GetLastChannel(); | 1790 int channel_num = voe_.GetLastChannel(); |
1788 cricket::AudioSendParameters parameters; | 1791 cricket::AudioSendParameters parameters; |
1789 parameters.codecs.push_back(kRedCodec); | 1792 parameters.codecs.push_back(kRedCodec); |
1790 parameters.codecs.push_back(kIsacCodec); | 1793 parameters.codecs.push_back(kIsacCodec); |
1791 parameters.codecs.push_back(kPcmuCodec); | 1794 parameters.codecs.push_back(kPcmuCodec); |
1792 parameters.codecs[0].id = 127; | 1795 parameters.codecs[0].id = 127; |
1793 parameters.codecs[0].params[""] = "96/0"; | 1796 parameters.codecs[0].params[""] = "96/0"; |
1794 parameters.codecs[1].id = 96; | 1797 parameters.codecs[1].id = 96; |
1795 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1798 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1796 webrtc::CodecInst gcodec; | 1799 webrtc::CodecInst gcodec; |
1797 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1800 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1798 EXPECT_EQ(96, gcodec.pltype); | 1801 EXPECT_EQ(96, gcodec.pltype); |
1799 EXPECT_STREQ("ISAC", gcodec.plname); | 1802 EXPECT_STREQ("ISAC", gcodec.plname); |
1800 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1803 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1801 } | 1804 } |
1802 | 1805 |
1803 // Test that we ignore RED if it uses more than 2 encodings. | 1806 // Test that we ignore RED if it uses more than 2 encodings. |
1804 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { | 1807 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED3) { |
1805 EXPECT_TRUE(SetupEngine()); | 1808 EXPECT_TRUE(SetupEngineWithSendStream()); |
1806 int channel_num = voe_.GetLastChannel(); | 1809 int channel_num = voe_.GetLastChannel(); |
1807 cricket::AudioSendParameters parameters; | 1810 cricket::AudioSendParameters parameters; |
1808 parameters.codecs.push_back(kRedCodec); | 1811 parameters.codecs.push_back(kRedCodec); |
1809 parameters.codecs.push_back(kIsacCodec); | 1812 parameters.codecs.push_back(kIsacCodec); |
1810 parameters.codecs.push_back(kPcmuCodec); | 1813 parameters.codecs.push_back(kPcmuCodec); |
1811 parameters.codecs[0].id = 127; | 1814 parameters.codecs[0].id = 127; |
1812 parameters.codecs[0].params[""] = "96/96/96"; | 1815 parameters.codecs[0].params[""] = "96/96/96"; |
1813 parameters.codecs[1].id = 96; | 1816 parameters.codecs[1].id = 96; |
1814 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1817 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1815 webrtc::CodecInst gcodec; | 1818 webrtc::CodecInst gcodec; |
1816 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1819 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1817 EXPECT_EQ(96, gcodec.pltype); | 1820 EXPECT_EQ(96, gcodec.pltype); |
1818 EXPECT_STREQ("ISAC", gcodec.plname); | 1821 EXPECT_STREQ("ISAC", gcodec.plname); |
1819 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1822 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1820 } | 1823 } |
1821 | 1824 |
1822 // Test that we ignore RED if it has bogus codec ids. | 1825 // Test that we ignore RED if it has bogus codec ids. |
1823 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { | 1826 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED4) { |
1824 EXPECT_TRUE(SetupEngine()); | 1827 EXPECT_TRUE(SetupEngineWithSendStream()); |
1825 int channel_num = voe_.GetLastChannel(); | 1828 int channel_num = voe_.GetLastChannel(); |
1826 cricket::AudioSendParameters parameters; | 1829 cricket::AudioSendParameters parameters; |
1827 parameters.codecs.push_back(kRedCodec); | 1830 parameters.codecs.push_back(kRedCodec); |
1828 parameters.codecs.push_back(kIsacCodec); | 1831 parameters.codecs.push_back(kIsacCodec); |
1829 parameters.codecs.push_back(kPcmuCodec); | 1832 parameters.codecs.push_back(kPcmuCodec); |
1830 parameters.codecs[0].id = 127; | 1833 parameters.codecs[0].id = 127; |
1831 parameters.codecs[0].params[""] = "ABC/ABC"; | 1834 parameters.codecs[0].params[""] = "ABC/ABC"; |
1832 parameters.codecs[1].id = 96; | 1835 parameters.codecs[1].id = 96; |
1833 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1836 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1834 webrtc::CodecInst gcodec; | 1837 webrtc::CodecInst gcodec; |
1835 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); | 1838 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, gcodec)); |
1836 EXPECT_EQ(96, gcodec.pltype); | 1839 EXPECT_EQ(96, gcodec.pltype); |
1837 EXPECT_STREQ("ISAC", gcodec.plname); | 1840 EXPECT_STREQ("ISAC", gcodec.plname); |
1838 EXPECT_FALSE(voe_.GetRED(channel_num)); | 1841 EXPECT_FALSE(voe_.GetRED(channel_num)); |
1839 } | 1842 } |
1840 | 1843 |
1841 // Test that we ignore RED if it refers to a codec that is not present. | 1844 // Test that we ignore RED if it refers to a codec that is not present. |
1842 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) { | 1845 TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsBadRED5) { |
1843 EXPECT_TRUE(SetupEngine()); | 1846 EXPECT_TRUE(SetupEngineWithSendStream()); |
1844 int channel_num = voe_.GetLastChannel(); | 1847 int channel_num = voe_.GetLastChannel(); |
1845 cricket::AudioSendParameters parameters; | 1848 cricket::AudioSendParameters parameters; |
1846 parameters.codecs.push_back(kRedCodec); | 1849 parameters.codecs.push_back(kRedCodec); |
1847 parameters.codecs.push_back(kIsacCodec); | 1850 parameters.codecs.push_back(kIsacCodec); |
1848 parameters.codecs.push_back(kPcmuCodec); | 1851 parameters.codecs.push_back(kPcmuCodec); |
1849 parameters.codecs[0].id = 127; | 1852 parameters.codecs[0].id = 127; |
1850 parameters.codecs[0].params[""] = "97/97"; | 1853 parameters.codecs[0].params[""] = "97/97"; |
1851 parameters.codecs[1].id = 96; | 1854 parameters.codecs[1].id = 96; |
1852 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1855 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1853 webrtc::CodecInst gcodec; | 1856 webrtc::CodecInst gcodec; |
(...skipping 12 matching lines...) Expand all Loading... |
1866 } | 1869 } |
1867 | 1870 |
1868 // Test support for absolute send time header extension. | 1871 // Test support for absolute send time header extension. |
1869 TEST_F(WebRtcVoiceEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) { | 1872 TEST_F(WebRtcVoiceEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) { |
1870 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); | 1873 TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); |
1871 } | 1874 } |
1872 TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { | 1875 TEST_F(WebRtcVoiceEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { |
1873 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); | 1876 TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); |
1874 } | 1877 } |
1875 | 1878 |
1876 // Test that we can create a channel and start sending/playing out on it. | 1879 // Test that we can create a channel and start sending on it. |
1877 TEST_F(WebRtcVoiceEngineTestFake, SendAndPlayout) { | 1880 TEST_F(WebRtcVoiceEngineTestFake, Send) { |
1878 EXPECT_TRUE(SetupEngine()); | 1881 EXPECT_TRUE(SetupEngineWithSendStream()); |
1879 int channel_num = voe_.GetLastChannel(); | 1882 int channel_num = voe_.GetLastChannel(); |
1880 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 1883 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1881 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 1884 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
1882 EXPECT_TRUE(voe_.GetSend(channel_num)); | 1885 EXPECT_TRUE(voe_.GetSend(channel_num)); |
| 1886 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); |
| 1887 EXPECT_FALSE(voe_.GetSend(channel_num)); |
| 1888 } |
| 1889 |
| 1890 // Test that we can create a channel and start playing out on it. |
| 1891 TEST_F(WebRtcVoiceEngineTestFake, Playout) { |
| 1892 EXPECT_TRUE(SetupEngineWithRecvStream()); |
| 1893 int channel_num = voe_.GetLastChannel(); |
| 1894 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
1883 EXPECT_TRUE(channel_->SetPlayout(true)); | 1895 EXPECT_TRUE(channel_->SetPlayout(true)); |
1884 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 1896 EXPECT_TRUE(voe_.GetPlayout(channel_num)); |
1885 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); | |
1886 EXPECT_FALSE(voe_.GetSend(channel_num)); | |
1887 EXPECT_TRUE(channel_->SetPlayout(false)); | 1897 EXPECT_TRUE(channel_->SetPlayout(false)); |
1888 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | 1898 EXPECT_FALSE(voe_.GetPlayout(channel_num)); |
1889 } | 1899 } |
1890 | 1900 |
1891 // Test that we can add and remove send streams. | 1901 // Test that we can add and remove send streams. |
1892 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { | 1902 TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { |
1893 SetupForMultiSendStream(); | 1903 SetupForMultiSendStream(); |
1894 | 1904 |
1895 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; | 1905 static const uint32 kSsrcs4[] = {1, 2, 3, 4}; |
1896 | 1906 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); | 2030 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); |
2021 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent); | 2031 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent); |
2022 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_sent); | 2032 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_sent); |
2023 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_lost); | 2033 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_lost); |
2024 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[i].fraction_lost); | 2034 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[i].fraction_lost); |
2025 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].ext_seqnum); | 2035 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].ext_seqnum); |
2026 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].rtt_ms); | 2036 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].rtt_ms); |
2027 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].jitter_ms); | 2037 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].jitter_ms); |
2028 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); | 2038 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); |
2029 } | 2039 } |
| 2040 EXPECT_EQ(0u, info.receivers.size()); |
2030 | 2041 |
2031 EXPECT_EQ(0u, info.receivers.size()); | 2042 // Registered stream's remote SSRC is kSsrc2. Send a packet with SSRC=1. |
| 2043 // We should drop the packet and no stats should be available. |
2032 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2044 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
2033 EXPECT_EQ(true, channel_->GetStats(&info)); | 2045 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2046 EXPECT_EQ(0u, info.receivers.size()); |
2034 | 2047 |
| 2048 // Remove the kSsrc2 stream and deliver a new packet - a default receive |
| 2049 // stream should be created and we should see stats. |
| 2050 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); |
| 2051 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2052 EXPECT_EQ(true, channel_->GetStats(&info)); |
2035 EXPECT_EQ(1u, info.receivers.size()); | 2053 EXPECT_EQ(1u, info.receivers.size()); |
| 2054 |
2036 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); | 2055 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); |
2037 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); | 2056 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); |
2038 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); | 2057 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); |
2039 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); | 2058 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); |
2040 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); | 2059 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); |
2041 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / | 2060 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / |
2042 (1 << 14), info.receivers[0].expand_rate); | 2061 (1 << 14), info.receivers[0].expand_rate); |
2043 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / | 2062 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / |
2044 (1 << 14), info.receivers[0].speech_expand_rate); | 2063 (1 << 14), info.receivers[0].speech_expand_rate); |
2045 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / | 2064 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / |
2046 (1 << 14), info.receivers[0].secondary_decoded_rate); | 2065 (1 << 14), info.receivers[0].secondary_decoded_rate); |
2047 EXPECT_EQ( | 2066 EXPECT_EQ( |
2048 static_cast<float>(cricket::kNetStats.currentAccelerateRate) / (1 << 14), | 2067 static_cast<float>(cricket::kNetStats.currentAccelerateRate) / (1 << 14), |
2049 info.receivers[0].accelerate_rate); | 2068 info.receivers[0].accelerate_rate); |
2050 EXPECT_EQ( | 2069 EXPECT_EQ( |
2051 static_cast<float>(cricket::kNetStats.currentPreemptiveRate) / (1 << 14), | 2070 static_cast<float>(cricket::kNetStats.currentPreemptiveRate) / (1 << 14), |
2052 info.receivers[0].preemptive_expand_rate); | 2071 info.receivers[0].preemptive_expand_rate); |
2053 } | 2072 } |
2054 | 2073 |
2055 // Test that we can add and remove receive streams, and do proper send/playout. | 2074 // Test that we can add and remove receive streams, and do proper send/playout. |
2056 // We can receive on multiple streams while sending one stream. | 2075 // We can receive on multiple streams while sending one stream. |
2057 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { | 2076 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { |
2058 EXPECT_TRUE(SetupEngine()); | 2077 EXPECT_TRUE(SetupEngineWithSendStream()); |
2059 int channel_num1 = voe_.GetLastChannel(); | 2078 int channel_num1 = voe_.GetLastChannel(); |
2060 | 2079 |
2061 // Start playout on the default channel. | 2080 // Start playout without a receive stream. |
2062 send_parameters_.options = options_conference_; | |
2063 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2081 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2064 EXPECT_TRUE(channel_->SetPlayout(true)); | 2082 EXPECT_TRUE(channel_->SetPlayout(true)); |
2065 EXPECT_TRUE(voe_.GetPlayout(channel_num1)); | 2083 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2066 | 2084 |
2067 // Adding another stream should disable playout on the default channel. | 2085 // Adding another stream should enable playout on the new stream only. |
2068 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2086 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2069 int channel_num2 = voe_.GetLastChannel(); | 2087 int channel_num2 = voe_.GetLastChannel(); |
2070 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2088 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2071 EXPECT_TRUE(voe_.GetSend(channel_num1)); | 2089 EXPECT_TRUE(voe_.GetSend(channel_num1)); |
2072 EXPECT_FALSE(voe_.GetSend(channel_num2)); | 2090 EXPECT_FALSE(voe_.GetSend(channel_num2)); |
2073 | 2091 |
2074 // Make sure only the new channel is played out. | 2092 // Make sure only the new stream is played out. |
2075 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2093 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2076 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | 2094 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); |
2077 | 2095 |
2078 // Adding yet another stream should have stream 2 and 3 enabled for playout. | 2096 // Adding yet another stream should have stream 2 and 3 enabled for playout. |
2079 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 2097 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
2080 int channel_num3 = voe_.GetLastChannel(); | 2098 int channel_num3 = voe_.GetLastChannel(); |
2081 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2099 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2082 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | 2100 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); |
2083 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); | 2101 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); |
2084 EXPECT_FALSE(voe_.GetSend(channel_num3)); | 2102 EXPECT_FALSE(voe_.GetSend(channel_num3)); |
2085 | 2103 |
2086 // Stop sending. | 2104 // Stop sending. |
2087 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); | 2105 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); |
2088 EXPECT_FALSE(voe_.GetSend(channel_num1)); | 2106 EXPECT_FALSE(voe_.GetSend(channel_num1)); |
2089 EXPECT_FALSE(voe_.GetSend(channel_num2)); | 2107 EXPECT_FALSE(voe_.GetSend(channel_num2)); |
2090 EXPECT_FALSE(voe_.GetSend(channel_num3)); | 2108 EXPECT_FALSE(voe_.GetSend(channel_num3)); |
2091 | 2109 |
2092 // Stop playout. | 2110 // Stop playout. |
2093 EXPECT_TRUE(channel_->SetPlayout(false)); | 2111 EXPECT_TRUE(channel_->SetPlayout(false)); |
2094 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2112 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2095 EXPECT_FALSE(voe_.GetPlayout(channel_num2)); | 2113 EXPECT_FALSE(voe_.GetPlayout(channel_num2)); |
2096 EXPECT_FALSE(voe_.GetPlayout(channel_num3)); | 2114 EXPECT_FALSE(voe_.GetPlayout(channel_num3)); |
2097 | 2115 |
2098 // Restart playout and make sure the default channel still is not played out. | 2116 // Restart playout and make sure only recv streams are played out. |
2099 EXPECT_TRUE(channel_->SetPlayout(true)); | 2117 EXPECT_TRUE(channel_->SetPlayout(true)); |
2100 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); | 2118 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2101 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); | 2119 EXPECT_TRUE(voe_.GetPlayout(channel_num2)); |
2102 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); | 2120 EXPECT_TRUE(voe_.GetPlayout(channel_num3)); |
2103 | 2121 |
2104 // Now remove the new streams and verify that the default channel is | 2122 // Now remove the recv streams and verify that the send stream doesn't play. |
2105 // played out again. | |
2106 EXPECT_TRUE(channel_->RemoveRecvStream(3)); | 2123 EXPECT_TRUE(channel_->RemoveRecvStream(3)); |
2107 EXPECT_TRUE(channel_->RemoveRecvStream(2)); | 2124 EXPECT_TRUE(channel_->RemoveRecvStream(2)); |
2108 | 2125 EXPECT_FALSE(voe_.GetPlayout(channel_num1)); |
2109 EXPECT_TRUE(voe_.GetPlayout(channel_num1)); | |
2110 } | 2126 } |
2111 | 2127 |
2112 // Test that we can set the devices to use. | 2128 // Test that we can set the devices to use. |
2113 TEST_F(WebRtcVoiceEngineTestFake, SetDevices) { | 2129 TEST_F(WebRtcVoiceEngineTestFake, SetDevices) { |
2114 EXPECT_TRUE(SetupEngine()); | 2130 EXPECT_TRUE(SetupEngineWithSendStream()); |
2115 int channel_num = voe_.GetLastChannel(); | 2131 int send_channel = voe_.GetLastChannel(); |
| 2132 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2133 int recv_channel = voe_.GetLastChannel(); |
2116 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2134 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2117 | 2135 |
2118 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, | 2136 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, |
2119 cricket::kFakeDefaultDeviceId); | 2137 cricket::kFakeDefaultDeviceId); |
2120 cricket::Device dev(cricket::kFakeDeviceName, | 2138 cricket::Device dev(cricket::kFakeDeviceName, |
2121 cricket::kFakeDeviceId); | 2139 cricket::kFakeDeviceId); |
2122 | 2140 |
2123 // Test SetDevices() while not sending or playing. | 2141 // Test SetDevices() while not sending or playing. |
2124 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); | 2142 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); |
2125 | 2143 |
2126 // Test SetDevices() while sending and playing. | 2144 // Test SetDevices() while sending and playing. |
2127 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2145 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2128 EXPECT_TRUE(channel_->SetPlayout(true)); | 2146 EXPECT_TRUE(channel_->SetPlayout(true)); |
2129 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2147 EXPECT_TRUE(voe_.GetSend(send_channel)); |
2130 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2148 EXPECT_TRUE(voe_.GetPlayout(recv_channel)); |
2131 | 2149 |
2132 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); | 2150 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); |
2133 | 2151 |
2134 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2152 EXPECT_TRUE(voe_.GetSend(send_channel)); |
2135 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2153 EXPECT_TRUE(voe_.GetPlayout(recv_channel)); |
2136 | 2154 |
2137 // Test that failure to open newly selected devices does not prevent opening | 2155 // Test that failure to open newly selected devices does not prevent opening |
2138 // ones after that. | 2156 // ones after that. |
2139 voe_.set_playout_fail_channel(channel_num); | 2157 voe_.set_playout_fail_channel(recv_channel); |
2140 voe_.set_send_fail_channel(channel_num); | 2158 voe_.set_send_fail_channel(send_channel); |
2141 | 2159 |
2142 EXPECT_FALSE(engine_.SetDevices(&default_dev, &default_dev)); | 2160 EXPECT_FALSE(engine_.SetDevices(&default_dev, &default_dev)); |
2143 | 2161 |
2144 EXPECT_FALSE(voe_.GetSend(channel_num)); | 2162 EXPECT_FALSE(voe_.GetSend(send_channel)); |
2145 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | 2163 EXPECT_FALSE(voe_.GetPlayout(recv_channel)); |
2146 | 2164 |
2147 voe_.set_playout_fail_channel(-1); | 2165 voe_.set_playout_fail_channel(-1); |
2148 voe_.set_send_fail_channel(-1); | 2166 voe_.set_send_fail_channel(-1); |
2149 | 2167 |
2150 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); | 2168 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); |
2151 | 2169 |
2152 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2170 EXPECT_TRUE(voe_.GetSend(send_channel)); |
2153 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2171 EXPECT_TRUE(voe_.GetPlayout(recv_channel)); |
2154 } | 2172 } |
2155 | 2173 |
2156 // Test that we can set the devices to use even if we failed to | 2174 // Test that we can set the devices to use even if we failed to |
2157 // open the initial ones. | 2175 // open the initial ones. |
2158 TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) { | 2176 TEST_F(WebRtcVoiceEngineTestFake, SetDevicesWithInitiallyBadDevices) { |
2159 EXPECT_TRUE(SetupEngine()); | 2177 EXPECT_TRUE(SetupEngineWithSendStream()); |
2160 int channel_num = voe_.GetLastChannel(); | 2178 int send_channel = voe_.GetLastChannel(); |
| 2179 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2180 int recv_channel = voe_.GetLastChannel(); |
2161 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2181 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2162 | 2182 |
2163 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, | 2183 cricket::Device default_dev(cricket::kFakeDefaultDeviceName, |
2164 cricket::kFakeDefaultDeviceId); | 2184 cricket::kFakeDefaultDeviceId); |
2165 cricket::Device dev(cricket::kFakeDeviceName, | 2185 cricket::Device dev(cricket::kFakeDeviceName, |
2166 cricket::kFakeDeviceId); | 2186 cricket::kFakeDeviceId); |
2167 | 2187 |
2168 // Test that failure to open devices selected before starting | 2188 // Test that failure to open devices selected before starting |
2169 // send/play does not prevent opening newly selected ones after that. | 2189 // send/play does not prevent opening newly selected ones after that. |
2170 voe_.set_playout_fail_channel(channel_num); | 2190 voe_.set_playout_fail_channel(recv_channel); |
2171 voe_.set_send_fail_channel(channel_num); | 2191 voe_.set_send_fail_channel(send_channel); |
2172 | 2192 |
2173 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); | 2193 EXPECT_TRUE(engine_.SetDevices(&default_dev, &default_dev)); |
2174 | 2194 |
2175 EXPECT_FALSE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2195 EXPECT_FALSE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2176 EXPECT_FALSE(channel_->SetPlayout(true)); | 2196 EXPECT_FALSE(channel_->SetPlayout(true)); |
2177 EXPECT_FALSE(voe_.GetSend(channel_num)); | 2197 EXPECT_FALSE(voe_.GetSend(send_channel)); |
2178 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | 2198 EXPECT_FALSE(voe_.GetPlayout(recv_channel)); |
2179 | 2199 |
2180 voe_.set_playout_fail_channel(-1); | 2200 voe_.set_playout_fail_channel(-1); |
2181 voe_.set_send_fail_channel(-1); | 2201 voe_.set_send_fail_channel(-1); |
2182 | 2202 |
2183 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); | 2203 EXPECT_TRUE(engine_.SetDevices(&dev, &dev)); |
2184 | 2204 |
2185 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2205 EXPECT_TRUE(voe_.GetSend(send_channel)); |
2186 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 2206 EXPECT_TRUE(voe_.GetPlayout(recv_channel)); |
2187 } | |
2188 | |
2189 // Test that we can create a channel configured for multi-point conferences, | |
2190 // and start sending/playing out on it. | |
2191 TEST_F(WebRtcVoiceEngineTestFake, ConferenceSendAndPlayout) { | |
2192 EXPECT_TRUE(SetupEngine()); | |
2193 int channel_num = voe_.GetLastChannel(); | |
2194 send_parameters_.options = options_conference_; | |
2195 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
2196 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | |
2197 EXPECT_TRUE(voe_.GetSend(channel_num)); | |
2198 } | 2207 } |
2199 | 2208 |
2200 // Test that we can create a channel configured for Codian bridges, | 2209 // Test that we can create a channel configured for Codian bridges, |
2201 // and start sending/playing out on it. | 2210 // and start sending on it. |
2202 TEST_F(WebRtcVoiceEngineTestFake, CodianSendAndPlayout) { | 2211 TEST_F(WebRtcVoiceEngineTestFake, CodianSend) { |
2203 EXPECT_TRUE(SetupEngine()); | 2212 EXPECT_TRUE(SetupEngineWithSendStream()); |
2204 int channel_num = voe_.GetLastChannel(); | 2213 int channel_num = voe_.GetLastChannel(); |
2205 webrtc::AgcConfig agc_config; | 2214 webrtc::AgcConfig agc_config; |
2206 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2215 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2207 EXPECT_EQ(0, agc_config.targetLeveldBOv); | 2216 EXPECT_EQ(0, agc_config.targetLeveldBOv); |
2208 send_parameters_.options = options_adjust_agc_; | 2217 send_parameters_.options = options_adjust_agc_; |
2209 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2218 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2210 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2219 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2211 EXPECT_TRUE(voe_.GetSend(channel_num)); | 2220 EXPECT_TRUE(voe_.GetSend(channel_num)); |
2212 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2221 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2213 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated | 2222 EXPECT_EQ(agc_config.targetLeveldBOv, 10); // level was attenuated |
2214 EXPECT_TRUE(channel_->SetPlayout(true)); | |
2215 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | |
2216 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); | 2223 EXPECT_TRUE(channel_->SetSend(cricket::SEND_NOTHING)); |
2217 EXPECT_FALSE(voe_.GetSend(channel_num)); | 2224 EXPECT_FALSE(voe_.GetSend(channel_num)); |
2218 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2225 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2219 EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored | 2226 EXPECT_EQ(0, agc_config.targetLeveldBOv); // level was restored |
2220 EXPECT_TRUE(channel_->SetPlayout(false)); | |
2221 EXPECT_FALSE(voe_.GetPlayout(channel_num)); | |
2222 } | 2227 } |
2223 | 2228 |
2224 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { | 2229 TEST_F(WebRtcVoiceEngineTestFake, TxAgcConfigViaOptions) { |
2225 EXPECT_TRUE(SetupEngine()); | 2230 EXPECT_TRUE(SetupEngineWithSendStream()); |
2226 webrtc::AgcConfig agc_config; | 2231 webrtc::AgcConfig agc_config; |
2227 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2232 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2228 EXPECT_EQ(0, agc_config.targetLeveldBOv); | 2233 EXPECT_EQ(0, agc_config.targetLeveldBOv); |
2229 | 2234 |
2230 cricket::AudioOptions options; | 2235 cricket::AudioOptions options; |
2231 options.tx_agc_target_dbov.Set(3); | 2236 options.tx_agc_target_dbov.Set(3); |
2232 options.tx_agc_digital_compression_gain.Set(9); | 2237 options.tx_agc_digital_compression_gain.Set(9); |
2233 options.tx_agc_limiter.Set(true); | 2238 options.tx_agc_limiter.Set(true); |
2234 options.auto_gain_control.Set(true); | 2239 options.auto_gain_control.Set(true); |
2235 EXPECT_TRUE(engine_.SetOptions(options)); | 2240 EXPECT_TRUE(engine_.SetOptions(options)); |
2236 | 2241 |
2237 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2242 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2238 EXPECT_EQ(3, agc_config.targetLeveldBOv); | 2243 EXPECT_EQ(3, agc_config.targetLeveldBOv); |
2239 EXPECT_EQ(9, agc_config.digitalCompressionGaindB); | 2244 EXPECT_EQ(9, agc_config.digitalCompressionGaindB); |
2240 EXPECT_TRUE(agc_config.limiterEnable); | 2245 EXPECT_TRUE(agc_config.limiterEnable); |
2241 | 2246 |
2242 // Check interaction with adjust_agc_delta. Both should be respected, for | 2247 // Check interaction with adjust_agc_delta. Both should be respected, for |
2243 // backwards compatibility. | 2248 // backwards compatibility. |
2244 options.adjust_agc_delta.Set(-10); | 2249 options.adjust_agc_delta.Set(-10); |
2245 EXPECT_TRUE(engine_.SetOptions(options)); | 2250 EXPECT_TRUE(engine_.SetOptions(options)); |
2246 | 2251 |
2247 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); | 2252 EXPECT_EQ(0, voe_.GetAgcConfig(agc_config)); |
2248 EXPECT_EQ(13, agc_config.targetLeveldBOv); | 2253 EXPECT_EQ(13, agc_config.targetLeveldBOv); |
2249 } | 2254 } |
2250 | 2255 |
2251 TEST_F(WebRtcVoiceEngineTestFake, RxAgcConfigViaOptions) { | 2256 TEST_F(WebRtcVoiceEngineTestFake, RxAgcConfigViaOptions) { |
2252 EXPECT_TRUE(SetupEngine()); | 2257 EXPECT_TRUE(SetupEngineWithSendStream()); |
2253 int channel_num = voe_.GetLastChannel(); | |
2254 send_parameters_.options.rx_agc_target_dbov.Set(6); | 2258 send_parameters_.options.rx_agc_target_dbov.Set(6); |
2255 send_parameters_.options.rx_agc_digital_compression_gain.Set(0); | 2259 send_parameters_.options.rx_agc_digital_compression_gain.Set(0); |
2256 send_parameters_.options.rx_agc_limiter.Set(true); | 2260 send_parameters_.options.rx_agc_limiter.Set(true); |
2257 send_parameters_.options.rx_auto_gain_control.Set(true); | 2261 send_parameters_.options.rx_auto_gain_control.Set(true); |
2258 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2262 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2263 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 2264 int channel_num = voe_.GetLastChannel(); |
2259 | 2265 |
2260 webrtc::AgcConfig agc_config; | 2266 webrtc::AgcConfig agc_config; |
2261 EXPECT_EQ(0, engine_.voe()->processing()->GetRxAgcConfig( | 2267 EXPECT_EQ(0, engine_.voe()->processing()->GetRxAgcConfig( |
2262 channel_num, agc_config)); | 2268 channel_num, agc_config)); |
2263 EXPECT_EQ(6, agc_config.targetLeveldBOv); | 2269 EXPECT_EQ(6, agc_config.targetLeveldBOv); |
2264 EXPECT_EQ(0, agc_config.digitalCompressionGaindB); | 2270 EXPECT_EQ(0, agc_config.digitalCompressionGaindB); |
2265 EXPECT_TRUE(agc_config.limiterEnable); | 2271 EXPECT_TRUE(agc_config.limiterEnable); |
2266 } | 2272 } |
2267 | 2273 |
2268 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { | 2274 TEST_F(WebRtcVoiceEngineTestFake, SampleRatesViaOptions) { |
2269 EXPECT_TRUE(SetupEngine()); | 2275 EXPECT_TRUE(SetupEngineWithSendStream()); |
2270 cricket::AudioOptions options; | 2276 cricket::AudioOptions options; |
2271 options.recording_sample_rate.Set(48000u); | 2277 options.recording_sample_rate.Set(48000u); |
2272 options.playout_sample_rate.Set(44100u); | 2278 options.playout_sample_rate.Set(44100u); |
2273 EXPECT_TRUE(engine_.SetOptions(options)); | 2279 EXPECT_TRUE(engine_.SetOptions(options)); |
2274 | 2280 |
2275 unsigned int recording_sample_rate, playout_sample_rate; | 2281 unsigned int recording_sample_rate, playout_sample_rate; |
2276 EXPECT_EQ(0, voe_.RecordingSampleRate(&recording_sample_rate)); | 2282 EXPECT_EQ(0, voe_.RecordingSampleRate(&recording_sample_rate)); |
2277 EXPECT_EQ(0, voe_.PlayoutSampleRate(&playout_sample_rate)); | 2283 EXPECT_EQ(0, voe_.PlayoutSampleRate(&playout_sample_rate)); |
2278 EXPECT_EQ(48000u, recording_sample_rate); | 2284 EXPECT_EQ(48000u, recording_sample_rate); |
2279 EXPECT_EQ(44100u, playout_sample_rate); | 2285 EXPECT_EQ(44100u, playout_sample_rate); |
2280 } | 2286 } |
2281 | 2287 |
2282 TEST_F(WebRtcVoiceEngineTestFake, TraceFilterViaTraceOptions) { | 2288 TEST_F(WebRtcVoiceEngineTestFake, TraceFilterViaTraceOptions) { |
2283 EXPECT_TRUE(SetupEngine()); | 2289 EXPECT_TRUE(SetupEngineWithSendStream()); |
2284 engine_.SetLogging(rtc::LS_INFO, ""); | 2290 engine_.SetLogging(rtc::LS_INFO, ""); |
2285 EXPECT_EQ( | 2291 EXPECT_EQ( |
2286 // Info: | 2292 // Info: |
2287 webrtc::kTraceStateInfo | webrtc::kTraceInfo | | 2293 webrtc::kTraceStateInfo | webrtc::kTraceInfo | |
2288 // Warning: | 2294 // Warning: |
2289 webrtc::kTraceTerseInfo | webrtc::kTraceWarning | | 2295 webrtc::kTraceTerseInfo | webrtc::kTraceWarning | |
2290 // Error: | 2296 // Error: |
2291 webrtc::kTraceError | webrtc::kTraceCritical, | 2297 webrtc::kTraceError | webrtc::kTraceCritical, |
2292 static_cast<int>(trace_wrapper_->filter_)); | 2298 static_cast<int>(trace_wrapper_->filter_)); |
2293 // Now set it explicitly | 2299 // Now set it explicitly |
2294 std::string filter = | 2300 std::string filter = |
2295 "tracefilter " + rtc::ToString(webrtc::kTraceDefault); | 2301 "tracefilter " + rtc::ToString(webrtc::kTraceDefault); |
2296 engine_.SetLogging(rtc::LS_VERBOSE, filter.c_str()); | 2302 engine_.SetLogging(rtc::LS_VERBOSE, filter.c_str()); |
2297 EXPECT_EQ(static_cast<unsigned int>(webrtc::kTraceDefault), | 2303 EXPECT_EQ(static_cast<unsigned int>(webrtc::kTraceDefault), |
2298 trace_wrapper_->filter_); | 2304 trace_wrapper_->filter_); |
2299 } | 2305 } |
2300 | 2306 |
2301 // Test that we can set the outgoing SSRC properly. | 2307 // Test that we can set the outgoing SSRC properly. |
2302 // SSRC is set in SetupEngine by calling AddSendStream. | 2308 // SSRC is set in SetupEngine by calling AddSendStream. |
2303 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { | 2309 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { |
2304 EXPECT_TRUE(SetupEngine()); | 2310 EXPECT_TRUE(SetupEngineWithSendStream()); |
2305 int channel_num = voe_.GetLastChannel(); | 2311 int channel_num = voe_.GetLastChannel(); |
2306 unsigned int send_ssrc; | 2312 unsigned int send_ssrc; |
2307 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); | 2313 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); |
2308 EXPECT_NE(0U, send_ssrc); | 2314 EXPECT_NE(0U, send_ssrc); |
2309 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); | 2315 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num, send_ssrc)); |
2310 EXPECT_EQ(kSsrc1, send_ssrc); | 2316 EXPECT_EQ(kSsrc1, send_ssrc); |
2311 } | 2317 } |
2312 | 2318 |
2313 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { | 2319 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { |
2314 // Setup. We need send codec to be set to get all stats. | 2320 // Setup. We need send codec to be set to get all stats. |
2315 EXPECT_TRUE(SetupEngine()); | 2321 EXPECT_TRUE(SetupEngineWithSendStream()); |
2316 // SetupEngine adds a send stream with kSsrc1, so the receive stream has to | 2322 // SetupEngineWithSendStream adds a send stream with kSsrc1, so the receive |
2317 // use a different SSRC. | 2323 // stream has to use a different SSRC. |
2318 EXPECT_TRUE(channel_->AddRecvStream( | 2324 EXPECT_TRUE(channel_->AddRecvStream( |
2319 cricket::StreamParams::CreateLegacy(kSsrc2))); | 2325 cricket::StreamParams::CreateLegacy(kSsrc2))); |
2320 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2326 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2321 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | 2327 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
2322 | 2328 |
2323 cricket::VoiceMediaInfo info; | 2329 cricket::VoiceMediaInfo info; |
2324 EXPECT_EQ(true, channel_->GetStats(&info)); | 2330 EXPECT_EQ(true, channel_->GetStats(&info)); |
2325 EXPECT_EQ(1u, info.senders.size()); | 2331 EXPECT_EQ(1u, info.senders.size()); |
2326 EXPECT_EQ(kSsrc1, info.senders[0].ssrc()); | 2332 EXPECT_EQ(kSsrc1, info.senders[0].ssrc()); |
2327 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); | 2333 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); |
2328 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].bytes_sent); | 2334 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].bytes_sent); |
2329 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_sent); | 2335 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_sent); |
2330 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_lost); | 2336 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].packets_lost); |
2331 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[0].fraction_lost); | 2337 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[0].fraction_lost); |
2332 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].ext_seqnum); | 2338 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].ext_seqnum); |
2333 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].rtt_ms); | 2339 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].rtt_ms); |
2334 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].jitter_ms); | 2340 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].jitter_ms); |
2335 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); | 2341 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); |
2336 // TODO(sriniv): Add testing for more fields. These are not populated | 2342 // TODO(sriniv): Add testing for more fields. These are not populated |
2337 // in FakeWebrtcVoiceEngine yet. | 2343 // in FakeWebrtcVoiceEngine yet. |
2338 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].audio_level); | 2344 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].audio_level); |
2339 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_median_ms); | 2345 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_median_ms); |
2340 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_std_ms); | 2346 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_std_ms); |
2341 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_return_loss); | 2347 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_return_loss); |
2342 // EXPECT_EQ(cricket::kIntStatValue, | 2348 // EXPECT_EQ(cricket::kIntStatValue, |
2343 // info.senders[0].echo_return_loss_enhancement); | 2349 // info.senders[0].echo_return_loss_enhancement); |
| 2350 EXPECT_EQ(0u, info.receivers.size()); |
2344 | 2351 |
| 2352 // Registered stream's remote SSRC is kSsrc2. Send a packet with SSRC=1. |
| 2353 // We should drop the packet and no stats should be available. |
| 2354 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2355 EXPECT_EQ(true, channel_->GetStats(&info)); |
2345 EXPECT_EQ(0u, info.receivers.size()); | 2356 EXPECT_EQ(0u, info.receivers.size()); |
| 2357 |
| 2358 // Remove the kSsrc2 stream and deliver a new packet - a default receive |
| 2359 // stream should be created and we should see stats. |
| 2360 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); |
2346 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2361 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
2347 EXPECT_EQ(true, channel_->GetStats(&info)); | 2362 EXPECT_EQ(true, channel_->GetStats(&info)); |
2348 EXPECT_EQ(1u, info.receivers.size()); | 2363 EXPECT_EQ(1u, info.receivers.size()); |
2349 | 2364 |
2350 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); | 2365 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); |
2351 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); | 2366 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); |
2352 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); | 2367 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); |
2353 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); | 2368 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); |
2354 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); | 2369 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); |
2355 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / | 2370 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / |
2356 (1 << 14), info.receivers[0].expand_rate); | 2371 (1 << 14), info.receivers[0].expand_rate); |
2357 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / | 2372 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / |
2358 (1 << 14), info.receivers[0].speech_expand_rate); | 2373 (1 << 14), info.receivers[0].speech_expand_rate); |
2359 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / | 2374 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / |
2360 (1 << 14), info.receivers[0].secondary_decoded_rate); | 2375 (1 << 14), info.receivers[0].secondary_decoded_rate); |
2361 // TODO(sriniv): Add testing for more receiver fields. | 2376 // TODO(sriniv): Add testing for more receiver fields. |
2362 } | 2377 } |
2363 | 2378 |
2364 // Test that we can set the outgoing SSRC properly with multiple streams. | 2379 // Test that we can set the outgoing SSRC properly with multiple streams. |
2365 // SSRC is set in SetupEngine by calling AddSendStream. | 2380 // SSRC is set in SetupEngine by calling AddSendStream. |
2366 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { | 2381 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { |
2367 EXPECT_TRUE(SetupEngine()); | 2382 EXPECT_TRUE(SetupEngineWithSendStream()); |
2368 int channel_num1 = voe_.GetLastChannel(); | 2383 int channel_num1 = voe_.GetLastChannel(); |
2369 unsigned int send_ssrc; | 2384 unsigned int send_ssrc; |
2370 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); | 2385 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); |
2371 EXPECT_EQ(kSsrc1, send_ssrc); | 2386 EXPECT_EQ(kSsrc1, send_ssrc); |
2372 | 2387 |
2373 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2388 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2374 int channel_num2 = voe_.GetLastChannel(); | 2389 int channel_num2 = voe_.GetLastChannel(); |
2375 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc)); | 2390 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num2, send_ssrc)); |
2376 EXPECT_EQ(kSsrc1, send_ssrc); | 2391 EXPECT_EQ(kSsrc1, send_ssrc); |
2377 } | 2392 } |
(...skipping 14 matching lines...) Expand all Loading... |
2392 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc)); | 2407 EXPECT_EQ(0, voe_.GetLocalSSRC(send_channel_num, ssrc)); |
2393 EXPECT_EQ(1234U, ssrc); | 2408 EXPECT_EQ(1234U, ssrc); |
2394 ssrc = 0; | 2409 ssrc = 0; |
2395 EXPECT_EQ(0, voe_.GetLocalSSRC(receive_channel_num, ssrc)); | 2410 EXPECT_EQ(0, voe_.GetLocalSSRC(receive_channel_num, ssrc)); |
2396 EXPECT_EQ(1234U, ssrc); | 2411 EXPECT_EQ(1234U, ssrc); |
2397 } | 2412 } |
2398 | 2413 |
2399 // Test that we can properly receive packets. | 2414 // Test that we can properly receive packets. |
2400 TEST_F(WebRtcVoiceEngineTestFake, Recv) { | 2415 TEST_F(WebRtcVoiceEngineTestFake, Recv) { |
2401 EXPECT_TRUE(SetupEngine()); | 2416 EXPECT_TRUE(SetupEngine()); |
| 2417 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
2402 int channel_num = voe_.GetLastChannel(); | 2418 int channel_num = voe_.GetLastChannel(); |
2403 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | |
2404 EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame, | 2419 EXPECT_TRUE(voe_.CheckPacket(channel_num, kPcmuFrame, |
2405 sizeof(kPcmuFrame))); | 2420 sizeof(kPcmuFrame))); |
2406 } | 2421 } |
2407 | 2422 |
2408 // Test that we can properly receive packets on multiple streams. | 2423 // Test that we can properly receive packets on multiple streams. |
2409 TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { | 2424 TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { |
2410 EXPECT_TRUE(SetupEngine()); | 2425 EXPECT_TRUE(SetupEngineWithSendStream()); |
2411 send_parameters_.options = options_conference_; | |
2412 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2426 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2413 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2427 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
2414 int channel_num1 = voe_.GetLastChannel(); | 2428 int channel_num1 = voe_.GetLastChannel(); |
2415 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2429 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2416 int channel_num2 = voe_.GetLastChannel(); | 2430 int channel_num2 = voe_.GetLastChannel(); |
2417 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 2431 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
2418 int channel_num3 = voe_.GetLastChannel(); | 2432 int channel_num3 = voe_.GetLastChannel(); |
2419 // Create packets with the right SSRCs. | 2433 // Create packets with the right SSRCs. |
2420 char packets[4][sizeof(kPcmuFrame)]; | 2434 char packets[4][sizeof(kPcmuFrame)]; |
2421 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { | 2435 for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { |
(...skipping 22 matching lines...) Expand all Loading... |
2444 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); | 2458 EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); |
2445 EXPECT_TRUE(voe_.CheckPacket(channel_num3, packets[3], | 2459 EXPECT_TRUE(voe_.CheckPacket(channel_num3, packets[3], |
2446 sizeof(packets[3]))); | 2460 sizeof(packets[3]))); |
2447 EXPECT_TRUE(channel_->RemoveRecvStream(3)); | 2461 EXPECT_TRUE(channel_->RemoveRecvStream(3)); |
2448 EXPECT_TRUE(channel_->RemoveRecvStream(2)); | 2462 EXPECT_TRUE(channel_->RemoveRecvStream(2)); |
2449 EXPECT_TRUE(channel_->RemoveRecvStream(1)); | 2463 EXPECT_TRUE(channel_->RemoveRecvStream(1)); |
2450 } | 2464 } |
2451 | 2465 |
2452 // Test that we properly handle failures to add a stream. | 2466 // Test that we properly handle failures to add a stream. |
2453 TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) { | 2467 TEST_F(WebRtcVoiceEngineTestFake, AddStreamFail) { |
2454 EXPECT_TRUE(SetupEngine()); | 2468 EXPECT_TRUE(SetupEngineWithSendStream()); |
2455 voe_.set_fail_create_channel(true); | 2469 voe_.set_fail_create_channel(true); |
2456 send_parameters_.options = options_conference_; | |
2457 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2470 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2458 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2471 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2459 | |
2460 // In 1:1 call, we should not try to create a new channel. | |
2461 send_parameters_.options.conference_mode.Set(false); | |
2462 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
2463 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | |
2464 } | 2472 } |
2465 | 2473 |
2466 // Test that AddRecvStream doesn't create new channel for 1:1 call. | 2474 // Test that AddRecvStream creates new stream. |
2467 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream1On1) { | 2475 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStream) { |
2468 EXPECT_TRUE(SetupEngine()); | 2476 EXPECT_TRUE(SetupEngineWithRecvStream()); |
2469 int channel_num = voe_.GetLastChannel(); | 2477 int channel_num = voe_.GetLastChannel(); |
2470 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2478 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
2471 EXPECT_EQ(channel_num, voe_.GetLastChannel()); | 2479 EXPECT_NE(channel_num, voe_.GetLastChannel()); |
2472 } | 2480 } |
2473 | 2481 |
2474 // Test that after adding a recv stream, we do not decode more codecs than | 2482 // Test that after adding a recv stream, we do not decode more codecs than |
2475 // those previously passed into SetRecvCodecs. | 2483 // those previously passed into SetRecvCodecs. |
2476 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { | 2484 TEST_F(WebRtcVoiceEngineTestFake, AddRecvStreamUnsupportedCodec) { |
2477 EXPECT_TRUE(SetupEngine()); | 2485 EXPECT_TRUE(SetupEngineWithSendStream()); |
2478 cricket::AudioRecvParameters parameters; | 2486 cricket::AudioRecvParameters parameters; |
2479 parameters.codecs.push_back(kIsacCodec); | 2487 parameters.codecs.push_back(kIsacCodec); |
2480 parameters.codecs.push_back(kPcmuCodec); | 2488 parameters.codecs.push_back(kPcmuCodec); |
2481 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2489 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2482 EXPECT_TRUE(channel_->AddRecvStream( | 2490 EXPECT_TRUE(channel_->AddRecvStream( |
2483 cricket::StreamParams::CreateLegacy(kSsrc1))); | 2491 cricket::StreamParams::CreateLegacy(kSsrc1))); |
2484 int channel_num2 = voe_.GetLastChannel(); | 2492 int channel_num2 = voe_.GetLastChannel(); |
2485 webrtc::CodecInst gcodec; | 2493 webrtc::CodecInst gcodec; |
2486 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus"); | 2494 rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus"); |
2487 gcodec.plfreq = 48000; | 2495 gcodec.plfreq = 48000; |
2488 gcodec.channels = 2; | 2496 gcodec.channels = 2; |
2489 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); | 2497 EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec)); |
2490 } | 2498 } |
2491 | 2499 |
2492 // Test that we properly clean up any streams that were added, even if | 2500 // Test that we properly clean up any streams that were added, even if |
2493 // not explicitly removed. | 2501 // not explicitly removed. |
2494 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { | 2502 TEST_F(WebRtcVoiceEngineTestFake, StreamCleanup) { |
2495 EXPECT_TRUE(SetupEngine()); | 2503 EXPECT_TRUE(SetupEngineWithSendStream()); |
2496 send_parameters_.options = options_conference_; | |
2497 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2504 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2498 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2505 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
2499 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2506 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2500 EXPECT_EQ(3, voe_.GetNumChannels()); // default channel + 2 added | 2507 EXPECT_EQ(3, voe_.GetNumChannels()); // default channel + 2 added |
2501 delete channel_; | 2508 delete channel_; |
2502 channel_ = NULL; | 2509 channel_ = NULL; |
2503 EXPECT_EQ(0, voe_.GetNumChannels()); | 2510 EXPECT_EQ(0, voe_.GetNumChannels()); |
2504 } | 2511 } |
2505 | 2512 |
2506 TEST_F(WebRtcVoiceEngineTestFake, TestAddRecvStreamFailWithZeroSsrc) { | 2513 TEST_F(WebRtcVoiceEngineTestFake, TestAddRecvStreamFailWithZeroSsrc) { |
2507 EXPECT_TRUE(SetupEngine()); | 2514 EXPECT_TRUE(SetupEngineWithSendStream()); |
2508 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0))); | 2515 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0))); |
2509 } | 2516 } |
2510 | 2517 |
2511 TEST_F(WebRtcVoiceEngineTestFake, TestNoLeakingWhenAddRecvStreamFail) { | 2518 TEST_F(WebRtcVoiceEngineTestFake, TestNoLeakingWhenAddRecvStreamFail) { |
2512 EXPECT_TRUE(SetupEngine()); | 2519 EXPECT_TRUE(SetupEngine()); |
2513 // Stream 1 reuses default channel. | |
2514 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 2520 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
2515 // Manually delete default channel to simulate a failure. | 2521 // Manually delete channel to simulate a failure. |
2516 int default_channel = voe_.GetLastChannel(); | 2522 int channel = voe_.GetLastChannel(); |
2517 EXPECT_EQ(0, voe_.DeleteChannel(default_channel)); | 2523 EXPECT_EQ(0, voe_.DeleteChannel(channel)); |
2518 // Add recv stream 2 should fail because default channel is gone. | 2524 // Add recv stream 2 should work. |
2519 EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2525 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2520 int new_channel = voe_.GetLastChannel(); | 2526 int new_channel = voe_.GetLastChannel(); |
2521 EXPECT_NE(default_channel, new_channel); | 2527 EXPECT_NE(channel, new_channel); |
2522 // The last created channel should have already been deleted. | 2528 // The last created channel is deleted too. |
2523 EXPECT_EQ(-1, voe_.DeleteChannel(new_channel)); | 2529 EXPECT_EQ(0, voe_.DeleteChannel(new_channel)); |
2524 } | 2530 } |
2525 | 2531 |
2526 // Test the InsertDtmf on default send stream as caller. | 2532 // Test the InsertDtmf on default send stream as caller. |
2527 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { | 2533 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCaller) { |
2528 TestInsertDtmf(0, true); | 2534 TestInsertDtmf(0, true); |
2529 } | 2535 } |
2530 | 2536 |
2531 // Test the InsertDtmf on default send stream as callee | 2537 // Test the InsertDtmf on default send stream as callee |
2532 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { | 2538 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnDefaultSendStreamAsCallee) { |
2533 TestInsertDtmf(0, false); | 2539 TestInsertDtmf(0, false); |
2534 } | 2540 } |
2535 | 2541 |
2536 // Test the InsertDtmf on specified send stream as caller. | 2542 // Test the InsertDtmf on specified send stream as caller. |
2537 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { | 2543 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCaller) { |
2538 TestInsertDtmf(kSsrc1, true); | 2544 TestInsertDtmf(kSsrc1, true); |
2539 } | 2545 } |
2540 | 2546 |
2541 // Test the InsertDtmf on specified send stream as callee. | 2547 // Test the InsertDtmf on specified send stream as callee. |
2542 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { | 2548 TEST_F(WebRtcVoiceEngineTestFake, InsertDtmfOnSendStreamAsCallee) { |
2543 TestInsertDtmf(kSsrc1, false); | 2549 TestInsertDtmf(kSsrc1, false); |
2544 } | 2550 } |
2545 | 2551 |
2546 TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) { | 2552 TEST_F(WebRtcVoiceEngineTestFake, MediaEngineCallbackOnError) { |
2547 rtc::scoped_ptr<ChannelErrorListener> listener; | 2553 rtc::scoped_ptr<ChannelErrorListener> listener; |
2548 cricket::WebRtcVoiceMediaChannel* media_channel; | 2554 cricket::WebRtcVoiceMediaChannel* media_channel; |
2549 unsigned int ssrc = 0; | 2555 unsigned int ssrc = 0; |
2550 | 2556 |
2551 EXPECT_TRUE(SetupEngine()); | 2557 EXPECT_TRUE(SetupEngineWithSendStream()); |
2552 send_parameters_.options = options_conference_; | |
2553 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2558 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2554 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2559 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2555 | 2560 |
2556 media_channel = static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 2561 media_channel = static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
2557 listener.reset(new ChannelErrorListener(channel_)); | 2562 listener.reset(new ChannelErrorListener(channel_)); |
2558 | 2563 |
2559 // Test on WebRtc VoE channel. | 2564 // Test on WebRtc VoE channel. |
2560 voe_.TriggerCallbackOnError(media_channel->voe_channel(), | 2565 voe_.TriggerCallbackOnError(media_channel->voe_channel(), |
2561 VE_SATURATION_WARNING); | 2566 VE_SATURATION_WARNING); |
2562 EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_REC_DEVICE_SATURATION, | 2567 EXPECT_EQ(cricket::VoiceMediaChannel::ERROR_REC_DEVICE_SATURATION, |
(...skipping 19 matching lines...) Expand all Loading... |
2582 EXPECT_EQ(ssrc, listener->ssrc()); | 2587 EXPECT_EQ(ssrc, listener->ssrc()); |
2583 | 2588 |
2584 // Testing a non-existing channel. | 2589 // Testing a non-existing channel. |
2585 listener->Reset(); | 2590 listener->Reset(); |
2586 voe_.TriggerCallbackOnError(voe_.GetLastChannel() + 2, | 2591 voe_.TriggerCallbackOnError(voe_.GetLastChannel() + 2, |
2587 VE_SATURATION_WARNING); | 2592 VE_SATURATION_WARNING); |
2588 EXPECT_EQ(0, listener->error()); | 2593 EXPECT_EQ(0, listener->error()); |
2589 } | 2594 } |
2590 | 2595 |
2591 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { | 2596 TEST_F(WebRtcVoiceEngineTestFake, TestSetPlayoutError) { |
2592 EXPECT_TRUE(SetupEngine()); | 2597 EXPECT_TRUE(SetupEngineWithSendStream()); |
2593 send_parameters_.options = options_conference_; | |
2594 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2598 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2595 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); | 2599 EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); |
2596 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | 2600 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
2597 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); | 2601 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
2598 EXPECT_TRUE(channel_->SetPlayout(true)); | 2602 EXPECT_TRUE(channel_->SetPlayout(true)); |
2599 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); | 2603 voe_.set_playout_fail_channel(voe_.GetLastChannel() - 1); |
2600 EXPECT_TRUE(channel_->SetPlayout(false)); | 2604 EXPECT_TRUE(channel_->SetPlayout(false)); |
2601 EXPECT_FALSE(channel_->SetPlayout(true)); | 2605 EXPECT_FALSE(channel_->SetPlayout(true)); |
2602 } | 2606 } |
2603 | 2607 |
2604 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { | 2608 TEST_F(WebRtcVoiceEngineTestFake, SetAudioOptions) { |
2605 EXPECT_TRUE(SetupEngine()); | 2609 EXPECT_TRUE(SetupEngineWithSendStream()); |
2606 | 2610 |
2607 bool ec_enabled; | 2611 bool ec_enabled; |
2608 webrtc::EcModes ec_mode; | 2612 webrtc::EcModes ec_mode; |
2609 bool ec_metrics_enabled; | 2613 bool ec_metrics_enabled; |
2610 webrtc::AecmModes aecm_mode; | 2614 webrtc::AecmModes aecm_mode; |
2611 bool cng_enabled; | 2615 bool cng_enabled; |
2612 bool agc_enabled; | 2616 bool agc_enabled; |
2613 webrtc::AgcModes agc_mode; | 2617 webrtc::AgcModes agc_mode; |
2614 webrtc::AgcConfig agc_config; | 2618 webrtc::AgcConfig agc_config; |
2615 bool ns_enabled; | 2619 bool ns_enabled; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 ASSERT_TRUE(engine_.SetOptions(options)); | 2749 ASSERT_TRUE(engine_.SetOptions(options)); |
2746 voe_.GetNsStatus(ns_enabled, ns_mode); | 2750 voe_.GetNsStatus(ns_enabled, ns_mode); |
2747 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); | 2751 highpass_filter_enabled = voe_.IsHighPassFilterEnabled(); |
2748 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); | 2752 stereo_swapping_enabled = voe_.IsStereoChannelSwappingEnabled(); |
2749 voe_.GetTypingDetectionStatus(typing_detection_enabled); | 2753 voe_.GetTypingDetectionStatus(typing_detection_enabled); |
2750 EXPECT_FALSE(ns_enabled); | 2754 EXPECT_FALSE(ns_enabled); |
2751 EXPECT_FALSE(highpass_filter_enabled); | 2755 EXPECT_FALSE(highpass_filter_enabled); |
2752 EXPECT_FALSE(typing_detection_enabled); | 2756 EXPECT_FALSE(typing_detection_enabled); |
2753 EXPECT_TRUE(stereo_swapping_enabled); | 2757 EXPECT_TRUE(stereo_swapping_enabled); |
2754 | 2758 |
2755 // Turn on "conference mode" to ensure it has no impact. | 2759 // Set options again to ensure it has no impact. |
2756 options.conference_mode.Set(true); | |
2757 ASSERT_TRUE(engine_.SetOptions(options)); | 2760 ASSERT_TRUE(engine_.SetOptions(options)); |
2758 voe_.GetEcStatus(ec_enabled, ec_mode); | 2761 voe_.GetEcStatus(ec_enabled, ec_mode); |
2759 voe_.GetNsStatus(ns_enabled, ns_mode); | 2762 voe_.GetNsStatus(ns_enabled, ns_mode); |
2760 EXPECT_TRUE(ec_enabled); | 2763 EXPECT_TRUE(ec_enabled); |
2761 EXPECT_EQ(webrtc::kEcConference, ec_mode); | 2764 EXPECT_EQ(webrtc::kEcConference, ec_mode); |
2762 EXPECT_FALSE(ns_enabled); | 2765 EXPECT_FALSE(ns_enabled); |
2763 EXPECT_EQ(webrtc::kNsHighSuppression, ns_mode); | 2766 EXPECT_EQ(webrtc::kNsHighSuppression, ns_mode); |
2764 } | 2767 } |
2765 | 2768 |
2766 TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) { | 2769 TEST_F(WebRtcVoiceEngineTestFake, DefaultOptions) { |
2767 EXPECT_TRUE(SetupEngine()); | 2770 EXPECT_TRUE(SetupEngineWithSendStream()); |
2768 | 2771 |
2769 bool ec_enabled; | 2772 bool ec_enabled; |
2770 webrtc::EcModes ec_mode; | 2773 webrtc::EcModes ec_mode; |
2771 bool ec_metrics_enabled; | 2774 bool ec_metrics_enabled; |
2772 bool agc_enabled; | 2775 bool agc_enabled; |
2773 webrtc::AgcModes agc_mode; | 2776 webrtc::AgcModes agc_mode; |
2774 bool ns_enabled; | 2777 bool ns_enabled; |
2775 webrtc::NsModes ns_mode; | 2778 webrtc::NsModes ns_mode; |
2776 bool highpass_filter_enabled; | 2779 bool highpass_filter_enabled; |
2777 bool stereo_swapping_enabled; | 2780 bool stereo_swapping_enabled; |
(...skipping 24 matching lines...) Expand all Loading... |
2802 | 2805 |
2803 webrtc::AgcConfig config = {0}; | 2806 webrtc::AgcConfig config = {0}; |
2804 EXPECT_EQ(0, voe_.GetAgcConfig(config)); | 2807 EXPECT_EQ(0, voe_.GetAgcConfig(config)); |
2805 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv); | 2808 EXPECT_EQ(set_config.targetLeveldBOv, config.targetLeveldBOv); |
2806 EXPECT_EQ(set_config.digitalCompressionGaindB, | 2809 EXPECT_EQ(set_config.digitalCompressionGaindB, |
2807 config.digitalCompressionGaindB); | 2810 config.digitalCompressionGaindB); |
2808 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable); | 2811 EXPECT_EQ(set_config.limiterEnable, config.limiterEnable); |
2809 } | 2812 } |
2810 | 2813 |
2811 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { | 2814 TEST_F(WebRtcVoiceEngineTestFake, SetOptionOverridesViaChannels) { |
2812 EXPECT_TRUE(SetupEngine()); | 2815 EXPECT_TRUE(SetupEngineWithSendStream()); |
2813 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel1( | 2816 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel1( |
2814 static_cast<cricket::WebRtcVoiceMediaChannel*>( | 2817 static_cast<cricket::WebRtcVoiceMediaChannel*>( |
2815 engine_.CreateChannel(&call_, cricket::AudioOptions()))); | 2818 engine_.CreateChannel(&call_, cricket::AudioOptions()))); |
2816 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel2( | 2819 rtc::scoped_ptr<cricket::WebRtcVoiceMediaChannel> channel2( |
2817 static_cast<cricket::WebRtcVoiceMediaChannel*>( | 2820 static_cast<cricket::WebRtcVoiceMediaChannel*>( |
2818 engine_.CreateChannel(&call_, cricket::AudioOptions()))); | 2821 engine_.CreateChannel(&call_, cricket::AudioOptions()))); |
2819 | 2822 |
2820 // Have to add a stream to make SetSend work. | 2823 // Have to add a stream to make SetSend work. |
2821 cricket::StreamParams stream1; | 2824 cricket::StreamParams stream1; |
2822 stream1.ssrcs.push_back(1); | 2825 stream1.ssrcs.push_back(1); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2915 voe_.GetEcStatus(ec_enabled, ec_mode); | 2918 voe_.GetEcStatus(ec_enabled, ec_mode); |
2916 voe_.GetAgcStatus(agc_enabled, agc_mode); | 2919 voe_.GetAgcStatus(agc_enabled, agc_mode); |
2917 voe_.GetNsStatus(ns_enabled, ns_mode); | 2920 voe_.GetNsStatus(ns_enabled, ns_mode); |
2918 EXPECT_TRUE(ec_enabled); | 2921 EXPECT_TRUE(ec_enabled); |
2919 EXPECT_FALSE(agc_enabled); | 2922 EXPECT_FALSE(agc_enabled); |
2920 EXPECT_FALSE(ns_enabled); | 2923 EXPECT_FALSE(ns_enabled); |
2921 } | 2924 } |
2922 | 2925 |
2923 // This test verifies DSCP settings are properly applied on voice media channel. | 2926 // This test verifies DSCP settings are properly applied on voice media channel. |
2924 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { | 2927 TEST_F(WebRtcVoiceEngineTestFake, TestSetDscpOptions) { |
2925 EXPECT_TRUE(SetupEngine()); | 2928 EXPECT_TRUE(SetupEngineWithSendStream()); |
2926 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel( | 2929 rtc::scoped_ptr<cricket::VoiceMediaChannel> channel( |
2927 engine_.CreateChannel(&call_, cricket::AudioOptions())); | 2930 engine_.CreateChannel(&call_, cricket::AudioOptions())); |
2928 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( | 2931 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( |
2929 new cricket::FakeNetworkInterface); | 2932 new cricket::FakeNetworkInterface); |
2930 channel->SetInterface(network_interface.get()); | 2933 channel->SetInterface(network_interface.get()); |
2931 cricket::AudioSendParameters parameters = send_parameters_; | 2934 cricket::AudioSendParameters parameters = send_parameters_; |
2932 parameters.options.dscp.Set(true); | 2935 parameters.options.dscp.Set(true); |
2933 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 2936 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
2934 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); | 2937 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); |
2935 // Verify previous value is not modified if dscp option is not set. | 2938 // Verify previous value is not modified if dscp option is not set. |
2936 EXPECT_TRUE(channel->SetSendParameters(send_parameters_)); | 2939 EXPECT_TRUE(channel->SetSendParameters(send_parameters_)); |
2937 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); | 2940 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); |
2938 parameters.options.dscp.Set(false); | 2941 parameters.options.dscp.Set(false); |
2939 EXPECT_TRUE(channel->SetSendParameters(parameters)); | 2942 EXPECT_TRUE(channel->SetSendParameters(parameters)); |
2940 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); | 2943 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); |
2941 } | 2944 } |
2942 | 2945 |
2943 // Test that GetReceiveChannelNum returns the default channel for the first | 2946 // Test that GetReceiveChannelNum returns the default channel for the first |
2944 // recv stream in 1-1 calls. | 2947 // recv stream in 1-1 calls. |
2945 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNumIn1To1Calls) { | 2948 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNum) { |
2946 EXPECT_TRUE(SetupEngine()); | 2949 EXPECT_TRUE(SetupEngine()); |
2947 cricket::WebRtcVoiceMediaChannel* media_channel = | 2950 cricket::WebRtcVoiceMediaChannel* media_channel = |
2948 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 2951 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
2949 // Test that GetChannelNum returns the default channel if the SSRC is unknown. | 2952 EXPECT_EQ(-1, media_channel->GetReceiveChannelNum(0)); |
2950 EXPECT_EQ(media_channel->voe_channel(), | 2953 EXPECT_TRUE(channel_->AddRecvStream( |
2951 media_channel->GetReceiveChannelNum(0)); | 2954 cricket::StreamParams::CreateLegacy(kSsrc1))); |
2952 cricket::StreamParams stream; | 2955 int channel_id = voe_.GetLastChannel(); |
2953 stream.ssrcs.push_back(kSsrc2); | 2956 EXPECT_EQ(channel_id, media_channel->GetReceiveChannelNum(kSsrc1)); |
2954 EXPECT_TRUE(channel_->AddRecvStream(stream)); | 2957 EXPECT_EQ(-1, media_channel->GetReceiveChannelNum(kSsrc2)); |
2955 EXPECT_EQ(media_channel->voe_channel(), | 2958 EXPECT_TRUE(channel_->AddRecvStream( |
2956 media_channel->GetReceiveChannelNum(kSsrc2)); | 2959 cricket::StreamParams::CreateLegacy(kSsrc2))); |
2957 } | 2960 int channel_id2 = voe_.GetLastChannel(); |
2958 | 2961 EXPECT_EQ(channel_id2, media_channel->GetReceiveChannelNum(kSsrc2)); |
2959 // Test that GetReceiveChannelNum doesn't return the default channel for the | |
2960 // first recv stream in conference calls. | |
2961 TEST_F(WebRtcVoiceEngineTestFake, TestGetChannelNumInConferenceCalls) { | |
2962 EXPECT_TRUE(SetupEngine()); | |
2963 send_parameters_.options = options_conference_; | |
2964 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
2965 cricket::StreamParams stream; | |
2966 stream.ssrcs.push_back(kSsrc2); | |
2967 EXPECT_TRUE(channel_->AddRecvStream(stream)); | |
2968 cricket::WebRtcVoiceMediaChannel* media_channel = | |
2969 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
2970 EXPECT_LT(media_channel->voe_channel(), | |
2971 media_channel->GetReceiveChannelNum(kSsrc2)); | |
2972 } | 2962 } |
2973 | 2963 |
2974 TEST_F(WebRtcVoiceEngineTestFake, SetOutputScaling) { | 2964 TEST_F(WebRtcVoiceEngineTestFake, SetOutputScaling) { |
2975 EXPECT_TRUE(SetupEngine()); | 2965 EXPECT_TRUE(SetupEngineWithRecvStream()); |
2976 float scale, left, right; | 2966 float scale, left, right; |
2977 EXPECT_TRUE(channel_->SetOutputScaling(0, 1, 2)); | 2967 EXPECT_TRUE(channel_->SetOutputScaling(0, 1, 2)); |
2978 int channel_id = voe_.GetLastChannel(); | 2968 int channel_id = voe_.GetLastChannel(); |
2979 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); | 2969 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); |
2980 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); | 2970 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); |
2981 EXPECT_DOUBLE_EQ(1, left * scale); | 2971 EXPECT_DOUBLE_EQ(1, left * scale); |
2982 EXPECT_DOUBLE_EQ(2, right * scale); | 2972 EXPECT_DOUBLE_EQ(2, right * scale); |
2983 | 2973 |
2984 EXPECT_FALSE(channel_->SetOutputScaling(kSsrc2, 1, 2)); | 2974 EXPECT_FALSE(channel_->SetOutputScaling(kSsrc2, 1, 2)); |
2985 cricket::StreamParams stream; | 2975 cricket::StreamParams stream; |
2986 stream.ssrcs.push_back(kSsrc2); | 2976 stream.ssrcs.push_back(kSsrc2); |
2987 EXPECT_TRUE(channel_->AddRecvStream(stream)); | 2977 EXPECT_TRUE(channel_->AddRecvStream(stream)); |
2988 | 2978 |
2989 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1)); | 2979 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1)); |
2990 channel_id = voe_.GetLastChannel(); | 2980 channel_id = voe_.GetLastChannel(); |
2991 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); | 2981 EXPECT_EQ(0, voe_.GetChannelOutputVolumeScaling(channel_id, scale)); |
2992 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); | 2982 EXPECT_EQ(0, voe_.GetOutputVolumePan(channel_id, left, right)); |
2993 EXPECT_DOUBLE_EQ(2, left * scale); | 2983 EXPECT_DOUBLE_EQ(2, left * scale); |
2994 EXPECT_DOUBLE_EQ(1, right * scale); | 2984 EXPECT_DOUBLE_EQ(1, right * scale); |
2995 } | 2985 } |
2996 | 2986 |
2997 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { | 2987 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { |
2998 const uint32 kAudioSsrc = 123; | 2988 const uint32 kAudioSsrc = 123; |
2999 const std::string kSyncLabel = "AvSyncLabel"; | 2989 const std::string kSyncLabel = "AvSyncLabel"; |
3000 | 2990 |
3001 EXPECT_TRUE(SetupEngine()); | 2991 EXPECT_TRUE(SetupEngineWithSendStream()); |
3002 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); | 2992 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); |
3003 sp.sync_label = kSyncLabel; | 2993 sp.sync_label = kSyncLabel; |
3004 // Creating two channels to make sure that sync label is set properly for both | 2994 // Creating two channels to make sure that sync label is set properly for both |
3005 // the default voice channel and following ones. | 2995 // the default voice channel and following ones. |
3006 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 2996 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
3007 sp.ssrcs[0] += 1; | 2997 sp.ssrcs[0] += 1; |
3008 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 2998 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
3009 | 2999 |
3010 ASSERT_EQ(2, call_.GetAudioReceiveStreams().size()); | 3000 ASSERT_EQ(2, call_.GetAudioReceiveStreams().size()); |
3011 EXPECT_EQ(kSyncLabel, | 3001 EXPECT_EQ(kSyncLabel, |
3012 call_.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) | 3002 call_.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) |
3013 << "SyncGroup should be set based on sync_label"; | 3003 << "SyncGroup should be set based on sync_label"; |
3014 EXPECT_EQ(kSyncLabel, | 3004 EXPECT_EQ(kSyncLabel, |
3015 call_.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) | 3005 call_.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) |
3016 << "SyncGroup should be set based on sync_label"; | 3006 << "SyncGroup should be set based on sync_label"; |
3017 } | 3007 } |
3018 | 3008 |
3019 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { | 3009 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { |
3020 // Test that changing the combined_audio_video_bwe option results in the | 3010 // Test that changing the combined_audio_video_bwe option results in the |
3021 // expected state changes on an associated Call. | 3011 // expected state changes on an associated Call. |
3022 std::vector<uint32> ssrcs; | 3012 std::vector<uint32> ssrcs; |
3023 ssrcs.push_back(223); | 3013 ssrcs.push_back(223); |
3024 ssrcs.push_back(224); | 3014 ssrcs.push_back(224); |
3025 | 3015 |
3026 EXPECT_TRUE(SetupEngine()); | 3016 EXPECT_TRUE(SetupEngineWithSendStream()); |
3027 cricket::WebRtcVoiceMediaChannel* media_channel = | 3017 cricket::WebRtcVoiceMediaChannel* media_channel = |
3028 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3018 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3029 for (uint32 ssrc : ssrcs) { | 3019 for (uint32 ssrc : ssrcs) { |
3030 EXPECT_TRUE(media_channel->AddRecvStream( | 3020 EXPECT_TRUE(media_channel->AddRecvStream( |
3031 cricket::StreamParams::CreateLegacy(ssrc))); | 3021 cricket::StreamParams::CreateLegacy(ssrc))); |
3032 } | 3022 } |
3033 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); | 3023 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); |
3034 | 3024 |
3035 // Combined BWE should be disabled. | 3025 // Combined BWE should be disabled. |
3036 for (uint32 ssrc : ssrcs) { | 3026 for (uint32 ssrc : ssrcs) { |
(...skipping 19 matching lines...) Expand all Loading... |
3056 EXPECT_NE(nullptr, s); | 3046 EXPECT_NE(nullptr, s); |
3057 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); | 3047 EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); |
3058 } | 3048 } |
3059 | 3049 |
3060 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); | 3050 EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); |
3061 } | 3051 } |
3062 | 3052 |
3063 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { | 3053 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { |
3064 // Test that adding receive streams after enabling combined bandwidth | 3054 // Test that adding receive streams after enabling combined bandwidth |
3065 // estimation will correctly configure each channel. | 3055 // estimation will correctly configure each channel. |
3066 EXPECT_TRUE(SetupEngine()); | 3056 EXPECT_TRUE(SetupEngineWithSendStream()); |
3067 cricket::WebRtcVoiceMediaChannel* media_channel = | 3057 cricket::WebRtcVoiceMediaChannel* media_channel = |
3068 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3058 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3069 send_parameters_.options.combined_audio_video_bwe.Set(true); | 3059 send_parameters_.options.combined_audio_video_bwe.Set(true); |
3070 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); | 3060 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); |
3071 | 3061 |
3072 static const uint32 kSsrcs[] = {1, 2, 3, 4}; | 3062 static const uint32 kSsrcs[] = {1, 2, 3, 4}; |
3073 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { | 3063 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { |
3074 EXPECT_TRUE(media_channel->AddRecvStream( | 3064 EXPECT_TRUE(media_channel->AddRecvStream( |
3075 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); | 3065 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); |
3076 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); | 3066 EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i])); |
3077 } | 3067 } |
3078 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); | 3068 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size()); |
3079 } | 3069 } |
3080 | 3070 |
3081 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { | 3071 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { |
3082 // Test that setting the header extensions results in the expected state | 3072 // Test that setting the header extensions results in the expected state |
3083 // changes on an associated Call. | 3073 // changes on an associated Call. |
3084 std::vector<uint32> ssrcs; | 3074 std::vector<uint32> ssrcs; |
3085 ssrcs.push_back(223); | 3075 ssrcs.push_back(223); |
3086 ssrcs.push_back(224); | 3076 ssrcs.push_back(224); |
3087 | 3077 |
3088 EXPECT_TRUE(SetupEngine()); | 3078 EXPECT_TRUE(SetupEngineWithSendStream()); |
3089 cricket::WebRtcVoiceMediaChannel* media_channel = | 3079 cricket::WebRtcVoiceMediaChannel* media_channel = |
3090 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3080 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3091 send_parameters_.options.combined_audio_video_bwe.Set(true); | 3081 send_parameters_.options.combined_audio_video_bwe.Set(true); |
3092 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); | 3082 EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); |
3093 for (uint32 ssrc : ssrcs) { | 3083 for (uint32 ssrc : ssrcs) { |
3094 EXPECT_TRUE(media_channel->AddRecvStream( | 3084 EXPECT_TRUE(media_channel->AddRecvStream( |
3095 cricket::StreamParams::CreateLegacy(ssrc))); | 3085 cricket::StreamParams::CreateLegacy(ssrc))); |
3096 } | 3086 } |
3097 | 3087 |
3098 // Combined BWE should be set up, but with no configured extensions. | 3088 // Combined BWE should be set up, but with no configured extensions. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3137 const uint32 kAudioSsrc = 1; | 3127 const uint32 kAudioSsrc = 1; |
3138 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 3128 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
3139 static const unsigned char kRtcp[] = { | 3129 static const unsigned char kRtcp[] = { |
3140 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, | 3130 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, |
3141 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, | 3131 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, |
3142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 3132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
3143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 3133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
3144 }; | 3134 }; |
3145 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); | 3135 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); |
3146 | 3136 |
3147 EXPECT_TRUE(SetupEngine()); | 3137 EXPECT_TRUE(SetupEngineWithSendStream()); |
3148 cricket::WebRtcVoiceMediaChannel* media_channel = | 3138 cricket::WebRtcVoiceMediaChannel* media_channel = |
3149 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3139 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3150 send_parameters_.options.combined_audio_video_bwe.Set(true); | 3140 send_parameters_.options.combined_audio_video_bwe.Set(true); |
3151 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 3141 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
3152 EXPECT_TRUE(media_channel->AddRecvStream( | 3142 EXPECT_TRUE(media_channel->AddRecvStream( |
3153 cricket::StreamParams::CreateLegacy(kAudioSsrc))); | 3143 cricket::StreamParams::CreateLegacy(kAudioSsrc))); |
3154 | 3144 |
3155 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size()); | 3145 EXPECT_EQ(1, call_.GetAudioReceiveStreams().size()); |
3156 const cricket::FakeAudioReceiveStream* s = | 3146 const cricket::FakeAudioReceiveStream* s = |
3157 call_.GetAudioReceiveStream(kAudioSsrc); | 3147 call_.GetAudioReceiveStream(kAudioSsrc); |
3158 EXPECT_EQ(0, s->received_packets()); | 3148 EXPECT_EQ(0, s->received_packets()); |
3159 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); | 3149 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); |
3160 EXPECT_EQ(1, s->received_packets()); | 3150 EXPECT_EQ(1, s->received_packets()); |
3161 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); | 3151 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); |
3162 EXPECT_EQ(2, s->received_packets()); | 3152 EXPECT_EQ(2, s->received_packets()); |
3163 } | 3153 } |
3164 | 3154 |
3165 // Associate channel should not set on 1:1 call, since the receive channel also | 3155 // All receive channels should be associated with the default send channel, |
3166 // sends RTCP SR. | 3156 // since they do not send RTCP SR. |
3167 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelUnset1On1) { | |
3168 EXPECT_TRUE(SetupEngine()); | |
3169 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
3170 int recv_ch = voe_.GetLastChannel(); | |
3171 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); | |
3172 } | |
3173 | |
3174 // This test is an extension of AssociateChannelUnset1On1. We create two receive | |
3175 // channels. The second should be associated with the default channel, since it | |
3176 // does not send RTCP SR. | |
3177 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnSecondRecvChannel) { | |
3178 EXPECT_TRUE(SetupEngine()); | |
3179 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3180 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3181 int default_channel = media_channel->voe_channel(); | |
3182 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
3183 int recv_ch_1 = voe_.GetLastChannel(); | |
3184 EXPECT_EQ(recv_ch_1, default_channel); | |
3185 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | |
3186 int recv_ch_2 = voe_.GetLastChannel(); | |
3187 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); | |
3188 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); | |
3189 // Add send stream, the association remains. | |
3190 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); | |
3191 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); | |
3192 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); | |
3193 } | |
3194 | |
3195 // In conference mode, all receive channels should be associated with the | |
3196 // default channel, since they do not send RTCP SR. | |
3197 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { | 3157 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { |
3198 EXPECT_TRUE(SetupEngine()); | 3158 EXPECT_TRUE(SetupEngineWithSendStream()); |
3199 send_parameters_.options = options_conference_; | |
3200 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 3159 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
3201 cricket::WebRtcVoiceMediaChannel* media_channel = | 3160 cricket::WebRtcVoiceMediaChannel* media_channel = |
3202 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3161 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3203 int default_channel = media_channel->voe_channel(); | 3162 int default_channel = media_channel->voe_channel(); |
3204 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 3163 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
3205 int recv_ch = voe_.GetLastChannel(); | 3164 int recv_ch = voe_.GetLastChannel(); |
3206 EXPECT_NE(recv_ch, default_channel); | 3165 EXPECT_NE(recv_ch, default_channel); |
3207 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | 3166 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); |
3208 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); | 3167 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); |
3209 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | 3168 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); |
| 3169 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(3))); |
| 3170 recv_ch = voe_.GetLastChannel(); |
| 3171 EXPECT_NE(recv_ch, default_channel); |
| 3172 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); |
3210 } | 3173 } |
3211 | 3174 |
3212 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { | 3175 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { |
3213 EXPECT_TRUE(SetupEngine()); | 3176 EXPECT_TRUE(SetupEngineWithSendStream()); |
3214 send_parameters_.options = options_conference_; | |
3215 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 3177 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
3216 | 3178 |
3217 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | 3179 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
3218 int recv_ch = voe_.GetLastChannel(); | 3180 int recv_ch = voe_.GetLastChannel(); |
3219 | 3181 |
3220 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); | 3182 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); |
3221 int send_ch = voe_.GetLastChannel(); | 3183 int send_ch = voe_.GetLastChannel(); |
3222 | 3184 |
3223 // Manually associate |recv_ch| to |send_ch|. This test is to verify a | 3185 // Manually associate |recv_ch| to |send_ch|. This test is to verify a |
3224 // deleting logic, i.e., deleting |send_ch| will reset the associate send | 3186 // 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... |
3357 break; | 3319 break; |
3358 channels[num_channels++] = channel; | 3320 channels[num_channels++] = channel; |
3359 } | 3321 } |
3360 | 3322 |
3361 int expected = ARRAY_SIZE(channels); | 3323 int expected = ARRAY_SIZE(channels); |
3362 EXPECT_EQ(expected, num_channels); | 3324 EXPECT_EQ(expected, num_channels); |
3363 | 3325 |
3364 while (num_channels > 0) { | 3326 while (num_channels > 0) { |
3365 delete channels[--num_channels]; | 3327 delete channels[--num_channels]; |
3366 } | 3328 } |
3367 | |
3368 engine.Terminate(); | 3329 engine.Terminate(); |
3369 } | 3330 } |
3370 | 3331 |
3371 // Test that we set our preferred codecs properly. | 3332 // Test that we set our preferred codecs properly. |
3372 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3333 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
3373 cricket::WebRtcVoiceEngine engine; | 3334 cricket::WebRtcVoiceEngine engine; |
3374 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3335 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3375 rtc::scoped_ptr<webrtc::Call> call( | 3336 rtc::scoped_ptr<webrtc::Call> call( |
3376 webrtc::Call::Create(webrtc::Call::Config())); | 3337 webrtc::Call::Create(webrtc::Call::Config())); |
3377 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), | 3338 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), |
3378 call.get()); | 3339 call.get()); |
3379 cricket::AudioRecvParameters parameters; | 3340 cricket::AudioRecvParameters parameters; |
3380 parameters.codecs = engine.codecs(); | 3341 parameters.codecs = engine.codecs(); |
3381 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3342 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3382 } | 3343 } |
OLD | NEW |