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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 static const size_t kMinProbePacketSize = 200; | 64 static const size_t kMinProbePacketSize = 200; |
65 | 65 |
66 PacedSender(Clock* clock, | 66 PacedSender(Clock* clock, |
67 Callback* callback, | 67 Callback* callback, |
68 int bitrate_kbps, | 68 int bitrate_kbps, |
69 int max_bitrate_kbps, | 69 int max_bitrate_kbps, |
70 int min_bitrate_kbps); | 70 int min_bitrate_kbps); |
71 | 71 |
72 virtual ~PacedSender(); | 72 virtual ~PacedSender(); |
73 | 73 |
74 // Enable/disable pacing. | |
75 void SetStatus(bool enable); | |
76 | |
77 bool Enabled() const; | |
78 | |
79 // Temporarily pause all sending. | 74 // Temporarily pause all sending. |
80 void Pause(); | 75 void Pause(); |
81 | 76 |
82 // Resume sending packets. | 77 // Resume sending packets. |
83 void Resume(); | 78 void Resume(); |
84 | 79 |
85 // Enable bitrate probing. Enabled by default, mostly here to simplify | 80 // Enable bitrate probing. Enabled by default, mostly here to simplify |
86 // testing. Must be called before any packets are being sent to have an | 81 // testing. Must be called before any packets are being sent to have an |
87 // effect. | 82 // effect. |
88 void SetProbingEnabled(bool enabled); | 83 void SetProbingEnabled(bool enabled); |
89 | 84 |
90 // Set target bitrates for the pacer. | 85 // Set target bitrates for the pacer. |
91 // We will pace out bursts of packets at a bitrate of |max_bitrate_kbps|. | 86 // We will pace out bursts of packets at a bitrate of |max_bitrate_kbps|. |
92 // |bitrate_kbps| is our estimate of what we are allowed to send on average. | 87 // |bitrate_kbps| is our estimate of what we are allowed to send on average. |
93 // Padding packets will be utilized to reach |min_bitrate| unless enough media | 88 // Padding packets will be utilized to reach |min_bitrate| unless enough media |
94 // packets are available. | 89 // packets are available. |
95 void UpdateBitrate(int bitrate_kbps, | 90 void UpdateBitrate(int bitrate_kbps, |
96 int max_bitrate_kbps, | 91 int max_bitrate_kbps, |
97 int min_bitrate_kbps); | 92 int min_bitrate_kbps); |
98 | 93 |
99 // Returns true if we send the packet now, else it will add the packet | 94 // Returns true if we send the packet now, else it will add the packet |
100 // information to the queue and call TimeToSendPacket when it's time to send. | 95 // information to the queue and call TimeToSendPacket when it's time to send. |
101 bool SendPacket(RtpPacketSender::Priority priority, | 96 void InsertPacket(RtpPacketSender::Priority priority, |
102 uint32_t ssrc, | 97 uint32_t ssrc, |
103 uint16_t sequence_number, | 98 uint16_t sequence_number, |
104 int64_t capture_time_ms, | 99 int64_t capture_time_ms, |
105 size_t bytes, | 100 size_t bytes, |
106 bool retransmission) override; | 101 bool retransmission) override; |
107 | 102 |
108 // Returns the time since the oldest queued packet was enqueued. | 103 // Returns the time since the oldest queued packet was enqueued. |
109 virtual int64_t QueueInMs() const; | 104 virtual int64_t QueueInMs() const; |
110 | 105 |
111 virtual size_t QueueSizePackets() const; | 106 virtual size_t QueueSizePackets() const; |
112 | 107 |
113 // Returns the number of milliseconds it will take to send the current | 108 // Returns the number of milliseconds it will take to send the current |
114 // packets in the queue, given the current size and bitrate, ignoring prio. | 109 // packets in the queue, given the current size and bitrate, ignoring prio. |
115 virtual int64_t ExpectedQueueTimeMs() const; | 110 virtual int64_t ExpectedQueueTimeMs() const; |
116 | 111 |
(...skipping 10 matching lines...) Expand all Loading... |
127 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 122 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
128 | 123 |
129 bool SendPacket(const paced_sender::Packet& packet) | 124 bool SendPacket(const paced_sender::Packet& packet) |
130 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 125 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
131 void SendPadding(size_t padding_needed) EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 126 void SendPadding(size_t padding_needed) EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
132 | 127 |
133 Clock* const clock_; | 128 Clock* const clock_; |
134 Callback* const callback_; | 129 Callback* const callback_; |
135 | 130 |
136 rtc::scoped_ptr<CriticalSectionWrapper> critsect_; | 131 rtc::scoped_ptr<CriticalSectionWrapper> critsect_; |
137 bool enabled_ GUARDED_BY(critsect_); | |
138 bool paused_ GUARDED_BY(critsect_); | 132 bool paused_ GUARDED_BY(critsect_); |
139 bool probing_enabled_; | 133 bool probing_enabled_; |
140 // This is the media budget, keeping track of how many bits of media | 134 // This is the media budget, keeping track of how many bits of media |
141 // we can pace out during the current interval. | 135 // we can pace out during the current interval. |
142 rtc::scoped_ptr<paced_sender::IntervalBudget> media_budget_ | 136 rtc::scoped_ptr<paced_sender::IntervalBudget> media_budget_ |
143 GUARDED_BY(critsect_); | 137 GUARDED_BY(critsect_); |
144 // This is the padding budget, keeping track of how many bits of padding we're | 138 // This is the padding budget, keeping track of how many bits of padding we're |
145 // allowed to send out during the current interval. This budget will be | 139 // allowed to send out during the current interval. This budget will be |
146 // utilized when there's no media to send. | 140 // utilized when there's no media to send. |
147 rtc::scoped_ptr<paced_sender::IntervalBudget> padding_budget_ | 141 rtc::scoped_ptr<paced_sender::IntervalBudget> padding_budget_ |
148 GUARDED_BY(critsect_); | 142 GUARDED_BY(critsect_); |
149 | 143 |
150 rtc::scoped_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); | 144 rtc::scoped_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); |
151 int bitrate_bps_ GUARDED_BY(critsect_); | 145 int bitrate_bps_ GUARDED_BY(critsect_); |
152 | 146 |
153 int64_t time_last_update_us_ GUARDED_BY(critsect_); | 147 int64_t time_last_update_us_ GUARDED_BY(critsect_); |
154 | 148 |
155 rtc::scoped_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); | 149 rtc::scoped_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); |
156 uint64_t packet_counter_; | 150 uint64_t packet_counter_; |
157 }; | 151 }; |
158 } // namespace webrtc | 152 } // namespace webrtc |
159 #endif // WEBRTC_MODULES_PACING_INCLUDE_PACED_SENDER_H_ | 153 #endif // WEBRTC_MODULES_PACING_INCLUDE_PACED_SENDER_H_ |
OLD | NEW |