Chromium Code Reviews| 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 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 webrtc::RtpParameters initial_params = channel_->GetRtpSendParameters(kSsrcX); | 1205 webrtc::RtpParameters initial_params = channel_->GetRtpSendParameters(kSsrcX); |
| 1206 | 1206 |
| 1207 // We should be able to set the params we just got. | 1207 // We should be able to set the params we just got. |
| 1208 EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, initial_params)); | 1208 EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, initial_params)); |
| 1209 | 1209 |
| 1210 // ... And this shouldn't change the params returned by GetRtpSendParameters. | 1210 // ... And this shouldn't change the params returned by GetRtpSendParameters. |
| 1211 webrtc::RtpParameters new_params = channel_->GetRtpSendParameters(kSsrcX); | 1211 webrtc::RtpParameters new_params = channel_->GetRtpSendParameters(kSsrcX); |
| 1212 EXPECT_EQ(initial_params, channel_->GetRtpSendParameters(kSsrcX)); | 1212 EXPECT_EQ(initial_params, channel_->GetRtpSendParameters(kSsrcX)); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 // Test that max_bitrate_bps in send stream config gets updated correctly when | |
| 1216 // SetRtpSendParameters is called. | |
| 1217 TEST_F(WebRtcVoiceEngineTestFake, SetRtpSendParameterUpdatesMaxBitrate) { | |
| 1218 webrtc::test::ScopedFieldTrials override_field_trials( | |
| 1219 "WebRTC-Audio-SendSideBwe/Enabled/"); | |
| 1220 EXPECT_TRUE(SetupSendStream()); | |
| 1221 cricket::AudioSendParameters send_parameters; | |
| 1222 send_parameters.codecs.push_back(kOpusCodec); | |
| 1223 SetSendParameters(send_parameters); | |
| 1224 | |
| 1225 webrtc::RtpParameters rtp_parameters = channel_->GetRtpSendParameters(kSsrcX); | |
| 1226 // Expect empty on parameters.encodings[0].max_bitrate_bps; | |
| 1227 EXPECT_FALSE(rtp_parameters.encodings[0].max_bitrate_bps); | |
| 1228 | |
| 1229 constexpr int kMaxBitrateBps = 6000; | |
| 1230 rtp_parameters.encodings[0].max_bitrate_bps = | |
| 1231 rtc::Optional<int>(kMaxBitrateBps); | |
| 1232 EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, rtp_parameters)); | |
| 1233 | |
| 1234 const int max_bitrate = GetSendStreamConfig(kSsrcX).max_bitrate_bps; | |
| 1235 EXPECT_EQ(max_bitrate, kMaxBitrateBps); | |
| 1236 } | |
| 1237 | |
| 1215 // Test that GetRtpReceiveParameters returns the currently configured codecs. | 1238 // Test that GetRtpReceiveParameters returns the currently configured codecs. |
| 1216 TEST_F(WebRtcVoiceEngineTestFake, GetRtpReceiveParametersCodecs) { | 1239 TEST_F(WebRtcVoiceEngineTestFake, GetRtpReceiveParametersCodecs) { |
| 1217 EXPECT_TRUE(SetupRecvStream()); | 1240 EXPECT_TRUE(SetupRecvStream()); |
| 1218 cricket::AudioRecvParameters parameters; | 1241 cricket::AudioRecvParameters parameters; |
| 1219 parameters.codecs.push_back(kIsacCodec); | 1242 parameters.codecs.push_back(kIsacCodec); |
| 1220 parameters.codecs.push_back(kPcmuCodec); | 1243 parameters.codecs.push_back(kPcmuCodec); |
| 1221 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 1244 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 1222 | 1245 |
| 1223 webrtc::RtpParameters rtp_parameters = | 1246 webrtc::RtpParameters rtp_parameters = |
| 1224 channel_->GetRtpReceiveParameters(kSsrcX); | 1247 channel_->GetRtpReceiveParameters(kSsrcX); |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2618 parameters.codecs.push_back(kOpusCodec); | 2641 parameters.codecs.push_back(kOpusCodec); |
| 2619 SetSendParameters(parameters); | 2642 SetSendParameters(parameters); |
| 2620 const int initial_num = call_.GetNumCreatedSendStreams(); | 2643 const int initial_num = call_.GetNumCreatedSendStreams(); |
| 2621 EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams()); | 2644 EXPECT_EQ(initial_num, call_.GetNumCreatedSendStreams()); |
| 2622 | 2645 |
| 2623 // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) | 2646 // OverheadPerPacket = Ipv4(20B) + UDP(8B) + SRTP(10B) + RTP(12) |
| 2624 constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; | 2647 constexpr int kOverheadPerPacket = 20 + 8 + 10 + 12; |
| 2625 constexpr int kOpusMaxPtimeMs = WEBRTC_OPUS_SUPPORT_120MS_PTIME ? 120 : 60; | 2648 constexpr int kOpusMaxPtimeMs = WEBRTC_OPUS_SUPPORT_120MS_PTIME ? 120 : 60; |
| 2626 constexpr int kMinOverheadBps = | 2649 constexpr int kMinOverheadBps = |
| 2627 kOverheadPerPacket * 8 * 1000 / kOpusMaxPtimeMs; | 2650 kOverheadPerPacket * 8 * 1000 / kOpusMaxPtimeMs; |
| 2628 constexpr int kMaxOverheadBps = kOverheadPerPacket * 8 * 1000 / 10; | |
| 2629 | 2651 |
| 2630 constexpr int kOpusMinBitrateBps = 6000; | 2652 constexpr int kOpusMinBitrateBps = 6000; |
| 2631 EXPECT_EQ(kOpusMinBitrateBps + kMinOverheadBps, | 2653 EXPECT_EQ(kOpusMinBitrateBps + kMinOverheadBps, |
| 2632 GetSendStreamConfig(kSsrcX).min_bitrate_bps); | 2654 GetSendStreamConfig(kSsrcX).min_bitrate_bps); |
| 2633 constexpr int kOpusBitrateFbBps = 32000; | 2655 constexpr int kOpusBitrateFbBps = 32000; |
| 2634 EXPECT_EQ(kOpusBitrateFbBps + kMaxOverheadBps, | 2656 EXPECT_EQ(kOpusBitrateFbBps + kMinOverheadBps, |
|
minyue-webrtc
2017/03/27 19:35:25
changed the behavior intentionally.
| |
| 2635 GetSendStreamConfig(kSsrcX).max_bitrate_bps); | 2657 GetSendStreamConfig(kSsrcX).max_bitrate_bps); |
| 2636 | 2658 |
| 2637 parameters.options.audio_network_adaptor = rtc::Optional<bool>(true); | 2659 parameters.options.audio_network_adaptor = rtc::Optional<bool>(true); |
| 2638 parameters.options.audio_network_adaptor_config = | 2660 parameters.options.audio_network_adaptor_config = |
| 2639 rtc::Optional<std::string>("1234"); | 2661 rtc::Optional<std::string>("1234"); |
| 2640 SetSendParameters(parameters); | 2662 SetSendParameters(parameters); |
| 2641 | 2663 |
| 2642 constexpr int kMinOverheadWithAnaBps = | 2664 constexpr int kMinOverheadWithAnaBps = |
| 2643 kOverheadPerPacket * 8 * 1000 / kOpusMaxPtimeMs; | 2665 kOverheadPerPacket * 8 * 1000 / kOpusMaxPtimeMs; |
| 2644 constexpr int kMaxOverheadWithAnaBps = kOverheadPerPacket * 8 * 1000 / 20; | |
| 2645 | 2666 |
| 2646 EXPECT_EQ(kOpusMinBitrateBps + kMinOverheadWithAnaBps, | 2667 EXPECT_EQ(kOpusMinBitrateBps + kMinOverheadWithAnaBps, |
| 2647 GetSendStreamConfig(kSsrcX).min_bitrate_bps); | 2668 GetSendStreamConfig(kSsrcX).min_bitrate_bps); |
| 2648 | 2669 |
| 2649 EXPECT_EQ(kOpusBitrateFbBps + kMaxOverheadWithAnaBps, | 2670 EXPECT_EQ(kOpusBitrateFbBps + kMinOverheadWithAnaBps, |
| 2650 GetSendStreamConfig(kSsrcX).max_bitrate_bps); | 2671 GetSendStreamConfig(kSsrcX).max_bitrate_bps); |
| 2651 } | 2672 } |
| 2652 | 2673 |
| 2674 // This test is similar to | |
| 2675 // WebRtcVoiceEngineTestFake.SetRtpSendParameterUpdatesMaxBitrate but with an | |
| 2676 // additional field trial. | |
| 2677 TEST_F(WebRtcVoiceEngineWithSendSideBweWithOverheadTest, | |
| 2678 SetRtpSendParameterUpdatesMaxBitrate) { | |
| 2679 EXPECT_TRUE(SetupSendStream()); | |
| 2680 cricket::AudioSendParameters send_parameters; | |
| 2681 send_parameters.codecs.push_back(kOpusCodec); | |
| 2682 SetSendParameters(send_parameters); | |
| 2683 | |
| 2684 webrtc::RtpParameters rtp_parameters = channel_->GetRtpSendParameters(kSsrcX); | |
| 2685 // Expect empty on parameters.encodings[0].max_bitrate_bps; | |
| 2686 EXPECT_FALSE(rtp_parameters.encodings[0].max_bitrate_bps); | |
| 2687 | |
| 2688 constexpr int kMaxBitrateBps = 6000; | |
| 2689 rtp_parameters.encodings[0].max_bitrate_bps = | |
| 2690 rtc::Optional<int>(kMaxBitrateBps); | |
| 2691 EXPECT_TRUE(channel_->SetRtpSendParameters(kSsrcX, rtp_parameters)); | |
| 2692 | |
| 2693 const int max_bitrate = GetSendStreamConfig(kSsrcX).max_bitrate_bps; | |
| 2694 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME | |
| 2695 constexpr int kMinOverhead = 3333; | |
| 2696 #else | |
| 2697 constexpr int kMinOverhead = 6666; | |
| 2698 #endif | |
| 2699 EXPECT_EQ(max_bitrate, kMaxBitrateBps + kMinOverhead); | |
| 2700 } | |
| 2701 | |
| 2653 // Test that we can set the outgoing SSRC properly. | 2702 // Test that we can set the outgoing SSRC properly. |
| 2654 // SSRC is set in SetupSendStream() by calling AddSendStream. | 2703 // SSRC is set in SetupSendStream() by calling AddSendStream. |
| 2655 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { | 2704 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrc) { |
| 2656 EXPECT_TRUE(SetupSendStream()); | 2705 EXPECT_TRUE(SetupSendStream()); |
| 2657 EXPECT_TRUE(call_.GetAudioSendStream(kSsrcX)); | 2706 EXPECT_TRUE(call_.GetAudioSendStream(kSsrcX)); |
| 2658 } | 2707 } |
| 2659 | 2708 |
| 2660 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { | 2709 TEST_F(WebRtcVoiceEngineTestFake, GetStats) { |
| 2661 // Setup. We need send codec to be set to get all stats. | 2710 // Setup. We need send codec to be set to get all stats. |
| 2662 EXPECT_TRUE(SetupSendStream()); | 2711 EXPECT_TRUE(SetupSendStream()); |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3836 // Without this cast, the comparison turned unsigned and, thus, failed for -1. | 3885 // Without this cast, the comparison turned unsigned and, thus, failed for -1. |
| 3837 const int num_specs = static_cast<int>(specs.size()); | 3886 const int num_specs = static_cast<int>(specs.size()); |
| 3838 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); | 3887 EXPECT_GE(find_codec({"cn", 8000, 1}), num_specs); |
| 3839 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); | 3888 EXPECT_GE(find_codec({"cn", 16000, 1}), num_specs); |
| 3840 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); | 3889 EXPECT_EQ(find_codec({"cn", 32000, 1}), -1); |
| 3841 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); | 3890 EXPECT_GE(find_codec({"telephone-event", 8000, 1}), num_specs); |
| 3842 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); | 3891 EXPECT_GE(find_codec({"telephone-event", 16000, 1}), num_specs); |
| 3843 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); | 3892 EXPECT_GE(find_codec({"telephone-event", 32000, 1}), num_specs); |
| 3844 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); | 3893 EXPECT_GE(find_codec({"telephone-event", 48000, 1}), num_specs); |
| 3845 } | 3894 } |
| OLD | NEW |