Home | History | Annotate | Download | only in remote_bitrate_estimator
      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 "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, 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);
    106   RunFor(60 * 1000);
    107   filter.SetCapacity(30);
    108   RunFor(60 * 1000);
    109   filter.SetCapacity(200);
    110   RunFor(60 * 1000);
    111 }
    112 
    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")));
    121   RunFor(300 * 1000);
    122 }
    123 
    124 class MultiFlowBweSimulation : public BweSimulation {
    125  public:
    126   MultiFlowBweSimulation() : BweSimulation() {}
    127   virtual ~MultiFlowBweSimulation() {}
    128 
    129  private:
    130   DISALLOW_COPY_AND_ASSIGN(MultiFlowBweSimulation);
    131 };
    132 
    133 INSTANTIATE_TEST_CASE_P(VideoSendersTest, MultiFlowBweSimulation,
    134     ::testing::Values(MakeMultiFlowBweTestConfig(3)));
    135 
    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,
    143                                              0));
    144   }
    145   // Second and third flow.
    146   ChokeFilter choke(this, CreateFlowIds(&kAllFlowIds[1], 2));
    147   choke.SetCapacity(1500);
    148   // First flow.
    149   ChokeFilter choke2(this, CreateFlowIds(&kAllFlowIds[0], 1));
    150   choke2.SetCapacity(1000);
    151 
    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"));
    156   }
    157   RunFor(30 * 60 * 1000);
    158 }
    159 #endif  // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE
    160 }  // namespace bwe
    161 }  // namespace testing
    162 }  // namespace webrtc
    163