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 18 matching lines...) Expand all Loading... |
29 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" | 29 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" |
30 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" | 30 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" |
31 | 31 |
32 namespace webrtc { | 32 namespace webrtc { |
33 | 33 |
34 class DelayBasedBwe { | 34 class DelayBasedBwe { |
35 public: | 35 public: |
36 static const int64_t kStreamTimeOutMs = 2000; | 36 static const int64_t kStreamTimeOutMs = 2000; |
37 | 37 |
38 struct Result { | 38 struct Result { |
39 Result() : updated(false), probe(false), target_bitrate_bps(0) {} | 39 Result() |
| 40 : updated(false), |
| 41 probe(false), |
| 42 overusing(false), |
| 43 target_bitrate_bps(0) {} |
40 Result(bool probe, uint32_t target_bitrate_bps) | 44 Result(bool probe, uint32_t target_bitrate_bps) |
41 : updated(true), probe(probe), target_bitrate_bps(target_bitrate_bps) {} | 45 : updated(true), |
| 46 probe(probe), |
| 47 overusing(false), |
| 48 target_bitrate_bps(target_bitrate_bps) {} |
42 bool updated; | 49 bool updated; |
43 bool probe; | 50 bool probe; |
| 51 bool overusing; |
44 uint32_t target_bitrate_bps; | 52 uint32_t target_bitrate_bps; |
45 }; | 53 }; |
46 | 54 |
47 explicit DelayBasedBwe(Clock* clock); | 55 explicit DelayBasedBwe(Clock* clock); |
48 virtual ~DelayBasedBwe() {} | 56 virtual ~DelayBasedBwe() {} |
49 | 57 |
50 Result IncomingPacketFeedbackVector( | 58 Result IncomingPacketFeedbackVector( |
51 const std::vector<PacketInfo>& packet_feedback_vector); | 59 const std::vector<PacketInfo>& packet_feedback_vector); |
52 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); | 60 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); |
53 bool LatestEstimate(std::vector<uint32_t>* ssrcs, | 61 bool LatestEstimate(std::vector<uint32_t>* ssrcs, |
(...skipping 15 matching lines...) Expand all Loading... |
69 | 77 |
70 private: | 78 private: |
71 float UpdateWindow(int64_t now_ms, int bytes, int rate_window_ms); | 79 float UpdateWindow(int64_t now_ms, int bytes, int rate_window_ms); |
72 int sum_; | 80 int sum_; |
73 int64_t current_win_ms_; | 81 int64_t current_win_ms_; |
74 int64_t prev_time_ms_; | 82 int64_t prev_time_ms_; |
75 float bitrate_estimate_; | 83 float bitrate_estimate_; |
76 float bitrate_estimate_var_; | 84 float bitrate_estimate_var_; |
77 RateStatistics old_estimator_; | 85 RateStatistics old_estimator_; |
78 const bool in_experiment_; | 86 const bool in_experiment_; |
| 87 bool last_result_was_valid_; |
79 }; | 88 }; |
80 | 89 |
81 Result IncomingPacketInfo(const PacketInfo& info); | 90 Result IncomingPacketInfo(const PacketInfo& info); |
| 91 |
| 92 void MaybeUpdateEstimate(Result* result); |
82 // Updates the current remote rate estimate and returns true if a valid | 93 // Updates the current remote rate estimate and returns true if a valid |
83 // estimate exists. | 94 // estimate exists. |
84 bool UpdateEstimate(int64_t packet_arrival_time_ms, | 95 bool UpdateEstimate(int64_t now_ms, |
85 int64_t now_ms, | |
86 rtc::Optional<uint32_t> acked_bitrate_bps, | 96 rtc::Optional<uint32_t> acked_bitrate_bps, |
87 uint32_t* target_bitrate_bps); | 97 Result* result); |
| 98 |
88 const bool in_trendline_experiment_; | 99 const bool in_trendline_experiment_; |
89 const bool in_median_slope_experiment_; | 100 const bool in_median_slope_experiment_; |
90 | 101 |
91 rtc::ThreadChecker network_thread_; | 102 rtc::ThreadChecker network_thread_; |
92 Clock* const clock_; | 103 Clock* const clock_; |
93 std::unique_ptr<InterArrival> inter_arrival_; | 104 std::unique_ptr<InterArrival> inter_arrival_; |
94 std::unique_ptr<OveruseEstimator> kalman_estimator_; | 105 std::unique_ptr<OveruseEstimator> kalman_estimator_; |
95 std::unique_ptr<TrendlineEstimator> trendline_estimator_; | 106 std::unique_ptr<TrendlineEstimator> trendline_estimator_; |
96 std::unique_ptr<MedianSlopeEstimator> median_slope_estimator_; | 107 std::unique_ptr<MedianSlopeEstimator> median_slope_estimator_; |
97 OveruseDetector detector_; | 108 OveruseDetector detector_; |
98 BitrateEstimator receiver_incoming_bitrate_; | 109 BitrateEstimator receiver_incoming_bitrate_; |
99 int64_t last_update_ms_; | |
100 int64_t last_seen_packet_ms_; | 110 int64_t last_seen_packet_ms_; |
101 bool uma_recorded_; | 111 bool uma_recorded_; |
102 AimdRateControl rate_control_; | 112 AimdRateControl rate_control_; |
103 ProbeBitrateEstimator probe_bitrate_estimator_; | 113 ProbeBitrateEstimator probe_bitrate_estimator_; |
104 size_t trendline_window_size_; | 114 size_t trendline_window_size_; |
105 double trendline_smoothing_coeff_; | 115 double trendline_smoothing_coeff_; |
106 double trendline_threshold_gain_; | 116 double trendline_threshold_gain_; |
107 ProbingIntervalEstimator probing_interval_estimator_; | 117 ProbingIntervalEstimator probing_interval_estimator_; |
108 size_t median_slope_window_size_; | 118 size_t median_slope_window_size_; |
109 double median_slope_threshold_gain_; | 119 double median_slope_threshold_gain_; |
110 | 120 |
111 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); | 121 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); |
112 }; | 122 }; |
113 | 123 |
114 } // namespace webrtc | 124 } // namespace webrtc |
115 | 125 |
116 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ | 126 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ |
OLD | NEW |