LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/audio_coding/audio_network_adaptor - controller_manager.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 4 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2016 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             : #ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_
      12             : #define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_
      13             : 
      14             : #include <map>
      15             : #include <memory>
      16             : #include <vector>
      17             : 
      18             : #include "webrtc/base/constructormagic.h"
      19             : #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h"
      20             : 
      21             : namespace webrtc {
      22             : 
      23             : class Clock;
      24             : 
      25           0 : class ControllerManager {
      26             :  public:
      27           0 :   virtual ~ControllerManager() = default;
      28             : 
      29             :   // Sort controllers based on their significance.
      30             :   virtual std::vector<Controller*> GetSortedControllers(
      31             :       const Controller::NetworkMetrics& metrics) = 0;
      32             : 
      33             :   virtual std::vector<Controller*> GetControllers() const = 0;
      34             : };
      35             : 
      36           0 : class ControllerManagerImpl final : public ControllerManager {
      37             :  public:
      38           0 :   struct Config {
      39             :     Config(int min_reordering_time_ms,
      40             :            float min_reordering_squared_distance,
      41             :            const Clock* clock);
      42             :     ~Config();
      43             :     // Least time since last reordering for a new reordering to be made.
      44             :     int min_reordering_time_ms;
      45             :     // Least squared distance from last scoring point for a new reordering to be
      46             :     // made.
      47             :     float min_reordering_squared_distance;
      48             :     const Clock* clock;
      49             :   };
      50             : 
      51             :   static std::unique_ptr<ControllerManager> Create(
      52             :       const std::string& config_string,
      53             :       size_t num_encoder_channels,
      54             :       rtc::ArrayView<const int> encoder_frame_lengths_ms,
      55             :       size_t intial_channels_to_encode,
      56             :       int initial_frame_length_ms,
      57             :       int initial_bitrate_bps,
      58             :       bool initial_fec_enabled,
      59             :       bool initial_dtx_enabled,
      60             :       const Clock* clock);
      61             : 
      62             :   explicit ControllerManagerImpl(const Config& config);
      63             : 
      64             :   // Dependency injection for testing.
      65             :   ControllerManagerImpl(
      66             :       const Config& config,
      67             :       std::vector<std::unique_ptr<Controller>>&& controllers,
      68             :       const std::map<const Controller*, std::pair<int, float>>&
      69             :           chracteristic_points);
      70             : 
      71             :   ~ControllerManagerImpl() override;
      72             : 
      73             :   // Sort controllers based on their significance.
      74             :   std::vector<Controller*> GetSortedControllers(
      75             :       const Controller::NetworkMetrics& metrics) override;
      76             : 
      77             :   std::vector<Controller*> GetControllers() const override;
      78             : 
      79             :  private:
      80             :   // Scoring point is a subset of NetworkMetrics that is used for comparing the
      81             :   // significance of controllers.
      82             :   struct ScoringPoint {
      83             :     ScoringPoint(int uplink_bandwidth_bps, float uplink_packet_loss_fraction);
      84             : 
      85             :     // Calculate the normalized [0,1] distance between two scoring points.
      86             :     float SquaredDistanceTo(const ScoringPoint& scoring_point) const;
      87             : 
      88             :     int uplink_bandwidth_bps;
      89             :     float uplink_packet_loss_fraction;
      90             :   };
      91             : 
      92             :   const Config config_;
      93             : 
      94             :   std::vector<std::unique_ptr<Controller>> controllers_;
      95             : 
      96             :   rtc::Optional<int64_t> last_reordering_time_ms_;
      97             :   ScoringPoint last_scoring_point_;
      98             : 
      99             :   std::vector<Controller*> default_sorted_controllers_;
     100             : 
     101             :   std::vector<Controller*> sorted_controllers_;
     102             : 
     103             :   // |scoring_points_| saves the characteristic scoring points of various
     104             :   // controllers.
     105             :   std::map<const Controller*, ScoringPoint> controller_scoring_points_;
     106             : 
     107             :   RTC_DISALLOW_COPY_AND_ASSIGN(ControllerManagerImpl);
     108             : };
     109             : 
     110             : }  // namespace webrtc
     111             : 
     112             : #endif  // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_

Generated by: LCOV version 1.13