Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: webrtc/modules/audio_coding/audio_network_adaptor/controller_manager.h

Issue 2349113002: Adding reordering logic in audio network adaptor. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
20 #include "webrtc/system_wrappers/include/clock.h"
hlundin-webrtc 2016/09/20 08:44:01 Forward-declare here, and include in .cc and unit
minyue-webrtc 2016/09/21 07:42:58 Done.
19 21
20 namespace webrtc { 22 namespace webrtc {
21 23
22 class ControllerManager { 24 class ControllerManager {
23 public: 25 public:
24 virtual ~ControllerManager() = default; 26 virtual ~ControllerManager() = default;
25 27
26 // Sort controllers based on their significance. 28 // Sort controllers based on their significance.
27 virtual std::vector<Controller*> GetSortedControllers( 29 virtual std::vector<Controller*> GetSortedControllers(
28 const Controller::NetworkMetrics& metrics) = 0; 30 const Controller::NetworkMetrics& metrics) = 0;
29 31
30 virtual std::vector<Controller*> GetControllers() const = 0; 32 virtual std::vector<Controller*> GetControllers() const = 0;
31 }; 33 };
32 34
33 class ControllerManagerImpl final : public ControllerManager { 35 class ControllerManagerImpl final : public ControllerManager {
34 public: 36 public:
35 struct Config { 37 struct Config {
36 Config(); 38 Config(int min_reordering_time_ms,
39 float min_reordering_squared_distance,
40 Clock* clock);
37 ~Config(); 41 ~Config();
42 int min_reordering_time_ms;
43 float min_reordering_squared_distance;
44 Clock* clock;
38 }; 45 };
39 46
40 explicit ControllerManagerImpl(const Config& config); 47 explicit ControllerManagerImpl(const Config& config);
41 48
42 // Dependency injection for testing. 49 // Dependency injection for testing.
43 ControllerManagerImpl(const Config& config, 50 ControllerManagerImpl(
44 std::vector<std::unique_ptr<Controller>> controllers); 51 const Config& config,
52 const std::map<const Controller*, std::pair<int, float>>&
53 chracteristic_points,
54 std::vector<std::unique_ptr<Controller>> controllers);
michaelt 2016/09/19 08:22:45 How a bout a vector with a pair with std::unique_p
minyue-webrtc 2016/09/19 10:06:58 I like the idea, but I want to keep ScoringPoint p
hlundin-webrtc 2016/09/20 08:44:00 It's not immediately clear that |controllers| is a
minyue-webrtc 2016/09/21 07:42:58 rvalue notation is very new to me. But I think it
45 55
46 ~ControllerManagerImpl() override; 56 ~ControllerManagerImpl() override;
47 57
48 // Sort controllers based on their significance. 58 // Sort controllers based on their significance.
49 std::vector<Controller*> GetSortedControllers( 59 std::vector<Controller*> GetSortedControllers(
50 const Controller::NetworkMetrics& metrics) override; 60 const Controller::NetworkMetrics& metrics) override;
51 61
52 std::vector<Controller*> GetControllers() const override; 62 std::vector<Controller*> GetControllers() const override;
53 63
54 private: 64 private:
65 // Scoring point is a subset of NetworkMetrics that is used for comparing the
66 // significance of controllers.
67 struct ScoringPoint {
68 ScoringPoint(int uplink_bandwidth_bps, float uplink_packet_loss_fraction);
69
70 // Calculate the normalized [0,1] distance between two scoring points.
71 float SquaredDistanceTo(const ScoringPoint& scoring_point) const;
72
73 int uplink_bandwidth_bps;
74 float uplink_packet_loss_fraction;
75 };
76
55 const Config config_; 77 const Config config_;
56 78
57 std::vector<std::unique_ptr<Controller>> controllers_; 79 std::vector<std::unique_ptr<Controller>> controllers_;
58 80
81 rtc::Optional<int64_t> last_reordering_time_ms_;
82 ScoringPoint last_scoring_point_;
83
59 std::vector<Controller*> default_sorted_controllers_; 84 std::vector<Controller*> default_sorted_controllers_;
60 85
86 std::vector<Controller*> sorted_controllers_;
87
88 // |scoring_points_| saves the characteristic scoring points of various
89 // controllers.
90 std::map<const Controller*, ScoringPoint> controller_scoring_points_;
91
61 RTC_DISALLOW_COPY_AND_ASSIGN(ControllerManagerImpl); 92 RTC_DISALLOW_COPY_AND_ASSIGN(ControllerManagerImpl);
62 }; 93 };
63 94
64 } // namespace webrtc 95 } // namespace webrtc
65 96
66 #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_ H_ 97 #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_MANAGER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698