OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 <algorithm> | 11 #include <algorithm> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h" | 15 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 TEST(SendSideBweTest, InitialRembWithProbing) { | 19 void TestProbing(bool use_delay_based) { |
20 SendSideBandwidthEstimation bwe; | 20 SendSideBandwidthEstimation bwe; |
21 bwe.SetMinMaxBitrate(100000, 1500000); | 21 bwe.SetMinMaxBitrate(100000, 1500000); |
22 bwe.SetSendBitrate(200000); | 22 bwe.SetSendBitrate(200000); |
23 | 23 |
24 const int kRembBps = 1000000; | 24 const int kRembBps = 1000000; |
25 const int kSecondRembBps = kRembBps + 500000; | 25 const int kSecondRembBps = kRembBps + 500000; |
26 int64_t now_ms = 0; | 26 int64_t now_ms = 0; |
27 | 27 |
28 bwe.UpdateReceiverBlock(0, 50, 1, now_ms); | 28 bwe.UpdateReceiverBlock(0, 50, 1, now_ms); |
29 | 29 |
30 // Initial REMB applies immediately. | 30 // Initial REMB applies immediately. |
31 bwe.UpdateReceiverEstimate(now_ms, kRembBps); | 31 if (use_delay_based) { |
| 32 bwe.UpdateDelayBasedEstimate(now_ms, kRembBps); |
| 33 } else { |
| 34 bwe.UpdateReceiverEstimate(now_ms, kRembBps); |
| 35 } |
32 bwe.UpdateEstimate(now_ms); | 36 bwe.UpdateEstimate(now_ms); |
33 int bitrate; | 37 int bitrate; |
34 uint8_t fraction_loss; | 38 uint8_t fraction_loss; |
35 int64_t rtt; | 39 int64_t rtt; |
36 bwe.CurrentEstimate(&bitrate, &fraction_loss, &rtt); | 40 bwe.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
37 EXPECT_EQ(kRembBps, bitrate); | 41 EXPECT_EQ(kRembBps, bitrate); |
38 | 42 |
39 // Second REMB doesn't apply immediately. | 43 // Second REMB doesn't apply immediately. |
40 now_ms += 2001; | 44 now_ms += 2001; |
41 bwe.UpdateReceiverEstimate(now_ms, kSecondRembBps); | 45 if (use_delay_based) { |
| 46 bwe.UpdateDelayBasedEstimate(now_ms, kSecondRembBps); |
| 47 } else { |
| 48 bwe.UpdateReceiverEstimate(now_ms, kSecondRembBps); |
| 49 } |
42 bwe.UpdateEstimate(now_ms); | 50 bwe.UpdateEstimate(now_ms); |
43 bitrate = 0; | 51 bitrate = 0; |
44 bwe.CurrentEstimate(&bitrate, &fraction_loss, &rtt); | 52 bwe.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
45 EXPECT_EQ(kRembBps, bitrate); | 53 EXPECT_EQ(kRembBps, bitrate); |
46 } | 54 } |
47 | 55 |
| 56 TEST(SendSideBweTest, InitialRembWithProbing) { |
| 57 TestProbing(false); |
| 58 } |
| 59 |
| 60 TEST(SendSideBweTest, InitialDelayBasedBweWithProbing) { |
| 61 TestProbing(true); |
| 62 } |
| 63 |
48 TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) { | 64 TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) { |
49 SendSideBandwidthEstimation bwe; | 65 SendSideBandwidthEstimation bwe; |
50 static const int kMinBitrateBps = 100000; | 66 static const int kMinBitrateBps = 100000; |
51 static const int kInitialBitrateBps = 1000000; | 67 static const int kInitialBitrateBps = 1000000; |
52 bwe.SetMinMaxBitrate(kMinBitrateBps, 1500000); | 68 bwe.SetMinMaxBitrate(kMinBitrateBps, 1500000); |
53 bwe.SetSendBitrate(kInitialBitrateBps); | 69 bwe.SetSendBitrate(kInitialBitrateBps); |
54 | 70 |
55 static const uint8_t kFractionLoss = 128; | 71 static const uint8_t kFractionLoss = 128; |
56 static const int64_t kRttMs = 50; | 72 static const int64_t kRttMs = 50; |
57 | 73 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 bwe.UpdateEstimate(now_ms); | 105 bwe.UpdateEstimate(now_ms); |
90 bwe.CurrentEstimate(&bitrate_bps, &fraction_loss, &rtt_ms); | 106 bwe.CurrentEstimate(&bitrate_bps, &fraction_loss, &rtt_ms); |
91 | 107 |
92 EXPECT_EQ(last_bitrate_bps, bitrate_bps); | 108 EXPECT_EQ(last_bitrate_bps, bitrate_bps); |
93 // The old loss rate should still be applied though. | 109 // The old loss rate should still be applied though. |
94 EXPECT_EQ(kFractionLoss, fraction_loss); | 110 EXPECT_EQ(kFractionLoss, fraction_loss); |
95 EXPECT_EQ(kRttMs, rtt_ms); | 111 EXPECT_EQ(kRttMs, rtt_ms); |
96 } | 112 } |
97 | 113 |
98 } // namespace webrtc | 114 } // namespace webrtc |
OLD | NEW |