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 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2561 TEST_F(WebRtcVoiceEngineWithSendSideBweWithOverheadTest, MinAndMaxBitrate) { | 2561 TEST_F(WebRtcVoiceEngineWithSendSideBweWithOverheadTest, MinAndMaxBitrate) { |
2562 EXPECT_TRUE(SetupSendStream()); | 2562 EXPECT_TRUE(SetupSendStream()); |
2563 cricket::AudioSendParameters parameters; | 2563 cricket::AudioSendParameters parameters; |
2564 parameters.codecs.push_back(kOpusCodec); | 2564 parameters.codecs.push_back(kOpusCodec); |
2565 SetSendParameters(parameters); | 2565 SetSendParameters(parameters); |
2566 const int initial_num = call_.GetNumCreatedSendStreams(); | 2566 const int initial_num = call_.GetNumCreatedSendStreams(); |
2567 EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams()); | 2567 EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams()); |
2568 | 2568 |
2569 // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) | 2569 // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) |
2570 constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; | 2570 constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; |
2571 constexpr int kMinOverheadBps = kOverheadPerPacket * 8 * 1000 / 60; | 2571 constexpr int kOpusMaxPtimeMs = WEBRTC_OPUS_SUPPORT_120MS_PTIME ? 120 : 60; |
| 2572 constexpr int kMinOverheadBps = |
| 2573 kOverheadPerPacket * 8 * 1000 / kOpusMaxPtimeMs; |
2572 constexpr int kMaxOverheadBps = kOverheadPerPacket * 8 * 1000 / 10; | 2574 constexpr int kMaxOverheadBps = kOverheadPerPacket * 8 * 1000 / 10; |
2573 | 2575 |
2574 constexpr int kOpusMinBitrateBps = 6000; | 2576 constexpr int kOpusMinBitrateBps = 6000; |
2575 EXPECT_EQ(kOpusMinBitrateBps + kMinOverheadBps, | 2577 EXPECT_EQ(kOpusMinBitrateBps + kMinOverheadBps, |
2576 GetSendStreamConfig(kSsrc1).min_bitrate_bps); | 2578 GetSendStreamConfig(kSsrc1).min_bitrate_bps); |
2577 constexpr int kOpusBitrateFbBps = 32000; | 2579 constexpr int kOpusBitrateFbBps = 32000; |
2578 EXPECT_EQ(kOpusBitrateFbBps + kMaxOverheadBps, | 2580 EXPECT_EQ(kOpusBitrateFbBps + kMaxOverheadBps, |
2579 GetSendStreamConfig(kSsrc1).max_bitrate_bps); | 2581 GetSendStreamConfig(kSsrc1).max_bitrate_bps); |
2580 | 2582 |
2581 parameters.options.audio_network_adaptor = rtc::Optional<bool>(true); | 2583 parameters.options.audio_network_adaptor = rtc::Optional<bool>(true); |
2582 parameters.options.audio_network_adaptor_config = | 2584 parameters.options.audio_network_adaptor_config = |
2583 rtc::Optional<std::string>("1234"); | 2585 rtc::Optional<std::string>("1234"); |
2584 SetSendParameters(parameters); | 2586 SetSendParameters(parameters); |
2585 | 2587 |
2586 constexpr int kMinOverheadWithAnaBps = kOverheadPerPacket * 8 * 1000 / 60; | 2588 constexpr int kMinOverheadWithAnaBps = |
| 2589 kOverheadPerPacket * 8 * 1000 / kOpusMaxPtimeMs; |
2587 constexpr int kMaxOverheadWithAnaBps = kOverheadPerPacket * 8 * 1000 / 20; | 2590 constexpr int kMaxOverheadWithAnaBps = kOverheadPerPacket * 8 * 1000 / 20; |
2588 | 2591 |
2589 EXPECT_EQ(kOpusMinBitrateBps + kMinOverheadWithAnaBps, | 2592 EXPECT_EQ(kOpusMinBitrateBps + kMinOverheadWithAnaBps, |
2590 GetSendStreamConfig(kSsrc1).min_bitrate_bps); | 2593 GetSendStreamConfig(kSsrc1).min_bitrate_bps); |
2591 | 2594 |
2592 EXPECT_EQ(kOpusBitrateFbBps + kMaxOverheadWithAnaBps, | 2595 EXPECT_EQ(kOpusBitrateFbBps + kMaxOverheadWithAnaBps, |
2593 GetSendStreamConfig(kSsrc1).max_bitrate_bps); | 2596 GetSendStreamConfig(kSsrc1).max_bitrate_bps); |
2594 } | 2597 } |
2595 | 2598 |
2596 // Test that we can set the outgoing SSRC properly. | 2599 // Test that we can set the outgoing SSRC properly. |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3544 delete channel; | 3547 delete channel; |
3545 } | 3548 } |
3546 } | 3549 } |
3547 | 3550 |
3548 // Tests that the library is configured with the codecs we want. | 3551 // Tests that the library is configured with the codecs we want. |
3549 TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { | 3552 TEST(WebRtcVoiceEngineTest, HasCorrectCodecs) { |
3550 // TODO(ossu): These tests should move into a future "builtin audio codecs" | 3553 // TODO(ossu): These tests should move into a future "builtin audio codecs" |
3551 // module. | 3554 // module. |
3552 | 3555 |
3553 // Check codecs by name. | 3556 // Check codecs by name. |
| 3557 #ifdef WEBRTC_CODEC_OPUS |
3554 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3558 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3555 cricket::AudioCodec(96, "OPUS", 48000, 0, 2), nullptr)); | 3559 cricket::AudioCodec(96, "OPUS", 48000, 0, 2), nullptr)); |
| 3560 #endif |
| 3561 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) |
3556 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3562 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3557 cricket::AudioCodec(96, "ISAC", 16000, 0, 1), nullptr)); | 3563 cricket::AudioCodec(96, "ISAC", 16000, 0, 1), nullptr)); |
| 3564 #endif |
| 3565 #if (defined(WEBRTC_CODEC_ISAC)) |
3558 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3566 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3559 cricket::AudioCodec(96, "ISAC", 32000, 0, 1), nullptr)); | 3567 cricket::AudioCodec(96, "ISAC", 32000, 0, 1), nullptr)); |
| 3568 #endif |
| 3569 #ifdef WEBRTC_CODEC_ILBC |
3560 // Check that name matching is case-insensitive. | 3570 // Check that name matching is case-insensitive. |
3561 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3571 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3562 cricket::AudioCodec(96, "ILBC", 8000, 0, 1), nullptr)); | 3572 cricket::AudioCodec(96, "ILBC", 8000, 0, 1), nullptr)); |
3563 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3573 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3564 cricket::AudioCodec(96, "iLBC", 8000, 0, 1), nullptr)); | 3574 cricket::AudioCodec(96, "iLBC", 8000, 0, 1), nullptr)); |
| 3575 #endif |
3565 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3576 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3566 cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr)); | 3577 cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr)); |
3567 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3578 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3568 cricket::AudioCodec(96, "CN", 16000, 0, 1), nullptr)); | 3579 cricket::AudioCodec(96, "CN", 16000, 0, 1), nullptr)); |
3569 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3580 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3570 cricket::AudioCodec(96, "telephone-event", 8000, 0, 1), nullptr)); | 3581 cricket::AudioCodec(96, "telephone-event", 8000, 0, 1), nullptr)); |
3571 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3582 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3572 cricket::AudioCodec(96, "telephone-event", 16000, 0, 1), nullptr)); | 3583 cricket::AudioCodec(96, "telephone-event", 16000, 0, 1), nullptr)); |
3573 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( | 3584 EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst( |
3574 cricket::AudioCodec(96, "telephone-event", 32000, 0, 1), nullptr)); | 3585 cricket::AudioCodec(96, "telephone-event", 32000, 0, 1), nullptr)); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3744 // Without this cast, the comparison turned unsigned and, thus, failed for -1. | 3755 // Without this cast, the comparison turned unsigned and, thus, failed for -1. |
3745 const int num_specs = static_cast<int>(specs.size()); | 3756 const int num_specs = static_cast<int>(specs.size()); |
3746 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); | 3757 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); |
3747 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); | 3758 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); |
3748 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); | 3759 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); |
3749 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); | 3760 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); |
3750 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); | 3761 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); |
3751 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); | 3762 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); |
3752 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); | 3763 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); |
3753 } | 3764 } |
OLD | NEW |