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

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: Rebased on top of the latest master branch 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
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | webrtc/pc/channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); 1073 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset);
1074 } 1074 }
1075 } 1075 }
1076 if (with_rtx) { 1076 if (with_rtx) {
1077 return AddSendStream( 1077 return AddSendStream(
1078 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1078 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1079 } 1079 }
1080 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); 1080 return AddSendStream(CreateSimStreamParams("cname", ssrcs));
1081 } 1081 }
1082 1082
1083 int GetMaxEncoderBitrate(cricket::FakeVideoCapturer& capturer) {
1084 EXPECT_TRUE(capturer.CaptureFrame());
1085
1086 std::vector<FakeVideoSendStream*> streams =
1087 fake_call_->GetVideoSendStreams();
1088 EXPECT_TRUE(streams.size() > 0);
1089 FakeVideoSendStream* stream = streams[streams.size() - 1];
1090
1091 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig();
1092 EXPECT_EQ(1, encoder_config.streams.size());
1093 return encoder_config.streams[0].max_bitrate_bps;
1094 }
1095
1096 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer,
1097 int global_max,
1098 int stream_max,
1099 int expected_encoder_bitrate) {
1100 VideoSendParameters limited_send_params = send_parameters_;
1101 limited_send_params.max_bandwidth_bps = global_max;
1102 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params));
1103 webrtc::RtpParameters parameters = channel_->GetRtpParameters(last_ssrc_);
1104 EXPECT_EQ(1UL, parameters.encodings.size());
1105 parameters.encodings[0].max_bitrate_bps = stream_max;
1106 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters));
1107 // Read back the parameteres and verify they have the correct value
1108 parameters = channel_->GetRtpParameters(last_ssrc_);
1109 EXPECT_EQ(1UL, parameters.encodings.size());
1110 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps);
1111 // Verify that the new value propagated down to the encoder
1112 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate(capturer));
1113 }
1114
1083 std::unique_ptr<FakeCall> fake_call_; 1115 std::unique_ptr<FakeCall> fake_call_;
1084 std::unique_ptr<VideoMediaChannel> channel_; 1116 std::unique_ptr<VideoMediaChannel> channel_;
1085 cricket::VideoSendParameters send_parameters_; 1117 cricket::VideoSendParameters send_parameters_;
1086 cricket::VideoRecvParameters recv_parameters_; 1118 cricket::VideoRecvParameters recv_parameters_;
1087 uint32_t last_ssrc_; 1119 uint32_t last_ssrc_;
1088 }; 1120 };
1089 1121
1090 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { 1122 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) {
1091 const uint32_t kVideoSsrc = 123; 1123 const uint32_t kVideoSsrc = 123;
1092 const std::string kSyncLabel = "AvSyncLabel"; 1124 const std::string kSyncLabel = "AvSyncLabel";
(...skipping 2013 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 } 3138 }
3107 3139
3108 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { 3140 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) {
3109 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); 3141 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false);
3110 } 3142 }
3111 3143
3112 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { 3144 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) {
3113 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); 3145 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false);
3114 } 3146 }
3115 3147
3148 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) {
3149 AddSendStream();
3150
3151 cricket::FakeVideoCapturer capturer;
3152 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
3153 cricket::VideoFormat capture_format_hd =
3154 capturer.GetSupportedFormats()->front();
3155 EXPECT_EQ(1280, capture_format_hd.width);
3156 EXPECT_EQ(720, capture_format_hd.height);
3157 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
3158 EXPECT_TRUE(channel_->SetSend(true));
3159
3160 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer);
3161 EXPECT_TRUE(default_encoder_bitrate > 1000);
3162
3163 // TODO(skvlad): Resolve the inconsistency between the interpretation
3164 // of the global bitrate limit for audio and video:
3165 // - Audio: max_bandwidth_bps = 0 - fail the operation,
3166 // max_bandwidth_bps = -1 - remove the bandwidth limit
3167 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit,
3168 // max_bandwidth_bps = -1 - do not change the previously set
3169 // limit.
3170
3171 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000);
3172 SetAndExpectMaxBitrate(capturer, 1000, 800, 800);
3173 SetAndExpectMaxBitrate(capturer, 600, 800, 600);
3174 SetAndExpectMaxBitrate(capturer, 0, 800, 800);
3175 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate);
3176
3177 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
3178 }
3179
3180 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) {
3181 webrtc::RtpParameters nonexistent_parameters =
3182 channel_->GetRtpParameters(last_ssrc_);
3183 EXPECT_EQ(0, nonexistent_parameters.encodings.size());
3184
3185 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3186 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters));
3187 }
3188
3189 TEST_F(WebRtcVideoChannel2Test,
3190 CannotSetRtpParametersWithIncorrectNumberOfEncodings) {
3191 // This test verifies that setting RtpParameters succeeds only if
3192 // the structure contains exactly one encoding.
3193 // TODO(skvlad): Update this test when we strat supporting setting parameters
3194 // for each encoding individually.
3195
3196 AddSendStream();
3197 // Setting RtpParameters with no encoding is expected to fail.
3198 webrtc::RtpParameters parameters;
3199 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, parameters));
3200 // Setting RtpParameters with exactly one encoding should succeed.
3201 parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3202 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters));
3203 // Two or more encodings should result in failure.
3204 parameters.encodings.push_back(webrtc::RtpEncodingParameters());
3205 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, parameters));
3206 }
3207
3116 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration( 3208 void WebRtcVideoChannel2Test::TestReceiverLocalSsrcConfiguration(
3117 bool receiver_first) { 3209 bool receiver_first) {
3118 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3210 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3119 3211
3120 const uint32_t kSenderSsrc = 0xC0FFEE; 3212 const uint32_t kSenderSsrc = 0xC0FFEE;
3121 const uint32_t kSecondSenderSsrc = 0xBADCAFE; 3213 const uint32_t kSecondSenderSsrc = 0xBADCAFE;
3122 const uint32_t kReceiverSsrc = 0x4711; 3214 const uint32_t kReceiverSsrc = 0x4711;
3123 const uint32_t kExpectedDefaultReceiverSsrc = 1; 3215 const uint32_t kExpectedDefaultReceiverSsrc = 1;
3124 3216
3125 if (receiver_first) { 3217 if (receiver_first) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3300 } 3392 }
3301 3393
3302 // Test that we normalize send codec format size in simulcast. 3394 // Test that we normalize send codec format size in simulcast.
3303 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3395 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3304 cricket::VideoCodec codec(kVp8Codec270p); 3396 cricket::VideoCodec codec(kVp8Codec270p);
3305 codec.width += 1; 3397 codec.width += 1;
3306 codec.height += 1; 3398 codec.height += 1;
3307 VerifySimulcastSettings(codec, 2, 2); 3399 VerifySimulcastSettings(codec, 2, 2);
3308 } 3400 }
3309 } // namespace cricket 3401 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | webrtc/pc/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698