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 "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, Choke200kbps30kbps200kbps) {
100 VerboseLogging(true);
101 AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
102 ChokeFilter filter(this);
103 RateCounterFilter counter(this, "receiver_input");
104 filter.SetCapacity(200);
105 filter.SetMaxDelay(500);
107 filter.SetCapacity(30);
109 filter.SetCapacity(200);
113 TEST_P(BweSimulation, GoogleWifiTrace3Mbps) {
114 VerboseLogging(true);
115 AdaptiveVideoSender sender(0, this, 30, 300, 0, 0);
116 RateCounterFilter counter1(this, "sender_output");
117 TraceBasedDeliveryFilter filter(this, "link_capacity");
118 filter.SetMaxDelay(500);
119 RateCounterFilter counter2(this, "receiver_input");
120 ASSERT_TRUE(filter.Init(test::ResourcePath("google-wifi-3mbps", "rx")));
124 class MultiFlowBweSimulation : public BweSimulation {
126 MultiFlowBweSimulation() : BweSimulation() {}
127 virtual ~MultiFlowBweSimulation() {}
130 DISALLOW_COPY_AND_ASSIGN(MultiFlowBweSimulation);
133 INSTANTIATE_TEST_CASE_P(VideoSendersTest, MultiFlowBweSimulation,
134 ::testing::Values(MakeMultiFlowBweTestConfig(3)));
136 TEST_P(MultiFlowBweSimulation, SelfFairnessTest) {
137 VerboseLogging(true);
138 const int kAllFlowIds[] = {0, 1, 2};
139 const size_t kNumFlows = sizeof(kAllFlowIds) / sizeof(kAllFlowIds[0]);
140 scoped_ptr<AdaptiveVideoSender> senders[kNumFlows];
141 for (size_t i = 0; i < kNumFlows; ++i) {
142 senders[i].reset(new AdaptiveVideoSender(kAllFlowIds[i], this, 30, 300, 0,
145 // Second and third flow.
146 ChokeFilter choke(this, CreateFlowIds(&kAllFlowIds[1], 2));
147 choke.SetCapacity(1500);
149 ChokeFilter choke2(this, CreateFlowIds(&kAllFlowIds[0], 1));
150 choke2.SetCapacity(1000);
152 scoped_ptr<RateCounterFilter> rate_counters[kNumFlows];
153 for (size_t i = 0; i < kNumFlows; ++i) {
154 rate_counters[i].reset(new RateCounterFilter(
155 this, CreateFlowIds(&kAllFlowIds[i], 1), "receiver_input"));
157 RunFor(30 * 60 * 1000);
159 #endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
161 } // namespace testing
162 } // namespace webrtc