Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2_unittest.cc

Issue 1788583004: Enable setting the maximum bitrate limit in RtpSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); 1037 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset);
1038 } 1038 }
1039 } 1039 }
1040 if (with_rtx) { 1040 if (with_rtx) {
1041 return AddSendStream( 1041 return AddSendStream(
1042 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1042 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1043 } 1043 }
1044 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); 1044 return AddSendStream(CreateSimStreamParams("cname", ssrcs));
1045 } 1045 }
1046 1046
1047 int GetMaxEncoderBitrate(cricket::FakeVideoCapturer& capturer) {
1048 EXPECT_TRUE(capturer.CaptureFrame());
1049
1050 std::vector<FakeVideoSendStream*> streams =
1051 fake_call_->GetVideoSendStreams();
1052 EXPECT_TRUE(streams.size() > 0);
1053 FakeVideoSendStream* stream = streams[streams.size() - 1];
1054
1055 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig();
1056 EXPECT_EQ(1, encoder_config.streams.size());
1057 return encoder_config.streams[0].max_bitrate_bps;
1058 }
1059
1060 void VerifyEncoderBitrate(cricket::FakeVideoCapturer& capturer,
pthatcher1 2016/03/14 16:26:51 Should this be called SetAndExpectMaxBandwidth?
skvlad 2016/03/15 21:18:18 Done.
1061 int global_max,
1062 int stream_max,
1063 int expected_encoder_bitrate) {
1064 VideoSendParameters limited_send_params = send_parameters_;
1065 limited_send_params.max_bandwidth_bps = global_max;
1066 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params));
1067 webrtc::RTCRtpParameters parameters =
1068 channel_->GetRtpParameters(last_ssrc_);
1069 EXPECT_EQ(1UL, parameters.encodings.size());
1070 parameters.encodings[0].max_bitrate_bps = stream_max;
1071 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters));
1072 // Read back the parameteres and verify they have the correct value
Taylor Brandstetter 2016/03/12 01:57:06 nit: Periods at ends of comments
skvlad 2016/03/15 21:18:18 Done.
1073 parameters = channel_->GetRtpParameters(last_ssrc_);
1074 EXPECT_EQ(1UL, parameters.encodings.size());
1075 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps);
1076 // Verify that the new value propagated down to the encoder
1077 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate(capturer));
1078 }
1079
1047 std::unique_ptr<FakeCall> fake_call_; 1080 std::unique_ptr<FakeCall> fake_call_;
1048 std::unique_ptr<VideoMediaChannel> channel_; 1081 std::unique_ptr<VideoMediaChannel> channel_;
1049 cricket::VideoSendParameters send_parameters_; 1082 cricket::VideoSendParameters send_parameters_;
1050 cricket::VideoRecvParameters recv_parameters_; 1083 cricket::VideoRecvParameters recv_parameters_;
1051 uint32_t last_ssrc_; 1084 uint32_t last_ssrc_;
1052 }; 1085 };
1053 1086
1054 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { 1087 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) {
1055 const uint32_t kVideoSsrc = 123; 1088 const uint32_t kVideoSsrc = 123;
1056 const std::string kSyncLabel = "AvSyncLabel"; 1089 const std::string kSyncLabel = "AvSyncLabel";
(...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 } 3007 }
2975 3008
2976 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { 3009 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) {
2977 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); 3010 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false);
2978 } 3011 }
2979 3012
2980 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { 3013 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) {
2981 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); 3014 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false);
2982 } 3015 }
2983 3016
3017 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) {
3018 AddSendStream();
3019
3020 cricket::FakeVideoCapturer capturer;
3021 capturer.SetScreencast(false);
3022 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
3023 cricket::VideoFormat capture_format_hd =
3024 capturer.GetSupportedFormats()->front();
3025 EXPECT_EQ(1280, capture_format_hd.width);
3026 EXPECT_EQ(720, capture_format_hd.height);
3027 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
3028 EXPECT_TRUE(channel_->SetSend(true));
3029
3030 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer);
3031 EXPECT_TRUE(default_encoder_bitrate > 1000);
3032
3033 // TODO(skvlad): Resolve the inconsistency between the interpretation
3034 // of the global bitrate limit for audio and video:
3035 // - audio: max_bandwidth_bps = 0 - fail the operation,
3036 // max_bandwidth_bps = -1 - remove the bandwidth limit
3037 // - video: max_bandwidth_bps = 0 - remove the bandwidth limit,
3038 // max_bandwidth_bps = -1 - do not change the previously set
3039 // limit...
pthatcher1 2016/03/14 16:26:51 FYI, I think we should make it: - An Optiona<int>
3040
3041 VerifyEncoderBitrate(capturer, 1000, 0, 1000);
3042 VerifyEncoderBitrate(capturer, 1000, 800, 800);
3043 VerifyEncoderBitrate(capturer, 600, 800, 600);
3044 VerifyEncoderBitrate(capturer, 0, 800, 800);
3045 VerifyEncoderBitrate(capturer, 0, 0, default_encoder_bitrate);
3046
3047 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
3048 }
3049
3050 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) {
3051 webrtc::RTCRtpParameters nonexistent_parameters =
3052 channel_->GetRtpParameters(last_ssrc_);
3053 EXPECT_EQ(0, nonexistent_parameters.encodings.size());
3054
3055 nonexistent_parameters.encodings.push_back(
3056 webrtc::RTCRtpEncodingParameters());
3057 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters));
3058 }
3059
3060 TEST_F(WebRtcVideoChannel2Test,
Taylor Brandstetter 2016/03/12 01:57:06 I'd add a "TODO: Change this when we support setti
skvlad 2016/03/15 21:18:18 Done.
3061 CannotSetRtpParametersWithIncorrectNumberOfEncodings) {
3062 AddSendStream();
3063 // no encodings - should fail
3064 webrtc::RTCRtpParameters parameters;
3065 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, parameters));
3066 // one encoding - expected to succeed
3067 parameters.encodings.push_back(webrtc::RTCRtpEncodingParameters());
3068 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters));
3069 // two encodings - too many
3070 parameters.encodings.push_back(webrtc::RTCRtpEncodingParameters());
3071 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, parameters));
3072 }
3073
2984 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( 3074 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration(
2985 bool receiver_first) { 3075 bool receiver_first) {
2986 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3076 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
2987 3077
2988 const uint32_t kSenderSsrc = 0xC0FFEE; 3078 const uint32_t kSenderSsrc = 0xC0FFEE;
2989 const uint32_t kSecondSenderSsrc = 0xBADCAFE; 3079 const uint32_t kSecondSenderSsrc = 0xBADCAFE;
2990 const uint32_t kReceiverSsrc = 0x4711; 3080 const uint32_t kReceiverSsrc = 0x4711;
2991 const uint32_t kExpectedDefaultReceiverSsrc = 1; 3081 const uint32_t kExpectedDefaultReceiverSsrc = 1;
2992 3082
2993 if (receiver_first) { 3083 if (receiver_first) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 // Test that we normalize send codec format size in simulcast. 3260 // Test that we normalize send codec format size in simulcast.
3171 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3261 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3172 cricket::VideoCodec codec(kVp8Codec270p); 3262 cricket::VideoCodec codec(kVp8Codec270p);
3173 codec.width += 1; 3263 codec.width += 1;
3174 codec.height += 1; 3264 codec.height += 1;
3175 VerifySimulcastSettings(codec, 2, 2); 3265 VerifySimulcastSettings(codec, 2, 2);
3176 } 3266 }
3177 } // namespace cricket 3267 } // namespace cricket
3178 3268
3179 #endif // HAVE_WEBRTC_VIDEO 3269 #endif // HAVE_WEBRTC_VIDEO
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698