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