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 |
11 #include <limits> | 11 #include <limits> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
15 #include "webrtc/system_wrappers/include/metrics_default.h" | 15 #include "webrtc/system_wrappers/include/metrics_default.h" |
16 #include "webrtc/test/encoder_settings.h" | 16 #include "webrtc/test/encoder_settings.h" |
17 #include "webrtc/test/fake_encoder.h" | 17 #include "webrtc/test/fake_encoder.h" |
18 #include "webrtc/test/frame_generator.h" | 18 #include "webrtc/test/frame_generator.h" |
19 #include "webrtc/test/gtest.h" | 19 #include "webrtc/test/gtest.h" |
20 #include "webrtc/video/send_statistics_proxy.h" | 20 #include "webrtc/video/send_statistics_proxy.h" |
21 #include "webrtc/video/vie_encoder.h" | 21 #include "webrtc/video/vie_encoder.h" |
22 | 22 |
23 namespace { | |
24 #if defined(WEBRTC_ANDROID) | |
25 // TODO(kthelgason): Lower this limit when better testing | |
26 // on MediaCodec and fallback implementations are in place. | |
27 const int kMinPixelsPerFrame = 320 * 180; | |
28 #else | |
29 const int kMinPixelsPerFrame = 120 * 90; | |
30 #endif | |
31 } | |
32 | |
33 namespace webrtc { | 23 namespace webrtc { |
34 | 24 |
35 using DegredationPreference = VideoSendStream::DegradationPreference; | 25 using DegredationPreference = VideoSendStream::DegradationPreference; |
36 using ScaleReason = ScalingObserverInterface::ScaleReason; | 26 using ScaleReason = ScalingObserverInterface::ScaleReason; |
37 | 27 |
38 namespace { | 28 namespace { |
39 const size_t kMaxPayloadLength = 1440; | 29 const size_t kMaxPayloadLength = 1440; |
40 const int kTargetBitrateBps = 100000; | 30 const int kTargetBitrateBps = 100000; |
41 const unsigned char kNumSlDummy = 0; | 31 const unsigned char kNumSlDummy = 0; |
42 | 32 |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 // Expect nothing to change, still no scaling | 1014 // Expect nothing to change, still no scaling |
1025 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); | 1015 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); |
1026 | 1016 |
1027 vie_encoder_->Stop(); | 1017 vie_encoder_->Stop(); |
1028 } | 1018 } |
1029 | 1019 |
1030 TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { | 1020 TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { |
1031 const int kTargetBitrateBps = 100000; | 1021 const int kTargetBitrateBps = 100000; |
1032 int frame_width = 1280; | 1022 int frame_width = 1280; |
1033 int frame_height = 720; | 1023 int frame_height = 720; |
| 1024 // from vie_encoder.cc |
| 1025 const int kMinPixelsPerFrame = 120 * 90; |
1034 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 1026 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
1035 | 1027 |
1036 for (size_t i = 1; i <= 10; i++) { | 1028 for (size_t i = 1; i <= 10; i++) { |
1037 video_source_.IncomingCapturedFrame( | 1029 video_source_.IncomingCapturedFrame( |
1038 CreateFrame(i, frame_width, frame_height)); | 1030 CreateFrame(i, frame_width, frame_height)); |
1039 sink_.WaitForEncodedFrame(i); | 1031 sink_.WaitForEncodedFrame(i); |
1040 // Trigger scale down | 1032 // Trigger scale down |
1041 vie_encoder_->TriggerQualityLow(); | 1033 vie_encoder_->TriggerQualityLow(); |
1042 EXPECT_GE(*video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame); | 1034 EXPECT_GE(*video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame); |
1043 } | 1035 } |
(...skipping 25 matching lines...) Expand all Loading... |
1069 vie_encoder_->Stop(); | 1061 vie_encoder_->Stop(); |
1070 | 1062 |
1071 stats_proxy_.reset(); | 1063 stats_proxy_.reset(); |
1072 EXPECT_EQ(1, | 1064 EXPECT_EQ(1, |
1073 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); | 1065 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); |
1074 EXPECT_EQ( | 1066 EXPECT_EQ( |
1075 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); | 1067 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); |
1076 } | 1068 } |
1077 | 1069 |
1078 } // namespace webrtc | 1070 } // namespace webrtc |
OLD | NEW |