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