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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class Observer { | 52 class Observer { |
53 public: | 53 public: |
54 virtual void OnNetworkChanged(uint32_t bitrate_bps, | 54 virtual void OnNetworkChanged(uint32_t bitrate_bps, |
55 uint8_t fraction_loss, // 0 - 255. | 55 uint8_t fraction_loss, // 0 - 255. |
56 int64_t rtt_ms, | 56 int64_t rtt_ms, |
57 int64_t probing_interval_ms) = 0; | 57 int64_t probing_interval_ms) = 0; |
58 | 58 |
59 protected: | 59 protected: |
60 virtual ~Observer() {} | 60 virtual ~Observer() {} |
61 }; | 61 }; |
62 CongestionController(Clock* clock, | 62 CongestionController(const Clock* clock, |
63 Observer* observer, | 63 Observer* observer, |
64 RemoteBitrateObserver* remote_bitrate_observer, | 64 RemoteBitrateObserver* remote_bitrate_observer, |
65 RtcEventLog* event_log, | 65 RtcEventLog* event_log, |
66 PacketRouter* packet_router); | 66 PacketRouter* packet_router); |
67 CongestionController(Clock* clock, | 67 CongestionController(const Clock* clock, |
68 Observer* observer, | 68 Observer* observer, |
69 RemoteBitrateObserver* remote_bitrate_observer, | 69 RemoteBitrateObserver* remote_bitrate_observer, |
70 RtcEventLog* event_log, | 70 RtcEventLog* event_log, |
71 PacketRouter* packet_router, | 71 PacketRouter* packet_router, |
72 std::unique_ptr<PacedSender> pacer); | 72 std::unique_ptr<PacedSender> pacer); |
73 virtual ~CongestionController(); | 73 virtual ~CongestionController(); |
74 | 74 |
75 virtual void OnReceivedPacket(int64_t arrival_time_ms, | 75 virtual void OnReceivedPacket(int64_t arrival_time_ms, |
76 size_t payload_size, | 76 size_t payload_size, |
77 const RTPHeader& header); | 77 const RTPHeader& header); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // Implements TransportFeedbackObserver. | 122 // Implements TransportFeedbackObserver. |
123 void AddPacket(uint16_t sequence_number, | 123 void AddPacket(uint16_t sequence_number, |
124 size_t length, | 124 size_t length, |
125 const PacedPacketInfo& pacing_info) override; | 125 const PacedPacketInfo& pacing_info) override; |
126 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override; | 126 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override; |
127 std::vector<PacketFeedback> GetTransportFeedbackVector() const override; | 127 std::vector<PacketFeedback> GetTransportFeedbackVector() const override; |
128 | 128 |
129 private: | 129 private: |
130 class WrappingBitrateEstimator : public RemoteBitrateEstimator { | 130 class WrappingBitrateEstimator : public RemoteBitrateEstimator { |
131 public: | 131 public: |
132 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock); | 132 WrappingBitrateEstimator(RemoteBitrateObserver* observer, |
| 133 const Clock* clock); |
133 | 134 |
134 virtual ~WrappingBitrateEstimator() {} | 135 virtual ~WrappingBitrateEstimator() {} |
135 | 136 |
136 void IncomingPacket(int64_t arrival_time_ms, | 137 void IncomingPacket(int64_t arrival_time_ms, |
137 size_t payload_size, | 138 size_t payload_size, |
138 const RTPHeader& header) override; | 139 const RTPHeader& header) override; |
139 | 140 |
140 void Process() override; | 141 void Process() override; |
141 | 142 |
142 int64_t TimeUntilNextProcess() override; | 143 int64_t TimeUntilNextProcess() override; |
143 | 144 |
144 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; | 145 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
145 | 146 |
146 void RemoveStream(unsigned int ssrc) override; | 147 void RemoveStream(unsigned int ssrc) override; |
147 | 148 |
148 bool LatestEstimate(std::vector<unsigned int>* ssrcs, | 149 bool LatestEstimate(std::vector<unsigned int>* ssrcs, |
149 unsigned int* bitrate_bps) const override; | 150 unsigned int* bitrate_bps) const override; |
150 | 151 |
151 void SetMinBitrate(int min_bitrate_bps) override; | 152 void SetMinBitrate(int min_bitrate_bps) override; |
152 | 153 |
153 private: | 154 private: |
154 void PickEstimatorFromHeader(const RTPHeader& header) | 155 void PickEstimatorFromHeader(const RTPHeader& header) |
155 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 156 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
156 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); | 157 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_); |
157 RemoteBitrateObserver* observer_; | 158 RemoteBitrateObserver* observer_; |
158 Clock* const clock_; | 159 const Clock* const clock_; |
159 rtc::CriticalSection crit_sect_; | 160 rtc::CriticalSection crit_sect_; |
160 std::unique_ptr<RemoteBitrateEstimator> rbe_; | 161 std::unique_ptr<RemoteBitrateEstimator> rbe_; |
161 bool using_absolute_send_time_; | 162 bool using_absolute_send_time_; |
162 uint32_t packets_since_absolute_send_time_; | 163 uint32_t packets_since_absolute_send_time_; |
163 int min_bitrate_bps_; | 164 int min_bitrate_bps_; |
164 | 165 |
165 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); | 166 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); |
166 }; | 167 }; |
167 | 168 |
168 void MaybeTriggerOnNetworkChanged(); | 169 void MaybeTriggerOnNetworkChanged(); |
169 | 170 |
170 bool IsSendQueueFull() const; | 171 bool IsSendQueueFull() const; |
171 bool IsNetworkDown() const; | 172 bool IsNetworkDown() const; |
172 bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps, | 173 bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps, |
173 uint8_t fraction_loss, | 174 uint8_t fraction_loss, |
174 int64_t rtt); | 175 int64_t rtt); |
175 Clock* const clock_; | 176 const Clock* const clock_; |
176 Observer* const observer_; | 177 Observer* const observer_; |
177 RtcEventLog* const event_log_; | 178 RtcEventLog* const event_log_; |
178 PacketRouter* const packet_router_; | 179 PacketRouter* const packet_router_; |
179 const std::unique_ptr<PacedSender> pacer_; | 180 const std::unique_ptr<PacedSender> pacer_; |
180 const std::unique_ptr<BitrateController> bitrate_controller_; | 181 const std::unique_ptr<BitrateController> bitrate_controller_; |
181 const std::unique_ptr<ProbeController> probe_controller_; | 182 const std::unique_ptr<ProbeController> probe_controller_; |
182 const std::unique_ptr<RateLimiter> retransmission_rate_limiter_; | 183 const std::unique_ptr<RateLimiter> retransmission_rate_limiter_; |
183 WrappingBitrateEstimator remote_bitrate_estimator_; | 184 WrappingBitrateEstimator remote_bitrate_estimator_; |
184 RemoteEstimatorProxy remote_estimator_proxy_; | 185 RemoteEstimatorProxy remote_estimator_proxy_; |
185 TransportFeedbackAdapter transport_feedback_adapter_; | 186 TransportFeedbackAdapter transport_feedback_adapter_; |
186 int min_bitrate_bps_; | 187 int min_bitrate_bps_; |
187 int max_bitrate_bps_; | 188 int max_bitrate_bps_; |
188 rtc::CriticalSection network_state_lock_; | 189 rtc::CriticalSection network_state_lock_; |
189 uint32_t last_reported_bitrate_bps_ GUARDED_BY(network_state_lock_); | 190 uint32_t last_reported_bitrate_bps_ GUARDED_BY(network_state_lock_); |
190 uint8_t last_reported_fraction_loss_ GUARDED_BY(network_state_lock_); | 191 uint8_t last_reported_fraction_loss_ GUARDED_BY(network_state_lock_); |
191 int64_t last_reported_rtt_ GUARDED_BY(network_state_lock_); | 192 int64_t last_reported_rtt_ GUARDED_BY(network_state_lock_); |
192 NetworkState network_state_ GUARDED_BY(network_state_lock_); | 193 NetworkState network_state_ GUARDED_BY(network_state_lock_); |
193 rtc::CriticalSection bwe_lock_; | 194 rtc::CriticalSection bwe_lock_; |
194 std::unique_ptr<DelayBasedBwe> delay_based_bwe_ GUARDED_BY(bwe_lock_); | 195 std::unique_ptr<DelayBasedBwe> delay_based_bwe_ GUARDED_BY(bwe_lock_); |
195 | 196 |
196 rtc::ThreadChecker worker_thread_checker_; | 197 rtc::ThreadChecker worker_thread_checker_; |
197 | 198 |
198 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController); | 199 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController); |
199 }; | 200 }; |
200 | 201 |
201 } // namespace webrtc | 202 } // namespace webrtc |
202 | 203 |
203 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ | 204 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ |
OLD | NEW |