Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / remote_bitrate_estimator / bwe_simulations.cc
1 /*
2  *  Copyright (c) 2014 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 "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"
15
16 using std::string;
17
18 namespace webrtc {
19 namespace testing {
20 namespace bwe {
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();
26
27   return BweTestConfig::EstimatorConfig("AST", flow_id, &factory, kAimdControl,
28                                         plot_delay, plot_estimate);
29 }
30
31 BweTestConfig MakeAdaptiveBweTestConfig() {
32   BweTestConfig result;
33   result.estimator_configs.push_back(CreateEstimatorConfig(0, true, true));
34   return result;
35 }
36
37 BweTestConfig MakeMultiFlowBweTestConfig(int flow_count) {
38   BweTestConfig result;
39   for (int i = 0; i < flow_count; ++i) {
40     result.estimator_configs.push_back(CreateEstimatorConfig(i, false, true));
41   }
42   return result;
43 }
44
45 // This test fixture is used to instantiate tests running with adaptive video
46 // senders.
47 class BweSimulation : public BweTest,
48                       public ::testing::TestWithParam<BweTestConfig> {
49  public:
50   BweSimulation() : BweTest() {}
51   virtual ~BweSimulation() {}
52
53   virtual void SetUp() {
54     const BweTestConfig& config = GetParam();
55     SetupTestFromConfig(config);
56   }
57
58  private:
59   DISALLOW_COPY_AND_ASSIGN(BweSimulation);
60 };
61
62 INSTANTIATE_TEST_CASE_P(VideoSendersTest, BweSimulation,
63     ::testing::Values(MakeAdaptiveBweTestConfig()));
64
65 TEST_P(BweSimulation, SprintUplinkTest) {
66   VerboseLogging(true);
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")));
72   RunFor(60 * 1000);
73 }
74
75 TEST_P(BweSimulation, Verizon4gDownlinkTest) {
76   VerboseLogging(true);
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);
83 }
84
85 TEST_P(BweSimulation, Choke1000kbps500kbps1000kbps) {
86   VerboseLogging(true);
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);
92   RunFor(60 * 1000);
93   filter.SetCapacity(500);
94   RunFor(60 * 1000);
95   filter.SetCapacity(1000);
96   RunFor(60 * 1000);
97 }
98
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);
107   RunFor(60 * 1000);
108   filter.SetCapacity(500);
109   RunFor(60 * 1000);
110   filter.SetCapacity(1000);
111   RunFor(60 * 1000);
112 }
113
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);
122   RunFor(60 * 1000);
123 }
124
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);
133   RunFor(60 * 1000);
134   filter.SetCapacity(30);
135   RunFor(60 * 1000);
136   filter.SetCapacity(200);
137   RunFor(60 * 1000);
138 }
139
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);
147   RunFor(60 * 1000);
148   filter.SetCapacity(30);
149   RunFor(60 * 1000);
150   filter.SetCapacity(200);
151   RunFor(60 * 1000);
152 }
153
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")));
162   RunFor(300 * 1000);
163 }
164
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")));
174   RunFor(300 * 1000);
175 }
176
177 class MultiFlowBweSimulation : public BweSimulation {
178  public:
179   MultiFlowBweSimulation() : BweSimulation() {}
180   virtual ~MultiFlowBweSimulation() {}
181
182  private:
183   DISALLOW_COPY_AND_ASSIGN(MultiFlowBweSimulation);
184 };
185
186 INSTANTIATE_TEST_CASE_P(VideoSendersTest, MultiFlowBweSimulation,
187     ::testing::Values(MakeMultiFlowBweTestConfig(3)));
188
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,
196                                              0));
197   }
198   // Second and third flow.
199   ChokeFilter choke(this, CreateFlowIds(&kAllFlowIds[1], 2));
200   choke.SetCapacity(1500);
201   // First flow.
202   ChokeFilter choke2(this, CreateFlowIds(&kAllFlowIds[0], 1));
203   choke2.SetCapacity(1000);
204
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"));
209   }
210   RunFor(30 * 60 * 1000);
211 }
212 #endif  // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
213 }  // namespace bwe
214 }  // namespace testing
215 }  // namespace webrtc