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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 1280, 720, cricket::VideoFormat::FpsToInterval(30), | 249 1280, 720, cricket::VideoFormat::FpsToInterval(30), |
250 cricket::FOURCC_I420))); | 250 cricket::FOURCC_I420))); |
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. The output resolution will have a resolution |
260 // with less than or equal to |wants.max_pixel_count| depending on how the | |
261 // capturer can scale the input frame size. | |
260 rtc::VideoSinkWants wants; | 262 rtc::VideoSinkWants wants; |
261 wants.max_pixel_count = rtc::Optional<int>(1280 * 720 / 2); | 263 wants.max_pixel_count = rtc::Optional<int>(1280 * 720 * 3 / 5); |
262 capturer_->AddOrUpdateSink(&renderer_, wants); | 264 capturer_->AddOrUpdateSink(&renderer_, wants); |
263 EXPECT_TRUE(capturer_->CaptureFrame()); | 265 EXPECT_TRUE(capturer_->CaptureFrame()); |
264 EXPECT_EQ(2, renderer_.num_rendered_frames()); | 266 EXPECT_EQ(2, renderer_.num_rendered_frames()); |
265 EXPECT_EQ(960, renderer_.width()); | 267 EXPECT_EQ(960, renderer_.width()); |
266 EXPECT_EQ(540, renderer_.height()); | 268 EXPECT_EQ(540, renderer_.height()); |
267 | 269 |
268 // Request a lower resolution. | 270 // Request a lower resolution. |
269 wants.max_pixel_count = | 271 wants.max_pixel_count = |
270 rtc::Optional<int>(renderer_.width() * renderer_.height() / 2); | 272 rtc::Optional<int>(renderer_.width() * renderer_.height() * 3 / 5); |
271 capturer_->AddOrUpdateSink(&renderer_, wants); | 273 capturer_->AddOrUpdateSink(&renderer_, wants); |
272 EXPECT_TRUE(capturer_->CaptureFrame()); | 274 EXPECT_TRUE(capturer_->CaptureFrame()); |
273 EXPECT_EQ(3, renderer_.num_rendered_frames()); | 275 EXPECT_EQ(3, renderer_.num_rendered_frames()); |
274 EXPECT_EQ(640, renderer_.width()); | 276 EXPECT_EQ(640, renderer_.width()); |
275 EXPECT_EQ(360, renderer_.height()); | 277 EXPECT_EQ(360, renderer_.height()); |
276 | 278 |
277 // Adding a new renderer should not affect resolution. | 279 // Adding a new renderer should not affect resolution. |
278 cricket::FakeVideoRenderer renderer2; | 280 cricket::FakeVideoRenderer renderer2; |
279 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); | 281 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); |
280 EXPECT_TRUE(capturer_->CaptureFrame()); | 282 EXPECT_TRUE(capturer_->CaptureFrame()); |
(...skipping 18 matching lines...) Expand all Loading... | |
299 | 301 |
300 // Updating with no wants should not affect resolution. | 302 // Updating with no wants should not affect resolution. |
301 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); | 303 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); |
302 EXPECT_TRUE(capturer_->CaptureFrame()); | 304 EXPECT_TRUE(capturer_->CaptureFrame()); |
303 EXPECT_EQ(6, renderer_.num_rendered_frames()); | 305 EXPECT_EQ(6, renderer_.num_rendered_frames()); |
304 EXPECT_EQ(960, renderer_.width()); | 306 EXPECT_EQ(960, renderer_.width()); |
305 EXPECT_EQ(540, renderer_.height()); | 307 EXPECT_EQ(540, renderer_.height()); |
306 EXPECT_EQ(3, renderer2.num_rendered_frames()); | 308 EXPECT_EQ(3, renderer2.num_rendered_frames()); |
307 EXPECT_EQ(960, renderer2.width()); | 309 EXPECT_EQ(960, renderer2.width()); |
308 EXPECT_EQ(540, renderer2.height()); | 310 EXPECT_EQ(540, renderer2.height()); |
311 | |
312 // But resetting the wants should reset the resolution to what the camera is | |
pbos-webrtc
2016/04/05 10:16:55
was opened with
| |
313 // opened with. | |
314 capturer_->AddOrUpdateSink(&renderer_, rtc::VideoSinkWants()); | |
315 EXPECT_TRUE(capturer_->CaptureFrame()); | |
316 EXPECT_EQ(7, renderer_.num_rendered_frames()); | |
317 EXPECT_EQ(1280, renderer_.width()); | |
318 EXPECT_EQ(720, renderer_.height()); | |
319 EXPECT_EQ(4, renderer2.num_rendered_frames()); | |
320 EXPECT_EQ(1280, renderer2.width()); | |
321 EXPECT_EQ(720, renderer2.height()); | |
309 } | 322 } |
310 | 323 |
311 TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) { | 324 TEST_F(VideoCapturerTest, ScreencastScaledSuperLarge) { |
312 InitScreencast(); | 325 InitScreencast(); |
313 | 326 |
314 const int kMaxWidth = 4096; | 327 const int kMaxWidth = 4096; |
315 const int kMaxHeight = 3072; | 328 const int kMaxHeight = 3072; |
316 int kWidth = kMaxWidth + 4; | 329 int kWidth = kMaxWidth + 4; |
317 int kHeight = kMaxHeight + 4; | 330 int kHeight = kMaxHeight + 4; |
318 | 331 |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
785 capturer_->set_enable_camera_list(true); | 798 capturer_->set_enable_camera_list(true); |
786 capturer_->ConstrainSupportedFormats(vga_format); | 799 capturer_->ConstrainSupportedFormats(vga_format); |
787 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); | 800 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); |
788 // To make sure it's not just the camera list being broken, add in VGA and | 801 // 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. | 802 // try again. This time, only the VGA format should be there. |
790 supported_formats.push_back(vga_format); | 803 supported_formats.push_back(vga_format); |
791 capturer_->ResetSupportedFormats(supported_formats); | 804 capturer_->ResetSupportedFormats(supported_formats); |
792 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); | 805 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); |
793 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); | 806 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); |
794 } | 807 } |
OLD | NEW |