Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "rtc_base/experiments/balanced_degradation_settings.h" |
| 12 | |
| 13 | #include <limits> |
| 14 | |
| 15 | #include "rtc_base/gunit.h" |
| 16 | #include "test/field_trial.h" |
| 17 | #include "test/gmock.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | namespace { |
| 21 | |
| 22 | void VerifyIsDefault( |
| 23 | const std::vector<BalancedDegradationSettings::Config>& config) { |
Åsa Persson | 48284b8 | 2019-07-08 10:01:12 +0200 | [diff] [blame] | 24 | EXPECT_THAT( |
| 25 | config, |
| 26 | ::testing::ElementsAre( |
| 27 | BalancedDegradationSettings::Config{ |
| 28 | 320 * 240, 7, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, |
| 29 | BalancedDegradationSettings::Config{ |
| 30 | 480 * 270, 10, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, |
| 31 | BalancedDegradationSettings::Config{ |
| 32 | 640 * 480, 15, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}})); |
Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 33 | } |
| 34 | } // namespace |
| 35 | |
| 36 | TEST(BalancedDegradationSettings, GetsDefaultConfigIfNoList) { |
| 37 | webrtc::test::ScopedFieldTrials field_trials(""); |
| 38 | BalancedDegradationSettings settings; |
| 39 | VerifyIsDefault(settings.GetConfigs()); |
Åsa Persson | 1231419 | 2019-06-20 15:45:07 +0200 | [diff] [blame] | 40 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP8, 1)); |
| 41 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP9, 1)); |
| 42 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecH264, 1)); |
| 43 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecGeneric, 1)); |
| 44 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecMultiplex, 1)); |
Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | TEST(BalancedDegradationSettings, GetsConfig) { |
| 48 | webrtc::test::ScopedFieldTrials field_trials( |
| 49 | "WebRTC-Video-BalancedDegradationSettings/" |
Åsa Persson | 1231419 | 2019-06-20 15:45:07 +0200 | [diff] [blame] | 50 | "pixels:11|22|33,fps:5|15|25,other:4|5|6/"); |
Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 51 | BalancedDegradationSettings settings; |
Åsa Persson | 1231419 | 2019-06-20 15:45:07 +0200 | [diff] [blame] | 52 | EXPECT_THAT(settings.GetConfigs(), |
| 53 | ::testing::ElementsAre( |
| 54 | BalancedDegradationSettings::Config{ |
Åsa Persson | 48284b8 | 2019-07-08 10:01:12 +0200 | [diff] [blame] | 55 | 11, 5, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, |
Åsa Persson | 1231419 | 2019-06-20 15:45:07 +0200 | [diff] [blame] | 56 | BalancedDegradationSettings::Config{ |
Åsa Persson | 48284b8 | 2019-07-08 10:01:12 +0200 | [diff] [blame] | 57 | 22, 15, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, |
Åsa Persson | 1231419 | 2019-06-20 15:45:07 +0200 | [diff] [blame] | 58 | BalancedDegradationSettings::Config{ |
Åsa Persson | 48284b8 | 2019-07-08 10:01:12 +0200 | [diff] [blame] | 59 | 33, 25, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}})); |
Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroFpsValue) { |
| 63 | webrtc::test::ScopedFieldTrials field_trials( |
| 64 | "WebRTC-Video-BalancedDegradationSettings/" |
| 65 | "pixels:1000|2000|3000,fps:0|15|25/"); |
| 66 | BalancedDegradationSettings settings; |
| 67 | VerifyIsDefault(settings.GetConfigs()); |
| 68 | } |
| 69 | |
| 70 | TEST(BalancedDegradationSettings, GetsDefaultConfigIfPixelsDecreases) { |
| 71 | webrtc::test::ScopedFieldTrials field_trials( |
| 72 | "WebRTC-Video-BalancedDegradationSettings/" |
| 73 | "pixels:1000|999|3000,fps:5|15|25/"); |
| 74 | BalancedDegradationSettings settings; |
| 75 | VerifyIsDefault(settings.GetConfigs()); |
| 76 | } |
| 77 | |
| 78 | TEST(BalancedDegradationSettings, GetsDefaultConfigIfFramerateDecreases) { |
| 79 | webrtc::test::ScopedFieldTrials field_trials( |
| 80 | "WebRTC-Video-BalancedDegradationSettings/" |
| 81 | "pixels:1000|2000|3000,fps:5|4|25/"); |
| 82 | BalancedDegradationSettings settings; |
| 83 | VerifyIsDefault(settings.GetConfigs()); |
| 84 | } |
| 85 | |
Åsa Persson | 48284b8 | 2019-07-08 10:01:12 +0200 | [diff] [blame] | 86 | TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { |
| 87 | webrtc::test::ScopedFieldTrials field_trials( |
| 88 | "WebRTC-Video-BalancedDegradationSettings/" |
| 89 | "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|8|9,vp9_fps:9|10|11," |
| 90 | "h264_fps:11|12|13,generic_fps:13|14|15/"); |
| 91 | BalancedDegradationSettings settings; |
| 92 | EXPECT_THAT( |
| 93 | settings.GetConfigs(), |
| 94 | ::testing::ElementsAre( |
| 95 | BalancedDegradationSettings::Config{ |
| 96 | 1000, 5, {0, 0, 7}, {0, 0, 9}, {0, 0, 11}, {0, 0, 13}}, |
| 97 | BalancedDegradationSettings::Config{ |
| 98 | 2000, 15, {0, 0, 8}, {0, 0, 10}, {0, 0, 12}, {0, 0, 14}}, |
| 99 | BalancedDegradationSettings::Config{ |
| 100 | 3000, 25, {0, 0, 9}, {0, 0, 11}, {0, 0, 13}, {0, 0, 15}})); |
| 101 | } |
| 102 | |
| 103 | TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroVp8FpsValue) { |
| 104 | webrtc::test::ScopedFieldTrials field_trials( |
| 105 | "WebRTC-Video-BalancedDegradationSettings/" |
| 106 | "pixels:1000|2000|3000,fps:7|15|25,vp8_fps:0|15|25/"); |
| 107 | BalancedDegradationSettings settings; |
| 108 | VerifyIsDefault(settings.GetConfigs()); |
| 109 | } |
| 110 | |
| 111 | TEST(BalancedDegradationSettings, GetsDefaultConfigForInvalidFpsValue) { |
| 112 | webrtc::test::ScopedFieldTrials field_trials( |
| 113 | "WebRTC-Video-BalancedDegradationSettings/" |
| 114 | "pixels:1000|2000|3000,fps:7|15|25,vp8_fps:10|15|2000/"); |
| 115 | BalancedDegradationSettings settings; |
| 116 | VerifyIsDefault(settings.GetConfigs()); |
| 117 | } |
| 118 | |
| 119 | TEST(BalancedDegradationSettings, GetsDefaultConfigIfVp8FramerateDecreases) { |
| 120 | webrtc::test::ScopedFieldTrials field_trials( |
| 121 | "WebRTC-Video-BalancedDegradationSettings/" |
| 122 | "pixels:1000|2000|3000,fps:4|5|25,vp8_fps:5|4|25/"); |
| 123 | BalancedDegradationSettings settings; |
| 124 | VerifyIsDefault(settings.GetConfigs()); |
| 125 | } |
| 126 | |
Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 127 | TEST(BalancedDegradationSettings, GetsMinFps) { |
| 128 | webrtc::test::ScopedFieldTrials field_trials( |
| 129 | "WebRTC-Video-BalancedDegradationSettings/" |
| 130 | "pixels:1000|2000|3000,fps:5|15|25/"); |
| 131 | BalancedDegradationSettings settings; |
Åsa Persson | 48284b8 | 2019-07-08 10:01:12 +0200 | [diff] [blame] | 132 | EXPECT_EQ(5, settings.MinFps(kVideoCodecVP8, 1)); |
| 133 | EXPECT_EQ(5, settings.MinFps(kVideoCodecVP8, 1000)); |
| 134 | EXPECT_EQ(15, settings.MinFps(kVideoCodecVP8, 1001)); |
| 135 | EXPECT_EQ(15, settings.MinFps(kVideoCodecVP8, 2000)); |
| 136 | EXPECT_EQ(25, settings.MinFps(kVideoCodecVP8, 2001)); |
| 137 | EXPECT_EQ(25, settings.MinFps(kVideoCodecVP8, 3000)); |
| 138 | EXPECT_EQ(std::numeric_limits<int>::max(), |
| 139 | settings.MinFps(kVideoCodecVP8, 3001)); |
| 140 | } |
| 141 | |
| 142 | TEST(BalancedDegradationSettings, GetsVp8MinFps) { |
| 143 | webrtc::test::ScopedFieldTrials field_trials( |
| 144 | "WebRTC-Video-BalancedDegradationSettings/" |
| 145 | "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|10|12/"); |
| 146 | BalancedDegradationSettings settings; |
| 147 | EXPECT_EQ(7, settings.MinFps(kVideoCodecVP8, 1)); |
| 148 | EXPECT_EQ(7, settings.MinFps(kVideoCodecVP8, 1000)); |
| 149 | EXPECT_EQ(10, settings.MinFps(kVideoCodecVP8, 1001)); |
| 150 | EXPECT_EQ(10, settings.MinFps(kVideoCodecVP8, 2000)); |
| 151 | EXPECT_EQ(12, settings.MinFps(kVideoCodecVP8, 2001)); |
| 152 | EXPECT_EQ(12, settings.MinFps(kVideoCodecVP8, 3000)); |
| 153 | EXPECT_EQ(std::numeric_limits<int>::max(), |
| 154 | settings.MinFps(kVideoCodecVP8, 3001)); |
Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | TEST(BalancedDegradationSettings, GetsMaxFps) { |
| 158 | webrtc::test::ScopedFieldTrials field_trials( |
| 159 | "WebRTC-Video-BalancedDegradationSettings/" |
| 160 | "pixels:1000|2000|3000,fps:5|15|25/"); |
| 161 | BalancedDegradationSettings settings; |
Åsa Persson | 48284b8 | 2019-07-08 10:01:12 +0200 | [diff] [blame] | 162 | EXPECT_EQ(15, settings.MaxFps(kVideoCodecVP8, 1)); |
| 163 | EXPECT_EQ(15, settings.MaxFps(kVideoCodecVP8, 1000)); |
| 164 | EXPECT_EQ(25, settings.MaxFps(kVideoCodecVP8, 1001)); |
| 165 | EXPECT_EQ(25, settings.MaxFps(kVideoCodecVP8, 2000)); |
| 166 | EXPECT_EQ(std::numeric_limits<int>::max(), |
| 167 | settings.MaxFps(kVideoCodecVP8, 2001)); |
| 168 | } |
| 169 | |
| 170 | TEST(BalancedDegradationSettings, GetsVp8MaxFps) { |
| 171 | webrtc::test::ScopedFieldTrials field_trials( |
| 172 | "WebRTC-Video-BalancedDegradationSettings/" |
| 173 | "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|10|12/"); |
| 174 | BalancedDegradationSettings settings; |
| 175 | EXPECT_EQ(10, settings.MaxFps(kVideoCodecVP8, 1)); |
| 176 | EXPECT_EQ(10, settings.MaxFps(kVideoCodecVP8, 1000)); |
| 177 | EXPECT_EQ(12, settings.MaxFps(kVideoCodecVP8, 1001)); |
| 178 | EXPECT_EQ(12, settings.MaxFps(kVideoCodecVP8, 2000)); |
| 179 | EXPECT_EQ(std::numeric_limits<int>::max(), |
| 180 | settings.MaxFps(kVideoCodecVP8, 2001)); |
| 181 | } |
| 182 | |
| 183 | TEST(BalancedDegradationSettings, GetsVp9Fps) { |
| 184 | webrtc::test::ScopedFieldTrials field_trials( |
| 185 | "WebRTC-Video-BalancedDegradationSettings/" |
| 186 | "pixels:1000|2000|3000,fps:5|15|25,vp9_fps:7|10|12/"); |
| 187 | BalancedDegradationSettings settings; |
| 188 | EXPECT_EQ(7, settings.MinFps(kVideoCodecVP9, 1000)); |
| 189 | EXPECT_EQ(10, settings.MaxFps(kVideoCodecVP9, 1000)); |
| 190 | } |
| 191 | |
| 192 | TEST(BalancedDegradationSettings, GetsH264Fps) { |
| 193 | webrtc::test::ScopedFieldTrials field_trials( |
| 194 | "WebRTC-Video-BalancedDegradationSettings/" |
| 195 | "pixels:1000|2000|3000,fps:5|15|25,h264_fps:8|11|13/"); |
| 196 | BalancedDegradationSettings settings; |
| 197 | EXPECT_EQ(11, settings.MinFps(kVideoCodecH264, 2000)); |
| 198 | EXPECT_EQ(13, settings.MaxFps(kVideoCodecH264, 2000)); |
| 199 | } |
| 200 | |
| 201 | TEST(BalancedDegradationSettings, GetsGenericFps) { |
| 202 | webrtc::test::ScopedFieldTrials field_trials( |
| 203 | "WebRTC-Video-BalancedDegradationSettings/" |
| 204 | "pixels:1000|2000|3000,fps:5|15|25,generic_fps:9|12|14/"); |
| 205 | BalancedDegradationSettings settings; |
| 206 | EXPECT_EQ(14, settings.MinFps(kVideoCodecGeneric, 3000)); |
| 207 | EXPECT_EQ(std::numeric_limits<int>::max(), |
| 208 | settings.MaxFps(kVideoCodecGeneric, 3000)); |
Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 209 | } |
| 210 | |
Åsa Persson | 0c38a86 | 2019-08-14 10:10:12 +0200 | [diff] [blame^] | 211 | TEST(BalancedDegradationSettings, GetsUnlimitedForMaxValidFps) { |
| 212 | webrtc::test::ScopedFieldTrials field_trials( |
| 213 | "WebRTC-Video-BalancedDegradationSettings/" |
| 214 | "pixels:1000|2000|3000,fps:5|15|100,vp8_fps:30|100|100/"); |
| 215 | const int kUnlimitedFps = std::numeric_limits<int>::max(); |
| 216 | BalancedDegradationSettings settings; |
| 217 | EXPECT_EQ(15, settings.MinFps(kVideoCodecH264, 2000)); |
| 218 | EXPECT_EQ(kUnlimitedFps, settings.MinFps(kVideoCodecH264, 2001)); |
| 219 | EXPECT_EQ(30, settings.MinFps(kVideoCodecVP8, 1000)); |
| 220 | EXPECT_EQ(kUnlimitedFps, settings.MinFps(kVideoCodecVP8, 1001)); |
| 221 | } |
| 222 | |
Åsa Persson | 1231419 | 2019-06-20 15:45:07 +0200 | [diff] [blame] | 223 | TEST(BalancedDegradationSettings, QpThresholdsNotSetByDefault) { |
| 224 | webrtc::test::ScopedFieldTrials field_trials( |
| 225 | "WebRTC-Video-BalancedDegradationSettings/" |
| 226 | "pixels:1000|2000|3000,fps:5|15|25/"); |
| 227 | BalancedDegradationSettings settings; |
| 228 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP8, 1)); |
| 229 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP9, 1)); |
| 230 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecH264, 1)); |
| 231 | EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecGeneric, 1)); |
| 232 | } |
| 233 | |
| 234 | TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { |
| 235 | webrtc::test::ScopedFieldTrials field_trials( |
| 236 | "WebRTC-Video-BalancedDegradationSettings/" |
| 237 | "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_low:89|90|88," |
| 238 | "vp8_qp_high:90|91|92,vp9_qp_low:27|28|29,vp9_qp_high:120|130|140," |
| 239 | "h264_qp_low:12|13|14,h264_qp_high:20|30|40,generic_qp_low:7|6|5," |
| 240 | "generic_qp_high:22|23|24/"); |
| 241 | BalancedDegradationSettings settings; |
Åsa Persson | 48284b8 | 2019-07-08 10:01:12 +0200 | [diff] [blame] | 242 | EXPECT_THAT( |
| 243 | settings.GetConfigs(), |
| 244 | ::testing::ElementsAre( |
| 245 | BalancedDegradationSettings::Config{ |
| 246 | 1000, 5, {89, 90, 0}, {27, 120, 0}, {12, 20, 0}, {7, 22, 0}}, |
| 247 | BalancedDegradationSettings::Config{ |
| 248 | 2000, 15, {90, 91, 0}, {28, 130, 0}, {13, 30, 0}, {6, 23, 0}}, |
| 249 | BalancedDegradationSettings::Config{ |
| 250 | 3000, 25, {88, 92, 0}, {29, 140, 0}, {14, 40, 0}, {5, 24, 0}})); |
Åsa Persson | 1231419 | 2019-06-20 15:45:07 +0200 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | TEST(BalancedDegradationSettings, GetsDefaultConfigIfOnlyHasLowThreshold) { |
| 254 | webrtc::test::ScopedFieldTrials field_trials( |
| 255 | "WebRTC-Video-BalancedDegradationSettings/" |
| 256 | "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_low:89|90|88/"); |
| 257 | BalancedDegradationSettings settings; |
| 258 | VerifyIsDefault(settings.GetConfigs()); |
| 259 | } |
| 260 | |
| 261 | TEST(BalancedDegradationSettings, GetsDefaultConfigIfOnlyHasHighThreshold) { |
| 262 | webrtc::test::ScopedFieldTrials field_trials( |
| 263 | "WebRTC-Video-BalancedDegradationSettings/" |
| 264 | "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_high:90|91|92/"); |
| 265 | BalancedDegradationSettings settings; |
| 266 | VerifyIsDefault(settings.GetConfigs()); |
| 267 | } |
| 268 | |
| 269 | TEST(BalancedDegradationSettings, GetsDefaultConfigIfLowEqualsHigh) { |
| 270 | webrtc::test::ScopedFieldTrials field_trials( |
| 271 | "WebRTC-Video-BalancedDegradationSettings/" |
| 272 | "pixels:1000|2000|3000,fps:5|15|25," |
| 273 | "vp8_qp_low:89|90|88,vp8_qp_high:90|91|88/"); |
| 274 | BalancedDegradationSettings settings; |
| 275 | VerifyIsDefault(settings.GetConfigs()); |
| 276 | } |
| 277 | |
| 278 | TEST(BalancedDegradationSettings, GetsDefaultConfigIfLowGreaterThanHigh) { |
| 279 | webrtc::test::ScopedFieldTrials field_trials( |
| 280 | "WebRTC-Video-BalancedDegradationSettings/" |
| 281 | "pixels:1000|2000|3000,fps:5|15|25," |
| 282 | "vp8_qp_low:89|90|88,vp8_qp_high:90|91|87/"); |
| 283 | BalancedDegradationSettings settings; |
| 284 | VerifyIsDefault(settings.GetConfigs()); |
| 285 | } |
| 286 | |
| 287 | TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroQpValue) { |
| 288 | webrtc::test::ScopedFieldTrials field_trials( |
| 289 | "WebRTC-Video-BalancedDegradationSettings/" |
| 290 | "pixels:1000|2000|3000,fps:5|15|25," |
| 291 | "vp8_qp_low:89|0|88,vp8_qp_high:90|91|92/"); |
| 292 | BalancedDegradationSettings settings; |
| 293 | VerifyIsDefault(settings.GetConfigs()); |
| 294 | } |
| 295 | |
| 296 | TEST(BalancedDegradationSettings, GetsVp8QpThresholds) { |
| 297 | webrtc::test::ScopedFieldTrials field_trials( |
| 298 | "WebRTC-Video-BalancedDegradationSettings/" |
| 299 | "pixels:1000|2000|3000,fps:5|15|25," |
| 300 | "vp8_qp_low:89|90|88,vp8_qp_high:90|91|92/"); |
| 301 | BalancedDegradationSettings settings; |
| 302 | EXPECT_EQ(89, settings.GetQpThresholds(kVideoCodecVP8, 1)->low); |
| 303 | EXPECT_EQ(90, settings.GetQpThresholds(kVideoCodecVP8, 1)->high); |
| 304 | EXPECT_EQ(90, settings.GetQpThresholds(kVideoCodecVP8, 1000)->high); |
| 305 | EXPECT_EQ(91, settings.GetQpThresholds(kVideoCodecVP8, 1001)->high); |
| 306 | EXPECT_EQ(91, settings.GetQpThresholds(kVideoCodecVP8, 2000)->high); |
| 307 | EXPECT_EQ(92, settings.GetQpThresholds(kVideoCodecVP8, 2001)->high); |
| 308 | EXPECT_EQ(92, settings.GetQpThresholds(kVideoCodecVP8, 3000)->high); |
| 309 | EXPECT_EQ(92, settings.GetQpThresholds(kVideoCodecVP8, 3001)->high); |
| 310 | } |
| 311 | |
| 312 | TEST(BalancedDegradationSettings, GetsVp9QpThresholds) { |
| 313 | webrtc::test::ScopedFieldTrials field_trials( |
| 314 | "WebRTC-Video-BalancedDegradationSettings/" |
| 315 | "pixels:1000|2000|3000,fps:5|15|25," |
| 316 | "vp9_qp_low:55|56|57,vp9_qp_high:155|156|157/"); |
| 317 | BalancedDegradationSettings settings; |
| 318 | const auto thresholds = settings.GetQpThresholds(kVideoCodecVP9, 1000); |
| 319 | EXPECT_TRUE(thresholds); |
| 320 | EXPECT_EQ(55, thresholds->low); |
| 321 | EXPECT_EQ(155, thresholds->high); |
| 322 | } |
| 323 | |
| 324 | TEST(BalancedDegradationSettings, GetsH264QpThresholds) { |
| 325 | webrtc::test::ScopedFieldTrials field_trials( |
| 326 | "WebRTC-Video-BalancedDegradationSettings/" |
| 327 | "pixels:1000|2000|3000,fps:5|15|25," |
| 328 | "h264_qp_low:21|22|23,h264_qp_high:41|43|42/"); |
| 329 | BalancedDegradationSettings settings; |
| 330 | const auto thresholds = settings.GetQpThresholds(kVideoCodecH264, 2000); |
| 331 | EXPECT_TRUE(thresholds); |
| 332 | EXPECT_EQ(22, thresholds->low); |
| 333 | EXPECT_EQ(43, thresholds->high); |
| 334 | } |
| 335 | |
| 336 | TEST(BalancedDegradationSettings, GetsGenericQpThresholds) { |
| 337 | webrtc::test::ScopedFieldTrials field_trials( |
| 338 | "WebRTC-Video-BalancedDegradationSettings/" |
| 339 | "pixels:1000|2000|3000,fps:5|15|25," |
| 340 | "generic_qp_low:2|3|4,generic_qp_high:22|23|24/"); |
| 341 | BalancedDegradationSettings settings; |
| 342 | const auto thresholds = settings.GetQpThresholds(kVideoCodecGeneric, 3000); |
| 343 | EXPECT_TRUE(thresholds); |
| 344 | EXPECT_EQ(4, thresholds->low); |
| 345 | EXPECT_EQ(24, thresholds->high); |
| 346 | } |
| 347 | |
Åsa Persson | f3d828e | 2019-05-06 12:22:49 +0200 | [diff] [blame] | 348 | } // namespace webrtc |