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/system_wrappers/include/sleep.h" | 22 #include "webrtc/system_wrappers/include/sleep.h" |
23 #include "webrtc/test/encoder_settings.h" | 23 #include "webrtc/test/encoder_settings.h" |
24 #include "webrtc/test/fake_encoder.h" | 24 #include "webrtc/test/fake_encoder.h" |
25 #include "webrtc/test/frame_generator.h" | 25 #include "webrtc/test/frame_generator.h" |
26 #include "webrtc/test/gmock.h" | 26 #include "webrtc/test/gmock.h" |
27 #include "webrtc/test/gtest.h" | 27 #include "webrtc/test/gtest.h" |
28 #include "webrtc/video/send_statistics_proxy.h" | 28 #include "webrtc/video/send_statistics_proxy.h" |
29 #include "webrtc/video/video_stream_encoder.h" | 29 #include "webrtc/video/video_stream_encoder.h" |
30 | 30 |
31 namespace { | 31 namespace { |
32 // TODO(kthelgason): Lower this limit when better testing | |
33 // on MediaCodec and fallback implementations are in place. | |
34 const int kMinPixelsPerFrame = 320 * 180; | 32 const int kMinPixelsPerFrame = 320 * 180; |
35 const int kMinFramerateFps = 2; | 33 const int kMinFramerateFps = 2; |
36 const int64_t kFrameTimeoutMs = 100; | 34 const int64_t kFrameTimeoutMs = 100; |
37 } // namespace | 35 } // namespace |
38 | 36 |
39 namespace webrtc { | 37 namespace webrtc { |
40 | 38 |
41 using DegredationPreference = VideoSendStream::DegradationPreference; | 39 using DegredationPreference = VideoSendStream::DegradationPreference; |
42 using ScaleReason = AdaptationObserverInterface::AdaptReason; | 40 using ScaleReason = AdaptationObserverInterface::AdaptReason; |
43 using ::testing::_; | 41 using ::testing::_; |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 } | 464 } |
467 | 465 |
468 void BlockNextEncode() { | 466 void BlockNextEncode() { |
469 rtc::CritScope lock(&local_crit_sect_); | 467 rtc::CritScope lock(&local_crit_sect_); |
470 block_next_encode_ = true; | 468 block_next_encode_ = true; |
471 } | 469 } |
472 | 470 |
473 VideoEncoder::ScalingSettings GetScalingSettings() const override { | 471 VideoEncoder::ScalingSettings GetScalingSettings() const override { |
474 rtc::CritScope lock(&local_crit_sect_); | 472 rtc::CritScope lock(&local_crit_sect_); |
475 if (quality_scaling_) | 473 if (quality_scaling_) |
476 return VideoEncoder::ScalingSettings(true, 1, 2); | 474 return VideoEncoder::ScalingSettings(true, 1, 2, kMinPixelsPerFrame); |
477 return VideoEncoder::ScalingSettings(false); | 475 return VideoEncoder::ScalingSettings(false); |
478 } | 476 } |
479 | 477 |
480 void ContinueEncode() { continue_encode_event_.Set(); } | 478 void ContinueEncode() { continue_encode_event_.Set(); } |
481 | 479 |
482 void CheckLastTimeStampsMatch(int64_t ntp_time_ms, | 480 void CheckLastTimeStampsMatch(int64_t ntp_time_ms, |
483 uint32_t timestamp) const { | 481 uint32_t timestamp) const { |
484 rtc::CritScope lock(&local_crit_sect_); | 482 rtc::CritScope lock(&local_crit_sect_); |
485 EXPECT_EQ(timestamp_, timestamp); | 483 EXPECT_EQ(timestamp_, timestamp); |
486 EXPECT_EQ(ntp_time_ms_, ntp_time_ms); | 484 EXPECT_EQ(ntp_time_ms_, ntp_time_ms); |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 } | 1803 } |
1806 | 1804 |
1807 TEST_F(VideoStreamEncoderTest, DoesNotScaleBelowSetResolutionLimit) { | 1805 TEST_F(VideoStreamEncoderTest, DoesNotScaleBelowSetResolutionLimit) { |
1808 const int kWidth = 1280; | 1806 const int kWidth = 1280; |
1809 const int kHeight = 720; | 1807 const int kHeight = 720; |
1810 const size_t kNumFrames = 10; | 1808 const size_t kNumFrames = 10; |
1811 | 1809 |
1812 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 1810 video_stream_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
1813 | 1811 |
1814 // Enable adapter, expected input resolutions when downscaling: | 1812 // Enable adapter, expected input resolutions when downscaling: |
1815 // 1280x720 -> 960x540 -> 640x360 -> 480x270 -> 320x180 (min resolution limit) | 1813 // 1280x720 -> 960x540 -> 640x360 -> 480x270 -> 320x180 (kMinPixelsPerFrame) |
1816 video_source_.set_adaptation_enabled(true); | 1814 video_source_.set_adaptation_enabled(true); |
1817 | 1815 |
1818 EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); | 1816 EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution); |
1819 EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes); | 1817 EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes); |
1820 | 1818 |
1821 int downscales = 0; | 1819 int downscales = 0; |
1822 for (size_t i = 1; i <= kNumFrames; i++) { | 1820 for (size_t i = 1; i <= kNumFrames; i++) { |
1823 video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight)); | 1821 video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight)); |
1824 WaitForEncodedFrame(i); | 1822 WaitForEncodedFrame(i); |
1825 | 1823 |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3176 // Bitrate observer should not be called. | 3174 // Bitrate observer should not be called. |
3177 EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(0); | 3175 EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(_)).Times(0); |
3178 video_source_.IncomingCapturedFrame( | 3176 video_source_.IncomingCapturedFrame( |
3179 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); | 3177 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); |
3180 ExpectDroppedFrame(); | 3178 ExpectDroppedFrame(); |
3181 | 3179 |
3182 video_stream_encoder_->Stop(); | 3180 video_stream_encoder_->Stop(); |
3183 } | 3181 } |
3184 | 3182 |
3185 } // namespace webrtc | 3183 } // namespace webrtc |
OLD | NEW |