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

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

Issue 2340763004: Add AlrDetector (Closed)
Patch Set: Addressed comments Created 4 years, 3 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/base/thread_annotations.h" 18 #include "webrtc/base/thread_annotations.h"
19 #include "webrtc/modules/include/module.h" 19 #include "webrtc/modules/include/module.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
21 #include "webrtc/typedefs.h" 21 #include "webrtc/typedefs.h"
22 22
23 namespace webrtc { 23 namespace webrtc {
24 class AlrDetector;
24 class BitrateProber; 25 class BitrateProber;
25 class Clock; 26 class Clock;
26 class CriticalSectionWrapper; 27 class CriticalSectionWrapper;
27 28
28 namespace paced_sender { 29 namespace paced_sender {
29 class IntervalBudget; 30 class IntervalBudget;
30 struct Packet; 31 struct Packet;
31 class PacketQueue; 32 class PacketQueue;
32 } // namespace paced_sender 33 } // namespace paced_sender
33 34
(...skipping 11 matching lines...) Expand all
45 bool retransmission, 46 bool retransmission,
46 int probe_cluster_id) = 0; 47 int probe_cluster_id) = 0;
47 // Called when it's a good time to send a padding data. 48 // Called when it's a good time to send a padding data.
48 // Returns the number of bytes sent. 49 // Returns the number of bytes sent.
49 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0; 50 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0;
50 51
51 protected: 52 protected:
52 virtual ~PacketSender() {} 53 virtual ~PacketSender() {}
53 }; 54 };
54 55
56 class PacingObserver {
philipel 2016/09/19 11:25:22 Add a unittest that use the PacingObserver.
Irfan 2016/09/19 22:15:03 Done.
57 public:
58 virtual void OnBytesSent(size_t bytes_sent, int64_t elapsed_time_ms) = 0;
59
60 protected:
61 virtual ~PacingObserver() {}
62 };
63
55 // Expected max pacer delay in ms. If ExpectedQueueTimeMs() is higher than 64 // Expected max pacer delay in ms. If ExpectedQueueTimeMs() is higher than
56 // this value, the packet producers should wait (eg drop frames rather than 65 // this value, the packet producers should wait (eg drop frames rather than
57 // encoding them). Bitrate sent may temporarily exceed target set by 66 // encoding them). Bitrate sent may temporarily exceed target set by
58 // UpdateBitrate() so that this limit will be upheld. 67 // UpdateBitrate() so that this limit will be upheld.
59 static const int64_t kMaxQueueLengthMs; 68 static const int64_t kMaxQueueLengthMs;
60 // Pacing-rate relative to our target send rate. 69 // Pacing-rate relative to our target send rate.
61 // Multiplicative factor that is applied to the target bitrate to calculate 70 // Multiplicative factor that is applied to the target bitrate to calculate
62 // the number of bytes that can be transmitted per interval. 71 // the number of bytes that can be transmitted per interval.
63 // Increasing this factor will result in lower delays in cases of bitrate 72 // Increasing this factor will result in lower delays in cases of bitrate
64 // overshoots from the encoder. 73 // overshoots from the encoder.
65 static const float kDefaultPaceMultiplier; 74 static const float kDefaultPaceMultiplier;
66 75
67 static const size_t kMinProbePacketSize = 200; 76 static const size_t kMinProbePacketSize = 200;
68 77
69 PacedSender(Clock* clock, 78 PacedSender(Clock* clock,
70 PacketSender* packet_sender); 79 PacketSender* packet_sender,
80 PacingObserver* pacing_observer);
71 81
72 virtual ~PacedSender(); 82 virtual ~PacedSender();
73 83
74 virtual void CreateProbeCluster(int bitrate_bps, int num_packets); 84 virtual void CreateProbeCluster(int bitrate_bps, int num_packets);
75 85
76 // Temporarily pause all sending. 86 // Temporarily pause all sending.
77 void Pause(); 87 void Pause();
78 88
79 // Resume sending packets. 89 // Resume sending packets.
80 void Resume(); 90 void Resume();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 135
126 // Returns the number of milliseconds until the module want a worker thread 136 // Returns the number of milliseconds until the module want a worker thread
127 // to call Process. 137 // to call Process.
128 int64_t TimeUntilNextProcess() override; 138 int64_t TimeUntilNextProcess() override;
129 139
130 // Process any pending packets in the queue(s). 140 // Process any pending packets in the queue(s).
131 void Process() override; 141 void Process() override;
132 142
133 private: 143 private:
134 // Updates the number of bytes that can be sent for the next time interval. 144 // Updates the number of bytes that can be sent for the next time interval.
135 void UpdateBytesPerInterval(int64_t delta_time_in_ms) 145 void UpdateBudgetWithElapsedTime(int64_t delta_time_in_ms)
146 EXCLUSIVE_LOCKS_REQUIRED(critsect_);
147 void UpdateBudgetWithBytesSent(size_t bytes)
136 EXCLUSIVE_LOCKS_REQUIRED(critsect_); 148 EXCLUSIVE_LOCKS_REQUIRED(critsect_);
137 149
138 bool SendPacket(const paced_sender::Packet& packet, int probe_cluster_id) 150 bool SendPacket(const paced_sender::Packet& packet, int probe_cluster_id)
139 EXCLUSIVE_LOCKS_REQUIRED(critsect_); 151 EXCLUSIVE_LOCKS_REQUIRED(critsect_);
140 size_t SendPadding(size_t padding_needed, int probe_cluster_id) 152 size_t SendPadding(size_t padding_needed, int probe_cluster_id)
141 EXCLUSIVE_LOCKS_REQUIRED(critsect_); 153 EXCLUSIVE_LOCKS_REQUIRED(critsect_);
142 154
143 Clock* const clock_; 155 Clock* const clock_;
144 PacketSender* const packet_sender_; 156 PacketSender* const packet_sender_;
157 PacingObserver* const pacing_observer_;
145 158
146 std::unique_ptr<CriticalSectionWrapper> critsect_; 159 std::unique_ptr<CriticalSectionWrapper> critsect_;
147 bool paused_ GUARDED_BY(critsect_); 160 bool paused_ GUARDED_BY(critsect_);
148 // This is the media budget, keeping track of how many bits of media 161 // This is the media budget, keeping track of how many bits of media
149 // we can pace out during the current interval. 162 // we can pace out during the current interval.
150 std::unique_ptr<paced_sender::IntervalBudget> media_budget_ 163 std::unique_ptr<paced_sender::IntervalBudget> media_budget_
151 GUARDED_BY(critsect_); 164 GUARDED_BY(critsect_);
152 // This is the padding budget, keeping track of how many bits of padding we're 165 // This is the padding budget, keeping track of how many bits of padding we're
153 // allowed to send out during the current interval. This budget will be 166 // allowed to send out during the current interval. This budget will be
154 // utilized when there's no media to send. 167 // utilized when there's no media to send.
155 std::unique_ptr<paced_sender::IntervalBudget> padding_budget_ 168 std::unique_ptr<paced_sender::IntervalBudget> padding_budget_
156 GUARDED_BY(critsect_); 169 GUARDED_BY(critsect_);
157 170
158 std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); 171 std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_);
159 // Actual configured bitrates (media_budget_ may temporarily be higher in 172 // Actual configured bitrates (media_budget_ may temporarily be higher in
160 // order to meet pace time constraint). 173 // order to meet pace time constraint).
161 uint32_t estimated_bitrate_bps_ GUARDED_BY(critsect_); 174 uint32_t estimated_bitrate_bps_ GUARDED_BY(critsect_);
162 uint32_t min_send_bitrate_kbps_ GUARDED_BY(critsect_); 175 uint32_t min_send_bitrate_kbps_ GUARDED_BY(critsect_);
163 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_); 176 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_);
164 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_); 177 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_);
165 178
166 int64_t time_last_update_us_ GUARDED_BY(critsect_); 179 int64_t time_last_update_us_ GUARDED_BY(critsect_);
167 180
168 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); 181 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_);
169 uint64_t packet_counter_; 182 uint64_t packet_counter_;
170 }; 183 };
171 } // namespace webrtc 184 } // namespace webrtc
172 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_ 185 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698