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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1, 0); | 47 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1, 0); |
48 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0); | 48 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0); |
49 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0); | 49 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0); |
50 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0); | 50 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0); |
51 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); | 51 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); |
52 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); | 52 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); |
53 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); | 53 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); |
54 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); | 54 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); |
55 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 0, | 55 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 0, |
56 1, 0); | 56 1, 0); |
57 const cricket::AudioCodec* const kAudioCodecs[] = { | |
58 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec, | |
59 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec, | |
60 }; | |
61 const uint32_t kSsrc1 = 0x99; | 57 const uint32_t kSsrc1 = 0x99; |
62 const uint32_t kSsrc2 = 0x98; | 58 const uint32_t kSsrc2 = 0x98; |
63 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; | 59 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; |
64 | 60 |
65 class FakeVoEWrapper : public cricket::VoEWrapper { | 61 class FakeVoEWrapper : public cricket::VoEWrapper { |
66 public: | 62 public: |
67 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) | 63 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) |
68 : cricket::VoEWrapper(engine, // processing | 64 : cricket::VoEWrapper(engine, // processing |
69 engine, // base | 65 engine, // base |
70 engine, // codec | 66 engine, // codec |
71 engine, // dtmf | 67 engine, // dtmf |
72 engine, // hw | 68 engine, // hw |
73 engine, // network | 69 engine, // network |
74 engine, // rtp | 70 engine, // rtp |
75 engine) { // volume | 71 engine) { // volume |
76 } | 72 } |
77 }; | 73 }; |
78 } // namespace | 74 } // namespace |
79 | 75 |
80 class WebRtcVoiceEngineTestFake : public testing::Test { | 76 class WebRtcVoiceEngineTestFake : public testing::Test { |
81 public: | 77 public: |
82 WebRtcVoiceEngineTestFake() | 78 WebRtcVoiceEngineTestFake() |
83 : call_(webrtc::Call::Config()), | 79 : call_(webrtc::Call::Config()), |
84 voe_(kAudioCodecs, arraysize(kAudioCodecs)), | |
85 engine_(new FakeVoEWrapper(&voe_)), | 80 engine_(new FakeVoEWrapper(&voe_)), |
86 channel_(nullptr) { | 81 channel_(nullptr) { |
87 send_parameters_.codecs.push_back(kPcmuCodec); | 82 send_parameters_.codecs.push_back(kPcmuCodec); |
88 recv_parameters_.codecs.push_back(kPcmuCodec); | 83 recv_parameters_.codecs.push_back(kPcmuCodec); |
89 options_adjust_agc_.adjust_agc_delta = rtc::Optional<int>(-10); | 84 options_adjust_agc_.adjust_agc_delta = rtc::Optional<int>(-10); |
90 } | 85 } |
91 bool SetupEngine() { | 86 bool SetupEngine() { |
92 if (!engine_.Init(rtc::Thread::Current())) { | 87 if (!engine_.Init(rtc::Thread::Current())) { |
93 return false; | 88 return false; |
94 } | 89 } |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 pref = codecs[i].preference; | 439 pref = codecs[i].preference; |
445 } | 440 } |
446 } | 441 } |
447 | 442 |
448 // Tests that we can find codecs by name or id, and that we interpret the | 443 // Tests that we can find codecs by name or id, and that we interpret the |
449 // clockrate and bitrate fields properly. | 444 // clockrate and bitrate fields properly. |
450 TEST_F(WebRtcVoiceEngineTestFake, FindCodec) { | 445 TEST_F(WebRtcVoiceEngineTestFake, FindCodec) { |
451 cricket::AudioCodec codec; | 446 cricket::AudioCodec codec; |
452 webrtc::CodecInst codec_inst; | 447 webrtc::CodecInst codec_inst; |
453 // Find PCMU with explicit clockrate and bitrate. | 448 // Find PCMU with explicit clockrate and bitrate. |
454 EXPECT_TRUE(engine_.FindWebRtcCodec(kPcmuCodec, &codec_inst)); | 449 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kPcmuCodec, &codec_inst)); |
455 // Find ISAC with explicit clockrate and 0 bitrate. | 450 // Find ISAC with explicit clockrate and 0 bitrate. |
456 EXPECT_TRUE(engine_.FindWebRtcCodec(kIsacCodec, &codec_inst)); | 451 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kIsacCodec, &codec_inst)); |
457 // Find telephone-event with explicit clockrate and 0 bitrate. | 452 // Find telephone-event with explicit clockrate and 0 bitrate. |
458 EXPECT_TRUE(engine_.FindWebRtcCodec(kTelephoneEventCodec, &codec_inst)); | 453 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kTelephoneEventCodec, |
| 454 &codec_inst)); |
459 // Find ISAC with a different payload id. | 455 // Find ISAC with a different payload id. |
460 codec = kIsacCodec; | 456 codec = kIsacCodec; |
461 codec.id = 127; | 457 codec.id = 127; |
462 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); | 458 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); |
463 EXPECT_EQ(codec.id, codec_inst.pltype); | 459 EXPECT_EQ(codec.id, codec_inst.pltype); |
464 // Find PCMU with a 0 clockrate. | 460 // Find PCMU with a 0 clockrate. |
465 codec = kPcmuCodec; | 461 codec = kPcmuCodec; |
466 codec.clockrate = 0; | 462 codec.clockrate = 0; |
467 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); | 463 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); |
468 EXPECT_EQ(codec.id, codec_inst.pltype); | 464 EXPECT_EQ(codec.id, codec_inst.pltype); |
469 EXPECT_EQ(8000, codec_inst.plfreq); | 465 EXPECT_EQ(8000, codec_inst.plfreq); |
470 // Find PCMU with a 0 bitrate. | 466 // Find PCMU with a 0 bitrate. |
471 codec = kPcmuCodec; | 467 codec = kPcmuCodec; |
472 codec.bitrate = 0; | 468 codec.bitrate = 0; |
473 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); | 469 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); |
474 EXPECT_EQ(codec.id, codec_inst.pltype); | 470 EXPECT_EQ(codec.id, codec_inst.pltype); |
475 EXPECT_EQ(64000, codec_inst.rate); | 471 EXPECT_EQ(64000, codec_inst.rate); |
476 // Find ISAC with an explicit bitrate. | 472 // Find ISAC with an explicit bitrate. |
477 codec = kIsacCodec; | 473 codec = kIsacCodec; |
478 codec.bitrate = 32000; | 474 codec.bitrate = 32000; |
479 EXPECT_TRUE(engine_.FindWebRtcCodec(codec, &codec_inst)); | 475 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(codec, &codec_inst)); |
480 EXPECT_EQ(codec.id, codec_inst.pltype); | 476 EXPECT_EQ(codec.id, codec_inst.pltype); |
481 EXPECT_EQ(32000, codec_inst.rate); | 477 EXPECT_EQ(32000, codec_inst.rate); |
482 } | 478 } |
483 | 479 |
484 // Test that we set our inbound codecs properly, including changing PT. | 480 // Test that we set our inbound codecs properly, including changing PT. |
485 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { | 481 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecs) { |
486 EXPECT_TRUE(SetupEngine()); | 482 EXPECT_TRUE(SetupEngine()); |
487 cricket::AudioRecvParameters parameters; | 483 cricket::AudioRecvParameters parameters; |
488 parameters.codecs.push_back(kIsacCodec); | 484 parameters.codecs.push_back(kIsacCodec); |
489 parameters.codecs.push_back(kPcmuCodec); | 485 parameters.codecs.push_back(kPcmuCodec); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 EXPECT_TRUE(SetupEngine()); | 528 EXPECT_TRUE(SetupEngine()); |
533 cricket::AudioRecvParameters parameters; | 529 cricket::AudioRecvParameters parameters; |
534 parameters.codecs.push_back(kIsacCodec); | 530 parameters.codecs.push_back(kIsacCodec); |
535 parameters.codecs.push_back(kPcmuCodec); | 531 parameters.codecs.push_back(kPcmuCodec); |
536 parameters.codecs.push_back(kOpusCodec); | 532 parameters.codecs.push_back(kOpusCodec); |
537 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 533 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
538 EXPECT_TRUE(channel_->AddRecvStream( | 534 EXPECT_TRUE(channel_->AddRecvStream( |
539 cricket::StreamParams::CreateLegacy(kSsrc1))); | 535 cricket::StreamParams::CreateLegacy(kSsrc1))); |
540 int channel_num = voe_.GetLastChannel(); | 536 int channel_num = voe_.GetLastChannel(); |
541 webrtc::CodecInst opus; | 537 webrtc::CodecInst opus; |
542 engine_.FindWebRtcCodec(kOpusCodec, &opus); | 538 cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &opus); |
543 // Even without stereo parameters, recv codecs still specify channels = 2. | 539 // Even without stereo parameters, recv codecs still specify channels = 2. |
544 EXPECT_EQ(2, opus.channels); | 540 EXPECT_EQ(2, opus.channels); |
545 EXPECT_EQ(111, opus.pltype); | 541 EXPECT_EQ(111, opus.pltype); |
546 EXPECT_STREQ("opus", opus.plname); | 542 EXPECT_STREQ("opus", opus.plname); |
547 opus.pltype = 0; | 543 opus.pltype = 0; |
548 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, opus)); | 544 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, opus)); |
549 EXPECT_EQ(111, opus.pltype); | 545 EXPECT_EQ(111, opus.pltype); |
550 } | 546 } |
551 | 547 |
552 // Test that we can decode OPUS with stereo = 0. | 548 // Test that we can decode OPUS with stereo = 0. |
553 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { | 549 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus0Stereo) { |
554 EXPECT_TRUE(SetupEngine()); | 550 EXPECT_TRUE(SetupEngine()); |
555 cricket::AudioRecvParameters parameters; | 551 cricket::AudioRecvParameters parameters; |
556 parameters.codecs.push_back(kIsacCodec); | 552 parameters.codecs.push_back(kIsacCodec); |
557 parameters.codecs.push_back(kPcmuCodec); | 553 parameters.codecs.push_back(kPcmuCodec); |
558 parameters.codecs.push_back(kOpusCodec); | 554 parameters.codecs.push_back(kOpusCodec); |
559 parameters.codecs[2].params["stereo"] = "0"; | 555 parameters.codecs[2].params["stereo"] = "0"; |
560 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 556 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
561 EXPECT_TRUE(channel_->AddRecvStream( | 557 EXPECT_TRUE(channel_->AddRecvStream( |
562 cricket::StreamParams::CreateLegacy(kSsrc1))); | 558 cricket::StreamParams::CreateLegacy(kSsrc1))); |
563 int channel_num2 = voe_.GetLastChannel(); | 559 int channel_num2 = voe_.GetLastChannel(); |
564 webrtc::CodecInst opus; | 560 webrtc::CodecInst opus; |
565 engine_.FindWebRtcCodec(kOpusCodec, &opus); | 561 cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &opus); |
566 // Even when stereo is off, recv codecs still specify channels = 2. | 562 // Even when stereo is off, recv codecs still specify channels = 2. |
567 EXPECT_EQ(2, opus.channels); | 563 EXPECT_EQ(2, opus.channels); |
568 EXPECT_EQ(111, opus.pltype); | 564 EXPECT_EQ(111, opus.pltype); |
569 EXPECT_STREQ("opus", opus.plname); | 565 EXPECT_STREQ("opus", opus.plname); |
570 opus.pltype = 0; | 566 opus.pltype = 0; |
571 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); | 567 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); |
572 EXPECT_EQ(111, opus.pltype); | 568 EXPECT_EQ(111, opus.pltype); |
573 } | 569 } |
574 | 570 |
575 // Test that we can decode OPUS with stereo = 1. | 571 // Test that we can decode OPUS with stereo = 1. |
576 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) { | 572 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithOpus1Stereo) { |
577 EXPECT_TRUE(SetupEngine()); | 573 EXPECT_TRUE(SetupEngine()); |
578 cricket::AudioRecvParameters parameters; | 574 cricket::AudioRecvParameters parameters; |
579 parameters.codecs.push_back(kIsacCodec); | 575 parameters.codecs.push_back(kIsacCodec); |
580 parameters.codecs.push_back(kPcmuCodec); | 576 parameters.codecs.push_back(kPcmuCodec); |
581 parameters.codecs.push_back(kOpusCodec); | 577 parameters.codecs.push_back(kOpusCodec); |
582 parameters.codecs[2].params["stereo"] = "1"; | 578 parameters.codecs[2].params["stereo"] = "1"; |
583 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 579 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
584 EXPECT_TRUE(channel_->AddRecvStream( | 580 EXPECT_TRUE(channel_->AddRecvStream( |
585 cricket::StreamParams::CreateLegacy(kSsrc1))); | 581 cricket::StreamParams::CreateLegacy(kSsrc1))); |
586 int channel_num2 = voe_.GetLastChannel(); | 582 int channel_num2 = voe_.GetLastChannel(); |
587 webrtc::CodecInst opus; | 583 webrtc::CodecInst opus; |
588 engine_.FindWebRtcCodec(kOpusCodec, &opus); | 584 cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &opus); |
589 EXPECT_EQ(2, opus.channels); | 585 EXPECT_EQ(2, opus.channels); |
590 EXPECT_EQ(111, opus.pltype); | 586 EXPECT_EQ(111, opus.pltype); |
591 EXPECT_STREQ("opus", opus.plname); | 587 EXPECT_STREQ("opus", opus.plname); |
592 opus.pltype = 0; | 588 opus.pltype = 0; |
593 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); | 589 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, opus)); |
594 EXPECT_EQ(111, opus.pltype); | 590 EXPECT_EQ(111, opus.pltype); |
595 } | 591 } |
596 | 592 |
597 // Test that changes to recv codecs are applied to all streams. | 593 // Test that changes to recv codecs are applied to all streams. |
598 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { | 594 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWithMultipleStreams) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 parameters.codecs.push_back(kIsacCodec); | 659 parameters.codecs.push_back(kIsacCodec); |
664 parameters.codecs.push_back(kCn16000Codec); | 660 parameters.codecs.push_back(kCn16000Codec); |
665 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 661 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
666 EXPECT_TRUE(channel_->SetPlayout(true)); | 662 EXPECT_TRUE(channel_->SetPlayout(true)); |
667 | 663 |
668 parameters.codecs.push_back(kOpusCodec); | 664 parameters.codecs.push_back(kOpusCodec); |
669 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 665 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
670 int channel_num = voe_.GetLastChannel(); | 666 int channel_num = voe_.GetLastChannel(); |
671 EXPECT_TRUE(voe_.GetPlayout(channel_num)); | 667 EXPECT_TRUE(voe_.GetPlayout(channel_num)); |
672 webrtc::CodecInst gcodec; | 668 webrtc::CodecInst gcodec; |
673 EXPECT_TRUE(engine_.FindWebRtcCodec(kOpusCodec, &gcodec)); | 669 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(kOpusCodec, &gcodec)); |
674 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); | 670 EXPECT_EQ(kOpusCodec.id, gcodec.pltype); |
675 } | 671 } |
676 | 672 |
677 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { | 673 TEST_F(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { |
678 EXPECT_TRUE(SetupEngineWithSendStream()); | 674 EXPECT_TRUE(SetupEngineWithSendStream()); |
679 | 675 |
680 // Test that when autobw is enabled, bitrate is kept as the default | 676 // Test that when autobw is enabled, bitrate is kept as the default |
681 // value. autobw is enabled for the following tests because the target | 677 // value. autobw is enabled for the following tests because the target |
682 // bitrate is <= 0. | 678 // bitrate is <= 0. |
683 | 679 |
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3239 delete channel; | 3235 delete channel; |
3240 engine.Terminate(); | 3236 engine.Terminate(); |
3241 | 3237 |
3242 // Reinit to catch regression where VoiceEngineObserver reference is lost | 3238 // Reinit to catch regression where VoiceEngineObserver reference is lost |
3243 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3239 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3244 engine.Terminate(); | 3240 engine.Terminate(); |
3245 } | 3241 } |
3246 | 3242 |
3247 // Tests that the library is configured with the codecs we want. | 3243 // Tests that the library is configured with the codecs we want. |
3248 TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { | 3244 TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { |
| 3245 // Check codecs by name. |
| 3246 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3247 cricket::AudioCodec(96, "OPUS", 48000, 0, 2, 0), nullptr)); |
| 3248 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3249 cricket::AudioCodec(96, "ISAC", 16000, 0, 1, 0), nullptr)); |
| 3250 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3251 cricket::AudioCodec(96, "ISAC", 32000, 0, 1, 0), nullptr)); |
| 3252 // Check that name matching is case-insensitive. |
| 3253 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3254 cricket::AudioCodec(96, "ILBC", 8000, 0, 1, 0), nullptr)); |
| 3255 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3256 cricket::AudioCodec(96, "iLBC", 8000, 0, 1, 0), nullptr)); |
| 3257 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3258 cricket::AudioCodec(96, "PCMU", 8000, 0, 1, 0), nullptr)); |
| 3259 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3260 cricket::AudioCodec(96, "PCMA", 8000, 0, 1, 0), nullptr)); |
| 3261 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3262 cricket::AudioCodec(96, "G722", 8000, 0, 1, 0), nullptr)); |
| 3263 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3264 cricket::AudioCodec(96, "red", 8000, 0, 1, 0), nullptr)); |
| 3265 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3266 cricket::AudioCodec(96, "CN", 32000, 0, 1, 0), nullptr)); |
| 3267 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3268 cricket::AudioCodec(96, "CN", 16000, 0, 1, 0), nullptr)); |
| 3269 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3270 cricket::AudioCodec(96, "CN", 8000, 0, 1, 0), nullptr)); |
| 3271 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3272 cricket::AudioCodec(96, "telephone-event", 8000, 0, 1, 0), nullptr)); |
| 3273 // Check codecs with an id by id. |
| 3274 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3275 cricket::AudioCodec(0, "", 8000, 0, 1, 0), nullptr)); // PCMU |
| 3276 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3277 cricket::AudioCodec(8, "", 8000, 0, 1, 0), nullptr)); // PCMA |
| 3278 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3279 cricket::AudioCodec(9, "", 8000, 0, 1, 0), nullptr)); // G722 |
| 3280 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3281 cricket::AudioCodec(13, "", 8000, 0, 1, 0), nullptr)); // CN |
| 3282 // Check sample/bitrate matching. |
| 3283 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3284 cricket::AudioCodec(0, "PCMU", 8000, 64000, 1, 0), nullptr)); |
| 3285 // Check that bad codecs fail. |
| 3286 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3287 cricket::AudioCodec(99, "ABCD", 0, 0, 1, 0), nullptr)); |
| 3288 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3289 cricket::AudioCodec(88, "", 0, 0, 1, 0), nullptr)); |
| 3290 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3291 cricket::AudioCodec(0, "", 0, 0, 2, 0), nullptr)); |
| 3292 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3293 cricket::AudioCodec(0, "", 5000, 0, 1, 0), nullptr)); |
| 3294 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
| 3295 cricket::AudioCodec(0, "", 0, 5000, 1, 0), nullptr)); |
| 3296 |
| 3297 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. |
3249 cricket::WebRtcVoiceEngine engine; | 3298 cricket::WebRtcVoiceEngine engine; |
3250 // Check codecs by name. | |
3251 EXPECT_TRUE(engine.FindCodec( | |
3252 cricket::AudioCodec(96, "OPUS", 48000, 0, 2, 0))); | |
3253 EXPECT_TRUE(engine.FindCodec( | |
3254 cricket::AudioCodec(96, "ISAC", 16000, 0, 1, 0))); | |
3255 EXPECT_TRUE(engine.FindCodec( | |
3256 cricket::AudioCodec(96, "ISAC", 32000, 0, 1, 0))); | |
3257 // Check that name matching is case-insensitive. | |
3258 EXPECT_TRUE(engine.FindCodec( | |
3259 cricket::AudioCodec(96, "ILBC", 8000, 0, 1, 0))); | |
3260 EXPECT_TRUE(engine.FindCodec( | |
3261 cricket::AudioCodec(96, "iLBC", 8000, 0, 1, 0))); | |
3262 EXPECT_TRUE(engine.FindCodec( | |
3263 cricket::AudioCodec(96, "PCMU", 8000, 0, 1, 0))); | |
3264 EXPECT_TRUE(engine.FindCodec( | |
3265 cricket::AudioCodec(96, "PCMA", 8000, 0, 1, 0))); | |
3266 EXPECT_TRUE(engine.FindCodec( | |
3267 cricket::AudioCodec(96, "G722", 8000, 0, 1, 0))); | |
3268 EXPECT_TRUE(engine.FindCodec( | |
3269 cricket::AudioCodec(96, "red", 8000, 0, 1, 0))); | |
3270 EXPECT_TRUE(engine.FindCodec( | |
3271 cricket::AudioCodec(96, "CN", 32000, 0, 1, 0))); | |
3272 EXPECT_TRUE(engine.FindCodec( | |
3273 cricket::AudioCodec(96, "CN", 16000, 0, 1, 0))); | |
3274 EXPECT_TRUE(engine.FindCodec( | |
3275 cricket::AudioCodec(96, "CN", 8000, 0, 1, 0))); | |
3276 EXPECT_TRUE(engine.FindCodec( | |
3277 cricket::AudioCodec(96, "telephone-event", 8000, 0, 1, 0))); | |
3278 // Check codecs with an id by id. | |
3279 EXPECT_TRUE(engine.FindCodec( | |
3280 cricket::AudioCodec(0, "", 8000, 0, 1, 0))); // PCMU | |
3281 EXPECT_TRUE(engine.FindCodec( | |
3282 cricket::AudioCodec(8, "", 8000, 0, 1, 0))); // PCMA | |
3283 EXPECT_TRUE(engine.FindCodec( | |
3284 cricket::AudioCodec(9, "", 8000, 0, 1, 0))); // G722 | |
3285 EXPECT_TRUE(engine.FindCodec( | |
3286 cricket::AudioCodec(13, "", 8000, 0, 1, 0))); // CN | |
3287 // Check sample/bitrate matching. | |
3288 EXPECT_TRUE(engine.FindCodec( | |
3289 cricket::AudioCodec(0, "PCMU", 8000, 64000, 1, 0))); | |
3290 // Check that bad codecs fail. | |
3291 EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(99, "ABCD", 0, 0, 1, 0))); | |
3292 EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(88, "", 0, 0, 1, 0))); | |
3293 EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 0, 0, 2, 0))); | |
3294 EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 5000, 0, 1, 0))); | |
3295 EXPECT_FALSE(engine.FindCodec(cricket::AudioCodec(0, "", 0, 5000, 1, 0))); | |
3296 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. | |
3297 for (std::vector<cricket::AudioCodec>::const_iterator it = | 3299 for (std::vector<cricket::AudioCodec>::const_iterator it = |
3298 engine.codecs().begin(); it != engine.codecs().end(); ++it) { | 3300 engine.codecs().begin(); it != engine.codecs().end(); ++it) { |
3299 if (it->name == "CN" && it->clockrate == 16000) { | 3301 if (it->name == "CN" && it->clockrate == 16000) { |
3300 EXPECT_EQ(105, it->id); | 3302 EXPECT_EQ(105, it->id); |
3301 } else if (it->name == "CN" && it->clockrate == 32000) { | 3303 } else if (it->name == "CN" && it->clockrate == 32000) { |
3302 EXPECT_EQ(106, it->id); | 3304 EXPECT_EQ(106, it->id); |
3303 } else if (it->name == "ISAC" && it->clockrate == 16000) { | 3305 } else if (it->name == "ISAC" && it->clockrate == 16000) { |
3304 EXPECT_EQ(103, it->id); | 3306 EXPECT_EQ(103, it->id); |
3305 } else if (it->name == "ISAC" && it->clockrate == 32000) { | 3307 } else if (it->name == "ISAC" && it->clockrate == 32000) { |
3306 EXPECT_EQ(104, it->id); | 3308 EXPECT_EQ(104, it->id); |
3307 } else if (it->name == "G722" && it->clockrate == 8000) { | 3309 } else if (it->name == "G722" && it->clockrate == 8000) { |
3308 EXPECT_EQ(9, it->id); | 3310 EXPECT_EQ(9, it->id); |
3309 } else if (it->name == "telephone-event") { | 3311 } else if (it->name == "telephone-event") { |
3310 EXPECT_EQ(126, it->id); | 3312 EXPECT_EQ(126, it->id); |
3311 } else if (it->name == "red") { | 3313 } else if (it->name == "red") { |
3312 EXPECT_EQ(127, it->id); | 3314 EXPECT_EQ(127, it->id); |
3313 } else if (it->name == "opus") { | 3315 } else if (it->name == "opus") { |
3314 EXPECT_EQ(111, it->id); | 3316 EXPECT_EQ(111, it->id); |
3315 ASSERT_TRUE(it->params.find("minptime") != it->params.end()); | 3317 ASSERT_TRUE(it->params.find("minptime") != it->params.end()); |
3316 EXPECT_EQ("10", it->params.find("minptime")->second); | 3318 EXPECT_EQ("10", it->params.find("minptime")->second); |
3317 ASSERT_TRUE(it->params.find("maxptime") != it->params.end()); | 3319 ASSERT_TRUE(it->params.find("maxptime") != it->params.end()); |
3318 EXPECT_EQ("60", it->params.find("maxptime")->second); | 3320 EXPECT_EQ("60", it->params.find("maxptime")->second); |
3319 ASSERT_TRUE(it->params.find("useinbandfec") != it->params.end()); | 3321 ASSERT_TRUE(it->params.find("useinbandfec") != it->params.end()); |
3320 EXPECT_EQ("1", it->params.find("useinbandfec")->second); | 3322 EXPECT_EQ("1", it->params.find("useinbandfec")->second); |
3321 } | 3323 } |
3322 } | 3324 } |
3323 | |
3324 engine.Terminate(); | 3325 engine.Terminate(); |
3325 } | 3326 } |
3326 | 3327 |
3327 // Tests that VoE supports at least 32 channels | 3328 // Tests that VoE supports at least 32 channels |
3328 TEST(WebRtcVoiceEngineTest, Has32Channels) { | 3329 TEST(WebRtcVoiceEngineTest, Has32Channels) { |
3329 cricket::WebRtcVoiceEngine engine; | 3330 cricket::WebRtcVoiceEngine engine; |
3330 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3331 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3331 rtc::scoped_ptr<webrtc::Call> call( | 3332 rtc::scoped_ptr<webrtc::Call> call( |
3332 webrtc::Call::Create(webrtc::Call::Config())); | 3333 webrtc::Call::Create(webrtc::Call::Config())); |
3333 | 3334 |
(...skipping 21 matching lines...) Expand all Loading... |
3355 cricket::WebRtcVoiceEngine engine; | 3356 cricket::WebRtcVoiceEngine engine; |
3356 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3357 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3357 rtc::scoped_ptr<webrtc::Call> call( | 3358 rtc::scoped_ptr<webrtc::Call> call( |
3358 webrtc::Call::Create(webrtc::Call::Config())); | 3359 webrtc::Call::Create(webrtc::Call::Config())); |
3359 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), | 3360 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), |
3360 call.get()); | 3361 call.get()); |
3361 cricket::AudioRecvParameters parameters; | 3362 cricket::AudioRecvParameters parameters; |
3362 parameters.codecs = engine.codecs(); | 3363 parameters.codecs = engine.codecs(); |
3363 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3364 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3364 } | 3365 } |
OLD | NEW |