OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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_INCLUDE_CONGESTION_CONTROLLER_H_ | 11 #ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ |
12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ | 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
18 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
| 19 #include "webrtc/base/thread_checker.h" |
19 #include "webrtc/common_types.h" | 20 #include "webrtc/common_types.h" |
| 21 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" |
20 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" | 22 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" |
21 #include "webrtc/modules/include/module.h" | 23 #include "webrtc/modules/include/module.h" |
22 #include "webrtc/modules/include/module_common_types.h" | 24 #include "webrtc/modules/include/module_common_types.h" |
| 25 #include "webrtc/modules/pacing/paced_sender.h" |
23 #include "webrtc/modules/pacing/packet_router.h" | 26 #include "webrtc/modules/pacing/packet_router.h" |
24 #include "webrtc/modules/pacing/paced_sender.h" | |
25 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" | 27 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
26 | 28 |
27 namespace rtc { | 29 namespace rtc { |
28 struct SentPacket; | 30 struct SentPacket; |
29 } | 31 } |
30 | 32 |
31 namespace webrtc { | 33 namespace webrtc { |
32 | 34 |
33 class BitrateController; | 35 class BitrateController; |
34 class Clock; | 36 class Clock; |
35 class ProbeController; | 37 class ProbeController; |
36 class RateLimiter; | 38 class RateLimiter; |
37 class RemoteBitrateEstimator; | 39 class RemoteBitrateEstimator; |
38 class RemoteBitrateObserver; | 40 class RemoteBitrateObserver; |
39 class RtcEventLog; | 41 class RtcEventLog; |
40 class TransportFeedbackObserver; | |
41 | 42 |
42 class CongestionController : public CallStatsObserver, public Module { | 43 class CongestionController : public CallStatsObserver, |
| 44 public Module, |
| 45 public TransportFeedbackObserver { |
43 public: | 46 public: |
44 // Observer class for bitrate changes announced due to change in bandwidth | 47 // Observer class for bitrate changes announced due to change in bandwidth |
45 // estimate or due to that the send pacer is full. Fraction loss and rtt is | 48 // estimate or due to that the send pacer is full. Fraction loss and rtt is |
46 // also part of this callback to allow the observer to optimize its settings | 49 // also part of this callback to allow the observer to optimize its settings |
47 // for different types of network environments. The bitrate does not include | 50 // for different types of network environments. The bitrate does not include |
48 // packet headers and is measured in bits per second. | 51 // packet headers and is measured in bits per second. |
49 class Observer { | 52 class Observer { |
50 public: | 53 public: |
51 virtual void OnNetworkChanged(uint32_t bitrate_bps, | 54 virtual void OnNetworkChanged(uint32_t bitrate_bps, |
52 uint8_t fraction_loss, // 0 - 255. | 55 uint8_t fraction_loss, // 0 - 255. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 virtual void SignalNetworkState(NetworkState state); | 87 virtual void SignalNetworkState(NetworkState state); |
85 virtual void SetTransportOverhead(size_t transport_overhead_bytes_per_packet); | 88 virtual void SetTransportOverhead(size_t transport_overhead_bytes_per_packet); |
86 | 89 |
87 virtual BitrateController* GetBitrateController() const; | 90 virtual BitrateController* GetBitrateController() const; |
88 virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator( | 91 virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator( |
89 bool send_side_bwe); | 92 bool send_side_bwe); |
90 virtual int64_t GetPacerQueuingDelayMs() const; | 93 virtual int64_t GetPacerQueuingDelayMs() const; |
91 // TODO(nisse): Delete this accessor function. The pacer should be | 94 // TODO(nisse): Delete this accessor function. The pacer should be |
92 // internal to the congestion controller. | 95 // internal to the congestion controller. |
93 virtual PacedSender* pacer() { return pacer_.get(); } | 96 virtual PacedSender* pacer() { return pacer_.get(); } |
94 virtual TransportFeedbackObserver* GetTransportFeedbackObserver(); | |
95 RateLimiter* GetRetransmissionRateLimiter(); | 97 RateLimiter* GetRetransmissionRateLimiter(); |
96 void EnablePeriodicAlrProbing(bool enable); | 98 void EnablePeriodicAlrProbing(bool enable); |
97 | 99 |
98 // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec | 100 // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec |
99 // settings. | 101 // settings. |
100 // |min_send_bitrate_bps| is the total minimum send bitrate required by all | 102 // |min_send_bitrate_bps| is the total minimum send bitrate required by all |
101 // sending streams. This is the minimum bitrate the PacedSender will use. | 103 // sending streams. This is the minimum bitrate the PacedSender will use. |
102 // Note that CongestionController::OnNetworkChanged can still be called with | 104 // Note that CongestionController::OnNetworkChanged can still be called with |
103 // a lower bitrate estimate. | 105 // a lower bitrate estimate. |
104 // |max_padding_bitrate_bps| is the max bitrate the send streams request for | 106 // |max_padding_bitrate_bps| is the max bitrate the send streams request for |
105 // padding. This can be higher than the current network estimate and tells | 107 // padding. This can be higher than the current network estimate and tells |
106 // the PacedSender how much it should max pad unless there is real packets to | 108 // the PacedSender how much it should max pad unless there is real packets to |
107 // send. | 109 // send. |
108 void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps, | 110 void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps, |
109 int max_padding_bitrate_bps); | 111 int max_padding_bitrate_bps); |
110 | 112 |
111 virtual void OnSentPacket(const rtc::SentPacket& sent_packet); | 113 virtual void OnSentPacket(const rtc::SentPacket& sent_packet); |
112 | 114 |
113 // Implements CallStatsObserver. | 115 // Implements CallStatsObserver. |
114 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; | 116 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
115 | 117 |
116 // Implements Module. | 118 // Implements Module. |
117 int64_t TimeUntilNextProcess() override; | 119 int64_t TimeUntilNextProcess() override; |
118 void Process() override; | 120 void Process() override; |
119 | 121 |
| 122 // Implements TransportFeedbackObserver. |
| 123 void AddPacket(uint16_t sequence_number, |
| 124 size_t length, |
| 125 const PacedPacketInfo& pacing_info) override; |
| 126 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override; |
| 127 std::vector<PacketFeedback> GetTransportFeedbackVector() const override; |
| 128 |
120 private: | 129 private: |
121 class WrappingBitrateEstimator : public RemoteBitrateEstimator { | 130 class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
122 public: | 131 public: |
123 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock); | 132 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock); |
124 | 133 |
125 virtual ~WrappingBitrateEstimator() {} | 134 virtual ~WrappingBitrateEstimator() {} |
126 | 135 |
127 void IncomingPacket(int64_t arrival_time_ms, | 136 void IncomingPacket(int64_t arrival_time_ms, |
128 size_t payload_size, | 137 size_t payload_size, |
129 const RTPHeader& header) override; | 138 const RTPHeader& header) override; |
(...skipping 28 matching lines...) Expand all Loading... |
158 | 167 |
159 void MaybeTriggerOnNetworkChanged(); | 168 void MaybeTriggerOnNetworkChanged(); |
160 | 169 |
161 bool IsSendQueueFull() const; | 170 bool IsSendQueueFull() const; |
162 bool IsNetworkDown() const; | 171 bool IsNetworkDown() const; |
163 bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps, | 172 bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps, |
164 uint8_t fraction_loss, | 173 uint8_t fraction_loss, |
165 int64_t rtt); | 174 int64_t rtt); |
166 Clock* const clock_; | 175 Clock* const clock_; |
167 Observer* const observer_; | 176 Observer* const observer_; |
| 177 RtcEventLog* const event_log_; |
168 PacketRouter* const packet_router_; | 178 PacketRouter* const packet_router_; |
169 const std::unique_ptr<PacedSender> pacer_; | 179 const std::unique_ptr<PacedSender> pacer_; |
170 const std::unique_ptr<BitrateController> bitrate_controller_; | 180 const std::unique_ptr<BitrateController> bitrate_controller_; |
171 const std::unique_ptr<ProbeController> probe_controller_; | 181 const std::unique_ptr<ProbeController> probe_controller_; |
172 const std::unique_ptr<RateLimiter> retransmission_rate_limiter_; | 182 const std::unique_ptr<RateLimiter> retransmission_rate_limiter_; |
173 WrappingBitrateEstimator remote_bitrate_estimator_; | 183 WrappingBitrateEstimator remote_bitrate_estimator_; |
174 RemoteEstimatorProxy remote_estimator_proxy_; | 184 RemoteEstimatorProxy remote_estimator_proxy_; |
175 TransportFeedbackAdapter transport_feedback_adapter_; | 185 TransportFeedbackAdapter transport_feedback_adapter_; |
176 int min_bitrate_bps_; | 186 int min_bitrate_bps_; |
177 int max_bitrate_bps_; | 187 int max_bitrate_bps_; |
178 rtc::CriticalSection critsect_; | 188 rtc::CriticalSection network_state_lock_; |
179 uint32_t last_reported_bitrate_bps_ GUARDED_BY(critsect_); | 189 uint32_t last_reported_bitrate_bps_ GUARDED_BY(network_state_lock_); |
180 uint8_t last_reported_fraction_loss_ GUARDED_BY(critsect_); | 190 uint8_t last_reported_fraction_loss_ GUARDED_BY(network_state_lock_); |
181 int64_t last_reported_rtt_ GUARDED_BY(critsect_); | 191 int64_t last_reported_rtt_ GUARDED_BY(network_state_lock_); |
182 NetworkState network_state_ GUARDED_BY(critsect_); | 192 NetworkState network_state_ GUARDED_BY(network_state_lock_); |
| 193 rtc::CriticalSection bwe_lock_; |
| 194 std::unique_ptr<DelayBasedBwe> delay_based_bwe_ GUARDED_BY(bwe_lock_); |
| 195 |
| 196 rtc::ThreadChecker worker_thread_checker_; |
183 | 197 |
184 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController); | 198 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController); |
185 }; | 199 }; |
186 | 200 |
187 } // namespace webrtc | 201 } // namespace webrtc |
188 | 202 |
189 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ | 203 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ |
OLD | NEW |