OLD | NEW |
---|---|
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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 EXPECT_TRUE(capturer_->IsRunning()); | 251 EXPECT_TRUE(capturer_->IsRunning()); |
252 | 252 |
253 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 253 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
254 EXPECT_TRUE(capturer_->CaptureFrame()); | 254 EXPECT_TRUE(capturer_->CaptureFrame()); |
255 EXPECT_EQ(1, renderer_.num_rendered_frames()); | 255 EXPECT_EQ(1, renderer_.num_rendered_frames()); |
256 EXPECT_EQ(1280, renderer_.width()); | 256 EXPECT_EQ(1280, renderer_.width()); |
257 EXPECT_EQ(720, renderer_.height()); | 257 EXPECT_EQ(720, renderer_.height()); |
258 | 258 |
259 // Request a lower resolution. | 259 // Request a lower resolution. |
260 rtc::VideoSinkWants wants; | 260 rtc::VideoSinkWants wants; |
261 wants.max_pixel_count = rtc::Optional<int>(1280 * 720 / 2); | 261 wants.max_pixel_count = rtc::Optional<int>(1280 * 720 * 3 / 5); |
nisse-webrtc
2016/04/01 07:09:35
Our magic constants here need commenting. (And mor
perkj_webrtc
2016/04/01 11:56:27
Done.
| |
262 capturer_->AddOrUpdateSink(&renderer_, wants); | 262 capturer_->AddOrUpdateSink(&renderer_, wants); |
263 EXPECT_TRUE(capturer_->CaptureFrame()); | 263 EXPECT_TRUE(capturer_->CaptureFrame()); |
264 EXPECT_EQ(2, renderer_.num_rendered_frames()); | 264 EXPECT_EQ(2, renderer_.num_rendered_frames()); |
265 EXPECT_EQ(960, renderer_.width()); | 265 EXPECT_EQ(960, renderer_.width()); |
266 EXPECT_EQ(540, renderer_.height()); | 266 EXPECT_EQ(540, renderer_.height()); |
267 | 267 |
268 // Request a lower resolution. | 268 // Request a lower resolution. |
269 wants.max_pixel_count = | 269 wants.max_pixel_count = |
270 rtc::Optional<int>(renderer_.width() * renderer_.height() / 2); | 270 rtc::Optional<int>(renderer_.width() * renderer_.height() * 3 / 5); |
271 capturer_->AddOrUpdateSink(&renderer_, wants); | 271 capturer_->AddOrUpdateSink(&renderer_, wants); |
272 EXPECT_TRUE(capturer_->CaptureFrame()); | 272 EXPECT_TRUE(capturer_->CaptureFrame()); |
273 EXPECT_EQ(3, renderer_.num_rendered_frames()); | 273 EXPECT_EQ(3, renderer_.num_rendered_frames()); |
274 EXPECT_EQ(640, renderer_.width()); | 274 EXPECT_EQ(640, renderer_.width()); |
275 EXPECT_EQ(360, renderer_.height()); | 275 EXPECT_EQ(360, renderer_.height()); |
276 | 276 |
277 // Adding a new renderer should not affect resolution. | 277 // Adding a new renderer should not affect resolution. |
278 cricket::FakeVideoRenderer renderer2; | 278 cricket::FakeVideoRenderer renderer2; |
279 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); | 279 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); |
280 EXPECT_TRUE(capturer_->CaptureFrame()); | 280 EXPECT_TRUE(capturer_->CaptureFrame()); |
(...skipping 18 matching lines...) Expand all Loading... | |
299 | 299 |
300 // Updating with no wants should not affect resolution. | 300 // Updating with no wants should not affect resolution. |
301 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); | 301 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); |
302 EXPECT_TRUE(capturer_->CaptureFrame()); | 302 EXPECT_TRUE(capturer_->CaptureFrame()); |
303 EXPECT_EQ(6, renderer_.num_rendered_frames()); | 303 EXPECT_EQ(6, renderer_.num_rendered_frames()); |
304 EXPECT_EQ(960, renderer_.width()); | 304 EXPECT_EQ(960, renderer_.width()); |
305 EXPECT_EQ(540, renderer_.height()); | 305 EXPECT_EQ(540, renderer_.height()); |
306 EXPECT_EQ(3, renderer2.num_rendered_frames()); | 306 EXPECT_EQ(3, renderer2.num_rendered_frames()); |
307 EXPECT_EQ(960, renderer2.width()); | 307 EXPECT_EQ(960, renderer2.width()); |
308 EXPECT_EQ(540, renderer2.height()); | 308 EXPECT_EQ(540, renderer2.height()); |
309 | |
310 // But resetting the wants should reset the resolution to what the camera is | |
311 // opened with. | |
312 capturer_->AddOrUpdateSink(&renderer_, rtc::VideoSinkWants()); | |
313 EXPECT_TRUE(capturer_->CaptureFrame()); | |
314 EXPECT_EQ(7, renderer_.num_rendered_frames()); | |
315 EXPECT_EQ(1280, renderer_.width()); | |
316 EXPECT_EQ(720, renderer_.height()); | |
317 EXPECT_EQ(4, renderer2.num_rendered_frames()); | |
318 EXPECT_EQ(1280, renderer2.width()); | |
319 EXPECT_EQ(720, renderer2.height());; | |
309 } | 320 } |
310 | 321 |
311 TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) { | 322 TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) { |
312 InitScreencast(); | 323 InitScreencast(); |
313 | 324 |
314 const int kMaxWidth = 4096; | 325 const int kMaxWidth = 4096; |
315 const int kMaxHeight = 3072; | 326 const int kMaxHeight = 3072; |
316 int kWidth = kMaxWidth + 4; | 327 int kWidth = kMaxWidth + 4; |
317 int kHeight = kMaxHeight + 4; | 328 int kHeight = kMaxHeight + 4; |
318 | 329 |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 capturer_->set_enable_camera_list(true); | 796 capturer_->set_enable_camera_list(true); |
786 capturer_->ConstrainSupportedFormats(vga_format); | 797 capturer_->ConstrainSupportedFormats(vga_format); |
787 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); | 798 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); |
788 // To make sure it's not just the camera list being broken, add in VGA and | 799 // To make sure it's not just the camera list being broken, add in VGA and |
789 // try again. This time, only the VGA format should be there. | 800 // try again. This time, only the VGA format should be there. |
790 supported_formats.push_back(vga_format); | 801 supported_formats.push_back(vga_format); |
791 capturer_->ResetSupportedFormats(supported_formats); | 802 capturer_->ResetSupportedFormats(supported_formats); |
792 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); | 803 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); |
793 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); | 804 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); |
794 } | 805 } |
OLD | NEW |