| 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/call/mock/mock_rtc_event_log.h" | |
| 16 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h" | 15 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h" |
| 17 | 16 |
| 18 namespace webrtc { | 17 namespace webrtc { |
| 19 | 18 |
| 20 void TestProbing(bool use_delay_based) { | 19 void TestProbing(bool use_delay_based) { |
| 21 MockRtcEventLog event_log; | 20 SendSideBandwidthEstimation bwe; |
| 22 SendSideBandwidthEstimation bwe(&event_log); | |
| 23 bwe.SetMinMaxBitrate(100000, 1500000); | 21 bwe.SetMinMaxBitrate(100000, 1500000); |
| 24 bwe.SetSendBitrate(200000); | 22 bwe.SetSendBitrate(200000); |
| 25 | 23 |
| 26 const int kRembBps = 1000000; | 24 const int kRembBps = 1000000; |
| 27 const int kSecondRembBps = kRembBps + 500000; | 25 const int kSecondRembBps = kRembBps + 500000; |
| 28 int64_t now_ms = 0; | 26 int64_t now_ms = 0; |
| 29 | 27 |
| 30 bwe.UpdateReceiverBlock(0, 50, 1, now_ms); | 28 bwe.UpdateReceiverBlock(0, 50, 1, now_ms); |
| 31 | 29 |
| 32 // Initial REMB applies immediately. | 30 // Initial REMB applies immediately. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 57 | 55 |
| 58 TEST(SendSideBweTest, InitialRembWithProbing) { | 56 TEST(SendSideBweTest, InitialRembWithProbing) { |
| 59 TestProbing(false); | 57 TestProbing(false); |
| 60 } | 58 } |
| 61 | 59 |
| 62 TEST(SendSideBweTest, InitialDelayBasedBweWithProbing) { | 60 TEST(SendSideBweTest, InitialDelayBasedBweWithProbing) { |
| 63 TestProbing(true); | 61 TestProbing(true); |
| 64 } | 62 } |
| 65 | 63 |
| 66 TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) { | 64 TEST(SendSideBweTest, DoesntReapplyBitrateDecreaseWithoutFollowingRemb) { |
| 67 MockRtcEventLog event_log; | 65 SendSideBandwidthEstimation bwe; |
| 68 EXPECT_CALL(event_log, | |
| 69 LogBwePacketLossEvent(testing::Gt(0), testing::Gt(0), 0)) | |
| 70 .Times(3); | |
| 71 SendSideBandwidthEstimation bwe(&event_log); | |
| 72 static const int kMinBitrateBps = 100000; | 66 static const int kMinBitrateBps = 100000; |
| 73 static const int kInitialBitrateBps = 1000000; | 67 static const int kInitialBitrateBps = 1000000; |
| 74 bwe.SetMinMaxBitrate(kMinBitrateBps, 1500000); | 68 bwe.SetMinMaxBitrate(kMinBitrateBps, 1500000); |
| 75 bwe.SetSendBitrate(kInitialBitrateBps); | 69 bwe.SetSendBitrate(kInitialBitrateBps); |
| 76 | 70 |
| 77 static const uint8_t kFractionLoss = 128; | 71 static const uint8_t kFractionLoss = 128; |
| 78 static const int64_t kRttMs = 50; | 72 static const int64_t kRttMs = 50; |
| 79 | 73 |
| 80 int64_t now_ms = 0; | 74 int64_t now_ms = 0; |
| 81 int bitrate_bps; | 75 int bitrate_bps; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 111 bwe.UpdateEstimate(now_ms); | 105 bwe.UpdateEstimate(now_ms); |
| 112 bwe.CurrentEstimate(&bitrate_bps, &fraction_loss, &rtt_ms); | 106 bwe.CurrentEstimate(&bitrate_bps, &fraction_loss, &rtt_ms); |
| 113 | 107 |
| 114 EXPECT_EQ(last_bitrate_bps, bitrate_bps); | 108 EXPECT_EQ(last_bitrate_bps, bitrate_bps); |
| 115 // The old loss rate should still be applied though. | 109 // The old loss rate should still be applied though. |
| 116 EXPECT_EQ(kFractionLoss, fraction_loss); | 110 EXPECT_EQ(kFractionLoss, fraction_loss); |
| 117 EXPECT_EQ(kRttMs, rtt_ms); | 111 EXPECT_EQ(kRttMs, rtt_ms); |
| 118 } | 112 } |
| 119 | 113 |
| 120 } // namespace webrtc | 114 } // namespace webrtc |
| OLD | NEW |