OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 11 matching lines...) Expand all Loading... |
22 #include "webrtc/test/frame_generator.h" | 22 #include "webrtc/test/frame_generator.h" |
23 #include "webrtc/test/gmock.h" | 23 #include "webrtc/test/gmock.h" |
24 #include "webrtc/test/gtest.h" | 24 #include "webrtc/test/gtest.h" |
25 #include "webrtc/video/send_statistics_proxy.h" | 25 #include "webrtc/video/send_statistics_proxy.h" |
26 #include "webrtc/video/vie_encoder.h" | 26 #include "webrtc/video/vie_encoder.h" |
27 | 27 |
28 namespace { | 28 namespace { |
29 #if defined(WEBRTC_ANDROID) | 29 #if defined(WEBRTC_ANDROID) |
30 // TODO(kthelgason): Lower this limit when better testing | 30 // TODO(kthelgason): Lower this limit when better testing |
31 // on MediaCodec and fallback implementations are in place. | 31 // on MediaCodec and fallback implementations are in place. |
32 const int kMinPixelsPerFrame = 320 * 180; | 32 const uint32_t kMinPixelsPerFrame = 320 * 180; |
33 #else | 33 #else |
34 const int kMinPixelsPerFrame = 120 * 90; | 34 const uint32_t kMinPixelsPerFrame = 120 * 90; |
35 #endif | 35 #endif |
36 } | 36 } |
37 | 37 |
38 namespace webrtc { | 38 namespace webrtc { |
39 | 39 |
40 using DegredationPreference = VideoSendStream::DegradationPreference; | 40 using DegredationPreference = VideoSendStream::DegradationPreference; |
41 using ScaleReason = AdaptationObserverInterface::AdaptReason; | 41 using ScaleReason = AdaptationObserverInterface::AdaptReason; |
42 using ::testing::_; | 42 using ::testing::_; |
43 using ::testing::Return; | 43 using ::testing::Return; |
44 | 44 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 adapted_frame.set_ntp_time_ms(video_frame.ntp_time_ms()); | 144 adapted_frame.set_ntp_time_ms(video_frame.ntp_time_ms()); |
145 test::FrameForwarder::IncomingCapturedFrame(adapted_frame); | 145 test::FrameForwarder::IncomingCapturedFrame(adapted_frame); |
146 } else { | 146 } else { |
147 test::FrameForwarder::IncomingCapturedFrame(video_frame); | 147 test::FrameForwarder::IncomingCapturedFrame(video_frame); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, | 151 void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, |
152 const rtc::VideoSinkWants& wants) override { | 152 const rtc::VideoSinkWants& wants) override { |
153 rtc::CritScope cs(&crit_); | 153 rtc::CritScope cs(&crit_); |
154 adapter_.OnResolutionRequest(wants.target_pixel_count, | 154 adapter_.OnSinkWantsUpdated(wants); |
155 wants.max_pixel_count); | |
156 test::FrameForwarder::AddOrUpdateSink(sink, wants); | 155 test::FrameForwarder::AddOrUpdateSink(sink, wants); |
157 } | 156 } |
158 | 157 |
159 cricket::VideoAdapter adapter_; | 158 cricket::VideoAdapter adapter_; |
160 bool adaptation_enabled_ GUARDED_BY(crit_); | 159 bool adaptation_enabled_ GUARDED_BY(crit_); |
161 }; | 160 }; |
162 } // namespace | 161 } // namespace |
163 | 162 |
164 class ViEEncoderTest : public ::testing::Test { | 163 class ViEEncoderTest : public ::testing::Test { |
165 public: | 164 public: |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 TEST_F(ViEEncoderTest, SinkWantsRotationApplied) { | 613 TEST_F(ViEEncoderTest, SinkWantsRotationApplied) { |
615 EXPECT_FALSE(video_source_.sink_wants().rotation_applied); | 614 EXPECT_FALSE(video_source_.sink_wants().rotation_applied); |
616 vie_encoder_->SetSink(&sink_, true /*rotation_applied*/); | 615 vie_encoder_->SetSink(&sink_, true /*rotation_applied*/); |
617 EXPECT_TRUE(video_source_.sink_wants().rotation_applied); | 616 EXPECT_TRUE(video_source_.sink_wants().rotation_applied); |
618 vie_encoder_->Stop(); | 617 vie_encoder_->Stop(); |
619 } | 618 } |
620 | 619 |
621 TEST_F(ViEEncoderTest, SinkWantsFromOveruseDetector) { | 620 TEST_F(ViEEncoderTest, SinkWantsFromOveruseDetector) { |
622 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 621 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
623 | 622 |
624 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); | 623 EXPECT_FALSE(video_source_.sink_wants().pixel_count); |
625 EXPECT_FALSE(video_source_.sink_wants().max_pixel_count); | |
626 | 624 |
627 int frame_width = 1280; | 625 int frame_width = 1280; |
628 int frame_height = 720; | 626 int frame_height = 720; |
629 | 627 |
630 // Trigger CPU overuse kMaxCpuDowngrades times. Every time, ViEEncoder should | 628 // Trigger CPU overuse kMaxCpuDowngrades times. Every time, ViEEncoder should |
631 // request lower resolution. | 629 // request lower resolution. |
632 for (int i = 1; i <= ViEEncoder::kMaxCpuDowngrades; ++i) { | 630 for (int i = 1; i <= ViEEncoder::kMaxCpuDowngrades; ++i) { |
633 video_source_.IncomingCapturedFrame( | 631 video_source_.IncomingCapturedFrame( |
634 CreateFrame(i, frame_width, frame_height)); | 632 CreateFrame(i, frame_width, frame_height)); |
635 sink_.WaitForEncodedFrame(i); | 633 sink_.WaitForEncodedFrame(i); |
636 | 634 |
637 vie_encoder_->TriggerCpuOveruse(); | 635 vie_encoder_->TriggerCpuOveruse(); |
638 | 636 |
639 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); | 637 ASSERT_TRUE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
640 EXPECT_LT(video_source_.sink_wants().max_pixel_count.value_or( | 638 EXPECT_LT(video_source_.sink_wants().pixel_count->max, |
641 std::numeric_limits<int>::max()), | 639 static_cast<uint32_t>(frame_width * frame_height)); |
642 frame_width * frame_height); | |
643 | 640 |
644 frame_width /= 2; | 641 frame_width /= 2; |
645 frame_height /= 2; | 642 frame_height /= 2; |
646 } | 643 } |
647 | 644 |
648 // Trigger CPU overuse one more time. This should not trigger a request for | 645 // Trigger CPU overuse one more time. This should not trigger a request for |
649 // lower resolution. | 646 // lower resolution. |
650 rtc::VideoSinkWants current_wants = video_source_.sink_wants(); | 647 rtc::VideoSinkWants current_wants = video_source_.sink_wants(); |
651 video_source_.IncomingCapturedFrame(CreateFrame( | 648 video_source_.IncomingCapturedFrame(CreateFrame( |
652 ViEEncoder::kMaxCpuDowngrades + 1, frame_width, frame_height)); | 649 ViEEncoder::kMaxCpuDowngrades + 1, frame_width, frame_height)); |
653 sink_.WaitForEncodedFrame(ViEEncoder::kMaxCpuDowngrades + 1); | 650 sink_.WaitForEncodedFrame(ViEEncoder::kMaxCpuDowngrades + 1); |
654 vie_encoder_->TriggerCpuOveruse(); | 651 vie_encoder_->TriggerCpuOveruse(); |
655 EXPECT_EQ(video_source_.sink_wants().target_pixel_count, | 652 ASSERT_TRUE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
656 current_wants.target_pixel_count); | 653 ASSERT_TRUE(static_cast<bool>(current_wants.pixel_count)); |
657 EXPECT_EQ(video_source_.sink_wants().max_pixel_count, | 654 EXPECT_EQ(video_source_.sink_wants().pixel_count->min, |
658 current_wants.max_pixel_count); | 655 current_wants.pixel_count->min); |
| 656 EXPECT_EQ(video_source_.sink_wants().pixel_count->target, |
| 657 current_wants.pixel_count->target); |
| 658 EXPECT_EQ(video_source_.sink_wants().pixel_count->max, |
| 659 current_wants.pixel_count->max); |
659 | 660 |
660 // Trigger CPU normal use. | 661 // Trigger CPU normal use. |
661 vie_encoder_->TriggerCpuNormalUsage(); | 662 vie_encoder_->TriggerCpuNormalUsage(); |
662 EXPECT_EQ(frame_width * frame_height * 5 / 3, | 663 EXPECT_GT(video_source_.sink_wants().pixel_count->min, 0U); |
663 video_source_.sink_wants().target_pixel_count.value_or(0)); | 664 EXPECT_LE(video_source_.sink_wants().pixel_count->min, |
664 EXPECT_EQ(frame_width * frame_height * 4, | 665 video_source_.sink_wants().pixel_count->target); |
665 video_source_.sink_wants().max_pixel_count.value_or(0)); | 666 EXPECT_EQ(static_cast<uint32_t>(frame_width * frame_height * 5 / 3), |
| 667 video_source_.sink_wants().pixel_count->target); |
| 668 EXPECT_EQ(static_cast<uint32_t>(frame_width * frame_height * 4), |
| 669 video_source_.sink_wants().pixel_count->max); |
666 | 670 |
667 vie_encoder_->Stop(); | 671 vie_encoder_->Stop(); |
668 } | 672 } |
669 | 673 |
670 TEST_F(ViEEncoderTest, | 674 TEST_F(ViEEncoderTest, |
671 ResolutionSinkWantsResetOnSetSourceWithDisabledResolutionScaling) { | 675 ResolutionSinkWantsResetOnSetSourceWithDisabledResolutionScaling) { |
672 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 676 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
673 | 677 |
674 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); | 678 EXPECT_FALSE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
675 EXPECT_FALSE(video_source_.sink_wants().max_pixel_count); | |
676 | 679 |
677 int frame_width = 1280; | 680 int frame_width = 1280; |
678 int frame_height = 720; | 681 int frame_height = 720; |
679 | 682 |
680 video_source_.IncomingCapturedFrame( | 683 video_source_.IncomingCapturedFrame( |
681 CreateFrame(1, frame_width, frame_height)); | 684 CreateFrame(1, frame_width, frame_height)); |
682 sink_.WaitForEncodedFrame(1); | 685 sink_.WaitForEncodedFrame(1); |
683 // Trigger CPU overuse. | 686 // Trigger CPU overuse. |
684 vie_encoder_->TriggerCpuOveruse(); | 687 vie_encoder_->TriggerCpuOveruse(); |
685 | 688 |
686 video_source_.IncomingCapturedFrame( | 689 video_source_.IncomingCapturedFrame( |
687 CreateFrame(2, frame_width, frame_height)); | 690 CreateFrame(2, frame_width, frame_height)); |
688 sink_.WaitForEncodedFrame(2); | 691 sink_.WaitForEncodedFrame(2); |
689 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); | 692 ASSERT_TRUE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
690 EXPECT_LT(video_source_.sink_wants().max_pixel_count.value_or( | 693 EXPECT_LT(video_source_.sink_wants().pixel_count->max, |
691 std::numeric_limits<int>::max()), | 694 static_cast<uint32_t>(frame_width * frame_height)); |
692 frame_width * frame_height); | |
693 | 695 |
694 // Set new source. | 696 // Set new source. |
695 test::FrameForwarder new_video_source; | 697 test::FrameForwarder new_video_source; |
696 vie_encoder_->SetSource( | 698 vie_encoder_->SetSource( |
697 &new_video_source, | 699 &new_video_source, |
698 VideoSendStream::DegradationPreference::kMaintainResolution); | 700 VideoSendStream::DegradationPreference::kMaintainResolution); |
699 | 701 |
700 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count); | 702 EXPECT_FALSE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
701 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); | |
702 | 703 |
703 new_video_source.IncomingCapturedFrame( | 704 new_video_source.IncomingCapturedFrame( |
704 CreateFrame(3, frame_width, frame_height)); | 705 CreateFrame(3, frame_width, frame_height)); |
705 sink_.WaitForEncodedFrame(3); | 706 sink_.WaitForEncodedFrame(3); |
706 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count); | 707 EXPECT_FALSE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
707 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); | |
708 | 708 |
709 // Calling SetSource with resolution scaling enabled apply the old SinkWants. | 709 // Calling SetSource with resolution scaling enabled apply the old SinkWants. |
710 vie_encoder_->SetSource(&new_video_source, | 710 vie_encoder_->SetSource(&new_video_source, |
711 VideoSendStream::DegradationPreference::kBalanced); | 711 VideoSendStream::DegradationPreference::kBalanced); |
712 EXPECT_LT(new_video_source.sink_wants().max_pixel_count.value_or( | 712 ASSERT_TRUE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
713 std::numeric_limits<int>::max()), | 713 EXPECT_LT(video_source_.sink_wants().pixel_count->max, |
714 frame_width * frame_height); | 714 static_cast<uint32_t>(frame_width * frame_height)); |
715 EXPECT_FALSE(new_video_source.sink_wants().target_pixel_count); | |
716 | 715 |
717 vie_encoder_->Stop(); | 716 vie_encoder_->Stop(); |
718 } | 717 } |
719 | 718 |
720 TEST_F(ViEEncoderTest, StatsTracksAdaptationStats) { | 719 TEST_F(ViEEncoderTest, StatsTracksAdaptationStats) { |
721 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 720 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
722 | 721 |
723 int frame_width = 1280; | 722 int frame_width = 1280; |
724 int frame_height = 720; | 723 int frame_height = 720; |
725 | 724 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 stats.preferred_media_bitrate_bps); | 963 stats.preferred_media_bitrate_bps); |
965 | 964 |
966 vie_encoder_->Stop(); | 965 vie_encoder_->Stop(); |
967 } | 966 } |
968 | 967 |
969 TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) { | 968 TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) { |
970 int frame_width = 1280; | 969 int frame_width = 1280; |
971 int frame_height = 720; | 970 int frame_height = 720; |
972 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 971 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
973 | 972 |
974 // Expect no scaling to begin with | 973 // Expect no scaling to begin with. |
975 EXPECT_FALSE(video_source_.sink_wants().target_pixel_count); | 974 EXPECT_FALSE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
976 EXPECT_FALSE(video_source_.sink_wants().max_pixel_count); | |
977 | 975 |
978 video_source_.IncomingCapturedFrame( | 976 video_source_.IncomingCapturedFrame( |
979 CreateFrame(1, frame_width, frame_height)); | 977 CreateFrame(1, frame_width, frame_height)); |
980 sink_.WaitForEncodedFrame(1); | 978 sink_.WaitForEncodedFrame(1); |
981 | 979 |
982 // Trigger scale down | 980 // Trigger scale down. |
983 vie_encoder_->TriggerQualityLow(); | 981 vie_encoder_->TriggerQualityLow(); |
984 | 982 |
985 video_source_.IncomingCapturedFrame( | 983 video_source_.IncomingCapturedFrame( |
986 CreateFrame(2, frame_width, frame_height)); | 984 CreateFrame(2, frame_width, frame_height)); |
987 sink_.WaitForEncodedFrame(2); | 985 sink_.WaitForEncodedFrame(2); |
988 | 986 |
989 // Expect a scale down. | 987 // Expect a scale down. |
990 EXPECT_TRUE(video_source_.sink_wants().max_pixel_count); | 988 ASSERT_TRUE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
991 EXPECT_LT(*video_source_.sink_wants().max_pixel_count, | 989 EXPECT_LT(video_source_.sink_wants().pixel_count->max, |
992 frame_width * frame_height); | 990 static_cast<uint32_t>(frame_width * frame_height)); |
993 | 991 |
994 // Set adaptation disabled. | 992 // Set adaptation disabled. |
995 test::FrameForwarder new_video_source; | 993 test::FrameForwarder new_video_source; |
996 vie_encoder_->SetSource( | 994 vie_encoder_->SetSource( |
997 &new_video_source, | 995 &new_video_source, |
998 VideoSendStream::DegradationPreference::kMaintainResolution); | 996 VideoSendStream::DegradationPreference::kMaintainResolution); |
999 | 997 |
1000 // Trigger scale down | 998 // Trigger scale down. |
1001 vie_encoder_->TriggerQualityLow(); | 999 vie_encoder_->TriggerQualityLow(); |
1002 new_video_source.IncomingCapturedFrame( | 1000 new_video_source.IncomingCapturedFrame( |
1003 CreateFrame(3, frame_width, frame_height)); | 1001 CreateFrame(3, frame_width, frame_height)); |
1004 sink_.WaitForEncodedFrame(3); | 1002 sink_.WaitForEncodedFrame(3); |
1005 | 1003 |
1006 // Expect no scaling | 1004 // Expect no scaling. |
1007 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); | 1005 EXPECT_FALSE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
1008 | 1006 |
1009 // Trigger scale up | 1007 // Trigger scale up. |
1010 vie_encoder_->TriggerQualityHigh(); | 1008 vie_encoder_->TriggerQualityHigh(); |
1011 new_video_source.IncomingCapturedFrame( | 1009 new_video_source.IncomingCapturedFrame( |
1012 CreateFrame(4, frame_width, frame_height)); | 1010 CreateFrame(4, frame_width, frame_height)); |
1013 sink_.WaitForEncodedFrame(4); | 1011 sink_.WaitForEncodedFrame(4); |
1014 | 1012 |
1015 // Expect nothing to change, still no scaling | 1013 // Expect nothing to change, still no scaling. |
1016 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); | 1014 EXPECT_FALSE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
1017 | 1015 |
1018 vie_encoder_->Stop(); | 1016 vie_encoder_->Stop(); |
1019 } | 1017 } |
1020 | 1018 |
1021 TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { | 1019 TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { |
1022 int frame_width = 1280; | 1020 int frame_width = 1280; |
1023 int frame_height = 720; | 1021 int frame_height = 720; |
1024 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 1022 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
1025 | 1023 |
1026 for (size_t i = 1; i <= 10; i++) { | 1024 for (size_t i = 1; i <= 10; i++) { |
1027 video_source_.IncomingCapturedFrame( | 1025 video_source_.IncomingCapturedFrame( |
1028 CreateFrame(i, frame_width, frame_height)); | 1026 CreateFrame(i, frame_width, frame_height)); |
1029 sink_.WaitForEncodedFrame(i); | 1027 sink_.WaitForEncodedFrame(i); |
1030 // Trigger scale down | 1028 // Trigger scale down |
1031 vie_encoder_->TriggerQualityLow(); | 1029 vie_encoder_->TriggerQualityLow(); |
1032 EXPECT_GE(*video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame); | 1030 ASSERT_TRUE(video_source_.sink_wants().pixel_count); |
| 1031 EXPECT_GE(video_source_.sink_wants().pixel_count->min, kMinPixelsPerFrame); |
| 1032 EXPECT_GE(video_source_.sink_wants().pixel_count->max, kMinPixelsPerFrame); |
1033 } | 1033 } |
1034 | 1034 |
1035 vie_encoder_->Stop(); | 1035 vie_encoder_->Stop(); |
1036 } | 1036 } |
1037 | 1037 |
1038 TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { | 1038 TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { |
1039 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 1039 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
1040 | 1040 |
1041 int frame_width = 640; | 1041 int frame_width = 640; |
1042 int frame_height = 360; | 1042 int frame_height = 360; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 int frame_width = 640; | 1114 int frame_width = 640; |
1115 int frame_height = 360; | 1115 int frame_height = 360; |
1116 | 1116 |
1117 video_source_.IncomingCapturedFrame( | 1117 video_source_.IncomingCapturedFrame( |
1118 CreateFrame(1, frame_width, frame_height)); | 1118 CreateFrame(1, frame_width, frame_height)); |
1119 | 1119 |
1120 // Expect to drop this frame, the wait should time out. | 1120 // Expect to drop this frame, the wait should time out. |
1121 sink_.ExpectDroppedFrame(); | 1121 sink_.ExpectDroppedFrame(); |
1122 | 1122 |
1123 // Expect the sink_wants to specify a scaled frame. | 1123 // Expect the sink_wants to specify a scaled frame. |
1124 EXPECT_TRUE(video_source_.sink_wants().max_pixel_count); | 1124 ASSERT_TRUE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
1125 EXPECT_LT(*video_source_.sink_wants().max_pixel_count, 1000 * 1000); | 1125 EXPECT_LT(video_source_.sink_wants().pixel_count->max, |
| 1126 static_cast<uint32_t>(1000 * 1000)); |
1126 | 1127 |
1127 int last_pixel_count = *video_source_.sink_wants().max_pixel_count; | 1128 int last_pixel_count = video_source_.sink_wants().pixel_count->max; |
1128 | 1129 |
1129 // Next frame is scaled | 1130 // Next frame is scaled. |
1130 video_source_.IncomingCapturedFrame( | 1131 video_source_.IncomingCapturedFrame( |
1131 CreateFrame(2, frame_width * 3 / 4, frame_height * 3 / 4)); | 1132 CreateFrame(2, frame_width * 3 / 4, frame_height * 3 / 4)); |
1132 | 1133 |
1133 // Expect to drop this frame, the wait should time out. | 1134 // Expect to drop this frame, the wait should time out. |
1134 sink_.ExpectDroppedFrame(); | 1135 sink_.ExpectDroppedFrame(); |
1135 | 1136 |
1136 EXPECT_LT(*video_source_.sink_wants().max_pixel_count, last_pixel_count); | 1137 EXPECT_LT(video_source_.sink_wants().pixel_count->max, |
| 1138 static_cast<uint32_t>(last_pixel_count)); |
1137 | 1139 |
1138 vie_encoder_->Stop(); | 1140 vie_encoder_->Stop(); |
1139 } | 1141 } |
1140 | 1142 |
1141 TEST_F(ViEEncoderTest, NrOfDroppedFramesLimited) { | 1143 TEST_F(ViEEncoderTest, NrOfDroppedFramesLimited) { |
1142 // 1kbps. This can never be achieved. | 1144 // 1kbps. This can never be achieved. |
1143 vie_encoder_->OnBitrateUpdated(1000, 0, 0); | 1145 vie_encoder_->OnBitrateUpdated(1000, 0, 0); |
1144 int frame_width = 640; | 1146 int frame_width = 640; |
1145 int frame_height = 360; | 1147 int frame_height = 360; |
1146 | 1148 |
1147 // We expect the n initial frames to get dropped. | 1149 // We expect the n initial frames to get dropped. |
1148 int i; | 1150 int i; |
1149 for (i = 1; i <= kMaxInitialFramedrop; ++i) { | 1151 for (i = 1; i <= kMaxInitialFramedrop; ++i) { |
1150 video_source_.IncomingCapturedFrame( | 1152 video_source_.IncomingCapturedFrame( |
1151 CreateFrame(i, frame_width, frame_height)); | 1153 CreateFrame(i, frame_width, frame_height)); |
1152 sink_.ExpectDroppedFrame(); | 1154 sink_.ExpectDroppedFrame(); |
1153 } | 1155 } |
1154 // The n+1th frame should not be dropped, even though it's size is too large. | 1156 // The n+1th frame should not be dropped, even though it's size is too large. |
1155 video_source_.IncomingCapturedFrame( | 1157 video_source_.IncomingCapturedFrame( |
1156 CreateFrame(i, frame_width, frame_height)); | 1158 CreateFrame(i, frame_width, frame_height)); |
1157 sink_.WaitForEncodedFrame(i); | 1159 sink_.WaitForEncodedFrame(i); |
1158 | 1160 |
1159 // Expect the sink_wants to specify a scaled frame. | 1161 // Expect the sink_wants to specify a scaled frame. |
1160 EXPECT_TRUE(video_source_.sink_wants().max_pixel_count); | 1162 ASSERT_TRUE(static_cast<bool>(video_source_.sink_wants().pixel_count)); |
1161 EXPECT_LT(*video_source_.sink_wants().max_pixel_count, 1000 * 1000); | 1163 EXPECT_LT(video_source_.sink_wants().pixel_count->max, |
| 1164 static_cast<uint32_t>(1000 * 1000)); |
1162 | 1165 |
1163 vie_encoder_->Stop(); | 1166 vie_encoder_->Stop(); |
1164 } | 1167 } |
1165 | 1168 |
1166 TEST_F(ViEEncoderTest, InitialFrameDropOffWithMaintainResolutionPreference) { | 1169 TEST_F(ViEEncoderTest, InitialFrameDropOffWithMaintainResolutionPreference) { |
1167 int frame_width = 640; | 1170 int frame_width = 640; |
1168 int frame_height = 360; | 1171 int frame_height = 360; |
1169 vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0); | 1172 vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0); |
1170 | 1173 |
1171 // Set degradation preference. | 1174 // Set degradation preference. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 | 1224 |
1222 // Trigger CPU normal use, return to original resoluton; | 1225 // Trigger CPU normal use, return to original resoluton; |
1223 vie_encoder_->TriggerCpuNormalUsage(); | 1226 vie_encoder_->TriggerCpuNormalUsage(); |
1224 video_source_.IncomingCapturedFrame( | 1227 video_source_.IncomingCapturedFrame( |
1225 CreateFrame(3, kFrameWidth, kFrameHeight)); | 1228 CreateFrame(3, kFrameWidth, kFrameHeight)); |
1226 sink_.WaitForEncodedFrame(kFrameWidth, kFrameHeight); | 1229 sink_.WaitForEncodedFrame(kFrameWidth, kFrameHeight); |
1227 | 1230 |
1228 vie_encoder_->Stop(); | 1231 vie_encoder_->Stop(); |
1229 } | 1232 } |
1230 } // namespace webrtc | 1233 } // namespace webrtc |
OLD | NEW |