Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: webrtc/modules/congestion_controller/include/send_side_congestion_controller.h

Issue 2752233002: Split CongestionController into send- and receive-side classes. (Closed)
Patch Set: Use variable names receive_side_cc and send_side_cc. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SEND_SIDE_CONGESTION_CONTRO LLER_H_
12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ 12 #define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_SEND_SIDE_CONGESTION_CONTRO LLER_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/networkroute.h" 19 #include "webrtc/base/networkroute.h"
20 #include "webrtc/base/thread_checker.h" 20 #include "webrtc/base/thread_checker.h"
21 #include "webrtc/common_types.h" 21 #include "webrtc/common_types.h"
22 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" 22 #include "webrtc/modules/congestion_controller/delay_based_bwe.h"
23 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" 23 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h"
24 #include "webrtc/modules/include/module.h" 24 #include "webrtc/modules/include/module.h"
25 #include "webrtc/modules/include/module_common_types.h" 25 #include "webrtc/modules/include/module_common_types.h"
26 #include "webrtc/modules/pacing/paced_sender.h" 26 #include "webrtc/modules/pacing/paced_sender.h"
27 #include "webrtc/modules/pacing/packet_router.h" 27 #include "webrtc/modules/pacing/packet_router.h"
28 #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
29 28
30 namespace rtc { 29 namespace rtc {
31 struct SentPacket; 30 struct SentPacket;
32 } 31 }
33 32
34 namespace webrtc { 33 namespace webrtc {
35 34
36 class BitrateController; 35 class BitrateController;
37 class Clock; 36 class Clock;
38 class ProbeController; 37 class ProbeController;
39 class RateLimiter; 38 class RateLimiter;
40 class RemoteBitrateEstimator;
41 class RemoteBitrateObserver;
42 class RtcEventLog; 39 class RtcEventLog;
43 40
44 class CongestionController : public CallStatsObserver, 41 class SendSideCongestionController : public CallStatsObserver,
45 public Module, 42 public Module,
46 public TransportFeedbackObserver { 43 public TransportFeedbackObserver {
47 public: 44 public:
48 // Observer class for bitrate changes announced due to change in bandwidth 45 // Observer class for bitrate changes announced due to change in bandwidth
49 // estimate or due to that the send pacer is full. Fraction loss and rtt is 46 // estimate or due to that the send pacer is full. Fraction loss and rtt is
50 // also part of this callback to allow the observer to optimize its settings 47 // also part of this callback to allow the observer to optimize its settings
51 // for different types of network environments. The bitrate does not include 48 // for different types of network environments. The bitrate does not include
52 // packet headers and is measured in bits per second. 49 // packet headers and is measured in bits per second.
53 class Observer { 50 class Observer {
54 public: 51 public:
55 virtual void OnNetworkChanged(uint32_t bitrate_bps, 52 virtual void OnNetworkChanged(uint32_t bitrate_bps,
56 uint8_t fraction_loss, // 0 - 255. 53 uint8_t fraction_loss, // 0 - 255.
57 int64_t rtt_ms, 54 int64_t rtt_ms,
58 int64_t probing_interval_ms) = 0; 55 int64_t probing_interval_ms) = 0;
59 56
60 protected: 57 protected:
61 virtual ~Observer() {} 58 virtual ~Observer() {}
62 }; 59 };
63 CongestionController(const Clock* clock, 60 SendSideCongestionController(const Clock* clock,
64 Observer* observer, 61 Observer* observer,
65 RemoteBitrateObserver* remote_bitrate_observer, 62 RtcEventLog* event_log,
66 RtcEventLog* event_log, 63 PacketRouter* packet_router);
67 PacketRouter* packet_router); 64 SendSideCongestionController(const Clock* clock,
68 CongestionController(const Clock* clock, 65 Observer* observer,
69 Observer* observer, 66 RtcEventLog* event_log,
70 RemoteBitrateObserver* remote_bitrate_observer, 67 std::unique_ptr<PacedSender> pacer);
71 RtcEventLog* event_log, 68 virtual ~SendSideCongestionController();
72 PacketRouter* packet_router,
73 std::unique_ptr<PacedSender> pacer);
74 virtual ~CongestionController();
75
76 virtual void OnReceivedPacket(int64_t arrival_time_ms,
77 size_t payload_size,
78 const RTPHeader& header);
79 69
80 virtual void SetBweBitrates(int min_bitrate_bps, 70 virtual void SetBweBitrates(int min_bitrate_bps,
81 int start_bitrate_bps, 71 int start_bitrate_bps,
82 int max_bitrate_bps); 72 int max_bitrate_bps);
83 // Resets both the BWE state and the bitrate estimator. Note the first 73 // Resets the BWE state. Note the first argument is the bitrate_bps.
84 // argument is the bitrate_bps.
85 virtual void OnNetworkRouteChanged(const rtc::NetworkRoute& network_route, 74 virtual void OnNetworkRouteChanged(const rtc::NetworkRoute& network_route,
86 int bitrate_bps, 75 int bitrate_bps,
87 int min_bitrate_bps, 76 int min_bitrate_bps,
88 int max_bitrate_bps); 77 int max_bitrate_bps);
89 virtual void SignalNetworkState(NetworkState state); 78 virtual void SignalNetworkState(NetworkState state);
90 virtual void SetTransportOverhead(size_t transport_overhead_bytes_per_packet); 79 virtual void SetTransportOverhead(size_t transport_overhead_bytes_per_packet);
91 80
92 virtual BitrateController* GetBitrateController() const; 81 virtual BitrateController* GetBitrateController() const;
93 virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
94 bool send_side_bwe);
95 virtual int64_t GetPacerQueuingDelayMs() const; 82 virtual int64_t GetPacerQueuingDelayMs() const;
96 // TODO(nisse): Delete this accessor function. The pacer should be 83 // TODO(nisse): Delete this accessor function. The pacer should be
97 // internal to the congestion controller. 84 // internal to the congestion controller.
98 virtual PacedSender* pacer() { return pacer_.get(); } 85 virtual PacedSender* pacer() { return pacer_.get(); }
99 virtual TransportFeedbackObserver* GetTransportFeedbackObserver() { 86 virtual TransportFeedbackObserver* GetTransportFeedbackObserver() {
100 return this; 87 return this;
101 } 88 }
102 RateLimiter* GetRetransmissionRateLimiter(); 89 RateLimiter* GetRetransmissionRateLimiter();
103 void EnablePeriodicAlrProbing(bool enable); 90 void EnablePeriodicAlrProbing(bool enable);
104 91
105 // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec 92 // SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
106 // settings. 93 // settings.
107 // |min_send_bitrate_bps| is the total minimum send bitrate required by all 94 // |min_send_bitrate_bps| is the total minimum send bitrate required by all
108 // sending streams. This is the minimum bitrate the PacedSender will use. 95 // sending streams. This is the minimum bitrate the PacedSender will use.
109 // Note that CongestionController::OnNetworkChanged can still be called with 96 // Note that SendSideCongestionController::OnNetworkChanged can still be
110 // a lower bitrate estimate. 97 // called with a lower bitrate estimate. |max_padding_bitrate_bps| is the max
111 // |max_padding_bitrate_bps| is the max bitrate the send streams request for 98 // bitrate the send streams request for padding. This can be higher than the
112 // padding. This can be higher than the current network estimate and tells 99 // current network estimate and tells the PacedSender how much it should max
113 // the PacedSender how much it should max pad unless there is real packets to 100 // pad unless there is real packets to send.
114 // send.
115 void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps, 101 void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps,
116 int max_padding_bitrate_bps); 102 int max_padding_bitrate_bps);
117 103
118 virtual void OnSentPacket(const rtc::SentPacket& sent_packet); 104 virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
119 105
120 // Implements CallStatsObserver. 106 // Implements CallStatsObserver.
121 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; 107 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
122 108
123 // Implements Module. 109 // Implements Module.
124 int64_t TimeUntilNextProcess() override; 110 int64_t TimeUntilNextProcess() override;
125 void Process() override; 111 void Process() override;
126 112
127 // Implements TransportFeedbackObserver. 113 // Implements TransportFeedbackObserver.
128 void AddPacket(uint16_t sequence_number, 114 void AddPacket(uint16_t sequence_number,
129 size_t length, 115 size_t length,
130 const PacedPacketInfo& pacing_info) override; 116 const PacedPacketInfo& pacing_info) override;
131 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override; 117 void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override;
132 std::vector<PacketFeedback> GetTransportFeedbackVector() const override; 118 std::vector<PacketFeedback> GetTransportFeedbackVector() const override;
133 119
134 private: 120 private:
135 class WrappingBitrateEstimator : public RemoteBitrateEstimator {
136 public:
137 WrappingBitrateEstimator(RemoteBitrateObserver* observer,
138 const Clock* clock);
139
140 virtual ~WrappingBitrateEstimator() {}
141
142 void IncomingPacket(int64_t arrival_time_ms,
143 size_t payload_size,
144 const RTPHeader& header) override;
145
146 void Process() override;
147
148 int64_t TimeUntilNextProcess() override;
149
150 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
151
152 void RemoveStream(unsigned int ssrc) override;
153
154 bool LatestEstimate(std::vector<unsigned int>* ssrcs,
155 unsigned int* bitrate_bps) const override;
156
157 void SetMinBitrate(int min_bitrate_bps) override;
158
159 private:
160 void PickEstimatorFromHeader(const RTPHeader& header)
161 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
162 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
163 RemoteBitrateObserver* observer_;
164 const Clock* const clock_;
165 rtc::CriticalSection crit_sect_;
166 std::unique_ptr<RemoteBitrateEstimator> rbe_;
167 bool using_absolute_send_time_;
168 uint32_t packets_since_absolute_send_time_;
169 int min_bitrate_bps_;
170
171 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator);
172 };
173
174 void MaybeTriggerOnNetworkChanged(); 121 void MaybeTriggerOnNetworkChanged();
175 122
176 bool IsSendQueueFull() const; 123 bool IsSendQueueFull() const;
177 bool IsNetworkDown() const; 124 bool IsNetworkDown() const;
178 bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps, 125 bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps,
179 uint8_t fraction_loss, 126 uint8_t fraction_loss,
180 int64_t rtt); 127 int64_t rtt);
181 const Clock* const clock_; 128 const Clock* const clock_;
182 Observer* const observer_; 129 Observer* const observer_;
183 RtcEventLog* const event_log_; 130 RtcEventLog* const event_log_;
184 PacketRouter* const packet_router_;
185 const std::unique_ptr<PacedSender> pacer_; 131 const std::unique_ptr<PacedSender> pacer_;
186 const std::unique_ptr<BitrateController> bitrate_controller_; 132 const std::unique_ptr<BitrateController> bitrate_controller_;
187 const std::unique_ptr<ProbeController> probe_controller_; 133 const std::unique_ptr<ProbeController> probe_controller_;
188 const std::unique_ptr<RateLimiter> retransmission_rate_limiter_; 134 const std::unique_ptr<RateLimiter> retransmission_rate_limiter_;
189 WrappingBitrateEstimator remote_bitrate_estimator_;
190 RemoteEstimatorProxy remote_estimator_proxy_;
191 TransportFeedbackAdapter transport_feedback_adapter_; 135 TransportFeedbackAdapter transport_feedback_adapter_;
192 rtc::CriticalSection network_state_lock_; 136 rtc::CriticalSection network_state_lock_;
193 uint32_t last_reported_bitrate_bps_ GUARDED_BY(network_state_lock_); 137 uint32_t last_reported_bitrate_bps_ GUARDED_BY(network_state_lock_);
194 uint8_t last_reported_fraction_loss_ GUARDED_BY(network_state_lock_); 138 uint8_t last_reported_fraction_loss_ GUARDED_BY(network_state_lock_);
195 int64_t last_reported_rtt_ GUARDED_BY(network_state_lock_); 139 int64_t last_reported_rtt_ GUARDED_BY(network_state_lock_);
196 NetworkState network_state_ GUARDED_BY(network_state_lock_); 140 NetworkState network_state_ GUARDED_BY(network_state_lock_);
197 rtc::CriticalSection bwe_lock_; 141 rtc::CriticalSection bwe_lock_;
198 int min_bitrate_bps_ GUARDED_BY(bwe_lock_); 142 int min_bitrate_bps_ GUARDED_BY(bwe_lock_);
199 std::unique_ptr<DelayBasedBwe> delay_based_bwe_ GUARDED_BY(bwe_lock_); 143 std::unique_ptr<DelayBasedBwe> delay_based_bwe_ GUARDED_BY(bwe_lock_);
200 144
201 rtc::ThreadChecker worker_thread_checker_; 145 rtc::ThreadChecker worker_thread_checker_;
202 146
203 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController); 147 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SendSideCongestionController);
204 }; 148 };
205 149
206 } // namespace webrtc 150 } // namespace webrtc
207 151
208 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_ 152 #endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_SEND_SIDE_CONGESTION_CON TROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698