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