OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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_FEC_CONTROLLER_RPLR_BA
SED_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_RPLR_BA
SED_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_RPLR_BA
SED_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_RPLR_BA
SED_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/base/constructormagic.h" | 16 #include "webrtc/base/constructormagic.h" |
17 #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h" | 17 #include "webrtc/modules/audio_coding/audio_network_adaptor/controller.h" |
| 18 #include "webrtc/modules/audio_coding/audio_network_adaptor/util/threshold_curve
.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 class FecControllerRplrBased final : public Controller { | 22 class FecControllerRplrBased final : public Controller { |
22 public: | 23 public: |
23 struct Config { | 24 struct Config { |
24 struct Threshold { | |
25 // Threshold defines a curve in the bandwidth/packet-loss domain. The | |
26 // curve is characterized by the two conjunction points: A and B. | |
27 // | |
28 // recoverable | |
29 // packet ^ | | |
30 // loss | A | | |
31 // | \ A: (low_bandwidth_bps, | |
32 // | \ low_bandwidth_recoverable_packet_loss) | |
33 // | \ B: (high_bandwidth_bps, | |
34 // | \ high_bandwidth_recoverable_packet_loss) | |
35 // | B \________ | |
36 // |---------------> bandwidth | |
37 Threshold(int low_bandwidth_bps, | |
38 float low_bandwidth_recoverable_packet_loss, | |
39 int high_bandwidth_bps, | |
40 float high_bandwidth_recoverable_packet_loss); | |
41 int low_bandwidth_bps; | |
42 float low_bandwidth_recoverable_packet_loss; | |
43 int high_bandwidth_bps; | |
44 float high_bandwidth_recoverable_packet_loss; | |
45 }; | |
46 | |
47 // |fec_enabling_threshold| defines a curve, above which FEC should be | 25 // |fec_enabling_threshold| defines a curve, above which FEC should be |
48 // enabled. |fec_disabling_threshold| defines a curve, under which FEC | 26 // enabled. |fec_disabling_threshold| defines a curve, under which FEC |
49 // should be disabled. See below | 27 // should be disabled. See below |
50 // | 28 // |
51 // recoverable | 29 // recoverable |
52 // packet-loss ^ | | | 30 // packet-loss ^ | | |
53 // | | | FEC | 31 // | | | FEC |
54 // | \ \ ON | 32 // | \ \ ON |
55 // | FEC \ \_______ fec_enabling_threshold | 33 // | FEC \ \_______ fec_enabling_threshold |
56 // | OFF \_________ fec_disabling_threshold | 34 // | OFF \_________ fec_disabling_threshold |
57 // |-----------------> bandwidth | 35 // |-----------------> bandwidth |
58 Config(bool initial_fec_enabled, | 36 Config(bool initial_fec_enabled, |
59 const Threshold& fec_enabling_threshold, | 37 const ThresholdCurve& fec_enabling_threshold, |
60 const Threshold& fec_disabling_threshold); | 38 const ThresholdCurve& fec_disabling_threshold); |
61 bool initial_fec_enabled; | 39 bool initial_fec_enabled; |
62 Threshold fec_enabling_threshold; | 40 ThresholdCurve fec_enabling_threshold; |
63 Threshold fec_disabling_threshold; | 41 ThresholdCurve fec_disabling_threshold; |
64 }; | 42 }; |
65 | 43 |
66 explicit FecControllerRplrBased(const Config& config); | 44 explicit FecControllerRplrBased(const Config& config); |
67 | 45 |
68 ~FecControllerRplrBased() override; | 46 ~FecControllerRplrBased() override; |
69 | 47 |
70 void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override; | 48 void UpdateNetworkMetrics(const NetworkMetrics& network_metrics) override; |
71 | 49 |
72 void MakeDecision(AudioNetworkAdaptor::EncoderRuntimeConfig* config) override; | 50 void MakeDecision(AudioNetworkAdaptor::EncoderRuntimeConfig* config) override; |
73 | 51 |
74 private: | 52 private: |
75 // Characterize Threshold with: | |
76 // recoverable_packet_loss = slope * bandwidth + offset. | |
77 struct ThresholdInfo { | |
78 explicit ThresholdInfo(const Config::Threshold& threshold); | |
79 float slope; | |
80 float offset; | |
81 }; | |
82 | |
83 float GetPacketLossThreshold(int bandwidth_bps, | |
84 const Config::Threshold& threshold, | |
85 const ThresholdInfo& threshold_info) const; | |
86 | |
87 bool FecEnablingDecision() const; | 53 bool FecEnablingDecision() const; |
88 bool FecDisablingDecision() const; | 54 bool FecDisablingDecision() const; |
89 | 55 |
90 const Config config_; | 56 const Config config_; |
91 bool fec_enabled_; | 57 bool fec_enabled_; |
92 rtc::Optional<int> uplink_bandwidth_bps_; | 58 rtc::Optional<int> uplink_bandwidth_bps_; |
93 rtc::Optional<float> uplink_recoverable_packet_loss_; | 59 rtc::Optional<float> uplink_recoverable_packet_loss_; |
94 | 60 |
95 const ThresholdInfo fec_enabling_threshold_info_; | |
96 const ThresholdInfo fec_disabling_threshold_info_; | |
97 | |
98 RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerRplrBased); | 61 RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerRplrBased); |
99 }; | 62 }; |
100 | 63 |
101 } // namespace webrtc | 64 } // namespace webrtc |
102 | 65 |
103 #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_RPLR
_BASED_H_ | 66 #endif // WEBRTC_MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_FEC_CONTROLLER_RPLR
_BASED_H_ |
OLD | NEW |