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

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

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

Powered by Google App Engine
This is Rietveld 408576698