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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 private: | 35 private: |
36 rtc::Optional<float> last_sample_; | 36 rtc::Optional<float> last_sample_; |
37 }; | 37 }; |
38 } | 38 } |
39 | 39 |
40 FecControllerPlrBased::Config::Config( | 40 FecControllerPlrBased::Config::Config( |
41 bool initial_fec_enabled, | 41 bool initial_fec_enabled, |
42 const ThresholdCurve& fec_enabling_threshold, | 42 const ThresholdCurve& fec_enabling_threshold, |
43 const ThresholdCurve& fec_disabling_threshold, | 43 const ThresholdCurve& fec_disabling_threshold, |
44 int time_constant_ms, | 44 int time_constant_ms) |
45 const Clock* clock) | |
46 : initial_fec_enabled(initial_fec_enabled), | 45 : initial_fec_enabled(initial_fec_enabled), |
47 fec_enabling_threshold(fec_enabling_threshold), | 46 fec_enabling_threshold(fec_enabling_threshold), |
48 fec_disabling_threshold(fec_disabling_threshold), | 47 fec_disabling_threshold(fec_disabling_threshold), |
49 time_constant_ms(time_constant_ms), | 48 time_constant_ms(time_constant_ms) {} |
50 clock(clock) {} | |
51 | 49 |
52 FecControllerPlrBased::FecControllerPlrBased( | 50 FecControllerPlrBased::FecControllerPlrBased( |
53 const Config& config, | 51 const Config& config, |
54 std::unique_ptr<SmoothingFilter> smoothing_filter) | 52 std::unique_ptr<SmoothingFilter> smoothing_filter) |
55 : config_(config), | 53 : config_(config), |
56 fec_enabled_(config.initial_fec_enabled), | 54 fec_enabled_(config.initial_fec_enabled), |
57 packet_loss_smoother_(std::move(smoothing_filter)) { | 55 packet_loss_smoother_(std::move(smoothing_filter)) { |
58 RTC_DCHECK(config_.fec_disabling_threshold <= config_.fec_enabling_threshold); | 56 RTC_DCHECK(config_.fec_disabling_threshold <= config_.fec_enabling_threshold); |
59 } | 57 } |
60 | 58 |
61 FecControllerPlrBased::FecControllerPlrBased(const Config& config) | 59 FecControllerPlrBased::FecControllerPlrBased(const Config& config) |
62 : FecControllerPlrBased( | 60 : FecControllerPlrBased( |
63 config, | 61 config, |
64 webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled" | 62 webrtc::field_trial::FindFullName("UseTwccPlrForAna") == "Enabled" |
65 ? std::unique_ptr<NullSmoothingFilter>(new NullSmoothingFilter()) | 63 ? std::unique_ptr<NullSmoothingFilter>(new NullSmoothingFilter()) |
66 : std::unique_ptr<SmoothingFilter>( | 64 : std::unique_ptr<SmoothingFilter>( |
67 new SmoothingFilterImpl(config.time_constant_ms, | 65 new SmoothingFilterImpl(config.time_constant_ms))) {} |
68 config.clock))) {} | |
69 | 66 |
70 FecControllerPlrBased::~FecControllerPlrBased() = default; | 67 FecControllerPlrBased::~FecControllerPlrBased() = default; |
71 | 68 |
72 void FecControllerPlrBased::UpdateNetworkMetrics( | 69 void FecControllerPlrBased::UpdateNetworkMetrics( |
73 const NetworkMetrics& network_metrics) { | 70 const NetworkMetrics& network_metrics) { |
74 if (network_metrics.uplink_bandwidth_bps) | 71 if (network_metrics.uplink_bandwidth_bps) |
75 uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps; | 72 uplink_bandwidth_bps_ = network_metrics.uplink_bandwidth_bps; |
76 if (network_metrics.uplink_packet_loss_fraction) { | 73 if (network_metrics.uplink_packet_loss_fraction) { |
77 packet_loss_smoother_->AddSample( | 74 packet_loss_smoother_->AddSample( |
78 *network_metrics.uplink_packet_loss_fraction); | 75 *network_metrics.uplink_packet_loss_fraction); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 if (!uplink_bandwidth_bps_ || !packet_loss) { | 107 if (!uplink_bandwidth_bps_ || !packet_loss) { |
111 return false; | 108 return false; |
112 } else { | 109 } else { |
113 // Disable when below the curve or exactly on it. | 110 // Disable when below the curve or exactly on it. |
114 return !config_.fec_disabling_threshold.IsAboveCurve( | 111 return !config_.fec_disabling_threshold.IsAboveCurve( |
115 {static_cast<float>(*uplink_bandwidth_bps_), *packet_loss}); | 112 {static_cast<float>(*uplink_bandwidth_bps_), *packet_loss}); |
116 } | 113 } |
117 } | 114 } |
118 | 115 |
119 } // namespace webrtc | 116 } // namespace webrtc |
OLD | NEW |