Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_H_ |
| 13 | 13 |
| 14 #include <map> | |
| 14 #include <memory> | 15 #include <memory> |
| 15 #include <vector> | 16 #include <vector> |
| 16 | 17 |
| 17 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
| 18 #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h" | 19 #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 | 22 |
| 23 class Clock; | |
| 24 | |
| 22 class ControllerManager { | 25 class ControllerManager { |
| 23 public: | 26 public: |
| 24 virtual ~ControllerManager() = default; | 27 virtual ~ControllerManager() = default; |
| 25 | 28 |
| 26 // Sort controllers based on their significance. | 29 // Sort controllers based on their significance. |
| 27 virtual std::vector<Controller*> GetSortedControllers( | 30 virtual std::vector<Controller*> GetSortedControllers( |
| 28 const Controller::NetworkMetrics& metrics) = 0; | 31 const Controller::NetworkMetrics& metrics) = 0; |
| 29 | 32 |
| 30 virtual std::vector<Controller*> GetControllers() const = 0; | 33 virtual std::vector<Controller*> GetControllers() const = 0; |
| 31 }; | 34 }; |
| 32 | 35 |
| 33 class ControllerManagerImpl final : public ControllerManager { | 36 class ControllerManagerImpl final : public ControllerManager { |
| 34 public: | 37 public: |
| 35 struct Config { | 38 struct Config { |
| 36 Config(); | 39 Config(int min_reordering_time_ms, |
| 40 float min_reordering_squared_distance, | |
| 41 const Clock* clock); | |
| 37 ~Config(); | 42 ~Config(); |
| 43 int min_reordering_time_ms; | |
| 44 float min_reordering_squared_distance; | |
| 45 const Clock* clock; | |
| 38 }; | 46 }; |
| 39 | 47 |
| 40 explicit ControllerManagerImpl(const Config& config); | 48 explicit ControllerManagerImpl(const Config& config); |
| 41 | 49 |
| 42 // Dependency injection for testing. | 50 // Dependency injection for testing. |
| 43 ControllerManagerImpl(const Config& config, | 51 ControllerManagerImpl( |
| 44 std::vector<std::unique_ptr<Controller>> controllers); | 52 const Config& config, |
| 53 std::vector<std::unique_ptr<Controller>>&& controllers, | |
|
minyue-webrtc
2016/09/21 07:42:59
I switched order to 2nd and 3rd args. It reads mor
hlundin-webrtc
2016/09/21 12:39:45
Acknowledged.
| |
| 54 const std::map<const Controller*, std::pair<int, float>>& | |
| 55 chracteristic_points); | |
| 45 | 56 |
| 46 ~ControllerManagerImpl() override; | 57 ~ControllerManagerImpl() override; |
| 47 | 58 |
| 48 // Sort controllers based on their significance. | 59 // Sort controllers based on their significance. |
| 49 std::vector<Controller*> GetSortedControllers( | 60 std::vector<Controller*> GetSortedControllers( |
| 50 const Controller::NetworkMetrics& metrics) override; | 61 const Controller::NetworkMetrics& metrics) override; |
| 51 | 62 |
| 52 std::vector<Controller*> GetControllers() const override; | 63 std::vector<Controller*> GetControllers() const override; |
| 53 | 64 |
| 54 private: | 65 private: |
| 66 // Scoring point is a subset of NetworkMetrics that is used for comparing the | |
| 67 // significance of controllers. | |
| 68 struct ScoringPoint { | |
| 69 ScoringPoint(int uplink_bandwidth_bps, float uplink_packet_loss_fraction); | |
| 70 | |
| 71 // Calculate the normalized [0,1] distance between two scoring points. | |
| 72 float SquaredDistanceTo(const ScoringPoint& scoring_point) const; | |
| 73 | |
| 74 int uplink_bandwidth_bps; | |
| 75 float uplink_packet_loss_fraction; | |
| 76 }; | |
| 77 | |
| 55 const Config config_; | 78 const Config config_; |
| 56 | 79 |
| 57 std::vector<std::unique_ptr<Controller>> controllers_; | 80 std::vector<std::unique_ptr<Controller>> controllers_; |
| 58 | 81 |
| 82 rtc::Optional<int64_t> last_reordering_time_ms_; | |
| 83 ScoringPoint last_scoring_point_; | |
| 84 | |
| 59 std::vector<Controller*> default_sorted_controllers_; | 85 std::vector<Controller*> default_sorted_controllers_; |
| 60 | 86 |
| 87 std::vector<Controller*> sorted_controllers_; | |
| 88 | |
| 89 // |scoring_points_| saves the characteristic scoring points of various | |
| 90 // controllers. | |
| 91 std::map<const Controller*, ScoringPoint> controller_scoring_points_; | |
| 92 | |
| 61 RTC_DISALLOW_COPY_AND_ASSIGN(ControllerManagerImpl); | 93 RTC_DISALLOW_COPY_AND_ASSIGN(ControllerManagerImpl); |
| 62 }; | 94 }; |
| 63 | 95 |
| 64 } // namespace webrtc | 96 } // namespace webrtc |
| 65 | 97 |
| 66 #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_ H_ | 98 #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_ H_ |
| OLD | NEW |