Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1071 std::vector<FakeVideoReceiveStream*> streams = | 1071 std::vector<FakeVideoReceiveStream*> streams = |
| 1072 fake_call_->GetVideoReceiveStreams(); | 1072 fake_call_->GetVideoReceiveStreams(); |
| 1073 EXPECT_EQ(num_streams + 1, streams.size()); | 1073 EXPECT_EQ(num_streams + 1, streams.size()); |
| 1074 return streams[streams.size() - 1]; | 1074 return streams[streams.size() - 1]; |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate_kbps, | 1077 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate_kbps, |
| 1078 int expected_min_bitrate_bps, | 1078 int expected_min_bitrate_bps, |
| 1079 const char* start_bitrate_kbps, | 1079 const char* start_bitrate_kbps, |
| 1080 int expected_start_bitrate_bps, | 1080 int expected_start_bitrate_bps, |
| 1081 const char* max_bitrate_kbps, | 1081 const char* max_bitrate_kbps) { |
| 1082 int expected_max_bitrate_bps) { | |
| 1083 auto& codecs = send_parameters_.codecs; | 1082 auto& codecs = send_parameters_.codecs; |
| 1084 codecs.clear(); | 1083 codecs.clear(); |
| 1085 codecs.push_back(GetEngineCodec("VP8")); | 1084 codecs.push_back(GetEngineCodec("VP8")); |
| 1086 codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; | 1085 codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; |
| 1087 codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; | 1086 codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; |
| 1088 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; | 1087 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; |
| 1089 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 1088 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 1090 | 1089 |
| 1091 EXPECT_EQ(expected_min_bitrate_bps, | 1090 EXPECT_EQ(expected_min_bitrate_bps, |
| 1092 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); | 1091 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); |
| 1093 EXPECT_EQ(expected_start_bitrate_bps, | 1092 EXPECT_EQ(expected_start_bitrate_bps, |
| 1094 fake_call_->GetConfig().bitrate_config.start_bitrate_bps); | 1093 fake_call_->GetConfig().bitrate_config.start_bitrate_bps); |
| 1095 EXPECT_EQ(expected_max_bitrate_bps, | 1094 // TODO(pbos): Consider checking stream bitrates. Codec bitrate does |
| 1096 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 1095 // intentionally not affect global max bitrate. |
| 1097 } | 1096 } |
| 1098 | 1097 |
| 1099 void TestSetSendRtpHeaderExtensions(const std::string& ext_uri) { | 1098 void TestSetSendRtpHeaderExtensions(const std::string& ext_uri) { |
| 1100 // Enable extension. | 1099 // Enable extension. |
| 1101 const int id = 1; | 1100 const int id = 1; |
| 1102 cricket::VideoSendParameters parameters = send_parameters_; | 1101 cricket::VideoSendParameters parameters = send_parameters_; |
| 1103 parameters.extensions.push_back(RtpExtension(ext_uri, id)); | 1102 parameters.extensions.push_back(RtpExtension(ext_uri, id)); |
| 1104 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1103 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
| 1105 FakeVideoSendStream* send_stream = | 1104 FakeVideoSendStream* send_stream = |
| 1106 AddSendStream(cricket::StreamParams::CreateLegacy(123)); | 1105 AddSendStream(cricket::StreamParams::CreateLegacy(123)); |
| (...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2640 parameters.codecs.clear(); | 2639 parameters.codecs.clear(); |
| 2641 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1); | 2640 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1); |
| 2642 parameters.codecs.push_back(codec); | 2641 parameters.codecs.push_back(codec); |
| 2643 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2642 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 2644 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); | 2643 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); |
| 2645 EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp); | 2644 EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp); |
| 2646 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2645 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
| 2647 } | 2646 } |
| 2648 | 2647 |
| 2649 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { | 2648 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { |
| 2650 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 2649 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200"); |
| 2651 200000); | |
| 2652 } | 2650 } |
| 2653 | 2651 |
| 2654 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { | 2652 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { |
| 2655 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); | 2653 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000"); |
| 2656 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); | 2654 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); |
| 2657 ASSERT_EQ(1u, streams.size()); | 2655 ASSERT_EQ(1u, streams.size()); |
| 2658 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); | 2656 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); |
| 2659 } | 2657 } |
| 2660 | 2658 |
| 2661 TEST_F(WebRtcVideoChannel2Test, | 2659 TEST_F(WebRtcVideoChannel2Test, |
| 2662 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { | 2660 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { |
| 2663 SetSendCodecsShouldWorkForBitrates( | 2661 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, ""); |
| 2664 "", 0, "", -1, "", -1); | |
| 2665 } | 2662 } |
| 2666 | 2663 |
| 2667 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { | 2664 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { |
| 2668 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1); | 2665 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, ""); |
| 2669 } | 2666 } |
| 2670 | 2667 |
| 2671 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { | 2668 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { |
| 2672 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; | 2669 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; |
| 2673 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; | 2670 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; |
| 2674 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); | 2671 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
| 2675 } | 2672 } |
| 2676 | 2673 |
| 2677 // Test that when both the codec-specific bitrate params and max_bandwidth_bps | 2674 // Test that when both the codec-specific bitrate params and max_bandwidth_bps |
| 2678 // are present in the same send parameters, the settings are combined correctly. | 2675 // are present in the same send parameters, the settings are combined correctly. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2706 // If we change the codec max, max_bandwidth_bps should still apply. | 2703 // If we change the codec max, max_bandwidth_bps should still apply. |
| 2707 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "350"; | 2704 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "350"; |
| 2708 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2705 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2709 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps); | 2706 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps); |
| 2710 EXPECT_EQ(200000, fake_call_->GetConfig().bitrate_config.start_bitrate_bps); | 2707 EXPECT_EQ(200000, fake_call_->GetConfig().bitrate_config.start_bitrate_bps); |
| 2711 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2708 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
| 2712 } | 2709 } |
| 2713 | 2710 |
| 2714 TEST_F(WebRtcVideoChannel2Test, | 2711 TEST_F(WebRtcVideoChannel2Test, |
| 2715 SetMaxSendBandwidthShouldPreserveOtherBitrates) { | 2712 SetMaxSendBandwidthShouldPreserveOtherBitrates) { |
| 2716 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 2713 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200"); |
| 2717 200000); | |
| 2718 send_parameters_.max_bandwidth_bps = 300000; | 2714 send_parameters_.max_bandwidth_bps = 300000; |
| 2719 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2715 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2720 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) | 2716 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) |
| 2721 << "Setting max bitrate should keep previous min bitrate."; | 2717 << "Setting max bitrate should keep previous min bitrate."; |
| 2722 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) | 2718 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) |
| 2723 << "Setting max bitrate should not reset start bitrate."; | 2719 << "Setting max bitrate should not reset start bitrate."; |
| 2724 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2720 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
| 2725 } | 2721 } |
| 2726 | 2722 |
| 2727 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { | 2723 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { |
| 2728 send_parameters_.max_bandwidth_bps = 300000; | 2724 send_parameters_.max_bandwidth_bps = 300000; |
| 2729 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2725 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2730 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2726 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
| 2731 // <= 0 means disable (infinite) max bitrate. | 2727 // -1 means disable (infinite) max bitrate. |
| 2732 send_parameters_.max_bandwidth_bps = 0; | 2728 send_parameters_.max_bandwidth_bps = -1; |
| 2733 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2729 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2734 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps) | 2730 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps) |
| 2735 << "Setting zero max bitrate did not reset start bitrate."; | 2731 << "Setting zero max bitrate did not reset start bitrate."; |
| 2736 } | 2732 } |
| 2737 | 2733 |
| 2738 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthAndAddSendStream) { | 2734 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthAndAddSendStream) { |
| 2739 send_parameters_.max_bandwidth_bps = 99999; | 2735 send_parameters_.max_bandwidth_bps = 99999; |
| 2740 FakeVideoSendStream* stream = AddSendStream(); | 2736 FakeVideoSendStream* stream = AddSendStream(); |
| 2741 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2737 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2742 EXPECT_EQ(send_parameters_.max_bandwidth_bps, | 2738 EXPECT_EQ(send_parameters_.max_bandwidth_bps, |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3860 capturer.CaptureFrame(); | 3856 capturer.CaptureFrame(); |
| 3861 | 3857 |
| 3862 int default_encoder_bitrate = GetMaxEncoderBitrate(); | 3858 int default_encoder_bitrate = GetMaxEncoderBitrate(); |
| 3863 EXPECT_GT(default_encoder_bitrate, 1000); | 3859 EXPECT_GT(default_encoder_bitrate, 1000); |
| 3864 | 3860 |
| 3865 // TODO(skvlad): Resolve the inconsistency between the interpretation | 3861 // TODO(skvlad): Resolve the inconsistency between the interpretation |
| 3866 // of the global bitrate limit for audio and video: | 3862 // of the global bitrate limit for audio and video: |
| 3867 // - Audio: max_bandwidth_bps = 0 - fail the operation, | 3863 // - Audio: max_bandwidth_bps = 0 - fail the operation, |
| 3868 // max_bandwidth_bps = -1 - remove the bandwidth limit | 3864 // max_bandwidth_bps = -1 - remove the bandwidth limit |
| 3869 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, | 3865 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, |
| 3870 // max_bandwidth_bps = -1 - do not change the previously set | 3866 // max_bandwidth_bps = -1 - remove the bandwidth limit |
|
Taylor Brandstetter
2017/03/09 23:48:38
Hey, one inconsistency fixed. :)
| |
| 3871 // limit. | |
| 3872 | 3867 |
| 3873 SetAndExpectMaxBitrate(1000, 0, 1000); | 3868 SetAndExpectMaxBitrate(1000, 0, 1000); |
| 3874 SetAndExpectMaxBitrate(1000, 800, 800); | 3869 SetAndExpectMaxBitrate(1000, 800, 800); |
| 3875 SetAndExpectMaxBitrate(600, 800, 600); | 3870 SetAndExpectMaxBitrate(600, 800, 600); |
| 3876 SetAndExpectMaxBitrate(0, 800, 800); | 3871 SetAndExpectMaxBitrate(0, 800, 800); |
| 3877 SetAndExpectMaxBitrate(0, 0, default_encoder_bitrate); | 3872 SetAndExpectMaxBitrate(0, 0, default_encoder_bitrate); |
| 3878 | 3873 |
| 3879 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 3874 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
| 3880 } | 3875 } |
| 3881 | 3876 |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4355 } | 4350 } |
| 4356 | 4351 |
| 4357 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { | 4352 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { |
| 4358 webrtc::test::ScopedFieldTrials override_field_trials_( | 4353 webrtc::test::ScopedFieldTrials override_field_trials_( |
| 4359 "WebRTC-SimulcastScreenshare/Enabled/"); | 4354 "WebRTC-SimulcastScreenshare/Enabled/"); |
| 4360 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, | 4355 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, |
| 4361 true); | 4356 true); |
| 4362 } | 4357 } |
| 4363 | 4358 |
| 4364 } // namespace cricket | 4359 } // namespace cricket |
| OLD | NEW |