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

Side by Side Diff: webrtc/media/base/videocapturer_unittest.cc

Issue 1695263002: Move direct use of VideoCapturer::VideoAdapter to VideoSinkWants. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed test for screencast from videocapturer Created 4 years, 10 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) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 wants.rotation_applied = true; 320 wants.rotation_applied = true;
321 capturer_.AddOrUpdateSink(&renderer2, wants); 321 capturer_.AddOrUpdateSink(&renderer2, wants);
322 322
323 EXPECT_TRUE(capturer_.CaptureFrame()); 323 EXPECT_TRUE(capturer_.CaptureFrame());
324 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames()); 324 EXPECT_EQ(++frame_count, renderer_.num_rendered_frames());
325 EXPECT_EQ(1, renderer2.num_rendered_frames()); 325 EXPECT_EQ(1, renderer2.num_rendered_frames());
326 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation()); 326 EXPECT_EQ(webrtc::kVideoRotation_0, renderer_.rotation());
327 EXPECT_EQ(webrtc::kVideoRotation_0, renderer2.rotation()); 327 EXPECT_EQ(webrtc::kVideoRotation_0, renderer2.rotation());
328 } 328 }
329 329
330 TEST_F(VideoCapturerTest, SinkWantsMaxPixelAndMaxPixelCountStepUp) {
331 EXPECT_EQ(cricket::CS_RUNNING,
332 capturer_.Start(cricket::VideoFormat(
333 1280, 720, cricket::VideoFormat::FpsToInterval(30),
334 cricket::FOURCC_I420)));
335 EXPECT_TRUE(capturer_.IsRunning());
336
337 EXPECT_EQ(0, renderer_.num_rendered_frames());
338 EXPECT_TRUE(capturer_.CaptureFrame());
339 EXPECT_EQ(1, renderer_.num_rendered_frames());
340 EXPECT_EQ(1280, renderer_.width());
341 EXPECT_EQ(720, renderer_.height());
342
343 // Request a lower resolution.
344 rtc::VideoSinkWants wants;
345 wants.max_pixel_count = rtc::Optional<int>(1280 * 720 / 2);
346 capturer_.AddOrUpdateSink(&renderer_, wants);
347 EXPECT_TRUE(capturer_.CaptureFrame());
348 EXPECT_EQ(2, renderer_.num_rendered_frames());
349 EXPECT_EQ(960, renderer_.width());
350 EXPECT_EQ(540, renderer_.height());
351
352 // Request a lower resolution.
353 wants.max_pixel_count =
354 rtc::Optional<int>(renderer_.width() * renderer_.height() / 2);
355 capturer_.AddOrUpdateSink(&renderer_, wants);
356 EXPECT_TRUE(capturer_.CaptureFrame());
357 EXPECT_EQ(3, renderer_.num_rendered_frames());
358 EXPECT_EQ(640, renderer_.width());
359 EXPECT_EQ(360, renderer_.height());
360
361 // Adding a new renderer should not affect resolution.
362 cricket::FakeVideoRenderer renderer2;
363 capturer_.AddOrUpdateSink(&renderer2, rtc::VideoSinkWants());
364 EXPECT_TRUE(capturer_.CaptureFrame());
365 EXPECT_EQ(4, renderer_.num_rendered_frames());
366 EXPECT_EQ(640, renderer_.width());
367 EXPECT_EQ(360, renderer_.height());
368 EXPECT_EQ(1, renderer2.num_rendered_frames());
369 EXPECT_EQ(640, renderer2.width());
370 EXPECT_EQ(360, renderer2.height());
371
372 // Request higher resolution.
373 wants.max_pixel_count_step_up = wants.max_pixel_count;
374 wants.max_pixel_count = rtc::Optional<int>();
375 capturer_.AddOrUpdateSink(&renderer_, wants);
376 EXPECT_TRUE(capturer_.CaptureFrame());
377 EXPECT_EQ(5, renderer_.num_rendered_frames());
378 EXPECT_EQ(960, renderer_.width());
379 EXPECT_EQ(540, renderer_.height());
380 EXPECT_EQ(2, renderer2.num_rendered_frames());
381 EXPECT_EQ(960, renderer2.width());
382 EXPECT_EQ(540, renderer2.height());
383
384 // Updating with no wants should not affect resolution.
385 capturer_.AddOrUpdateSink(&renderer2, rtc::VideoSinkWants());
386 EXPECT_TRUE(capturer_.CaptureFrame());
387 EXPECT_EQ(6, renderer_.num_rendered_frames());
388 EXPECT_EQ(960, renderer_.width());
389 EXPECT_EQ(540, renderer_.height());
390 EXPECT_EQ(3, renderer2.num_rendered_frames());
391 EXPECT_EQ(960, renderer2.width());
392 EXPECT_EQ(540, renderer2.height());
393 }
394
330 TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) { 395 TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) {
331 capturer_.SetScreencast(true); 396 capturer_.SetScreencast(true);
332 397
333 const int kMaxWidth = 4096; 398 const int kMaxWidth = 4096;
334 const int kMaxHeight = 3072; 399 const int kMaxHeight = 3072;
335 int kWidth = kMaxWidth + 4; 400 int kWidth = kMaxWidth + 4;
336 int kHeight = kMaxHeight + 4; 401 int kHeight = kMaxHeight + 4;
337 402
338 std::vector<cricket::VideoFormat> formats; 403 std::vector<cricket::VideoFormat> formats;
339 formats.push_back(cricket::VideoFormat(kWidth, kHeight, 404 formats.push_back(cricket::VideoFormat(kWidth, kHeight,
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 capturer_.set_enable_camera_list(true); 869 capturer_.set_enable_camera_list(true);
805 capturer_.ConstrainSupportedFormats(vga_format); 870 capturer_.ConstrainSupportedFormats(vga_format);
806 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size()); 871 EXPECT_EQ(2u, capturer_.GetSupportedFormats()->size());
807 // To make sure it's not just the camera list being broken, add in VGA and 872 // To make sure it's not just the camera list being broken, add in VGA and
808 // try again. This time, only the VGA format should be there. 873 // try again. This time, only the VGA format should be there.
809 supported_formats.push_back(vga_format); 874 supported_formats.push_back(vga_format);
810 capturer_.ResetSupportedFormats(supported_formats); 875 capturer_.ResetSupportedFormats(supported_formats);
811 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size()); 876 ASSERT_EQ(1u, capturer_.GetSupportedFormats()->size());
812 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height); 877 EXPECT_EQ(vga_format.height, capturer_.GetSupportedFormats()->at(0).height);
813 } 878 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698