| 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 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 | 908 |
| 909 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { | 909 FakeVideoReceiveStream* AddRecvStream(const StreamParams& sp) { |
| 910 size_t num_streams = fake_call_->GetVideoReceiveStreams().size(); | 910 size_t num_streams = fake_call_->GetVideoReceiveStreams().size(); |
| 911 EXPECT_TRUE(channel_->AddRecvStream(sp)); | 911 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
| 912 std::vector<FakeVideoReceiveStream*> streams = | 912 std::vector<FakeVideoReceiveStream*> streams = |
| 913 fake_call_->GetVideoReceiveStreams(); | 913 fake_call_->GetVideoReceiveStreams(); |
| 914 EXPECT_EQ(num_streams + 1, streams.size()); | 914 EXPECT_EQ(num_streams + 1, streams.size()); |
| 915 return streams[streams.size() - 1]; | 915 return streams[streams.size() - 1]; |
| 916 } | 916 } |
| 917 | 917 |
| 918 void SetSendCodecsShouldWorkForBitrates(const char* min_bitrate_kbps, | 918 void SetSendCodecsShouldWorkForBitrates( |
| 919 int expected_min_bitrate_bps, | 919 const char* min_bitrate_kbps, |
| 920 const char* start_bitrate_kbps, | 920 int expected_min_bitrate_bps, |
| 921 int expected_start_bitrate_bps, | 921 const char* start_bitrate_kbps, |
| 922 const char* max_bitrate_kbps, | 922 int expected_start_bitrate_bps, |
| 923 int expected_max_bitrate_bps) { | 923 const char* max_bitrate_kbps, |
| 924 rtc::Optional<int> expected_max_bitrate_bps) { |
| 924 auto& codecs = send_parameters_.codecs; | 925 auto& codecs = send_parameters_.codecs; |
| 925 codecs.clear(); | 926 codecs.clear(); |
| 926 codecs.push_back(kVp8Codec); | 927 codecs.push_back(kVp8Codec); |
| 927 codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; | 928 codecs[0].params[kCodecParamMinBitrate] = min_bitrate_kbps; |
| 928 codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; | 929 codecs[0].params[kCodecParamStartBitrate] = start_bitrate_kbps; |
| 929 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; | 930 codecs[0].params[kCodecParamMaxBitrate] = max_bitrate_kbps; |
| 930 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 931 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 931 | 932 |
| 932 EXPECT_EQ(expected_min_bitrate_bps, | 933 EXPECT_EQ(expected_min_bitrate_bps, |
| 933 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); | 934 fake_call_->GetConfig().bitrate_config.min_bitrate_bps); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 fake_call_->GetVideoSendStreams(); | 1084 fake_call_->GetVideoSendStreams(); |
| 1084 EXPECT_TRUE(streams.size() > 0); | 1085 EXPECT_TRUE(streams.size() > 0); |
| 1085 FakeVideoSendStream* stream = streams[streams.size() - 1]; | 1086 FakeVideoSendStream* stream = streams[streams.size() - 1]; |
| 1086 | 1087 |
| 1087 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig(); | 1088 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig(); |
| 1088 EXPECT_EQ(1, encoder_config.streams.size()); | 1089 EXPECT_EQ(1, encoder_config.streams.size()); |
| 1089 return encoder_config.streams[0].max_bitrate_bps; | 1090 return encoder_config.streams[0].max_bitrate_bps; |
| 1090 } | 1091 } |
| 1091 | 1092 |
| 1092 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer, | 1093 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer, |
| 1093 int global_max, | 1094 rtc::Optional<int> global_max, |
| 1094 int stream_max, | 1095 rtc::Optional<int> stream_max, |
| 1095 int expected_encoder_bitrate) { | 1096 int expected_encoder_bitrate) { |
| 1096 VideoSendParameters limited_send_params = send_parameters_; | 1097 VideoSendParameters limited_send_params = send_parameters_; |
| 1097 limited_send_params.max_bandwidth_bps = global_max; | 1098 limited_send_params.max_bitrate_bps = global_max; |
| 1098 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params)); | 1099 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params)); |
| 1099 webrtc::RtpParameters parameters = channel_->GetRtpParameters(last_ssrc_); | 1100 webrtc::RtpParameters parameters = channel_->GetRtpParameters(last_ssrc_); |
| 1100 EXPECT_EQ(1UL, parameters.encodings.size()); | 1101 EXPECT_EQ(1UL, parameters.encodings.size()); |
| 1101 parameters.encodings[0].max_bitrate_bps = stream_max; | 1102 parameters.encodings[0].max_bitrate_bps = stream_max; |
| 1102 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); | 1103 EXPECT_TRUE(channel_->SetRtpParameters(last_ssrc_, parameters)); |
| 1103 // Read back the parameteres and verify they have the correct value | 1104 // Read back the parameteres and verify they have the correct value |
| 1104 parameters = channel_->GetRtpParameters(last_ssrc_); | 1105 parameters = channel_->GetRtpParameters(last_ssrc_); |
| 1105 EXPECT_EQ(1UL, parameters.encodings.size()); | 1106 EXPECT_EQ(1UL, parameters.encodings.size()); |
| 1106 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps); | 1107 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps); |
| 1107 // Verify that the new value propagated down to the encoder | 1108 // Verify that the new value propagated down to the encoder |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2250 parameters.codecs.push_back(kVp8Codec360p); | 2251 parameters.codecs.push_back(kVp8Codec360p); |
| 2251 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2252 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 2252 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); | 2253 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); |
| 2253 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); | 2254 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); |
| 2254 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); | 2255 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); |
| 2255 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 2256 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
| 2256 } | 2257 } |
| 2257 | 2258 |
| 2258 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { | 2259 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { |
| 2259 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 2260 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
| 2260 200000); | 2261 rtc::Optional<int>(200000)); |
| 2261 } | 2262 } |
| 2262 | 2263 |
| 2263 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { | 2264 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { |
| 2264 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); | 2265 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", |
| 2266 rtc::Optional<int>(10000000)); |
| 2265 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); | 2267 std::vector<webrtc::VideoStream> streams = AddSendStream()->GetVideoStreams(); |
| 2266 ASSERT_EQ(1u, streams.size()); | 2268 ASSERT_EQ(1u, streams.size()); |
| 2267 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); | 2269 EXPECT_EQ(10000000, streams[0].max_bitrate_bps); |
| 2268 } | 2270 } |
| 2269 | 2271 |
| 2270 TEST_F(WebRtcVideoChannel2Test, | 2272 TEST_F(WebRtcVideoChannel2Test, |
| 2271 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { | 2273 SetSendCodecsWithoutBitratesUsesCorrectDefaults) { |
| 2272 SetSendCodecsShouldWorkForBitrates( | 2274 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "", rtc::Optional<int>()); |
| 2273 "", 0, "", -1, "", -1); | |
| 2274 } | 2275 } |
| 2275 | 2276 |
| 2276 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { | 2277 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsCapsMinAndStartBitrate) { |
| 2277 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", -1); | 2278 SetSendCodecsShouldWorkForBitrates("-1", 0, "-100", -1, "", |
| 2279 rtc::Optional<int>()); |
| 2278 } | 2280 } |
| 2279 | 2281 |
| 2280 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { | 2282 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsRejectsMaxLessThanMinBitrate) { |
| 2281 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; | 2283 send_parameters_.codecs[0].params[kCodecParamMinBitrate] = "300"; |
| 2282 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; | 2284 send_parameters_.codecs[0].params[kCodecParamMaxBitrate] = "200"; |
| 2283 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); | 2285 EXPECT_FALSE(channel_->SetSendParameters(send_parameters_)); |
| 2284 } | 2286 } |
| 2285 | 2287 |
| 2286 TEST_F(WebRtcVideoChannel2Test, | 2288 TEST_F(WebRtcVideoChannel2Test, |
| 2287 SetMaxSendBandwidthShouldPreserveOtherBitrates) { | 2289 SetMaxSendBandwidthShouldPreserveOtherBitrates) { |
| 2288 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 2290 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
| 2289 200000); | 2291 rtc::Optional<int>(200000)); |
| 2290 send_parameters_.max_bandwidth_bps = 300000; | 2292 send_parameters_.max_bitrate_bps = rtc::Optional<int>(300000); |
| 2291 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2293 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2292 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) | 2294 EXPECT_EQ(100000, fake_call_->GetConfig().bitrate_config.min_bitrate_bps) |
| 2293 << "Setting max bitrate should keep previous min bitrate."; | 2295 << "Setting max bitrate should keep previous min bitrate."; |
| 2294 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) | 2296 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.start_bitrate_bps) |
| 2295 << "Setting max bitrate should not reset start bitrate."; | 2297 << "Setting max bitrate should not reset start bitrate."; |
| 2296 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2298 EXPECT_EQ(rtc::Optional<int>(300000), |
| 2299 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
| 2297 } | 2300 } |
| 2298 | 2301 |
| 2299 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { | 2302 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthShouldBeRemovable) { |
| 2300 send_parameters_.max_bandwidth_bps = 300000; | 2303 send_parameters_.max_bitrate_bps = rtc::Optional<int>(300000); |
| 2301 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2304 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2302 EXPECT_EQ(300000, fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2305 EXPECT_EQ(rtc::Optional<int>(300000), |
| 2303 // <= 0 means disable (infinite) max bitrate. | 2306 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
| 2304 send_parameters_.max_bandwidth_bps = 0; | 2307 // <not set> means disable (infinite) max bitrate. |
| 2308 send_parameters_.max_bitrate_bps = rtc::Optional<int>(); |
| 2305 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2309 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 2306 EXPECT_EQ(-1, fake_call_->GetConfig().bitrate_config.max_bitrate_bps) | 2310 EXPECT_EQ(rtc::Optional<int>(), |
| 2311 fake_call_->GetConfig().bitrate_config.max_bitrate_bps) |
| 2307 << "Setting zero max bitrate did not reset start bitrate."; | 2312 << "Setting zero max bitrate did not reset start bitrate."; |
| 2308 } | 2313 } |
| 2309 | 2314 |
| 2310 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { | 2315 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { |
| 2311 cricket::VideoSendParameters parameters; | 2316 cricket::VideoSendParameters parameters; |
| 2312 parameters.codecs.push_back(kVp8Codec720p); | 2317 parameters.codecs.push_back(kVp8Codec720p); |
| 2313 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2318 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 2314 channel_->SetSend(true); | 2319 channel_->SetSend(true); |
| 2315 | 2320 |
| 2316 FakeVideoSendStream* stream = AddSendStream(); | 2321 FakeVideoSendStream* stream = AddSendStream(); |
| 2317 | 2322 |
| 2318 cricket::FakeVideoCapturer capturer; | 2323 cricket::FakeVideoCapturer capturer; |
| 2319 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 2324 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 2320 EXPECT_EQ(cricket::CS_RUNNING, | 2325 EXPECT_EQ(cricket::CS_RUNNING, |
| 2321 capturer.Start(capturer.GetSupportedFormats()->front())); | 2326 capturer.Start(capturer.GetSupportedFormats()->front())); |
| 2322 | 2327 |
| 2323 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2328 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
| 2324 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; | 2329 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; |
| 2325 EXPECT_GT(initial_max_bitrate_bps, 0); | 2330 EXPECT_GT(initial_max_bitrate_bps, 0); |
| 2326 | 2331 |
| 2327 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; | 2332 parameters.max_bitrate_bps = rtc::Optional<int>(initial_max_bitrate_bps * 2); |
| 2328 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 2333 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
| 2329 // Insert a frame to update the encoder config. | 2334 // Insert a frame to update the encoder config. |
| 2330 EXPECT_TRUE(capturer.CaptureFrame()); | 2335 EXPECT_TRUE(capturer.CaptureFrame()); |
| 2331 streams = stream->GetVideoStreams(); | 2336 streams = stream->GetVideoStreams(); |
| 2332 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); | 2337 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); |
| 2333 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); | 2338 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); |
| 2334 } | 2339 } |
| 2335 | 2340 |
| 2336 TEST_F(WebRtcVideoChannel2Test, | 2341 TEST_F(WebRtcVideoChannel2Test, |
| 2337 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { | 2342 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2349 EXPECT_EQ(cricket::CS_RUNNING, | 2354 EXPECT_EQ(cricket::CS_RUNNING, |
| 2350 capturer.Start(capturer.GetSupportedFormats()->front())); | 2355 capturer.Start(capturer.GetSupportedFormats()->front())); |
| 2351 EXPECT_TRUE(capturer.CaptureFrame()); | 2356 EXPECT_TRUE(capturer.CaptureFrame()); |
| 2352 | 2357 |
| 2353 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2358 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
| 2354 ASSERT_GT(streams.size(), 1u) | 2359 ASSERT_GT(streams.size(), 1u) |
| 2355 << "Without simulcast this test doesn't make sense."; | 2360 << "Without simulcast this test doesn't make sense."; |
| 2356 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams); | 2361 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams); |
| 2357 EXPECT_GT(initial_max_bitrate_bps, 0); | 2362 EXPECT_GT(initial_max_bitrate_bps, 0); |
| 2358 | 2363 |
| 2359 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; | 2364 parameters.max_bitrate_bps = rtc::Optional<int>(initial_max_bitrate_bps * 2); |
| 2360 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 2365 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
| 2361 // Insert a frame to update the encoder config. | 2366 // Insert a frame to update the encoder config. |
| 2362 EXPECT_TRUE(capturer.CaptureFrame()); | 2367 EXPECT_TRUE(capturer.CaptureFrame()); |
| 2363 streams = stream->GetVideoStreams(); | 2368 streams = stream->GetVideoStreams(); |
| 2364 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams); | 2369 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams); |
| 2365 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); | 2370 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); |
| 2366 | 2371 |
| 2367 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr)); | 2372 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr)); |
| 2368 } | 2373 } |
| 2369 | 2374 |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3213 } | 3218 } |
| 3214 | 3219 |
| 3215 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { | 3220 TEST_F(WebRtcVideoChannel2Test, UlpfecPacketDoesntCreateUnsignalledStream) { |
| 3216 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); | 3221 TestReceiveUnsignalledSsrcPacket(kDefaultUlpfecType, false); |
| 3217 } | 3222 } |
| 3218 | 3223 |
| 3219 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { | 3224 TEST_F(WebRtcVideoChannel2Test, RedRtxPacketDoesntCreateUnsignalledStream) { |
| 3220 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); | 3225 TestReceiveUnsignalledSsrcPacket(kRedRtxPayloadType, false); |
| 3221 } | 3226 } |
| 3222 | 3227 |
| 3223 TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) { | 3228 TEST_F(WebRtcVideoChannel2Test, CanSetMaxBitrateForExistingStream) { |
| 3224 AddSendStream(); | 3229 AddSendStream(); |
| 3225 | 3230 |
| 3226 cricket::FakeVideoCapturer capturer; | 3231 cricket::FakeVideoCapturer capturer; |
| 3227 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 3232 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 3228 cricket::VideoFormat capture_format_hd = | 3233 cricket::VideoFormat capture_format_hd = |
| 3229 capturer.GetSupportedFormats()->front(); | 3234 capturer.GetSupportedFormats()->front(); |
| 3230 EXPECT_EQ(1280, capture_format_hd.width); | 3235 EXPECT_EQ(1280, capture_format_hd.width); |
| 3231 EXPECT_EQ(720, capture_format_hd.height); | 3236 EXPECT_EQ(720, capture_format_hd.height); |
| 3232 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); | 3237 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); |
| 3233 EXPECT_TRUE(channel_->SetSend(true)); | 3238 EXPECT_TRUE(channel_->SetSend(true)); |
| 3234 | 3239 |
| 3235 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer); | 3240 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer); |
| 3236 EXPECT_TRUE(default_encoder_bitrate > 1000); | 3241 EXPECT_TRUE(default_encoder_bitrate > 1000); |
| 3237 | 3242 |
| 3238 // TODO(skvlad): Resolve the inconsistency between the interpretation | 3243 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(1000), |
| 3239 // of the global bitrate limit for audio and video: | 3244 rtc::Optional<int>(), 1000); |
| 3240 // - Audio: max_bandwidth_bps = 0 - fail the operation, | 3245 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(1000), |
| 3241 // max_bandwidth_bps = -1 - remove the bandwidth limit | 3246 rtc::Optional<int>(800), 800); |
| 3242 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, | 3247 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(600), |
| 3243 // max_bandwidth_bps = -1 - do not change the previously set | 3248 rtc::Optional<int>(800), 600); |
| 3244 // limit. | 3249 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(), |
| 3245 | 3250 rtc::Optional<int>(800), 800); |
| 3246 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000); | 3251 SetAndExpectMaxBitrate(capturer, rtc::Optional<int>(), rtc::Optional<int>(), |
| 3247 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); | 3252 default_encoder_bitrate); |
| 3248 SetAndExpectMaxBitrate(capturer, 600, 800, 600); | |
| 3249 SetAndExpectMaxBitrate(capturer, 0, 800, 800); | |
| 3250 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); | |
| 3251 | 3253 |
| 3252 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 3254 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
| 3253 } | 3255 } |
| 3254 | 3256 |
| 3257 TEST_F(WebRtcVideoChannel2Test, CannotSetNegativeOrZeroMaxBitrate) { |
| 3258 AddSendStream(); |
| 3259 webrtc::RtpParameters bad_parameters; |
| 3260 bad_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); |
| 3261 |
| 3262 bad_parameters.encodings[0].max_bitrate_bps = rtc::Optional<int>(0); |
| 3263 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, bad_parameters)); |
| 3264 bad_parameters.encodings[0].max_bitrate_bps = rtc::Optional<int>(-1); |
| 3265 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, bad_parameters)); |
| 3266 } |
| 3267 |
| 3255 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { | 3268 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { |
| 3256 webrtc::RtpParameters nonexistent_parameters = | 3269 webrtc::RtpParameters nonexistent_parameters = |
| 3257 channel_->GetRtpParameters(last_ssrc_); | 3270 channel_->GetRtpParameters(last_ssrc_); |
| 3258 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); | 3271 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); |
| 3259 | 3272 |
| 3260 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); | 3273 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); |
| 3261 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters)); | 3274 EXPECT_FALSE(channel_->SetRtpParameters(last_ssrc_, nonexistent_parameters)); |
| 3262 } | 3275 } |
| 3263 | 3276 |
| 3264 TEST_F(WebRtcVideoChannel2Test, | 3277 TEST_F(WebRtcVideoChannel2Test, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3388 codec.width, codec.height, | 3401 codec.width, codec.height, |
| 3389 cricket::VideoFormat::FpsToInterval(30), | 3402 cricket::VideoFormat::FpsToInterval(30), |
| 3390 cricket::FOURCC_I420))); | 3403 cricket::FOURCC_I420))); |
| 3391 channel_->SetSend(true); | 3404 channel_->SetSend(true); |
| 3392 EXPECT_TRUE(capturer.CaptureFrame()); | 3405 EXPECT_TRUE(capturer.CaptureFrame()); |
| 3393 | 3406 |
| 3394 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); | 3407 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 3395 ASSERT_EQ(expected_num_streams, video_streams.size()); | 3408 ASSERT_EQ(expected_num_streams, video_streams.size()); |
| 3396 | 3409 |
| 3397 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( | 3410 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( |
| 3398 num_configured_streams, codec.width, codec.height, 0, kDefaultQpMax, | 3411 num_configured_streams, codec.width, codec.height, rtc::Optional<int>(), |
| 3412 kDefaultQpMax, |
| 3399 codec.framerate != 0 ? codec.framerate : kDefaultFramerate); | 3413 codec.framerate != 0 ? codec.framerate : kDefaultFramerate); |
| 3400 | 3414 |
| 3401 ASSERT_EQ(expected_streams.size(), video_streams.size()); | 3415 ASSERT_EQ(expected_streams.size(), video_streams.size()); |
| 3402 | 3416 |
| 3403 size_t num_streams = video_streams.size(); | 3417 size_t num_streams = video_streams.size(); |
| 3404 int total_max_bitrate_bps = 0; | 3418 int total_max_bitrate_bps = 0; |
| 3405 for (size_t i = 0; i < num_streams; ++i) { | 3419 for (size_t i = 0; i < num_streams; ++i) { |
| 3406 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); | 3420 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); |
| 3407 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); | 3421 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); |
| 3408 | 3422 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3490 } | 3504 } |
| 3491 | 3505 |
| 3492 // Test that we normalize send codec format size in simulcast. | 3506 // Test that we normalize send codec format size in simulcast. |
| 3493 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3507 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
| 3494 cricket::VideoCodec codec(kVp8Codec270p); | 3508 cricket::VideoCodec codec(kVp8Codec270p); |
| 3495 codec.width += 1; | 3509 codec.width += 1; |
| 3496 codec.height += 1; | 3510 codec.height += 1; |
| 3497 VerifySimulcastSettings(codec, 2, 2); | 3511 VerifySimulcastSettings(codec, 2, 2); |
| 3498 } | 3512 } |
| 3499 } // namespace cricket | 3513 } // namespace cricket |
| OLD | NEW |