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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 SimulatedClock clock_; | 47 SimulatedClock clock_; |
48 ProtectionCallback protection_callback_; | 48 ProtectionCallback protection_callback_; |
49 ProtectionBitrateCalculator media_opt_; | 49 ProtectionBitrateCalculator media_opt_; |
50 }; | 50 }; |
51 | 51 |
52 TEST_F(ProtectionBitrateCalculatorTest, ProtectsUsingFecBitrate) { | 52 TEST_F(ProtectionBitrateCalculatorTest, ProtectsUsingFecBitrate) { |
53 static const uint32_t kMaxBitrateBps = 130000; | 53 static const uint32_t kMaxBitrateBps = 130000; |
54 | 54 |
55 media_opt_.SetProtectionMethod(true /*enable_fec*/, false /* enable_nack */); | 55 media_opt_.SetProtectionMethod(true /*enable_fec*/, false /* enable_nack */); |
56 media_opt_.SetEncodingData(kCodecBitrateBps, 640, 480, 30, 1, 1000); | 56 media_opt_.SetEncodingData(640, 480, 1, 1000); |
57 | 57 |
58 // Using 10% of codec bitrate for FEC. | 58 // Using 10% of codec bitrate for FEC. |
59 protection_callback_.fec_rate_bps_ = kCodecBitrateBps / 10; | 59 protection_callback_.fec_rate_bps_ = kCodecBitrateBps / 10; |
60 uint32_t target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 0, 0); | 60 uint32_t target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 0, 0); |
61 | 61 |
62 EXPECT_GT(target_bitrate, 0u); | 62 EXPECT_GT(target_bitrate, 0u); |
63 EXPECT_GT(kMaxBitrateBps, target_bitrate); | 63 EXPECT_GT(kMaxBitrateBps, target_bitrate); |
64 | 64 |
65 // Using as much for codec bitrate as fec rate, new target rate should share | 65 // Using as much for codec bitrate as fec rate, new target rate should share |
66 // both equally, but only be half of max (since that ceiling should be hit). | 66 // both equally, but only be half of max (since that ceiling should be hit). |
67 protection_callback_.fec_rate_bps_ = kCodecBitrateBps; | 67 protection_callback_.fec_rate_bps_ = kCodecBitrateBps; |
68 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); | 68 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); |
69 EXPECT_EQ(kMaxBitrateBps / 2, target_bitrate); | 69 EXPECT_EQ(kMaxBitrateBps / 2, target_bitrate); |
70 } | 70 } |
71 | 71 |
72 TEST_F(ProtectionBitrateCalculatorTest, ProtectsUsingNackBitrate) { | 72 TEST_F(ProtectionBitrateCalculatorTest, ProtectsUsingNackBitrate) { |
73 static const uint32_t kMaxBitrateBps = 130000; | 73 static const uint32_t kMaxBitrateBps = 130000; |
74 | 74 |
75 media_opt_.SetProtectionMethod(false /*enable_fec*/, true /* enable_nack */); | 75 media_opt_.SetProtectionMethod(false /*enable_fec*/, true /* enable_nack */); |
76 media_opt_.SetEncodingData(kCodecBitrateBps, 640, 480, 30, 1, 1000); | 76 media_opt_.SetEncodingData(640, 480, 1, 1000); |
77 | 77 |
78 uint32_t target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 0, 0); | 78 uint32_t target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 0, 0); |
79 | 79 |
80 EXPECT_EQ(kMaxBitrateBps, target_bitrate); | 80 EXPECT_EQ(kMaxBitrateBps, target_bitrate); |
81 | 81 |
82 // Using as much for codec bitrate as nack rate, new target rate should share | 82 // Using as much for codec bitrate as nack rate, new target rate should share |
83 // both equally, but only be half of max (since that ceiling should be hit). | 83 // both equally, but only be half of max (since that ceiling should be hit). |
84 protection_callback_.nack_rate_bps_ = kMaxBitrateBps; | 84 protection_callback_.nack_rate_bps_ = kMaxBitrateBps; |
85 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); | 85 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); |
86 EXPECT_EQ(kMaxBitrateBps / 2, target_bitrate); | 86 EXPECT_EQ(kMaxBitrateBps / 2, target_bitrate); |
87 } | 87 } |
88 | 88 |
89 TEST_F(ProtectionBitrateCalculatorTest, NoProtection) { | 89 TEST_F(ProtectionBitrateCalculatorTest, NoProtection) { |
90 static const uint32_t kMaxBitrateBps = 130000; | 90 static const uint32_t kMaxBitrateBps = 130000; |
91 | 91 |
92 media_opt_.SetProtectionMethod(false /*enable_fec*/, false /* enable_nack */); | 92 media_opt_.SetProtectionMethod(false /*enable_fec*/, false /* enable_nack */); |
93 media_opt_.SetEncodingData(kCodecBitrateBps, 640, 480, 30, 1, 1000); | 93 media_opt_.SetEncodingData(640, 480, 1, 1000); |
94 | 94 |
95 uint32_t target_bitrate = | 95 uint32_t target_bitrate = |
96 media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); | 96 media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); |
97 EXPECT_EQ(kMaxBitrateBps, target_bitrate); | 97 EXPECT_EQ(kMaxBitrateBps, target_bitrate); |
98 } | 98 } |
99 | 99 |
100 } // namespace webrtc | 100 } // namespace webrtc |
OLD | NEW |