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

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

Issue 2716643002: Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: windows warning Created 3 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 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 send_stream = fake_call_->GetVideoSendStreams().front(); 2235 send_stream = fake_call_->GetVideoSendStreams().front();
2236 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2236 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2237 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); 2237 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth());
2238 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); 2238 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
2239 2239
2240 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2240 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2241 } 2241 }
2242 2242
2243 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, 2243 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
2244 bool is_screenshare) { 2244 bool is_screenshare) {
2245 const int kDefaultFps = 30;
2245 cricket::VideoCodec codec = GetEngineCodec("VP8"); 2246 cricket::VideoCodec codec = GetEngineCodec("VP8");
2246 cricket::VideoSendParameters parameters; 2247 cricket::VideoSendParameters parameters;
2247 parameters.codecs.push_back(codec); 2248 parameters.codecs.push_back(codec);
2248 2249
2249 MediaConfig media_config = GetMediaConfig(); 2250 MediaConfig media_config = GetMediaConfig();
2250 if (enable_overuse) { 2251 if (enable_overuse) {
2251 media_config.video.enable_cpu_overuse_detection = true; 2252 media_config.video.enable_cpu_overuse_detection = true;
2252 } 2253 }
2253 channel_.reset( 2254 channel_.reset(
2254 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); 2255 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
2255 channel_->OnReadyToSend(true); 2256 channel_->OnReadyToSend(true);
2256 2257
2257 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2258 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2258 2259
2259 AddSendStream(); 2260 AddSendStream();
2260 2261
2261 cricket::FakeVideoCapturer capturer; 2262 cricket::FakeVideoCapturer capturer;
2262 VideoOptions options; 2263 VideoOptions options;
2263 options.is_screencast = rtc::Optional<bool>(is_screenshare); 2264 options.is_screencast = rtc::Optional<bool>(is_screenshare);
2264 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 2265 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
2265 cricket::VideoFormat capture_format = capturer.GetSupportedFormats()->front(); 2266 cricket::VideoFormat capture_format = capturer.GetSupportedFormats()->front();
2267 capture_format.interval = rtc::kNumNanosecsPerSec / kDefaultFps;
2266 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format)); 2268 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format));
2267 2269
2268 EXPECT_TRUE(channel_->SetSend(true)); 2270 EXPECT_TRUE(channel_->SetSend(true));
2269 2271
2270 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 2272 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
2271 2273
2272 if (!enable_overuse || is_screenshare) { 2274 if (!enable_overuse) {
2273 EXPECT_FALSE(send_stream->resolution_scaling_enabled()); 2275 EXPECT_FALSE(send_stream->resolution_scaling_enabled());
2276 EXPECT_FALSE(send_stream->framerate_scaling_enabled());
2277 EXPECT_EQ(is_screenshare, send_stream->framerate_scaling_enabled());
2274 2278
2275 EXPECT_TRUE(capturer.CaptureFrame()); 2279 EXPECT_TRUE(capturer.CaptureFrame());
2276 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2280 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2277 2281
2278 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); 2282 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth());
2279 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); 2283 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight());
2280 2284
2281 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2285 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2282 return; 2286 return;
2283 } 2287 }
2284 2288
2285 EXPECT_TRUE(send_stream->resolution_scaling_enabled()); 2289 if (is_screenshare) {
2290 EXPECT_FALSE(send_stream->resolution_scaling_enabled());
2291 EXPECT_TRUE(send_stream->framerate_scaling_enabled());
2292 } else {
2293 EXPECT_TRUE(send_stream->resolution_scaling_enabled());
2294 EXPECT_FALSE(send_stream->framerate_scaling_enabled());
2295 }
2296
2286 // Trigger overuse. 2297 // Trigger overuse.
2287 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 2298 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
2288 2299
2289 rtc::VideoSinkWants wants; 2300 rtc::VideoSinkWants wants;
2290 wants.max_pixel_count = 2301 if (is_screenshare) {
2291 rtc::Optional<int>(capture_format.width * capture_format.height - 1); 2302 wants.max_framerate_fps.emplace((kDefaultFps * 2) / 3);
2303 } else {
2304 wants.max_pixel_count.emplace(capture_format.width * capture_format.height -
2305 1);
2306 }
2292 send_stream->InjectVideoSinkWants(wants); 2307 send_stream->InjectVideoSinkWants(wants);
2293 2308
2294 EXPECT_TRUE(capturer.CaptureFrame()); 2309 for (int i = 0; i < kDefaultFps; ++i)
2295 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2310 EXPECT_TRUE(capturer.CaptureFrame());
2296 2311
2297 EXPECT_TRUE(capturer.CaptureFrame()); 2312 if (is_screenshare) {
2298 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 2313 // Drops every third frame.
2299 2314 EXPECT_EQ(kDefaultFps * 2 / 3, send_stream->GetNumberOfSwappedFrames());
2300 EXPECT_LT(send_stream->GetLastWidth(), capture_format.width); 2315 EXPECT_EQ(send_stream->GetLastWidth(), capture_format.width);
2301 EXPECT_LT(send_stream->GetLastHeight(), capture_format.height); 2316 EXPECT_EQ(send_stream->GetLastHeight(), capture_format.height);
2317 } else {
2318 EXPECT_EQ(kDefaultFps, send_stream->GetNumberOfSwappedFrames());
2319 EXPECT_LT(send_stream->GetLastWidth(), capture_format.width);
2320 EXPECT_LT(send_stream->GetLastHeight(), capture_format.height);
2321 }
2302 2322
2303 // Trigger underuse which should go back to normal resolution. 2323 // Trigger underuse which should go back to normal resolution.
2304 int last_pixel_count = 2324 int last_pixel_count =
2305 send_stream->GetLastWidth() * send_stream->GetLastHeight(); 2325 send_stream->GetLastWidth() * send_stream->GetLastHeight();
2306 wants.max_pixel_count = rtc::Optional<int>(last_pixel_count * 4); 2326 if (is_screenshare) {
2307 wants.target_pixel_count = rtc::Optional<int>((last_pixel_count * 5) / 3); 2327 wants.max_framerate_fps.emplace(kDefaultFps);
2328 } else {
2329 wants.max_pixel_count.emplace(last_pixel_count * 4);
2330 wants.target_pixel_count.emplace((last_pixel_count * 5) / 3);
2331 }
2308 send_stream->InjectVideoSinkWants(wants); 2332 send_stream->InjectVideoSinkWants(wants);
2309 2333
2310 EXPECT_TRUE(capturer.CaptureFrame()); 2334 for (int i = 0; i < kDefaultFps; ++i)
2311 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); 2335 EXPECT_TRUE(capturer.CaptureFrame());
2336
2337 if (is_screenshare) {
2338 EXPECT_EQ(kDefaultFps + (kDefaultFps * 2 / 3),
2339 send_stream->GetNumberOfSwappedFrames());
2340 } else {
2341 EXPECT_EQ(kDefaultFps * 2, send_stream->GetNumberOfSwappedFrames());
2342 }
2312 2343
2313 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); 2344 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth());
2314 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); 2345 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight());
2315 2346
2316 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2347 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2317 } 2348 }
2318 2349
2319 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { 2350 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) {
2320 // Start at last timestamp to verify that wraparounds are estimated correctly. 2351 // Start at last timestamp to verify that wraparounds are estimated correctly.
2321 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; 2352 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu;
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
4366 } 4397 }
4367 4398
4368 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { 4399 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) {
4369 webrtc::test::ScopedFieldTrials override_field_trials_( 4400 webrtc::test::ScopedFieldTrials override_field_trials_(
4370 "WebRTC-SimulcastScreenshare/Enabled/"); 4401 "WebRTC-SimulcastScreenshare/Enabled/");
4371 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, 4402 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true,
4372 true); 4403 true);
4373 } 4404 }
4374 4405
4375 } // namespace cricket 4406 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698