9e71ead6637892a6739a930922af1df62095e11f
[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 "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
12 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test.h"
13 #include "webrtc/test/testsupport/fileutils.h"
14
15 namespace webrtc {
16 namespace testing {
17 namespace bwe {
18 #if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
19 std::vector<BweTestConfig::EstimatorConfig> SingleEstimatorConfig() {
20   static const AbsoluteSendTimeRemoteBitrateEstimatorFactory factory =
21       AbsoluteSendTimeRemoteBitrateEstimatorFactory();
22
23   std::vector<BweTestConfig::EstimatorConfig> result;
24   result.push_back(BweTestConfig::EstimatorConfig("AST", &factory, kAimdControl,
25                                                   false));
26   return result;
27 }
28
29 std::vector<const PacketSenderFactory*> AdaptiveVideoSenderFactories(
30     uint32_t count) {
31   static const AdaptiveVideoPacketSenderFactory factories[] = {
32     AdaptiveVideoPacketSenderFactory(30.00f, 150, 0x1234, 0.13f),
33     AdaptiveVideoPacketSenderFactory(30.00f, 300, 0x3456, 0.26f),
34     AdaptiveVideoPacketSenderFactory(15.00f, 600, 0x4567, 0.39f),
35   };
36
37   assert(count <= sizeof(factories) / sizeof(factories[0]));
38
39   std::vector<const PacketSenderFactory*> result;
40   for (uint32_t i = 0; i < count; ++i) {
41     result.push_back(&factories[i]);
42   }
43   return result;
44 }
45
46 BweTestConfig MakeAdaptiveBweTestConfig(uint32_t sender_count) {
47   BweTestConfig result = {
48     AdaptiveVideoSenderFactories(sender_count), SingleEstimatorConfig()
49   };
50   return result;
51 }
52
53 // This test fixture is used to instantiate tests running with adaptive video
54 // senders.
55 class BweSimulation : public BweTest {
56  public:
57   BweSimulation() : BweTest() {}
58   virtual ~BweSimulation() {}
59
60  private:
61   DISALLOW_COPY_AND_ASSIGN(BweSimulation);
62 };
63
64 INSTANTIATE_TEST_CASE_P(VideoSendersTest, BweSimulation,
65     ::testing::Values(MakeAdaptiveBweTestConfig(1),
66                       MakeAdaptiveBweTestConfig(3)));
67
68 TEST_P(BweSimulation, SprintUplinkTest) {
69   VerboseLogging(true);
70   RateCounterFilter counter1(this, "sender_output");
71   TraceBasedDeliveryFilter filter(this, "link_capacity");
72   RateCounterFilter counter2(this, "receiver_input");
73   ASSERT_TRUE(filter.Init(test::ResourcePath("sprint-uplink", "rx")));
74   RunFor(60 * 1000);
75 }
76
77 TEST_P(BweSimulation, Verizon4gDownlinkTest) {
78   VerboseLogging(true);
79   RateCounterFilter counter1(this, "sender_output");
80   TraceBasedDeliveryFilter filter(this, "link_capacity");
81   RateCounterFilter counter2(this, "receiver_input");
82   ASSERT_TRUE(filter.Init(test::ResourcePath("verizon4g-downlink", "rx")));
83   RunFor(22 * 60 * 1000);
84 }
85 #endif  // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
86 }  // namespace bwe
87 }  // namespace testing
88 }  // namespace webrtc