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 |
23 namespace webrtc { | 33 namespace webrtc { |
24 | 34 |
25 using DegredationPreference = VideoSendStream::DegradationPreference; | 35 using DegredationPreference = VideoSendStream::DegradationPreference; |
26 using ScaleReason = ScalingObserverInterface::ScaleReason; | 36 using ScaleReason = ScalingObserverInterface::ScaleReason; |
27 | 37 |
28 namespace { | 38 namespace { |
29 const size_t kMaxPayloadLength = 1440; | 39 const size_t kMaxPayloadLength = 1440; |
30 const int kTargetBitrateBps = 100000; | 40 const int kTargetBitrateBps = 100000; |
31 const unsigned char kNumSlDummy = 0; | 41 const unsigned char kNumSlDummy = 0; |
32 | 42 |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 // Expect nothing to change, still no scaling | 1024 // Expect nothing to change, still no scaling |
1015 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); | 1025 EXPECT_FALSE(new_video_source.sink_wants().max_pixel_count); |
1016 | 1026 |
1017 vie_encoder_->Stop(); | 1027 vie_encoder_->Stop(); |
1018 } | 1028 } |
1019 | 1029 |
1020 TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { | 1030 TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { |
1021 const int kTargetBitrateBps = 100000; | 1031 const int kTargetBitrateBps = 100000; |
1022 int frame_width = 1280; | 1032 int frame_width = 1280; |
1023 int frame_height = 720; | 1033 int frame_height = 720; |
1024 // from vie_encoder.cc | |
1025 const int kMinPixelsPerFrame = 120 * 90; | |
1026 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 1034 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
1027 | 1035 |
1028 for (size_t i = 1; i <= 10; i++) { | 1036 for (size_t i = 1; i <= 10; i++) { |
1029 video_source_.IncomingCapturedFrame( | 1037 video_source_.IncomingCapturedFrame( |
1030 CreateFrame(i, frame_width, frame_height)); | 1038 CreateFrame(i, frame_width, frame_height)); |
1031 sink_.WaitForEncodedFrame(i); | 1039 sink_.WaitForEncodedFrame(i); |
1032 // Trigger scale down | 1040 // Trigger scale down |
1033 vie_encoder_->TriggerQualityLow(); | 1041 vie_encoder_->TriggerQualityLow(); |
1034 EXPECT_GE(*video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame); | 1042 EXPECT_GE(*video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame); |
1035 } | 1043 } |
(...skipping 25 matching lines...) Expand all Loading... |
1061 vie_encoder_->Stop(); | 1069 vie_encoder_->Stop(); |
1062 | 1070 |
1063 stats_proxy_.reset(); | 1071 stats_proxy_.reset(); |
1064 EXPECT_EQ(1, | 1072 EXPECT_EQ(1, |
1065 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); | 1073 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); |
1066 EXPECT_EQ( | 1074 EXPECT_EQ( |
1067 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); | 1075 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); |
1068 } | 1076 } |
1069 | 1077 |
1070 } // namespace webrtc | 1078 } // namespace webrtc |
OLD | NEW |