| 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 | 16 |
| 16 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
| 17 #include "webrtc/base/deprecation.h" | 18 #include "webrtc/base/criticalsection.h" |
| 18 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
| 19 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" | 20 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" |
| 20 #include "webrtc/modules/include/module.h" | 21 #include "webrtc/modules/include/module.h" |
| 21 #include "webrtc/modules/include/module_common_types.h" | 22 #include "webrtc/modules/include/module_common_types.h" |
| 22 #include "webrtc/modules/pacing/packet_router.h" | 23 #include "webrtc/modules/pacing/packet_router.h" |
| 23 #include "webrtc/modules/pacing/paced_sender.h" | 24 #include "webrtc/modules/pacing/paced_sender.h" |
| 24 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" | 25 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
| 25 | 26 |
| 26 namespace rtc { | 27 namespace rtc { |
| 27 struct SentPacket; | 28 struct SentPacket; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 virtual void OnSentPacket(const rtc::SentPacket& sent_packet); | 111 virtual void OnSentPacket(const rtc::SentPacket& sent_packet); |
| 111 | 112 |
| 112 // Implements CallStatsObserver. | 113 // Implements CallStatsObserver. |
| 113 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; | 114 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 114 | 115 |
| 115 // Implements Module. | 116 // Implements Module. |
| 116 int64_t TimeUntilNextProcess() override; | 117 int64_t TimeUntilNextProcess() override; |
| 117 void Process() override; | 118 void Process() override; |
| 118 | 119 |
| 119 private: | 120 private: |
| 121 class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
| 122 public: |
| 123 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock); |
| 124 |
| 125 virtual ~WrappingBitrateEstimator() {} |
| 126 |
| 127 void IncomingPacket(int64_t arrival_time_ms, |
| 128 size_t payload_size, |
| 129 const RTPHeader& header) override; |
| 130 |
| 131 void Process() override; |
| 132 |
| 133 int64_t TimeUntilNextProcess() override; |
| 134 |
| 135 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 136 |
| 137 void RemoveStream(unsigned int ssrc) override; |
| 138 |
| 139 bool LatestEstimate(std::vector<unsigned int>* ssrcs, |
| 140 unsigned int* bitrate_bps) const override; |
| 141 |
| 142 void SetMinBitrate(int min_bitrate_bps) override; |
| 143 |
| 144 private: |
| 145 void PickEstimatorFromHeader(const RTPHeader& header) |
| 146 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 147 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
| 148 RemoteBitrateObserver* observer_; |
| 149 Clock* const clock_; |
| 150 rtc::CriticalSection crit_sect_; |
| 151 std::unique_ptr<RemoteBitrateEstimator> rbe_; |
| 152 bool using_absolute_send_time_; |
| 153 uint32_t packets_since_absolute_send_time_; |
| 154 int min_bitrate_bps_; |
| 155 |
| 156 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); |
| 157 }; |
| 158 |
| 120 void MaybeTriggerOnNetworkChanged(); | 159 void MaybeTriggerOnNetworkChanged(); |
| 121 | 160 |
| 122 bool IsSendQueueFull() const; | 161 bool IsSendQueueFull() const; |
| 123 bool IsNetworkDown() const; | 162 bool IsNetworkDown() const; |
| 124 bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps, | 163 bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps, |
| 125 uint8_t fraction_loss, | 164 uint8_t fraction_loss, |
| 126 int64_t rtt); | 165 int64_t rtt); |
| 127 Clock* const clock_; | 166 Clock* const clock_; |
| 128 Observer* const observer_; | 167 Observer* const observer_; |
| 129 PacketRouter* const packet_router_; | 168 PacketRouter* const packet_router_; |
| 130 const std::unique_ptr<PacedSender> pacer_; | 169 const std::unique_ptr<PacedSender> pacer_; |
| 131 const std::unique_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; | |
| 132 const std::unique_ptr<BitrateController> bitrate_controller_; | 170 const std::unique_ptr<BitrateController> bitrate_controller_; |
| 133 const std::unique_ptr<ProbeController> probe_controller_; | 171 const std::unique_ptr<ProbeController> probe_controller_; |
| 134 const std::unique_ptr<RateLimiter> retransmission_rate_limiter_; | 172 const std::unique_ptr<RateLimiter> retransmission_rate_limiter_; |
| 173 WrappingBitrateEstimator remote_bitrate_estimator_; |
| 135 RemoteEstimatorProxy remote_estimator_proxy_; | 174 RemoteEstimatorProxy remote_estimator_proxy_; |
| 136 TransportFeedbackAdapter transport_feedback_adapter_; | 175 TransportFeedbackAdapter transport_feedback_adapter_; |
| 137 int min_bitrate_bps_; | 176 int min_bitrate_bps_; |
| 138 int max_bitrate_bps_; | 177 int max_bitrate_bps_; |
| 139 rtc::CriticalSection critsect_; | 178 rtc::CriticalSection critsect_; |
| 140 uint32_t last_reported_bitrate_bps_ GUARDED_BY(critsect_); | 179 uint32_t last_reported_bitrate_bps_ GUARDED_BY(critsect_); |
| 141 uint8_t last_reported_fraction_loss_ GUARDED_BY(critsect_); | 180 uint8_t last_reported_fraction_loss_ GUARDED_BY(critsect_); |
| 142 int64_t last_reported_rtt_ GUARDED_BY(critsect_); | 181 int64_t last_reported_rtt_ GUARDED_BY(critsect_); |
| 143 NetworkState network_state_ GUARDED_BY(critsect_); | 182 NetworkState network_state_ GUARDED_BY(critsect_); |
| 144 | 183 |
| 145 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController); | 184 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController); |
| 146 }; | 185 }; |
| 147 | 186 |
| 148 } // namespace webrtc | 187 } // namespace webrtc |
| 149 | 188 |
| 150 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ | 189 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ |
| OLD | NEW |