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