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

Side by Side Diff: webrtc/modules/pacing/paced_sender.h

Issue 2999073002: Tweaked version of BBR for WebRTC. (Closed)
Patch Set: Rebase. Created 3 years, 4 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_PACING_PACED_SENDER_H_ 11 #ifndef WEBRTC_MODULES_PACING_PACED_SENDER_H_
12 #define WEBRTC_MODULES_PACING_PACED_SENDER_H_ 12 #define WEBRTC_MODULES_PACING_PACED_SENDER_H_
13 13
14 #include <list> 14 #include <list>
15 #include <memory> 15 #include <memory>
16 #include <set> 16 #include <set>
17 17
18 #include "webrtc/modules/include/module.h" 18 #include "webrtc/modules/pacing/pacer.h"
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
20 #include "webrtc/rtc_base/criticalsection.h" 19 #include "webrtc/rtc_base/criticalsection.h"
21 #include "webrtc/rtc_base/optional.h" 20 #include "webrtc/rtc_base/optional.h"
22 #include "webrtc/rtc_base/thread_annotations.h" 21 #include "webrtc/rtc_base/thread_annotations.h"
23 #include "webrtc/typedefs.h" 22 #include "webrtc/typedefs.h"
24 23
25 namespace webrtc { 24 namespace webrtc {
26 class AlrDetector; 25 class AlrDetector;
27 class BitrateProber; 26 class BitrateProber;
28 class Clock; 27 class Clock;
29 class ProbeClusterCreatedObserver; 28 class ProbeClusterCreatedObserver;
30 class RtcEventLog; 29 class RtcEventLog;
31 class IntervalBudget;
32 30
33 namespace paced_sender { 31 namespace paced_sender {
32 class IntervalBudget;
34 struct Packet; 33 struct Packet;
35 class PacketQueue; 34 class PacketQueue;
36 } // namespace paced_sender 35 } // namespace paced_sender
37 36
38 class PacedSender : public Module, public RtpPacketSender { 37 class PacedSender : public Pacer {
39 public: 38 public:
40 class PacketSender { 39 class PacketSender {
41 public: 40 public:
42 // Note: packets sent as a result of a callback should not pass by this 41 // Note: packets sent as a result of a callback should not pass by this
43 // module again. 42 // module again.
44 // Called when it's time to send a queued packet. 43 // Called when it's time to send a queued packet.
45 // Returns false if packet cannot be sent. 44 // Returns false if packet cannot be sent.
46 virtual bool TimeToSendPacket(uint32_t ssrc, 45 virtual bool TimeToSendPacket(uint32_t ssrc,
47 uint16_t sequence_number, 46 uint16_t sequence_number,
48 int64_t capture_time_ms, 47 int64_t capture_time_ms,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Enable bitrate probing. Enabled by default, mostly here to simplify 85 // Enable bitrate probing. Enabled by default, mostly here to simplify
87 // testing. Must be called before any packets are being sent to have an 86 // testing. Must be called before any packets are being sent to have an
88 // effect. 87 // effect.
89 void SetProbingEnabled(bool enabled); 88 void SetProbingEnabled(bool enabled);
90 89
91 // Sets the estimated capacity of the network. Must be called once before 90 // Sets the estimated capacity of the network. Must be called once before
92 // packets can be sent. 91 // packets can be sent.
93 // |bitrate_bps| is our estimate of what we are allowed to send on average. 92 // |bitrate_bps| is our estimate of what we are allowed to send on average.
94 // We will pace out bursts of packets at a bitrate of 93 // We will pace out bursts of packets at a bitrate of
95 // |bitrate_bps| * kDefaultPaceMultiplier. 94 // |bitrate_bps| * kDefaultPaceMultiplier.
96 virtual void SetEstimatedBitrate(uint32_t bitrate_bps); 95 void SetEstimatedBitrate(uint32_t bitrate_bps) override;
97 96
98 // Sets the minimum send bitrate and maximum padding bitrate requested by send 97 // Sets the minimum send bitrate and maximum padding bitrate requested by send
99 // streams. 98 // streams.
100 // |min_send_bitrate_bps| might be higher that the estimated available network 99 // |min_send_bitrate_bps| might be higher that the estimated available network
101 // bitrate and if so, the pacer will send with |min_send_bitrate_bps|. 100 // bitrate and if so, the pacer will send with |min_send_bitrate_bps|.
102 // |max_padding_bitrate_bps| might be higher than the estimate available 101 // |max_padding_bitrate_bps| might be higher than the estimate available
103 // network bitrate and if so, the pacer will send padding packets to reach 102 // network bitrate and if so, the pacer will send padding packets to reach
104 // the min of the estimated available bitrate and |max_padding_bitrate_bps|. 103 // the min of the estimated available bitrate and |max_padding_bitrate_bps|.
105 void SetSendBitrateLimits(int min_send_bitrate_bps, 104 void SetSendBitrateLimits(int min_send_bitrate_bps,
106 int max_padding_bitrate_bps); 105 int max_padding_bitrate_bps);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Returns the number of milliseconds until the module want a worker thread 142 // Returns the number of milliseconds until the module want a worker thread
144 // to call Process. 143 // to call Process.
145 int64_t TimeUntilNextProcess() override; 144 int64_t TimeUntilNextProcess() override;
146 145
147 // Process any pending packets in the queue(s). 146 // Process any pending packets in the queue(s).
148 void Process() override; 147 void Process() override;
149 148
150 // Called when the prober is associated with a process thread. 149 // Called when the prober is associated with a process thread.
151 void ProcessThreadAttached(ProcessThread* process_thread) override; 150 void ProcessThreadAttached(ProcessThread* process_thread) override;
152 151
153 void SetPacingFactor(float pacing_factor);
154 void SetQueueTimeLimit(int limit_ms);
155
156 private: 152 private:
157 // Updates the number of bytes that can be sent for the next time interval. 153 // Updates the number of bytes that can be sent for the next time interval.
158 void UpdateBudgetWithElapsedTime(int64_t delta_time_in_ms) 154 void UpdateBudgetWithElapsedTime(int64_t delta_time_in_ms)
159 EXCLUSIVE_LOCKS_REQUIRED(critsect_); 155 EXCLUSIVE_LOCKS_REQUIRED(critsect_);
160 void UpdateBudgetWithBytesSent(size_t bytes) 156 void UpdateBudgetWithBytesSent(size_t bytes)
161 EXCLUSIVE_LOCKS_REQUIRED(critsect_); 157 EXCLUSIVE_LOCKS_REQUIRED(critsect_);
162 158
163 bool SendPacket(const paced_sender::Packet& packet, 159 bool SendPacket(const paced_sender::Packet& packet,
164 const PacedPacketInfo& cluster_info) 160 const PacedPacketInfo& cluster_info)
165 EXCLUSIVE_LOCKS_REQUIRED(critsect_); 161 EXCLUSIVE_LOCKS_REQUIRED(critsect_);
166 size_t SendPadding(size_t padding_needed, const PacedPacketInfo& cluster_info) 162 size_t SendPadding(size_t padding_needed, const PacedPacketInfo& cluster_info)
167 EXCLUSIVE_LOCKS_REQUIRED(critsect_); 163 EXCLUSIVE_LOCKS_REQUIRED(critsect_);
168 164
169 const Clock* const clock_; 165 const Clock* const clock_;
170 PacketSender* const packet_sender_; 166 PacketSender* const packet_sender_;
171 std::unique_ptr<AlrDetector> alr_detector_ GUARDED_BY(critsect_); 167 std::unique_ptr<AlrDetector> alr_detector_ GUARDED_BY(critsect_);
172 168
173 rtc::CriticalSection critsect_; 169 rtc::CriticalSection critsect_;
174 bool paused_ GUARDED_BY(critsect_); 170 bool paused_ GUARDED_BY(critsect_);
175 // This is the media budget, keeping track of how many bits of media 171 // This is the media budget, keeping track of how many bits of media
176 // we can pace out during the current interval. 172 // we can pace out during the current interval.
177 std::unique_ptr<IntervalBudget> media_budget_ GUARDED_BY(critsect_); 173 std::unique_ptr<paced_sender::IntervalBudget> media_budget_
174 GUARDED_BY(critsect_);
178 // This is the padding budget, keeping track of how many bits of padding we're 175 // This is the padding budget, keeping track of how many bits of padding we're
179 // allowed to send out during the current interval. This budget will be 176 // allowed to send out during the current interval. This budget will be
180 // utilized when there's no media to send. 177 // utilized when there's no media to send.
181 std::unique_ptr<IntervalBudget> padding_budget_ GUARDED_BY(critsect_); 178 std::unique_ptr<paced_sender::IntervalBudget> padding_budget_
179 GUARDED_BY(critsect_);
182 180
183 std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); 181 std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_);
184 bool probing_send_failure_; 182 bool probing_send_failure_;
185 // Actual configured bitrates (media_budget_ may temporarily be higher in 183 // Actual configured bitrates (media_budget_ may temporarily be higher in
186 // order to meet pace time constraint). 184 // order to meet pace time constraint).
187 uint32_t estimated_bitrate_bps_ GUARDED_BY(critsect_); 185 uint32_t estimated_bitrate_bps_ GUARDED_BY(critsect_);
188 uint32_t min_send_bitrate_kbps_ GUARDED_BY(critsect_); 186 uint32_t min_send_bitrate_kbps_ GUARDED_BY(critsect_);
189 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_); 187 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_);
190 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_); 188 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_);
191 189
192 int64_t time_last_update_us_ GUARDED_BY(critsect_); 190 int64_t time_last_update_us_ GUARDED_BY(critsect_);
193 int64_t first_sent_packet_ms_ GUARDED_BY(critsect_); 191 int64_t first_sent_packet_ms_ GUARDED_BY(critsect_);
194 192
195 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); 193 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_);
196 uint64_t packet_counter_; 194 uint64_t packet_counter_;
197 ProcessThread* process_thread_ = nullptr; 195 ProcessThread* process_thread_ = nullptr;
198
199 float pacing_factor_ GUARDED_BY(critsect_);
200 int64_t queue_time_limit GUARDED_BY(critsect_);
201 }; 196 };
202 } // namespace webrtc 197 } // namespace webrtc
203 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_ 198 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698