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_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ | 11 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ |
12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ | 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ |
13 | 13 |
14 #include <list> | 14 #include <deque> |
15 #include <map> | |
16 #include <memory> | 15 #include <memory> |
| 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
20 #include "webrtc/base/constructormagic.h" | 20 #include "webrtc/base/constructormagic.h" |
21 #include "webrtc/base/rate_statistics.h" | 21 #include "webrtc/base/rate_statistics.h" |
22 #include "webrtc/base/thread_checker.h" | 22 #include "webrtc/base/thread_checker.h" |
23 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" | 23 #include "webrtc/modules/congestion_controller/probe_bitrate_estimator.h" |
24 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" | 24 #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" |
25 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 25 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
26 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" | 26 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" |
(...skipping 19 matching lines...) Expand all Loading... |
46 virtual ~DelayBasedBwe() {} | 46 virtual ~DelayBasedBwe() {} |
47 | 47 |
48 Result IncomingPacketFeedbackVector( | 48 Result IncomingPacketFeedbackVector( |
49 const std::vector<PacketInfo>& packet_feedback_vector); | 49 const std::vector<PacketInfo>& packet_feedback_vector); |
50 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); | 50 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); |
51 bool LatestEstimate(std::vector<uint32_t>* ssrcs, | 51 bool LatestEstimate(std::vector<uint32_t>* ssrcs, |
52 uint32_t* bitrate_bps) const; | 52 uint32_t* bitrate_bps) const; |
53 void SetMinBitrate(int min_bitrate_bps); | 53 void SetMinBitrate(int min_bitrate_bps); |
54 | 54 |
55 private: | 55 private: |
| 56 class RateEstimator { |
| 57 public: |
| 58 RateEstimator(); |
| 59 void Update(int64_t now_ms, int bytes); |
| 60 int bitrate_estimate() const; |
| 61 |
| 62 private: |
| 63 void UpdateWindow(int64_t now_ms, int bytes); |
| 64 int sum_; |
| 65 int count_; |
| 66 std::deque<std::pair<int64_t, int>> payloads_; |
| 67 float bitrate_estimate_; |
| 68 float bitrate_estimate_std_; |
| 69 }; |
| 70 |
56 Result IncomingPacketInfo(const PacketInfo& info); | 71 Result IncomingPacketInfo(const PacketInfo& info); |
57 // Updates the current remote rate estimate and returns true if a valid | 72 // Updates the current remote rate estimate and returns true if a valid |
58 // estimate exists. | 73 // estimate exists. |
59 bool UpdateEstimate(int64_t packet_arrival_time_ms, | 74 bool UpdateEstimate(int64_t packet_arrival_time_ms, |
60 int64_t now_ms, | 75 int64_t now_ms, |
| 76 int acked_bitrate_bps, |
61 uint32_t* target_bitrate_bps); | 77 uint32_t* target_bitrate_bps); |
62 | 78 |
63 rtc::ThreadChecker network_thread_; | 79 rtc::ThreadChecker network_thread_; |
64 Clock* const clock_; | 80 Clock* const clock_; |
65 std::unique_ptr<InterArrival> inter_arrival_; | 81 std::unique_ptr<InterArrival> inter_arrival_; |
66 std::unique_ptr<OveruseEstimator> estimator_; | 82 std::unique_ptr<OveruseEstimator> estimator_; |
67 OveruseDetector detector_; | 83 OveruseDetector detector_; |
68 RateStatistics receiver_incoming_bitrate_; | 84 RateEstimator receiver_incoming_bitrate_; |
69 int64_t last_update_ms_; | 85 int64_t last_update_ms_; |
70 int64_t last_seen_packet_ms_; | 86 int64_t last_seen_packet_ms_; |
71 bool uma_recorded_; | 87 bool uma_recorded_; |
72 AimdRateControl rate_control_; | 88 AimdRateControl rate_control_; |
73 ProbeBitrateEstimator probe_bitrate_estimator_; | 89 ProbeBitrateEstimator probe_bitrate_estimator_; |
74 | 90 |
75 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); | 91 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(DelayBasedBwe); |
76 }; | 92 }; |
77 | 93 |
78 } // namespace webrtc | 94 } // namespace webrtc |
79 | 95 |
80 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ | 96 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_DELAY_BASED_BWE_H_ |
OLD | NEW |