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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 EXPECT_EQ(0, renderer_.num_rendered_frames()); | 259 EXPECT_EQ(0, renderer_.num_rendered_frames()); |
260 EXPECT_TRUE(capturer_->CaptureFrame()); | 260 EXPECT_TRUE(capturer_->CaptureFrame()); |
261 EXPECT_EQ(1, renderer_.num_rendered_frames()); | 261 EXPECT_EQ(1, renderer_.num_rendered_frames()); |
262 EXPECT_EQ(1280, renderer_.width()); | 262 EXPECT_EQ(1280, renderer_.width()); |
263 EXPECT_EQ(720, renderer_.height()); | 263 EXPECT_EQ(720, renderer_.height()); |
264 | 264 |
265 // Request a lower resolution. The output resolution will have a resolution | 265 // Request a lower resolution. The output resolution will have a resolution |
266 // with less than or equal to |wants.max_pixel_count| depending on how the | 266 // with less than or equal to |wants.max_pixel_count| depending on how the |
267 // capturer can scale the input frame size. | 267 // capturer can scale the input frame size. |
268 rtc::VideoSinkWants wants; | 268 rtc::VideoSinkWants wants; |
269 wants.max_pixel_count = rtc::Optional<int>(1280 * 720 * 3 / 5); | 269 wants.max_pixel_count = 1280 * 720 * 3 / 5; |
270 capturer_->AddOrUpdateSink(&renderer_, wants); | 270 capturer_->AddOrUpdateSink(&renderer_, wants); |
271 EXPECT_TRUE(capturer_->CaptureFrame()); | 271 EXPECT_TRUE(capturer_->CaptureFrame()); |
272 EXPECT_EQ(2, renderer_.num_rendered_frames()); | 272 EXPECT_EQ(2, renderer_.num_rendered_frames()); |
273 EXPECT_EQ(960, renderer_.width()); | 273 EXPECT_EQ(960, renderer_.width()); |
274 EXPECT_EQ(540, renderer_.height()); | 274 EXPECT_EQ(540, renderer_.height()); |
275 | 275 |
276 // Request a lower resolution. | 276 // Request a lower resolution. |
277 wants.max_pixel_count = | 277 wants.max_pixel_count = (renderer_.width() * renderer_.height() * 3) / 5; |
278 rtc::Optional<int>((renderer_.width() * renderer_.height() * 3) / 5); | |
279 capturer_->AddOrUpdateSink(&renderer_, wants); | 278 capturer_->AddOrUpdateSink(&renderer_, wants); |
280 EXPECT_TRUE(capturer_->CaptureFrame()); | 279 EXPECT_TRUE(capturer_->CaptureFrame()); |
281 EXPECT_EQ(3, renderer_.num_rendered_frames()); | 280 EXPECT_EQ(3, renderer_.num_rendered_frames()); |
282 EXPECT_EQ(640, renderer_.width()); | 281 EXPECT_EQ(640, renderer_.width()); |
283 EXPECT_EQ(360, renderer_.height()); | 282 EXPECT_EQ(360, renderer_.height()); |
284 | 283 |
285 // Adding a new renderer should not affect resolution. | 284 // Adding a new renderer should not affect resolution. |
286 cricket::FakeVideoRenderer renderer2; | 285 cricket::FakeVideoRenderer renderer2; |
287 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); | 286 capturer_->AddOrUpdateSink(&renderer2, rtc::VideoSinkWants()); |
288 EXPECT_TRUE(capturer_->CaptureFrame()); | 287 EXPECT_TRUE(capturer_->CaptureFrame()); |
289 EXPECT_EQ(4, renderer_.num_rendered_frames()); | 288 EXPECT_EQ(4, renderer_.num_rendered_frames()); |
290 EXPECT_EQ(640, renderer_.width()); | 289 EXPECT_EQ(640, renderer_.width()); |
291 EXPECT_EQ(360, renderer_.height()); | 290 EXPECT_EQ(360, renderer_.height()); |
292 EXPECT_EQ(1, renderer2.num_rendered_frames()); | 291 EXPECT_EQ(1, renderer2.num_rendered_frames()); |
293 EXPECT_EQ(640, renderer2.width()); | 292 EXPECT_EQ(640, renderer2.width()); |
294 EXPECT_EQ(360, renderer2.height()); | 293 EXPECT_EQ(360, renderer2.height()); |
295 | 294 |
296 // Request higher resolution. | 295 // Request higher resolution. |
297 wants.target_pixel_count.emplace((*wants.max_pixel_count * 5) / 3); | 296 wants.target_pixel_count.emplace((wants.max_pixel_count * 5) / 3); |
298 wants.max_pixel_count.emplace(*wants.max_pixel_count * 4); | 297 wants.max_pixel_count = wants.max_pixel_count * 4; |
299 capturer_->AddOrUpdateSink(&renderer_, wants); | 298 capturer_->AddOrUpdateSink(&renderer_, wants); |
300 EXPECT_TRUE(capturer_->CaptureFrame()); | 299 EXPECT_TRUE(capturer_->CaptureFrame()); |
301 EXPECT_EQ(5, renderer_.num_rendered_frames()); | 300 EXPECT_EQ(5, renderer_.num_rendered_frames()); |
302 EXPECT_EQ(960, renderer_.width()); | 301 EXPECT_EQ(960, renderer_.width()); |
303 EXPECT_EQ(540, renderer_.height()); | 302 EXPECT_EQ(540, renderer_.height()); |
304 EXPECT_EQ(2, renderer2.num_rendered_frames()); | 303 EXPECT_EQ(2, renderer2.num_rendered_frames()); |
305 EXPECT_EQ(960, renderer2.width()); | 304 EXPECT_EQ(960, renderer2.width()); |
306 EXPECT_EQ(540, renderer2.height()); | 305 EXPECT_EQ(540, renderer2.height()); |
307 | 306 |
308 // Updating with no wants should not affect resolution. | 307 // Updating with no wants should not affect resolution. |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 capturer_->set_enable_camera_list(true); | 777 capturer_->set_enable_camera_list(true); |
779 capturer_->ConstrainSupportedFormats(vga_format); | 778 capturer_->ConstrainSupportedFormats(vga_format); |
780 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); | 779 EXPECT_EQ(2u, capturer_->GetSupportedFormats()->size()); |
781 // To make sure it's not just the camera list being broken, add in VGA and | 780 // To make sure it's not just the camera list being broken, add in VGA and |
782 // try again. This time, only the VGA format should be there. | 781 // try again. This time, only the VGA format should be there. |
783 supported_formats.push_back(vga_format); | 782 supported_formats.push_back(vga_format); |
784 capturer_->ResetSupportedFormats(supported_formats); | 783 capturer_->ResetSupportedFormats(supported_formats); |
785 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); | 784 ASSERT_EQ(1u, capturer_->GetSupportedFormats()->size()); |
786 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); | 785 EXPECT_EQ(vga_format.height, capturer_->GetSupportedFormats()->at(0).height); |
787 } | 786 } |
OLD | NEW |