OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 |
11 #include <limits.h> // For INT_MAX | 11 #include <limits.h> // For INT_MAX |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/base/gunit.h" | 17 #include "webrtc/base/gunit.h" |
18 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
19 #include "webrtc/media/base/fakevideocapturer.h" | 19 #include "webrtc/media/base/fakevideocapturer.h" |
20 #include "webrtc/media/base/mediachannel.h" | 20 #include "webrtc/media/base/mediachannel.h" |
21 #include "webrtc/media/base/testutils.h" | 21 #include "webrtc/media/base/testutils.h" |
22 #include "webrtc/media/base/videoadapter.h" | 22 #include "webrtc/media/base/videoadapter.h" |
23 | 23 |
24 namespace cricket { | 24 namespace cricket { |
| 25 namespace { |
| 26 const int kDefaultFps = 30; |
| 27 } // namespace |
25 | 28 |
26 class VideoAdapterTest : public testing::Test { | 29 class VideoAdapterTest : public testing::Test { |
27 public: | 30 public: |
28 virtual void SetUp() { | 31 virtual void SetUp() { |
29 capturer_.reset(new FakeVideoCapturer); | 32 capturer_.reset(new FakeVideoCapturer); |
30 capture_format_ = capturer_->GetSupportedFormats()->at(0); | 33 capture_format_ = capturer_->GetSupportedFormats()->at(0); |
31 capture_format_.interval = VideoFormat::FpsToInterval(30); | 34 capture_format_.interval = VideoFormat::FpsToInterval(kDefaultFps); |
32 | 35 |
33 listener_.reset(new VideoCapturerListener(&adapter_)); | 36 listener_.reset(new VideoCapturerListener(&adapter_)); |
34 capturer_->AddOrUpdateSink(listener_.get(), rtc::VideoSinkWants()); | 37 capturer_->AddOrUpdateSink(listener_.get(), rtc::VideoSinkWants()); |
35 } | 38 } |
36 | 39 |
37 virtual void TearDown() { | 40 virtual void TearDown() { |
38 // Explicitly disconnect the VideoCapturer before to avoid data races | 41 // Explicitly disconnect the VideoCapturer before to avoid data races |
39 // (frames delivered to VideoCapturerListener while it's being destructed). | 42 // (frames delivered to VideoCapturerListener while it's being destructed). |
40 capturer_->RemoveSink(listener_.get()); | 43 capturer_->RemoveSink(listener_.get()); |
41 } | 44 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 capturer_->CaptureFrame(); | 286 capturer_->CaptureFrame(); |
284 | 287 |
285 // Verify no frame drop. | 288 // Verify no frame drop. |
286 EXPECT_EQ(0, listener_->GetStats().dropped_frames); | 289 EXPECT_EQ(0, listener_->GetStats().dropped_frames); |
287 } | 290 } |
288 | 291 |
289 // After the first timestamp, add a big offset to the timestamps. Expect that | 292 // After the first timestamp, add a big offset to the timestamps. Expect that |
290 // the adapter is conservative and resets to the new offset and does not drop | 293 // the adapter is conservative and resets to the new offset and does not drop |
291 // any frame. | 294 // any frame. |
292 TEST_F(VideoAdapterTest, AdaptFramerateTimestampOffset) { | 295 TEST_F(VideoAdapterTest, AdaptFramerateTimestampOffset) { |
293 const int64_t capture_interval = VideoFormat::FpsToInterval(30); | 296 const int64_t capture_interval = VideoFormat::FpsToInterval(kDefaultFps); |
294 adapter_.OnOutputFormatRequest( | 297 adapter_.OnOutputFormatRequest( |
295 VideoFormat(640, 480, capture_interval, cricket::FOURCC_ANY)); | 298 VideoFormat(640, 480, capture_interval, cricket::FOURCC_ANY)); |
296 | 299 |
297 const int64_t first_timestamp = 0; | 300 const int64_t first_timestamp = 0; |
298 adapter_.AdaptFrameResolution(640, 480, first_timestamp, | 301 adapter_.AdaptFrameResolution(640, 480, first_timestamp, |
299 &cropped_width_, &cropped_height_, | 302 &cropped_width_, &cropped_height_, |
300 &out_width_, &out_height_); | 303 &out_width_, &out_height_); |
301 EXPECT_GT(out_width_, 0); | 304 EXPECT_GT(out_width_, 0); |
302 EXPECT_GT(out_height_, 0); | 305 EXPECT_GT(out_height_, 0); |
303 | 306 |
304 const int64_t big_offset = -987654321LL * 1000; | 307 const int64_t big_offset = -987654321LL * 1000; |
305 const int64_t second_timestamp = big_offset; | 308 const int64_t second_timestamp = big_offset; |
306 adapter_.AdaptFrameResolution(640, 480, second_timestamp, | 309 adapter_.AdaptFrameResolution(640, 480, second_timestamp, |
307 &cropped_width_, &cropped_height_, | 310 &cropped_width_, &cropped_height_, |
308 &out_width_, &out_height_); | 311 &out_width_, &out_height_); |
309 EXPECT_GT(out_width_, 0); | 312 EXPECT_GT(out_width_, 0); |
310 EXPECT_GT(out_height_, 0); | 313 EXPECT_GT(out_height_, 0); |
311 | 314 |
312 const int64_t third_timestamp = big_offset + capture_interval; | 315 const int64_t third_timestamp = big_offset + capture_interval; |
313 adapter_.AdaptFrameResolution(640, 480, third_timestamp, | 316 adapter_.AdaptFrameResolution(640, 480, third_timestamp, |
314 &cropped_width_, &cropped_height_, | 317 &cropped_width_, &cropped_height_, |
315 &out_width_, &out_height_); | 318 &out_width_, &out_height_); |
316 EXPECT_GT(out_width_, 0); | 319 EXPECT_GT(out_width_, 0); |
317 EXPECT_GT(out_height_, 0); | 320 EXPECT_GT(out_height_, 0); |
318 } | 321 } |
319 | 322 |
320 // Request 30 fps and send 30 fps with jitter. Expect that no frame is dropped. | 323 // Request 30 fps and send 30 fps with jitter. Expect that no frame is dropped. |
321 TEST_F(VideoAdapterTest, AdaptFramerateTimestampJitter) { | 324 TEST_F(VideoAdapterTest, AdaptFramerateTimestampJitter) { |
322 const int64_t capture_interval = VideoFormat::FpsToInterval(30); | 325 const int64_t capture_interval = VideoFormat::FpsToInterval(kDefaultFps); |
323 adapter_.OnOutputFormatRequest( | 326 adapter_.OnOutputFormatRequest( |
324 VideoFormat(640, 480, capture_interval, cricket::FOURCC_ANY)); | 327 VideoFormat(640, 480, capture_interval, cricket::FOURCC_ANY)); |
325 | 328 |
326 adapter_.AdaptFrameResolution(640, 480, capture_interval * 0 / 10, | 329 adapter_.AdaptFrameResolution(640, 480, capture_interval * 0 / 10, |
327 &cropped_width_, &cropped_height_, | 330 &cropped_width_, &cropped_height_, |
328 &out_width_, &out_height_); | 331 &out_width_, &out_height_); |
329 EXPECT_GT(out_width_, 0); | 332 EXPECT_GT(out_width_, 0); |
330 EXPECT_GT(out_height_, 0); | 333 EXPECT_GT(out_height_, 0); |
331 | 334 |
332 adapter_.AdaptFrameResolution(640, 480, capture_interval * 10 / 10 - 1, | 335 adapter_.AdaptFrameResolution(640, 480, capture_interval * 10 / 10 - 1, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 request_format.interval *= 2; | 380 request_format.interval *= 2; |
378 adapter_.OnOutputFormatRequest(request_format); | 381 adapter_.OnOutputFormatRequest(request_format); |
379 | 382 |
380 for (int i = 0; i < 20; ++i) | 383 for (int i = 0; i < 20; ++i) |
381 capturer_->CaptureFrame(); | 384 capturer_->CaptureFrame(); |
382 | 385 |
383 // Verify frame drop after adaptation. | 386 // Verify frame drop after adaptation. |
384 EXPECT_GT(listener_->GetStats().dropped_frames, 0); | 387 EXPECT_GT(listener_->GetStats().dropped_frames, 0); |
385 } | 388 } |
386 | 389 |
| 390 // Do not adapt the frame rate or the resolution. Expect no frame drop, no |
| 391 // cropping, and no resolution change. |
| 392 TEST_F(VideoAdapterTest, OnFramerateRequestMax) { |
| 393 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), |
| 394 std::numeric_limits<int>::max(), |
| 395 std::numeric_limits<int>::max()); |
| 396 |
| 397 EXPECT_EQ(CS_RUNNING, capturer_->Start(capture_format_)); |
| 398 for (int i = 0; i < 10; ++i) |
| 399 capturer_->CaptureFrame(); |
| 400 |
| 401 // Verify no frame drop and no resolution change. |
| 402 VideoCapturerListener::Stats stats = listener_->GetStats(); |
| 403 EXPECT_GE(stats.captured_frames, 10); |
| 404 EXPECT_EQ(0, stats.dropped_frames); |
| 405 VerifyAdaptedResolution(stats, capture_format_.width, capture_format_.height, |
| 406 capture_format_.width, capture_format_.height); |
| 407 EXPECT_TRUE(stats.last_adapt_was_no_op); |
| 408 } |
| 409 |
| 410 TEST_F(VideoAdapterTest, OnFramerateRequestZero) { |
| 411 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), |
| 412 std::numeric_limits<int>::max(), 0); |
| 413 EXPECT_EQ(CS_RUNNING, capturer_->Start(capture_format_)); |
| 414 for (int i = 0; i < 10; ++i) |
| 415 capturer_->CaptureFrame(); |
| 416 |
| 417 // Verify no crash and that frames aren't dropped. |
| 418 VideoCapturerListener::Stats stats = listener_->GetStats(); |
| 419 EXPECT_GE(stats.captured_frames, 10); |
| 420 EXPECT_EQ(10, stats.dropped_frames); |
| 421 } |
| 422 |
| 423 // Adapt the frame rate to be half of the capture rate at the beginning. Expect |
| 424 // the number of dropped frames to be half of the number the captured frames. |
| 425 TEST_F(VideoAdapterTest, OnFramerateRequestHalf) { |
| 426 adapter_.OnResolutionFramerateRequest( |
| 427 rtc::Optional<int>(), std::numeric_limits<int>::max(), kDefaultFps / 2); |
| 428 EXPECT_EQ(CS_RUNNING, capturer_->Start(capture_format_)); |
| 429 for (int i = 0; i < 10; ++i) |
| 430 capturer_->CaptureFrame(); |
| 431 |
| 432 // Verify no crash and that frames aren't dropped. |
| 433 VideoCapturerListener::Stats stats = listener_->GetStats(); |
| 434 EXPECT_GE(stats.captured_frames, 10); |
| 435 EXPECT_EQ(5, stats.dropped_frames); |
| 436 VerifyAdaptedResolution(stats, capture_format_.width, capture_format_.height, |
| 437 capture_format_.width, capture_format_.height); |
| 438 } |
| 439 |
387 // Set a very high output pixel resolution. Expect no cropping or resolution | 440 // Set a very high output pixel resolution. Expect no cropping or resolution |
388 // change. | 441 // change. |
389 TEST_F(VideoAdapterTest, AdaptFrameResolutionHighLimit) { | 442 TEST_F(VideoAdapterTest, AdaptFrameResolutionHighLimit) { |
390 VideoFormat output_format = capture_format_; | 443 VideoFormat output_format = capture_format_; |
391 output_format.width *= 10; | 444 output_format.width *= 10; |
392 output_format.height *= 10; | 445 output_format.height *= 10; |
393 adapter_.OnOutputFormatRequest(output_format); | 446 adapter_.OnOutputFormatRequest(output_format); |
394 EXPECT_TRUE(adapter_.AdaptFrameResolution( | 447 EXPECT_TRUE(adapter_.AdaptFrameResolution( |
395 capture_format_.width, capture_format_.height, 0, | 448 capture_format_.width, capture_format_.height, 0, |
396 &cropped_width_, &cropped_height_, | 449 &cropped_width_, &cropped_height_, |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 TEST_F(VideoAdapterTest, TestOnResolutionRequestInSmallSteps) { | 742 TEST_F(VideoAdapterTest, TestOnResolutionRequestInSmallSteps) { |
690 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 743 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
691 &cropped_width_, &cropped_height_, | 744 &cropped_width_, &cropped_height_, |
692 &out_width_, &out_height_)); | 745 &out_width_, &out_height_)); |
693 EXPECT_EQ(1280, cropped_width_); | 746 EXPECT_EQ(1280, cropped_width_); |
694 EXPECT_EQ(720, cropped_height_); | 747 EXPECT_EQ(720, cropped_height_); |
695 EXPECT_EQ(1280, out_width_); | 748 EXPECT_EQ(1280, out_width_); |
696 EXPECT_EQ(720, out_height_); | 749 EXPECT_EQ(720, out_height_); |
697 | 750 |
698 // Adapt down one step. | 751 // Adapt down one step. |
699 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 752 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 1280 * 720 - 1, |
700 rtc::Optional<int>(1280 * 720 - 1)); | 753 std::numeric_limits<int>::max()); |
701 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 754 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
702 &cropped_width_, &cropped_height_, | 755 &cropped_width_, &cropped_height_, |
703 &out_width_, &out_height_)); | 756 &out_width_, &out_height_)); |
704 EXPECT_EQ(1280, cropped_width_); | 757 EXPECT_EQ(1280, cropped_width_); |
705 EXPECT_EQ(720, cropped_height_); | 758 EXPECT_EQ(720, cropped_height_); |
706 EXPECT_EQ(960, out_width_); | 759 EXPECT_EQ(960, out_width_); |
707 EXPECT_EQ(540, out_height_); | 760 EXPECT_EQ(540, out_height_); |
708 | 761 |
709 // Adapt down one step more. | 762 // Adapt down one step more. |
710 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 763 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 960 * 540 - 1, |
711 rtc::Optional<int>(960 * 540 - 1)); | 764 std::numeric_limits<int>::max()); |
712 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 765 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
713 &cropped_width_, &cropped_height_, | 766 &cropped_width_, &cropped_height_, |
714 &out_width_, &out_height_)); | 767 &out_width_, &out_height_)); |
715 EXPECT_EQ(1280, cropped_width_); | 768 EXPECT_EQ(1280, cropped_width_); |
716 EXPECT_EQ(720, cropped_height_); | 769 EXPECT_EQ(720, cropped_height_); |
717 EXPECT_EQ(640, out_width_); | 770 EXPECT_EQ(640, out_width_); |
718 EXPECT_EQ(360, out_height_); | 771 EXPECT_EQ(360, out_height_); |
719 | 772 |
720 // Adapt down one step more. | 773 // Adapt down one step more. |
721 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 774 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 640 * 360 - 1, |
722 rtc::Optional<int>(640 * 360 - 1)); | 775 std::numeric_limits<int>::max()); |
723 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 776 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
724 &cropped_width_, &cropped_height_, | 777 &cropped_width_, &cropped_height_, |
725 &out_width_, &out_height_)); | 778 &out_width_, &out_height_)); |
726 EXPECT_EQ(1280, cropped_width_); | 779 EXPECT_EQ(1280, cropped_width_); |
727 EXPECT_EQ(720, cropped_height_); | 780 EXPECT_EQ(720, cropped_height_); |
728 EXPECT_EQ(480, out_width_); | 781 EXPECT_EQ(480, out_width_); |
729 EXPECT_EQ(270, out_height_); | 782 EXPECT_EQ(270, out_height_); |
730 | 783 |
731 // Adapt up one step. | 784 // Adapt up one step. |
732 adapter_.OnResolutionRequest(rtc::Optional<int>(640 * 360), | 785 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(640 * 360), |
733 rtc::Optional<int>(960 * 540)); | 786 960 * 540, |
| 787 std::numeric_limits<int>::max()); |
734 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 788 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
735 &cropped_width_, &cropped_height_, | 789 &cropped_width_, &cropped_height_, |
736 &out_width_, &out_height_)); | 790 &out_width_, &out_height_)); |
737 EXPECT_EQ(1280, cropped_width_); | 791 EXPECT_EQ(1280, cropped_width_); |
738 EXPECT_EQ(720, cropped_height_); | 792 EXPECT_EQ(720, cropped_height_); |
739 EXPECT_EQ(640, out_width_); | 793 EXPECT_EQ(640, out_width_); |
740 EXPECT_EQ(360, out_height_); | 794 EXPECT_EQ(360, out_height_); |
741 | 795 |
742 // Adapt up one step more. | 796 // Adapt up one step more. |
743 adapter_.OnResolutionRequest(rtc::Optional<int>(960 * 540), | 797 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(960 * 540), |
744 rtc::Optional<int>(1280 * 720)); | 798 1280 * 720, |
| 799 std::numeric_limits<int>::max()); |
745 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 800 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
746 &cropped_width_, &cropped_height_, | 801 &cropped_width_, &cropped_height_, |
747 &out_width_, &out_height_)); | 802 &out_width_, &out_height_)); |
748 EXPECT_EQ(1280, cropped_width_); | 803 EXPECT_EQ(1280, cropped_width_); |
749 EXPECT_EQ(720, cropped_height_); | 804 EXPECT_EQ(720, cropped_height_); |
750 EXPECT_EQ(960, out_width_); | 805 EXPECT_EQ(960, out_width_); |
751 EXPECT_EQ(540, out_height_); | 806 EXPECT_EQ(540, out_height_); |
752 | 807 |
753 // Adapt up one step more. | 808 // Adapt up one step more. |
754 adapter_.OnResolutionRequest(rtc::Optional<int>(1280 * 720), | 809 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(1280 * 720), |
755 rtc::Optional<int>(1920 * 1080)); | 810 1920 * 1080, |
| 811 std::numeric_limits<int>::max()); |
756 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 812 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
757 &cropped_width_, &cropped_height_, | 813 &cropped_width_, &cropped_height_, |
758 &out_width_, &out_height_)); | 814 &out_width_, &out_height_)); |
759 EXPECT_EQ(1280, cropped_width_); | 815 EXPECT_EQ(1280, cropped_width_); |
760 EXPECT_EQ(720, cropped_height_); | 816 EXPECT_EQ(720, cropped_height_); |
761 EXPECT_EQ(1280, out_width_); | 817 EXPECT_EQ(1280, out_width_); |
762 EXPECT_EQ(720, out_height_); | 818 EXPECT_EQ(720, out_height_); |
763 } | 819 } |
764 | 820 |
765 TEST_F(VideoAdapterTest, TestOnResolutionRequestMaxZero) { | 821 TEST_F(VideoAdapterTest, TestOnResolutionRequestMaxZero) { |
766 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 822 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
767 &cropped_width_, &cropped_height_, | 823 &cropped_width_, &cropped_height_, |
768 &out_width_, &out_height_)); | 824 &out_width_, &out_height_)); |
769 EXPECT_EQ(1280, cropped_width_); | 825 EXPECT_EQ(1280, cropped_width_); |
770 EXPECT_EQ(720, cropped_height_); | 826 EXPECT_EQ(720, cropped_height_); |
771 EXPECT_EQ(1280, out_width_); | 827 EXPECT_EQ(1280, out_width_); |
772 EXPECT_EQ(720, out_height_); | 828 EXPECT_EQ(720, out_height_); |
773 | 829 |
774 adapter_.OnResolutionRequest(rtc::Optional<int>(), rtc::Optional<int>(0)); | 830 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 0, |
| 831 std::numeric_limits<int>::max()); |
775 EXPECT_FALSE(adapter_.AdaptFrameResolution(1280, 720, 0, | 832 EXPECT_FALSE(adapter_.AdaptFrameResolution(1280, 720, 0, |
776 &cropped_width_, &cropped_height_, | 833 &cropped_width_, &cropped_height_, |
777 &out_width_, &out_height_)); | 834 &out_width_, &out_height_)); |
778 } | 835 } |
779 | 836 |
780 TEST_F(VideoAdapterTest, TestOnResolutionRequestInLargeSteps) { | 837 TEST_F(VideoAdapterTest, TestOnResolutionRequestInLargeSteps) { |
781 // Large step down. | 838 // Large step down. |
782 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 839 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 640 * 360 - 1, |
783 rtc::Optional<int>(640 * 360 - 1)); | 840 std::numeric_limits<int>::max()); |
784 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 841 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
785 &cropped_width_, &cropped_height_, | 842 &cropped_width_, &cropped_height_, |
786 &out_width_, &out_height_)); | 843 &out_width_, &out_height_)); |
787 EXPECT_EQ(1280, cropped_width_); | 844 EXPECT_EQ(1280, cropped_width_); |
788 EXPECT_EQ(720, cropped_height_); | 845 EXPECT_EQ(720, cropped_height_); |
789 EXPECT_EQ(480, out_width_); | 846 EXPECT_EQ(480, out_width_); |
790 EXPECT_EQ(270, out_height_); | 847 EXPECT_EQ(270, out_height_); |
791 | 848 |
792 // Large step up. | 849 // Large step up. |
793 adapter_.OnResolutionRequest(rtc::Optional<int>(1280 * 720), | 850 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(1280 * 720), |
794 rtc::Optional<int>(1920 * 1080)); | 851 1920 * 1080, |
| 852 std::numeric_limits<int>::max()); |
795 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 853 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
796 &cropped_width_, &cropped_height_, | 854 &cropped_width_, &cropped_height_, |
797 &out_width_, &out_height_)); | 855 &out_width_, &out_height_)); |
798 EXPECT_EQ(1280, cropped_width_); | 856 EXPECT_EQ(1280, cropped_width_); |
799 EXPECT_EQ(720, cropped_height_); | 857 EXPECT_EQ(720, cropped_height_); |
800 EXPECT_EQ(1280, out_width_); | 858 EXPECT_EQ(1280, out_width_); |
801 EXPECT_EQ(720, out_height_); | 859 EXPECT_EQ(720, out_height_); |
802 } | 860 } |
803 | 861 |
804 TEST_F(VideoAdapterTest, TestOnOutputFormatRequestCapsMaxResolution) { | 862 TEST_F(VideoAdapterTest, TestOnOutputFormatRequestCapsMaxResolution) { |
805 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 863 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 640 * 360 - 1, |
806 rtc::Optional<int>(640 * 360 - 1)); | 864 std::numeric_limits<int>::max()); |
807 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 865 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
808 &cropped_width_, &cropped_height_, | 866 &cropped_width_, &cropped_height_, |
809 &out_width_, &out_height_)); | 867 &out_width_, &out_height_)); |
810 EXPECT_EQ(1280, cropped_width_); | 868 EXPECT_EQ(1280, cropped_width_); |
811 EXPECT_EQ(720, cropped_height_); | 869 EXPECT_EQ(720, cropped_height_); |
812 EXPECT_EQ(480, out_width_); | 870 EXPECT_EQ(480, out_width_); |
813 EXPECT_EQ(270, out_height_); | 871 EXPECT_EQ(270, out_height_); |
814 | 872 |
815 VideoFormat new_format(640, 360, 0, FOURCC_I420); | 873 VideoFormat new_format(640, 360, 0, FOURCC_I420); |
816 adapter_.OnOutputFormatRequest(new_format); | 874 adapter_.OnOutputFormatRequest(new_format); |
817 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 875 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
818 &cropped_width_, &cropped_height_, | 876 &cropped_width_, &cropped_height_, |
819 &out_width_, &out_height_)); | 877 &out_width_, &out_height_)); |
820 EXPECT_EQ(1280, cropped_width_); | 878 EXPECT_EQ(1280, cropped_width_); |
821 EXPECT_EQ(720, cropped_height_); | 879 EXPECT_EQ(720, cropped_height_); |
822 EXPECT_EQ(480, out_width_); | 880 EXPECT_EQ(480, out_width_); |
823 EXPECT_EQ(270, out_height_); | 881 EXPECT_EQ(270, out_height_); |
824 | 882 |
825 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 883 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 960 * 720, |
826 rtc::Optional<int>(960 * 720)); | 884 std::numeric_limits<int>::max()); |
827 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 885 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
828 &cropped_width_, &cropped_height_, | 886 &cropped_width_, &cropped_height_, |
829 &out_width_, &out_height_)); | 887 &out_width_, &out_height_)); |
830 EXPECT_EQ(1280, cropped_width_); | 888 EXPECT_EQ(1280, cropped_width_); |
831 EXPECT_EQ(720, cropped_height_); | 889 EXPECT_EQ(720, cropped_height_); |
832 EXPECT_EQ(640, out_width_); | 890 EXPECT_EQ(640, out_width_); |
833 EXPECT_EQ(360, out_height_); | 891 EXPECT_EQ(360, out_height_); |
834 } | 892 } |
835 | 893 |
836 TEST_F(VideoAdapterTest, TestOnResolutionRequestReset) { | 894 TEST_F(VideoAdapterTest, TestOnResolutionRequestReset) { |
837 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 895 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
838 &cropped_width_, &cropped_height_, | 896 &cropped_width_, &cropped_height_, |
839 &out_width_, &out_height_)); | 897 &out_width_, &out_height_)); |
840 EXPECT_EQ(1280, cropped_width_); | 898 EXPECT_EQ(1280, cropped_width_); |
841 EXPECT_EQ(720, cropped_height_); | 899 EXPECT_EQ(720, cropped_height_); |
842 EXPECT_EQ(1280, out_width_); | 900 EXPECT_EQ(1280, out_width_); |
843 EXPECT_EQ(720, out_height_); | 901 EXPECT_EQ(720, out_height_); |
844 | 902 |
845 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 903 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 640 * 360 - 1, |
846 rtc::Optional<int>(640 * 360 - 1)); | 904 std::numeric_limits<int>::max()); |
847 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 905 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
848 &cropped_width_, &cropped_height_, | 906 &cropped_width_, &cropped_height_, |
849 &out_width_, &out_height_)); | 907 &out_width_, &out_height_)); |
850 EXPECT_EQ(1280, cropped_width_); | 908 EXPECT_EQ(1280, cropped_width_); |
851 EXPECT_EQ(720, cropped_height_); | 909 EXPECT_EQ(720, cropped_height_); |
852 EXPECT_EQ(480, out_width_); | 910 EXPECT_EQ(480, out_width_); |
853 EXPECT_EQ(270, out_height_); | 911 EXPECT_EQ(270, out_height_); |
854 | 912 |
855 adapter_.OnResolutionRequest(rtc::Optional<int>(), rtc::Optional<int>()); | 913 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), |
| 914 std::numeric_limits<int>::max(), |
| 915 std::numeric_limits<int>::max()); |
856 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, | 916 EXPECT_TRUE(adapter_.AdaptFrameResolution(1280, 720, 0, |
857 &cropped_width_, &cropped_height_, | 917 &cropped_width_, &cropped_height_, |
858 &out_width_, &out_height_)); | 918 &out_width_, &out_height_)); |
859 EXPECT_EQ(1280, cropped_width_); | 919 EXPECT_EQ(1280, cropped_width_); |
860 EXPECT_EQ(720, cropped_height_); | 920 EXPECT_EQ(720, cropped_height_); |
861 EXPECT_EQ(1280, out_width_); | 921 EXPECT_EQ(1280, out_width_); |
862 EXPECT_EQ(720, out_height_); | 922 EXPECT_EQ(720, out_height_); |
863 } | 923 } |
864 | 924 |
865 TEST_F(VideoAdapterTest, TestCroppingWithResolutionRequest) { | 925 TEST_F(VideoAdapterTest, TestCroppingWithResolutionRequest) { |
866 // Ask for 640x360 (16:9 aspect). | 926 // Ask for 640x360 (16:9 aspect). |
867 adapter_.OnOutputFormatRequest(VideoFormat(640, 360, 0, FOURCC_I420)); | 927 adapter_.OnOutputFormatRequest(VideoFormat(640, 360, 0, FOURCC_I420)); |
868 // Send 640x480 (4:3 aspect). | 928 // Send 640x480 (4:3 aspect). |
869 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, | 929 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, |
870 &cropped_width_, &cropped_height_, | 930 &cropped_width_, &cropped_height_, |
871 &out_width_, &out_height_)); | 931 &out_width_, &out_height_)); |
872 // Expect cropping to 16:9 format and no scaling. | 932 // Expect cropping to 16:9 format and no scaling. |
873 EXPECT_EQ(640, cropped_width_); | 933 EXPECT_EQ(640, cropped_width_); |
874 EXPECT_EQ(360, cropped_height_); | 934 EXPECT_EQ(360, cropped_height_); |
875 EXPECT_EQ(640, out_width_); | 935 EXPECT_EQ(640, out_width_); |
876 EXPECT_EQ(360, out_height_); | 936 EXPECT_EQ(360, out_height_); |
877 | 937 |
878 // Adapt down one step. | 938 // Adapt down one step. |
879 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 939 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 640 * 360 - 1, |
880 rtc::Optional<int>(640 * 360 - 1)); | 940 std::numeric_limits<int>::max()); |
881 // Expect cropping to 16:9 format and 3/4 scaling. | 941 // Expect cropping to 16:9 format and 3/4 scaling. |
882 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, | 942 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, |
883 &cropped_width_, &cropped_height_, | 943 &cropped_width_, &cropped_height_, |
884 &out_width_, &out_height_)); | 944 &out_width_, &out_height_)); |
885 EXPECT_EQ(640, cropped_width_); | 945 EXPECT_EQ(640, cropped_width_); |
886 EXPECT_EQ(360, cropped_height_); | 946 EXPECT_EQ(360, cropped_height_); |
887 EXPECT_EQ(480, out_width_); | 947 EXPECT_EQ(480, out_width_); |
888 EXPECT_EQ(270, out_height_); | 948 EXPECT_EQ(270, out_height_); |
889 | 949 |
890 // Adapt down one step more. | 950 // Adapt down one step more. |
891 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 951 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 480 * 270 - 1, |
892 rtc::Optional<int>(480 * 270 - 1)); | 952 std::numeric_limits<int>::max()); |
893 // Expect cropping to 16:9 format and 1/2 scaling. | 953 // Expect cropping to 16:9 format and 1/2 scaling. |
894 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, | 954 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, |
895 &cropped_width_, &cropped_height_, | 955 &cropped_width_, &cropped_height_, |
896 &out_width_, &out_height_)); | 956 &out_width_, &out_height_)); |
897 EXPECT_EQ(640, cropped_width_); | 957 EXPECT_EQ(640, cropped_width_); |
898 EXPECT_EQ(360, cropped_height_); | 958 EXPECT_EQ(360, cropped_height_); |
899 EXPECT_EQ(320, out_width_); | 959 EXPECT_EQ(320, out_width_); |
900 EXPECT_EQ(180, out_height_); | 960 EXPECT_EQ(180, out_height_); |
901 | 961 |
902 // Adapt up one step. | 962 // Adapt up one step. |
903 adapter_.OnResolutionRequest(rtc::Optional<int>(480 * 270), | 963 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(480 * 270), |
904 rtc::Optional<int>(640 * 360)); | 964 640 * 360, |
| 965 std::numeric_limits<int>::max()); |
905 // Expect cropping to 16:9 format and 3/4 scaling. | 966 // Expect cropping to 16:9 format and 3/4 scaling. |
906 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, | 967 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, |
907 &cropped_width_, &cropped_height_, | 968 &cropped_width_, &cropped_height_, |
908 &out_width_, &out_height_)); | 969 &out_width_, &out_height_)); |
909 EXPECT_EQ(640, cropped_width_); | 970 EXPECT_EQ(640, cropped_width_); |
910 EXPECT_EQ(360, cropped_height_); | 971 EXPECT_EQ(360, cropped_height_); |
911 EXPECT_EQ(480, out_width_); | 972 EXPECT_EQ(480, out_width_); |
912 EXPECT_EQ(270, out_height_); | 973 EXPECT_EQ(270, out_height_); |
913 | 974 |
914 // Adapt up one step more. | 975 // Adapt up one step more. |
915 adapter_.OnResolutionRequest(rtc::Optional<int>(640 * 360), | 976 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(640 * 360), |
916 rtc::Optional<int>(960 * 540)); | 977 960 * 540, |
| 978 std::numeric_limits<int>::max()); |
917 // Expect cropping to 16:9 format and no scaling. | 979 // Expect cropping to 16:9 format and no scaling. |
918 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, | 980 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, |
919 &cropped_width_, &cropped_height_, | 981 &cropped_width_, &cropped_height_, |
920 &out_width_, &out_height_)); | 982 &out_width_, &out_height_)); |
921 EXPECT_EQ(640, cropped_width_); | 983 EXPECT_EQ(640, cropped_width_); |
922 EXPECT_EQ(360, cropped_height_); | 984 EXPECT_EQ(360, cropped_height_); |
923 EXPECT_EQ(640, out_width_); | 985 EXPECT_EQ(640, out_width_); |
924 EXPECT_EQ(360, out_height_); | 986 EXPECT_EQ(360, out_height_); |
925 | 987 |
926 // Try to adapt up one step more. | 988 // Try to adapt up one step more. |
927 adapter_.OnResolutionRequest(rtc::Optional<int>(960 * 540), | 989 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(960 * 540), |
928 rtc::Optional<int>(1280 * 720)); | 990 1280 * 720, |
| 991 std::numeric_limits<int>::max()); |
929 // Expect cropping to 16:9 format and no scaling. | 992 // Expect cropping to 16:9 format and no scaling. |
930 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, | 993 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, |
931 &cropped_width_, &cropped_height_, | 994 &cropped_width_, &cropped_height_, |
932 &out_width_, &out_height_)); | 995 &out_width_, &out_height_)); |
933 EXPECT_EQ(640, cropped_width_); | 996 EXPECT_EQ(640, cropped_width_); |
934 EXPECT_EQ(360, cropped_height_); | 997 EXPECT_EQ(360, cropped_height_); |
935 EXPECT_EQ(640, out_width_); | 998 EXPECT_EQ(640, out_width_); |
936 EXPECT_EQ(360, out_height_); | 999 EXPECT_EQ(360, out_height_); |
937 } | 1000 } |
938 | 1001 |
939 TEST_F(VideoAdapterTest, TestCroppingOddResolution) { | 1002 TEST_F(VideoAdapterTest, TestCroppingOddResolution) { |
940 // Ask for 640x360 (16:9 aspect), with 3/16 scaling. | 1003 // Ask for 640x360 (16:9 aspect), with 3/16 scaling. |
941 adapter_.OnOutputFormatRequest( | 1004 adapter_.OnOutputFormatRequest( |
942 VideoFormat(640, 360, 0, FOURCC_I420)); | 1005 VideoFormat(640, 360, 0, FOURCC_I420)); |
943 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 1006 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), |
944 rtc::Optional<int>(640 * 360 * 3 / 16 * 3 / 16)); | 1007 640 * 360 * 3 / 16 * 3 / 16, |
| 1008 std::numeric_limits<int>::max()); |
945 | 1009 |
946 // Send 640x480 (4:3 aspect). | 1010 // Send 640x480 (4:3 aspect). |
947 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, | 1011 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 480, 0, |
948 &cropped_width_, &cropped_height_, | 1012 &cropped_width_, &cropped_height_, |
949 &out_width_, &out_height_)); | 1013 &out_width_, &out_height_)); |
950 | 1014 |
951 // Instead of getting the exact aspect ratio with cropped resolution 640x360, | 1015 // Instead of getting the exact aspect ratio with cropped resolution 640x360, |
952 // the resolution should be adjusted to get a perfect scale factor instead. | 1016 // the resolution should be adjusted to get a perfect scale factor instead. |
953 EXPECT_EQ(640, cropped_width_); | 1017 EXPECT_EQ(640, cropped_width_); |
954 EXPECT_EQ(368, cropped_height_); | 1018 EXPECT_EQ(368, cropped_height_); |
955 EXPECT_EQ(120, out_width_); | 1019 EXPECT_EQ(120, out_width_); |
956 EXPECT_EQ(69, out_height_); | 1020 EXPECT_EQ(69, out_height_); |
957 } | 1021 } |
958 | 1022 |
959 TEST_F(VideoAdapterTest, TestAdaptToVerySmallResolution) { | 1023 TEST_F(VideoAdapterTest, TestAdaptToVerySmallResolution) { |
960 // Ask for 1920x1080 (16:9 aspect), with 1/16 scaling. | 1024 // Ask for 1920x1080 (16:9 aspect), with 1/16 scaling. |
961 const int w = 1920; | 1025 const int w = 1920; |
962 const int h = 1080; | 1026 const int h = 1080; |
963 adapter_.OnOutputFormatRequest(VideoFormat(w, h, 0, FOURCC_I420)); | 1027 adapter_.OnOutputFormatRequest(VideoFormat(w, h, 0, FOURCC_I420)); |
964 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 1028 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), |
965 rtc::Optional<int>(w * h * 1 / 16 * 1 / 16)); | 1029 w * h * 1 / 16 * 1 / 16, |
| 1030 std::numeric_limits<int>::max()); |
966 | 1031 |
967 // Send 1920x1080 (16:9 aspect). | 1032 // Send 1920x1080 (16:9 aspect). |
968 EXPECT_TRUE(adapter_.AdaptFrameResolution( | 1033 EXPECT_TRUE(adapter_.AdaptFrameResolution( |
969 w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); | 1034 w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); |
970 | 1035 |
971 // Instead of getting the exact aspect ratio with cropped resolution 1920x1080 | 1036 // Instead of getting the exact aspect ratio with cropped resolution 1920x1080 |
972 // the resolution should be adjusted to get a perfect scale factor instead. | 1037 // the resolution should be adjusted to get a perfect scale factor instead. |
973 EXPECT_EQ(1920, cropped_width_); | 1038 EXPECT_EQ(1920, cropped_width_); |
974 EXPECT_EQ(1072, cropped_height_); | 1039 EXPECT_EQ(1072, cropped_height_); |
975 EXPECT_EQ(120, out_width_); | 1040 EXPECT_EQ(120, out_width_); |
976 EXPECT_EQ(67, out_height_); | 1041 EXPECT_EQ(67, out_height_); |
977 | 1042 |
978 // Adapt back up one step to 3/32. | 1043 // Adapt back up one step to 3/32. |
979 adapter_.OnResolutionRequest(rtc::Optional<int>(w * h * 3 / 32 * 3 / 32), | 1044 adapter_.OnResolutionFramerateRequest( |
980 rtc::Optional<int>(w * h * 1 / 8 * 1 / 8)); | 1045 rtc::Optional<int>(w * h * 3 / 32 * 3 / 32), w * h * 1 / 8 * 1 / 8, |
| 1046 std::numeric_limits<int>::max()); |
981 | 1047 |
982 // Send 1920x1080 (16:9 aspect). | 1048 // Send 1920x1080 (16:9 aspect). |
983 EXPECT_TRUE(adapter_.AdaptFrameResolution( | 1049 EXPECT_TRUE(adapter_.AdaptFrameResolution( |
984 w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); | 1050 w, h, 0, &cropped_width_, &cropped_height_, &out_width_, &out_height_)); |
985 | 1051 |
986 EXPECT_EQ(180, out_width_); | 1052 EXPECT_EQ(180, out_width_); |
987 EXPECT_EQ(99, out_height_); | 1053 EXPECT_EQ(99, out_height_); |
988 } | 1054 } |
989 | 1055 |
990 TEST_F(VideoAdapterTest, AdaptFrameResolutionDropWithResolutionRequest) { | 1056 TEST_F(VideoAdapterTest, AdaptFrameResolutionDropWithResolutionRequest) { |
991 VideoFormat output_format = capture_format_; | 1057 VideoFormat output_format = capture_format_; |
992 output_format.width = 0; | 1058 output_format.width = 0; |
993 output_format.height = 0; | 1059 output_format.height = 0; |
994 adapter_.OnOutputFormatRequest(output_format); | 1060 adapter_.OnOutputFormatRequest(output_format); |
995 EXPECT_FALSE(adapter_.AdaptFrameResolution( | 1061 EXPECT_FALSE(adapter_.AdaptFrameResolution( |
996 capture_format_.width, capture_format_.height, 0, | 1062 capture_format_.width, capture_format_.height, 0, |
997 &cropped_width_, &cropped_height_, | 1063 &cropped_width_, &cropped_height_, |
998 &out_width_, &out_height_)); | 1064 &out_width_, &out_height_)); |
999 | 1065 |
1000 adapter_.OnResolutionRequest(rtc::Optional<int>(960 * 540), | 1066 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(960 * 540), |
1001 rtc::Optional<int>()); | 1067 std::numeric_limits<int>::max(), |
| 1068 std::numeric_limits<int>::max()); |
1002 | 1069 |
1003 // Still expect all frames to be dropped | 1070 // Still expect all frames to be dropped |
1004 EXPECT_FALSE(adapter_.AdaptFrameResolution( | 1071 EXPECT_FALSE(adapter_.AdaptFrameResolution( |
1005 capture_format_.width, capture_format_.height, 0, | 1072 capture_format_.width, capture_format_.height, 0, |
1006 &cropped_width_, &cropped_height_, | 1073 &cropped_width_, &cropped_height_, |
1007 &out_width_, &out_height_)); | 1074 &out_width_, &out_height_)); |
1008 | 1075 |
1009 adapter_.OnResolutionRequest(rtc::Optional<int>(), | 1076 adapter_.OnResolutionFramerateRequest(rtc::Optional<int>(), 640 * 480 - 1, |
1010 rtc::Optional<int>(640 * 480 - 1)); | 1077 std::numeric_limits<int>::max()); |
1011 | 1078 |
1012 // Still expect all frames to be dropped | 1079 // Still expect all frames to be dropped |
1013 EXPECT_FALSE(adapter_.AdaptFrameResolution( | 1080 EXPECT_FALSE(adapter_.AdaptFrameResolution( |
1014 capture_format_.width, capture_format_.height, 0, | 1081 capture_format_.width, capture_format_.height, 0, |
1015 &cropped_width_, &cropped_height_, | 1082 &cropped_width_, &cropped_height_, |
1016 &out_width_, &out_height_)); | 1083 &out_width_, &out_height_)); |
1017 } | 1084 } |
1018 | 1085 |
1019 // Test that we will adapt to max given a target pixel count close to max. | 1086 // Test that we will adapt to max given a target pixel count close to max. |
1020 TEST_F(VideoAdapterTest, TestAdaptToMax) { | 1087 TEST_F(VideoAdapterTest, TestAdaptToMax) { |
1021 adapter_.OnOutputFormatRequest(VideoFormat(640, 360, 0, FOURCC_I420)); | 1088 adapter_.OnOutputFormatRequest(VideoFormat(640, 360, 0, FOURCC_I420)); |
1022 adapter_.OnResolutionRequest(rtc::Optional<int>(640 * 360 - 1) /* target */, | 1089 adapter_.OnResolutionFramerateRequest( |
1023 rtc::Optional<int>()); | 1090 rtc::Optional<int>(640 * 360 - 1) /* target */, |
| 1091 std::numeric_limits<int>::max(), std::numeric_limits<int>::max()); |
1024 | 1092 |
1025 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 360, 0, &cropped_width_, | 1093 EXPECT_TRUE(adapter_.AdaptFrameResolution(640, 360, 0, &cropped_width_, |
1026 &cropped_height_, &out_width_, | 1094 &cropped_height_, &out_width_, |
1027 &out_height_)); | 1095 &out_height_)); |
1028 EXPECT_EQ(640, out_width_); | 1096 EXPECT_EQ(640, out_width_); |
1029 EXPECT_EQ(360, out_height_); | 1097 EXPECT_EQ(360, out_height_); |
1030 } | 1098 } |
1031 | |
1032 } // namespace cricket | 1099 } // namespace cricket |
OLD | NEW |