OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 EXPECT_EQ(0xFA17FA17, config.rtp.local_ssrc); | 518 EXPECT_EQ(0xFA17FA17, config.rtp.local_ssrc); |
519 EXPECT_FALSE(config.rtp.transport_cc); | 519 EXPECT_FALSE(config.rtp.transport_cc); |
520 EXPECT_EQ(0u, config.rtp.extensions.size()); | 520 EXPECT_EQ(0u, config.rtp.extensions.size()); |
521 EXPECT_EQ(static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_), | 521 EXPECT_EQ(static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_), |
522 config.rtcp_send_transport); | 522 config.rtcp_send_transport); |
523 EXPECT_EQ("", config.sync_group); | 523 EXPECT_EQ("", config.sync_group); |
524 } | 524 } |
525 | 525 |
526 // Tests that the list of supported codecs is created properly and ordered | 526 // Tests that the list of supported codecs is created properly and ordered |
527 // correctly (such that opus appears first). | 527 // correctly (such that opus appears first). |
| 528 // TODO(ossu): This test should move into a separate builtin audio codecs |
| 529 // module. |
528 TEST_F(WebRtcVoiceEngineTestFake, CodecOrder) { | 530 TEST_F(WebRtcVoiceEngineTestFake, CodecOrder) { |
529 const std::vector<cricket::AudioCodec>& codecs = engine_->codecs(); | 531 const std::vector<cricket::AudioCodec>& codecs = engine_->send_codecs(); |
530 ASSERT_FALSE(codecs.empty()); | 532 ASSERT_FALSE(codecs.empty()); |
531 EXPECT_STRCASEEQ("opus", codecs[0].name.c_str()); | 533 EXPECT_STRCASEEQ("opus", codecs[0].name.c_str()); |
532 EXPECT_EQ(48000, codecs[0].clockrate); | 534 EXPECT_EQ(48000, codecs[0].clockrate); |
533 EXPECT_EQ(2, codecs[0].channels); | 535 EXPECT_EQ(2, codecs[0].channels); |
534 EXPECT_EQ(64000, codecs[0].bitrate); | 536 EXPECT_EQ(64000, codecs[0].bitrate); |
535 } | 537 } |
536 | 538 |
537 TEST_F(WebRtcVoiceEngineTestFake, OpusSupportsTransportCc) { | 539 TEST_F(WebRtcVoiceEngineTestFake, OpusSupportsTransportCc) { |
538 const std::vector<cricket::AudioCodec>& codecs = engine_->codecs(); | 540 const std::vector<cricket::AudioCodec>& codecs = engine_->send_codecs(); |
539 bool opus_found = false; | 541 bool opus_found = false; |
540 for (cricket::AudioCodec codec : codecs) { | 542 for (cricket::AudioCodec codec : codecs) { |
541 if (codec.name == "opus") { | 543 if (codec.name == "opus") { |
542 EXPECT_TRUE(HasTransportCc(codec)); | 544 EXPECT_TRUE(HasTransportCc(codec)); |
543 opus_found = true; | 545 opus_found = true; |
544 } | 546 } |
545 } | 547 } |
546 EXPECT_TRUE(opus_found); | 548 EXPECT_TRUE(opus_found); |
547 } | 549 } |
548 | 550 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 TestMaxSendBandwidth(kPcmuCodec, 32000, false, 64000); | 826 TestMaxSendBandwidth(kPcmuCodec, 32000, false, 64000); |
825 TestMaxSendBandwidth(kPcmuCodec, 64000, true, 64000); | 827 TestMaxSendBandwidth(kPcmuCodec, 64000, true, 64000); |
826 TestMaxSendBandwidth(kPcmuCodec, 63999, false, 64000); | 828 TestMaxSendBandwidth(kPcmuCodec, 63999, false, 64000); |
827 TestMaxSendBandwidth(kPcmuCodec, 64001, true, 64000); | 829 TestMaxSendBandwidth(kPcmuCodec, 64001, true, 64000); |
828 } | 830 } |
829 | 831 |
830 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { | 832 TEST_F(WebRtcVoiceEngineTestFake, SetMaxSendBandwidthMultiRateAsCallee) { |
831 EXPECT_TRUE(SetupChannel()); | 833 EXPECT_TRUE(SetupChannel()); |
832 const int kDesiredBitrate = 128000; | 834 const int kDesiredBitrate = 128000; |
833 cricket::AudioSendParameters parameters; | 835 cricket::AudioSendParameters parameters; |
834 parameters.codecs = engine_->codecs(); | 836 parameters.codecs = engine_->send_codecs(); |
835 parameters.max_bandwidth_bps = kDesiredBitrate; | 837 parameters.max_bandwidth_bps = kDesiredBitrate; |
836 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 838 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
837 | 839 |
838 EXPECT_TRUE(channel_->AddSendStream( | 840 EXPECT_TRUE(channel_->AddSendStream( |
839 cricket::StreamParams::CreateLegacy(kSsrc1))); | 841 cricket::StreamParams::CreateLegacy(kSsrc1))); |
840 | 842 |
841 int channel_num = voe_.GetLastChannel(); | 843 int channel_num = voe_.GetLastChannel(); |
842 webrtc::CodecInst codec; | 844 webrtc::CodecInst codec; |
843 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); | 845 EXPECT_EQ(0, voe_.GetSendCodec(channel_num, codec)); |
844 EXPECT_EQ(kDesiredBitrate, codec.rate); | 846 EXPECT_EQ(kDesiredBitrate, codec.rate); |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 | 1545 |
1544 cricket::AudioRecvParameters recv_parameters; | 1546 cricket::AudioRecvParameters recv_parameters; |
1545 recv_parameters.codecs.push_back(kIsacCodec); | 1547 recv_parameters.codecs.push_back(kIsacCodec); |
1546 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters)); | 1548 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters)); |
1547 EXPECT_TRUE( | 1549 EXPECT_TRUE( |
1548 channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc1))); | 1550 channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc1))); |
1549 ASSERT_TRUE(call_.GetAudioReceiveStream(kSsrc1) != nullptr); | 1551 ASSERT_TRUE(call_.GetAudioReceiveStream(kSsrc1) != nullptr); |
1550 EXPECT_FALSE( | 1552 EXPECT_FALSE( |
1551 call_.GetAudioReceiveStream(kSsrc1)->GetConfig().rtp.transport_cc); | 1553 call_.GetAudioReceiveStream(kSsrc1)->GetConfig().rtp.transport_cc); |
1552 | 1554 |
1553 send_parameters.codecs = engine_->codecs(); | 1555 send_parameters.codecs = engine_->send_codecs(); |
1554 EXPECT_TRUE(channel_->SetSendParameters(send_parameters)); | 1556 EXPECT_TRUE(channel_->SetSendParameters(send_parameters)); |
1555 ASSERT_TRUE(call_.GetAudioReceiveStream(kSsrc1) != nullptr); | 1557 ASSERT_TRUE(call_.GetAudioReceiveStream(kSsrc1) != nullptr); |
1556 EXPECT_TRUE( | 1558 EXPECT_TRUE( |
1557 call_.GetAudioReceiveStream(kSsrc1)->GetConfig().rtp.transport_cc); | 1559 call_.GetAudioReceiveStream(kSsrc1)->GetConfig().rtp.transport_cc); |
1558 } | 1560 } |
1559 | 1561 |
1560 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. | 1562 // Test maxplaybackrate <= 8000 triggers Opus narrow band mode. |
1561 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { | 1563 TEST_F(WebRtcVoiceEngineTestFake, SetOpusMaxPlaybackRateNb) { |
1562 EXPECT_TRUE(SetupSendStream()); | 1564 EXPECT_TRUE(SetupSendStream()); |
1563 int channel_num = voe_.GetLastChannel(); | 1565 int channel_num = voe_.GetLastChannel(); |
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3528 std::unique_ptr<webrtc::Call> call( | 3530 std::unique_ptr<webrtc::Call> call( |
3529 webrtc::Call::Create(webrtc::Call::Config())); | 3531 webrtc::Call::Create(webrtc::Call::Config())); |
3530 cricket::VoiceMediaChannel* channel = engine.CreateChannel( | 3532 cricket::VoiceMediaChannel* channel = engine.CreateChannel( |
3531 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); | 3533 call.get(), cricket::MediaConfig(), cricket::AudioOptions()); |
3532 EXPECT_TRUE(channel != nullptr); | 3534 EXPECT_TRUE(channel != nullptr); |
3533 delete channel; | 3535 delete channel; |
3534 } | 3536 } |
3535 } | 3537 } |
3536 | 3538 |
3537 // Tests that the library is configured with the codecs we want. | 3539 // Tests that the library is configured with the codecs we want. |
| 3540 // TODO(ossu): This test should move into the builtin audio codecs module |
| 3541 // eventually. |
3538 TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { | 3542 TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { |
3539 // Check codecs by name. | 3543 // Check codecs by name. |
3540 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3544 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3541 cricket::AudioCodec(96, "OPUS", 48000, 0, 2), nullptr)); | 3545 cricket::AudioCodec(96, "OPUS", 48000, 0, 2), nullptr)); |
3542 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3546 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3543 cricket::AudioCodec(96, "ISAC", 16000, 0, 1), nullptr)); | 3547 cricket::AudioCodec(96, "ISAC", 16000, 0, 1), nullptr)); |
3544 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3548 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3545 cricket::AudioCodec(96, "ISAC", 32000, 0, 1), nullptr)); | 3549 cricket::AudioCodec(96, "ISAC", 32000, 0, 1), nullptr)); |
3546 // Check that name matching is case-insensitive. | 3550 // Check that name matching is case-insensitive. |
3547 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3551 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3584 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3588 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3585 cricket::AudioCodec(0, "", 0, 0, 2), nullptr)); | 3589 cricket::AudioCodec(0, "", 0, 0, 2), nullptr)); |
3586 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3590 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3587 cricket::AudioCodec(0, "", 5000, 0, 1), nullptr)); | 3591 cricket::AudioCodec(0, "", 5000, 0, 1), nullptr)); |
3588 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3592 EXPECT_FALSE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3589 cricket::AudioCodec(0, "", 0, 5000, 1), nullptr)); | 3593 cricket::AudioCodec(0, "", 0, 5000, 1), nullptr)); |
3590 | 3594 |
3591 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. | 3595 // Verify the payload id of common audio codecs, including CN, ISAC, and G722. |
3592 cricket::WebRtcVoiceEngine engine(nullptr); | 3596 cricket::WebRtcVoiceEngine engine(nullptr); |
3593 for (std::vector<cricket::AudioCodec>::const_iterator it = | 3597 for (std::vector<cricket::AudioCodec>::const_iterator it = |
3594 engine.codecs().begin(); it != engine.codecs().end(); ++it) { | 3598 engine.send_codecs().begin(); it != engine.send_codecs().end(); ++it) { |
3595 if (it->name == "CN" && it->clockrate == 16000) { | 3599 if (it->name == "CN" && it->clockrate == 16000) { |
3596 EXPECT_EQ(105, it->id); | 3600 EXPECT_EQ(105, it->id); |
3597 } else if (it->name == "CN" && it->clockrate == 32000) { | 3601 } else if (it->name == "CN" && it->clockrate == 32000) { |
3598 EXPECT_EQ(106, it->id); | 3602 EXPECT_EQ(106, it->id); |
3599 } else if (it->name == "ISAC" && it->clockrate == 16000) { | 3603 } else if (it->name == "ISAC" && it->clockrate == 16000) { |
3600 EXPECT_EQ(103, it->id); | 3604 EXPECT_EQ(103, it->id); |
3601 } else if (it->name == "ISAC" && it->clockrate == 32000) { | 3605 } else if (it->name == "ISAC" && it->clockrate == 32000) { |
3602 EXPECT_EQ(104, it->id); | 3606 EXPECT_EQ(104, it->id); |
3603 } else if (it->name == "G722" && it->clockrate == 8000) { | 3607 } else if (it->name == "G722" && it->clockrate == 8000) { |
3604 EXPECT_EQ(9, it->id); | 3608 EXPECT_EQ(9, it->id); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3643 } | 3647 } |
3644 | 3648 |
3645 // Test that we set our preferred codecs properly. | 3649 // Test that we set our preferred codecs properly. |
3646 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3650 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
3647 cricket::WebRtcVoiceEngine engine(nullptr); | 3651 cricket::WebRtcVoiceEngine engine(nullptr); |
3648 std::unique_ptr<webrtc::Call> call( | 3652 std::unique_ptr<webrtc::Call> call( |
3649 webrtc::Call::Create(webrtc::Call::Config())); | 3653 webrtc::Call::Create(webrtc::Call::Config())); |
3650 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3654 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3651 cricket::AudioOptions(), call.get()); | 3655 cricket::AudioOptions(), call.get()); |
3652 cricket::AudioRecvParameters parameters; | 3656 cricket::AudioRecvParameters parameters; |
3653 parameters.codecs = engine.codecs(); | 3657 parameters.codecs = engine.recv_codecs(); |
3654 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3658 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3655 } | 3659 } |
OLD | NEW |