2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
13 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test.h"
14 #include "webrtc/test/testsupport/fileutils.h"
21 #if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
22 BweTestConfig::EstimatorConfig CreateEstimatorConfig(
23 int flow_id, bool plot_delay, bool plot_estimate) {
24 static const AbsoluteSendTimeRemoteBitrateEstimatorFactory factory =
25 AbsoluteSendTimeRemoteBitrateEstimatorFactory();
27 return BweTestConfig::EstimatorConfig("AST", flow_id, &factory, kAimdControl,
28 plot_delay, plot_estimate);
31 BweTestConfig MakeAdaptiveBweTestConfig() {
33 result.estimator_configs.push_back(CreateEstimatorConfig(0, true, true));
37 BweTestConfig MakeMultiFlowBweTestConfig(int flow_count) {
39 for (int i = 0; i < flow_count; ++i) {
40 result.estimator_configs.push_back(CreateEstimatorConfig(i, false, true));
45 // This test fixture is used to instantiate tests running with adaptive video
47 class BweSimulation : public BweTest,
48 public ::testing::TestWithParam<BweTestConfig> {
50 BweSimulation() : BweTest() {}
51 virtual ~BweSimulation() {}
53 virtual void SetUp() {
54 const BweTestConfig& config = GetParam();
55 SetupTestFromConfig(config);
59 DISALLOW_COPY_AND_ASSIGN(BweSimulation);
62 INSTANTIATE_TEST_CASE_P(VideoSendersTest, BweSimulation,
63 ::testing::Values(MakeAdaptiveBweTestConfig()));
65 TEST_P(BweSimulation, SprintUplinkTest) {
67 AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
68 RateCounterFilter counter1(this, "sender_output");
69 TraceBasedDeliveryFilter filter(this, "link_capacity");
70 RateCounterFilter counter2(this, "receiver_input");
71 ASSERT_TRUE(filter.Init(test::ResourcePath("sprint-uplink", "rx")));
75 TEST_P(BweSimulation, Verizon4gDownlinkTest) {
77 AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
78 RateCounterFilter counter1(this, "sender_output");
79 TraceBasedDeliveryFilter filter(this, "link_capacity");
80 RateCounterFilter counter2(this, "receiver_input");
81 ASSERT_TRUE(filter.Init(test::ResourcePath("verizon4g-downlink", "rx")));
82 RunFor(22 * 60 * 1000);
85 TEST_P(BweSimulation, Choke1000kbps500kbps1000kbps) {
87 AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
88 ChokeFilter filter(this);
89 RateCounterFilter counter(this, "receiver_input");
90 filter.SetCapacity(1000);
91 filter.SetMaxDelay(500);
93 filter.SetCapacity(500);
95 filter.SetCapacity(1000);
99 TEST_P(BweSimulation, PacerChoke1000kbps500kbps1000kbps) {
100 VerboseLogging(true);
101 PeriodicKeyFrameSender source(0, NULL, 30, 300, 0, 0, 1000);
102 PacedVideoSender sender(this, 300, &source);
103 ChokeFilter filter(this);
104 RateCounterFilter counter(this, "receiver_input");
105 filter.SetCapacity(1000);
106 filter.SetMaxDelay(500);
108 filter.SetCapacity(500);
110 filter.SetCapacity(1000);
114 TEST_P(BweSimulation, PacerChoke10000kbps) {
115 VerboseLogging(true);
116 PeriodicKeyFrameSender source(0, NULL, 30, 300, 0, 0, 0);
117 PacedVideoSender sender(this, 300, &source);
118 ChokeFilter filter(this);
119 RateCounterFilter counter(this, "receiver_input");
120 filter.SetCapacity(10000);
121 filter.SetMaxDelay(500);
125 TEST_P(BweSimulation, PacerChoke200kbps30kbps200kbps) {
126 VerboseLogging(true);
127 PeriodicKeyFrameSender source(0, NULL, 30, 300, 0, 0, 1000);
128 PacedVideoSender sender(this, 300, &source);
129 ChokeFilter filter(this);
130 RateCounterFilter counter(this, "receiver_input");
131 filter.SetCapacity(200);
132 filter.SetMaxDelay(500);
134 filter.SetCapacity(30);
136 filter.SetCapacity(200);
140 TEST_P(BweSimulation, Choke200kbps30kbps200kbps) {
141 VerboseLogging(true);
142 AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
143 ChokeFilter filter(this);
144 RateCounterFilter counter(this, "receiver_input");
145 filter.SetCapacity(200);
146 filter.SetMaxDelay(500);
148 filter.SetCapacity(30);
150 filter.SetCapacity(200);
154 TEST_P(BweSimulation, GoogleWifiTrace3Mbps) {
155 VerboseLogging(true);
156 AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
157 RateCounterFilter counter1(this, "sender_output");
158 TraceBasedDeliveryFilter filter(this, "link_capacity");
159 filter.SetMaxDelay(500);
160 RateCounterFilter counter2(this, "receiver_input");
161 ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
165 TEST_P(BweSimulation, PacerGoogleWifiTrace3Mbps) {
166 VerboseLogging(true);
167 PeriodicKeyFrameSender source(0, NULL, 30, 300, 0, 0, 1000);
168 PacedVideoSender sender(this, 300, &source);
169 RateCounterFilter counter1(this, "sender_output");
170 TraceBasedDeliveryFilter filter(this, "link_capacity");
171 filter.SetMaxDelay(500);
172 RateCounterFilter counter2(this, "receiver_input");
173 ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
177 class MultiFlowBweSimulation : public BweSimulation {
179 MultiFlowBweSimulation() : BweSimulation() {}
180 virtual ~MultiFlowBweSimulation() {}
183 DISALLOW_COPY_AND_ASSIGN(MultiFlowBweSimulation);
186 INSTANTIATE_TEST_CASE_P(VideoSendersTest, MultiFlowBweSimulation,
187 ::testing::Values(MakeMultiFlowBweTestConfig(3)));
189 TEST_P(MultiFlowBweSimulation, SelfFairnessTest) {
190 VerboseLogging(true);
191 const int kAllFlowIds[] = {0, 1, 2};
192 const size_t kNumFlows = sizeof(kAllFlowIds) / sizeof(kAllFlowIds[0]);
193 scoped_ptr<AdaptiveVideoSender> senders[kNumFlows];
194 for (size_t i = 0; i < kNumFlows; ++i) {
195 senders[i].reset(new AdaptiveVideoSender(kAllFlowIds[i], this, 30, 300, 0,
198 // Second and third flow.
199 ChokeFilter choke(this, CreateFlowIds(&kAllFlowIds[1], 2));
200 choke.SetCapacity(1500);
202 ChokeFilter choke2(this, CreateFlowIds(&kAllFlowIds[0], 1));
203 choke2.SetCapacity(1000);
205 scoped_ptr<RateCounterFilter> rate_counters[kNumFlows];
206 for (size_t i = 0; i < kNumFlows; ++i) {
207 rate_counters[i].reset(new RateCounterFilter(
208 this, CreateFlowIds(&kAllFlowIds[i], 1), "receiver_input"));
210 RunFor(30 * 60 * 1000);
212 #endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
214 } // namespace testing
215 } // namespace webrtc