| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 EXPECT_EQ(target_bitrate, media_opt_.GetEncoderTargetRate()); |
| 70 } | 71 } |
| 71 | 72 |
| 72 TEST_F(ProtectionBitrateCalculatorTest, ProtectsUsingNackBitrate) { | 73 TEST_F(ProtectionBitrateCalculatorTest, ProtectsUsingNackBitrate) { |
| 73 static const uint32_t kMaxBitrateBps = 130000; | 74 static const uint32_t kMaxBitrateBps = 130000; |
| 74 | 75 |
| 75 media_opt_.SetProtectionMethod(false /*enable_fec*/, true /* enable_nack */); | 76 media_opt_.SetProtectionMethod(false /*enable_fec*/, true /* enable_nack */); |
| 76 media_opt_.SetEncodingData(kCodecBitrateBps, 640, 480, 30, 1, 1000); | 77 media_opt_.SetEncodingData(kCodecBitrateBps, 640, 480, 30, 1, 1000); |
| 77 | 78 |
| 78 uint32_t target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 0, 0); | 79 uint32_t target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 0, 0); |
| 79 | 80 |
| 80 EXPECT_EQ(kMaxBitrateBps, target_bitrate); | 81 EXPECT_EQ(kMaxBitrateBps, target_bitrate); |
| 81 | 82 |
| 82 // Using as much for codec bitrate as nack rate, new target rate should share | 83 // 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). | 84 // both equally, but only be half of max (since that ceiling should be hit). |
| 84 protection_callback_.nack_rate_bps_ = kMaxBitrateBps; | 85 protection_callback_.nack_rate_bps_ = kMaxBitrateBps; |
| 85 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); | 86 target_bitrate = media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); |
| 86 EXPECT_EQ(kMaxBitrateBps / 2, target_bitrate); | 87 EXPECT_EQ(kMaxBitrateBps / 2, target_bitrate); |
| 88 EXPECT_EQ(target_bitrate, media_opt_.GetEncoderTargetRate()); |
| 89 } |
| 90 |
| 91 TEST_F(ProtectionBitrateCalculatorTest, NoProtection) { |
| 92 static const uint32_t kMaxBitrateBps = 130000; |
| 93 |
| 94 media_opt_.SetProtectionMethod(false /*enable_fec*/, false /* enable_nack */); |
| 95 media_opt_.SetEncodingData(kCodecBitrateBps, 640, 480, 30, 1, 1000); |
| 96 |
| 97 uint32_t target_bitrate = |
| 98 media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); |
| 99 EXPECT_EQ(kMaxBitrateBps, target_bitrate); |
| 100 EXPECT_EQ(target_bitrate, media_opt_.GetEncoderTargetRate()); |
| 87 } | 101 } |
| 88 | 102 |
| 89 } // namespace webrtc | 103 } // namespace webrtc |
| OLD | NEW |