Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc

Issue 2380883003: Add interval estimator to remote bitrate estimator (Closed)
Patch Set: Rebased. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 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 #include <memory>
11
12 #include "webrtc/modules/audio_coding/audio_network_adaptor/smoothing_filter.h"
13 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
14 #include "webrtc/test/gtest.h"
15
16 namespace webrtc {
17 namespace {
18
19 constexpr int64_t kClockInitialTime = 123456;
20
21 struct AimdRateControlStates {
22 std::unique_ptr<AimdRateControl> aimd_rate_control;
23 std::unique_ptr<SimulatedClock> simulated_clock;
24 };
25
26 AimdRateControlStates CreateAimdRateControlStates() {
27 AimdRateControlStates states;
28 states.aimd_rate_control.reset(new AimdRateControl());
29 states.simulated_clock.reset(new SimulatedClock(kClockInitialTime));
30 return states;
31 }
32
33 void InitBitrate(const AimdRateControlStates& states,
34 int bitrate,
35 int64_t now_ms) {
36 // Reduce the bitrate by 1000 to compensate for the Update after SetEstimate.
37 bitrate -= 1000;
38
39 states.aimd_rate_control->SetEstimate(bitrate, now_ms);
40 }
41
42 void UpdateRateControl(const AimdRateControlStates& states,
43 const BandwidthUsage& bandwidth_usage,
44 int bitrate,
45 int64_t now_ms) {
46 RateControlInput input(bandwidth_usage, rtc::Optional<uint32_t>(bitrate),
47 now_ms);
48 states.aimd_rate_control->Update(&input, now_ms);
49 states.aimd_rate_control->UpdateBandwidthEstimate(now_ms);
50 }
51
52 } // namespace
53
54 TEST(AimdRateControlTest, MinNearMaxIncreaseRateOnLowBandwith) {
55 auto states = CreateAimdRateControlStates();
56 constexpr int kBitrate = 30000;
57 InitBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds());
58 EXPECT_EQ(4000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
59 }
60
61 TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn90kbpsAnd200msRtt) {
62 auto states = CreateAimdRateControlStates();
63 constexpr int kBitrate = 90000;
64 InitBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds());
65 EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
66 }
67
68 TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn60kbpsAnd100msRtt) {
69 auto states = CreateAimdRateControlStates();
70 constexpr int kBitrate = 60000;
71 InitBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds());
72 states.aimd_rate_control->SetRtt(100);
73 EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
74 }
75
76 TEST(AimdRateControlTest, UnknownBitrateDecreaseBeforeFirstOveruse) {
77 auto states = CreateAimdRateControlStates();
78 EXPECT_EQ(rtc::Optional<int>(),
79 states.aimd_rate_control->GetLastBitrateDecreaseBps());
80 }
81
82 TEST(AimdRateControlTest, GetLastBitrateDecrease) {
83 auto states = CreateAimdRateControlStates();
84 constexpr int kBitrate = 300000;
85 InitBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds());
86 UpdateRateControl(states, kBwOverusing, kBitrate - 2000,
87 states.simulated_clock->TimeInMilliseconds());
88 EXPECT_EQ(rtc::Optional<int>(46700),
89 states.aimd_rate_control->GetLastBitrateDecreaseBps());
90 }
91
92 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698