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

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: Respond to comments. 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 int kTimeConstantMs = 1000;
minyue-webrtc 2016/11/14 16:50:42 can we remove these commented lines
michaelt 2016/11/15 09:41:59 sure :)
20 // constexpr float kMaxAbsError = 0.0001f;
21 constexpr int64_t kClockInitialTime = 123456;
22
23 struct AimdRateControlStates {
24 std::unique_ptr<AimdRateControl> aimd_rate_control;
25 std::unique_ptr<SimulatedClock> simulated_clock;
26 };
27
28 AimdRateControlStates CreateAimdRateControlStates() {
29 AimdRateControlStates states;
30 states.aimd_rate_control.reset(new AimdRateControl());
31 states.simulated_clock.reset(new SimulatedClock(kClockInitialTime));
32 return states;
33 }
34
35 void InitToBitrate(const AimdRateControlStates& states,
minyue-webrtc 2016/11/14 16:50:42 InitBitrate?
michaelt 2016/11/15 09:41:59 Done.
36 int bitrate,
37 int64_t now_ms) {
38 // Reduce the bitrate by 1000 to compensate for the Update after SetEstimate.
39 bitrate -= 1000;
40
41 states.aimd_rate_control->SetEstimate(bitrate, now_ms);
42 }
43
44 void UpdateRateControl(const AimdRateControlStates& states,
45 const BandwidthUsage& bandwidth_usage,
46 int bitrate,
47 int64_t now_ms) {
48 RateControlInput input(bandwidth_usage, rtc::Optional<uint32_t>(bitrate),
49 now_ms);
50 states.aimd_rate_control->Update(&input, now_ms);
51 states.aimd_rate_control->UpdateBandwidthEstimate(now_ms);
52 }
53
54 } // namespace
55
56 TEST(AimdRateControlTest, MinNearMaxIncreaseRateOnLowBandwith) {
57 auto states = CreateAimdRateControlStates();
58 constexpr int kBitrate = 30000;
59 InitToBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds());
60 EXPECT_EQ(4000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
61 }
62
63 TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn90kbpsAn200msRtt) {
minyue-webrtc 2016/11/14 16:50:42 An->And
michaelt 2016/11/15 09:41:59 Done.
64 auto states = CreateAimdRateControlStates();
65 constexpr int kBitrate = 90000;
66 InitToBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds());
67 EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
68 }
69
70 TEST(AimdRateControlTest, NearMaxIncreaseRateIs5kbpsOn60kbpsAn100msRtt) {
minyue-webrtc 2016/11/14 16:50:42 An->And
michaelt 2016/11/15 09:41:59 Done.
71 auto states = CreateAimdRateControlStates();
72 constexpr int kBitrate = 60000;
73 InitToBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds());
74 states.aimd_rate_control->SetRtt(100);
75 EXPECT_EQ(5000, states.aimd_rate_control->GetNearMaxIncreaseRateBps());
76 }
77
78 TEST(AimdRateControlTest, UnknownDropHightBeforeFirstOveruse) {
minyue-webrtc 2016/11/14 16:50:42 Hight -> Height or maybe even rename to "UnknownBi
michaelt 2016/11/15 09:41:59 Done.
79 auto states = CreateAimdRateControlStates();
80 EXPECT_EQ(rtc::Optional<int>(), states.aimd_rate_control->GetLastDecrease());
81 }
82
83 TEST(AimdRateControlTest, GetLastBitrateDrop) {
84 auto states = CreateAimdRateControlStates();
85 constexpr int kBitrate = 300000;
86 InitToBitrate(states, kBitrate, states.simulated_clock->TimeInMilliseconds());
87 UpdateRateControl(states, kBwOverusing, kBitrate - 2000,
88 states.simulated_clock->TimeInMilliseconds());
89 EXPECT_EQ(rtc::Optional<int>(46700),
90 states.aimd_rate_control->GetLastDecrease());
91 }
92
93 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698