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

Side by Side Diff: webrtc/modules/congestion_controller/probe_bitrate_estimator_unittest.cc

Issue 2239143002: ProbingEstimator: Erase history based on time threshold (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 3 months 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
« no previous file with comments | « webrtc/modules/congestion_controller/probe_bitrate_estimator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" 11 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h"
12 12
13 #include <vector> 13 #include <vector>
14 #include <utility> 14 #include <utility>
15 15
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" 18 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 constexpr int INVALID_BPS = -1;
23
22 class TestProbeBitrateEstimator : public ::testing::Test { 24 class TestProbeBitrateEstimator : public ::testing::Test {
23 public: 25 public:
24 TestProbeBitrateEstimator() : probe_bitrate_estimator_() {} 26 TestProbeBitrateEstimator() : probe_bitrate_estimator_() {}
25 27
26 void AddPacketFeedback(int probe_cluster_id, 28 void AddPacketFeedback(int probe_cluster_id,
27 size_t size_bytes, 29 size_t size_bytes,
28 int64_t send_time_ms, 30 int64_t send_time_ms,
29 int64_t arrival_time_ms) { 31 int64_t arrival_time_ms) {
30 PacketInfo info(arrival_time_ms, send_time_ms, 0, size_bytes, 32 PacketInfo info(arrival_time_ms, send_time_ms, 0, size_bytes,
31 probe_cluster_id); 33 probe_cluster_id);
32 ProbingResult res = probe_bitrate_estimator_.PacketFeedback(info); 34 measured_bps_ =
33 if (res.valid()) 35 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(info);
34 results_.emplace_back(res.bps, res.timestamp);
35 }
36
37 void CheckResult(size_t index, int bps, int max_diff, int64_t timestamp) {
38 ASSERT_GT(results_.size(), index);
39 EXPECT_NEAR(results_[index].first, bps, max_diff);
40 EXPECT_EQ(results_[index].second, timestamp);
41 } 36 }
42 37
43 protected: 38 protected:
44 std::vector<std::pair<int, int64_t>> results_; 39 int measured_bps_ = INVALID_BPS;
45 ProbeBitrateEstimator probe_bitrate_estimator_; 40 ProbeBitrateEstimator probe_bitrate_estimator_;
46 }; 41 };
47 42
48 TEST_F(TestProbeBitrateEstimator, OneCluster) { 43 TEST_F(TestProbeBitrateEstimator, OneCluster) {
49 AddPacketFeedback(0, 1000, 0, 10); 44 AddPacketFeedback(0, 1000, 0, 10);
50 AddPacketFeedback(0, 1000, 10, 20); 45 AddPacketFeedback(0, 1000, 10, 20);
51 AddPacketFeedback(0, 1000, 20, 30); 46 AddPacketFeedback(0, 1000, 20, 30);
52 AddPacketFeedback(0, 1000, 30, 40); 47 AddPacketFeedback(0, 1000, 30, 40);
53 48
54 CheckResult(0, 800000, 10, 40); 49 EXPECT_NEAR(measured_bps_, 800000, 10);
55 } 50 }
56 51
57 TEST_F(TestProbeBitrateEstimator, FastReceive) { 52 TEST_F(TestProbeBitrateEstimator, FastReceive) {
58 AddPacketFeedback(0, 1000, 0, 15); 53 AddPacketFeedback(0, 1000, 0, 15);
59 AddPacketFeedback(0, 1000, 10, 30); 54 AddPacketFeedback(0, 1000, 10, 30);
60 AddPacketFeedback(0, 1000, 20, 35); 55 AddPacketFeedback(0, 1000, 20, 35);
61 AddPacketFeedback(0, 1000, 30, 40); 56 AddPacketFeedback(0, 1000, 30, 40);
62 57
63 CheckResult(0, 800000, 10, 40); 58 EXPECT_NEAR(measured_bps_, 800000, 10);
64 } 59 }
65 60
66 TEST_F(TestProbeBitrateEstimator, TooFastReceive) { 61 TEST_F(TestProbeBitrateEstimator, TooFastReceive) {
67 AddPacketFeedback(0, 1000, 0, 19); 62 AddPacketFeedback(0, 1000, 0, 19);
68 AddPacketFeedback(0, 1000, 10, 30); 63 AddPacketFeedback(0, 1000, 10, 30);
69 AddPacketFeedback(0, 1000, 20, 40); 64 AddPacketFeedback(0, 1000, 20, 40);
70 AddPacketFeedback(0, 1000, 40, 50); 65 AddPacketFeedback(0, 1000, 40, 50);
71 66
72 EXPECT_TRUE(results_.empty()); 67 EXPECT_EQ(measured_bps_, INVALID_BPS);
73 } 68 }
74 69
75 TEST_F(TestProbeBitrateEstimator, SlowReceive) { 70 TEST_F(TestProbeBitrateEstimator, SlowReceive) {
76 AddPacketFeedback(0, 1000, 0, 10); 71 AddPacketFeedback(0, 1000, 0, 10);
77 AddPacketFeedback(0, 1000, 10, 40); 72 AddPacketFeedback(0, 1000, 10, 40);
78 AddPacketFeedback(0, 1000, 20, 70); 73 AddPacketFeedback(0, 1000, 20, 70);
79 AddPacketFeedback(0, 1000, 30, 85); 74 AddPacketFeedback(0, 1000, 30, 85);
80 75
81 CheckResult(0, 320000, 10, 85); 76 EXPECT_NEAR(measured_bps_, 320000, 10);
82 } 77 }
83 78
84 TEST_F(TestProbeBitrateEstimator, BurstReceive) { 79 TEST_F(TestProbeBitrateEstimator, BurstReceive) {
85 AddPacketFeedback(0, 1000, 0, 50); 80 AddPacketFeedback(0, 1000, 0, 50);
86 AddPacketFeedback(0, 1000, 10, 50); 81 AddPacketFeedback(0, 1000, 10, 50);
87 AddPacketFeedback(0, 1000, 20, 50); 82 AddPacketFeedback(0, 1000, 20, 50);
88 AddPacketFeedback(0, 1000, 40, 50); 83 AddPacketFeedback(0, 1000, 40, 50);
89 84
90 EXPECT_TRUE(results_.empty()); 85 EXPECT_EQ(measured_bps_, INVALID_BPS);
91 } 86 }
92 87
93 TEST_F(TestProbeBitrateEstimator, MultipleClusters) { 88 TEST_F(TestProbeBitrateEstimator, MultipleClusters) {
94 AddPacketFeedback(0, 1000, 0, 10); 89 AddPacketFeedback(0, 1000, 0, 10);
95 AddPacketFeedback(0, 1000, 10, 20); 90 AddPacketFeedback(0, 1000, 10, 20);
96 AddPacketFeedback(0, 1000, 20, 30); 91 AddPacketFeedback(0, 1000, 20, 30);
97 AddPacketFeedback(0, 1000, 40, 60); 92 AddPacketFeedback(0, 1000, 40, 60);
93
94 EXPECT_NEAR(measured_bps_, 480000, 10);
95
98 AddPacketFeedback(0, 1000, 50, 60); 96 AddPacketFeedback(0, 1000, 50, 60);
99 97
100 CheckResult(0, 480000, 10, 60); 98 EXPECT_NEAR(measured_bps_, 640000, 10);
101 CheckResult(1, 640000, 10, 60);
102 99
103 AddPacketFeedback(1, 1000, 60, 70); 100 AddPacketFeedback(1, 1000, 60, 70);
104 AddPacketFeedback(1, 1000, 65, 77); 101 AddPacketFeedback(1, 1000, 65, 77);
105 AddPacketFeedback(1, 1000, 70, 84); 102 AddPacketFeedback(1, 1000, 70, 84);
106 AddPacketFeedback(1, 1000, 75, 90); 103 AddPacketFeedback(1, 1000, 75, 90);
107 104
108 CheckResult(2, 1200000, 10, 90); 105 EXPECT_NEAR(measured_bps_, 1200000, 10);
109 } 106 }
110 107
111 TEST_F(TestProbeBitrateEstimator, OldProbe) { 108 TEST_F(TestProbeBitrateEstimator, IgnoreOldClusters) {
112 AddPacketFeedback(0, 1000, 0, 10); 109 AddPacketFeedback(0, 1000, 0, 10);
113 AddPacketFeedback(0, 1000, 10, 20); 110 AddPacketFeedback(0, 1000, 10, 20);
114 AddPacketFeedback(0, 1000, 20, 30); 111 AddPacketFeedback(0, 1000, 20, 30);
115 112
116 AddPacketFeedback(1, 1000, 60, 70); 113 AddPacketFeedback(1, 1000, 60, 70);
117 AddPacketFeedback(1, 1000, 65, 77); 114 AddPacketFeedback(1, 1000, 65, 77);
118 AddPacketFeedback(1, 1000, 70, 84); 115 AddPacketFeedback(1, 1000, 70, 84);
119 AddPacketFeedback(1, 1000, 75, 90); 116 AddPacketFeedback(1, 1000, 75, 90);
120 117
121 CheckResult(0, 1200000, 10, 90); 118 EXPECT_NEAR(measured_bps_, 1200000, 10);
122 119
123 AddPacketFeedback(0, 1000, 40, 60); 120 // Coming in 6s later
121 AddPacketFeedback(0, 1000, 40 + 6000, 60 + 6000);
124 122
125 EXPECT_EQ(1ul, results_.size()); 123 EXPECT_EQ(measured_bps_, INVALID_BPS);
126 } 124 }
127 125
128 } // namespace webrtc 126 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/probe_bitrate_estimator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698