| 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 |
| 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/checks.h" |
| 18 #include "webrtc/base/thread_annotations.h" | 19 #include "webrtc/base/thread_annotations.h" |
| 19 #include "webrtc/modules/include/module.h" | 20 #include "webrtc/modules/include/module.h" |
| 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 21 #include "webrtc/typedefs.h" | 22 #include "webrtc/typedefs.h" |
| 22 | 23 |
| 23 namespace webrtc { | 24 namespace webrtc { |
| 24 class BitrateProber; | 25 class BitrateProber; |
| 25 class Clock; | 26 class Clock; |
| 26 class CriticalSectionWrapper; | 27 class CriticalSectionWrapper; |
| 27 | 28 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Enable bitrate probing. Enabled by default, mostly here to simplify | 81 // Enable bitrate probing. Enabled by default, mostly here to simplify |
| 81 // testing. Must be called before any packets are being sent to have an | 82 // testing. Must be called before any packets are being sent to have an |
| 82 // effect. | 83 // effect. |
| 83 void SetProbingEnabled(bool enabled); | 84 void SetProbingEnabled(bool enabled); |
| 84 | 85 |
| 85 // Sets the estimated capacity of the network. Must be called once before | 86 // Sets the estimated capacity of the network. Must be called once before |
| 86 // packets can be sent. | 87 // packets can be sent. |
| 87 // |bitrate_bps| is our estimate of what we are allowed to send on average. | 88 // |bitrate_bps| is our estimate of what we are allowed to send on average. |
| 88 // We will pace out bursts of packets at a bitrate of | 89 // We will pace out bursts of packets at a bitrate of |
| 89 // |bitrate_bps| * kDefaultPaceMultiplier. | 90 // |bitrate_bps| * kDefaultPaceMultiplier. |
| 90 virtual void SetEstimatedBitrate(uint32_t bitrate_bps); | 91 virtual void SetEstimatedBitrate(int bitrate_bps); |
| 91 | 92 |
| 92 // Sets the minimum send bitrate and maximum padding bitrate requested by send | 93 // Sets the minimum send bitrate and maximum padding bitrate requested by send |
| 93 // streams. | 94 // streams. |
| 94 // |min_send_bitrate_bps| might be higher that the estimated available network | 95 // |min_send_bitrate_bps| might be higher that the estimated available network |
| 95 // bitrate and if so, the pacer will send with |min_send_bitrate_bps|. | 96 // bitrate and if so, the pacer will send with |min_send_bitrate_bps|. |
| 96 // |max_padding_bitrate_bps| might be higher than the estimate available | 97 // |max_padding_bitrate_bps| might be higher than the estimate available |
| 97 // network bitrate and if so, the pacer will send padding packets to reach | 98 // network bitrate and if so, the pacer will send padding packets to reach |
| 98 // the min of the estimated available bitrate and |max_padding_bitrate_bps|. | 99 // the min of the estimated available bitrate and |max_padding_bitrate_bps|. |
| 99 void SetSendBitrateLimits(int min_send_bitrate_bps, | 100 void SetSendBitrateLimits(int min_send_bitrate_bps, |
| 100 int max_padding_bitrate_bps); | 101 int max_padding_bitrate_bps); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 121 // packets currently in the pacer queue, or 0 if queue is empty. | 122 // packets currently in the pacer queue, or 0 if queue is empty. |
| 122 virtual int64_t AverageQueueTimeMs(); | 123 virtual int64_t AverageQueueTimeMs(); |
| 123 | 124 |
| 124 // Returns the number of milliseconds until the module want a worker thread | 125 // Returns the number of milliseconds until the module want a worker thread |
| 125 // to call Process. | 126 // to call Process. |
| 126 int64_t TimeUntilNextProcess() override; | 127 int64_t TimeUntilNextProcess() override; |
| 127 | 128 |
| 128 // Process any pending packets in the queue(s). | 129 // Process any pending packets in the queue(s). |
| 129 void Process() override; | 130 void Process() override; |
| 130 | 131 |
| 132 bool IsExpectingProbingResults() const; |
| 133 |
| 131 private: | 134 private: |
| 132 // Updates the number of bytes that can be sent for the next time interval. | 135 // Updates the number of bytes that can be sent for the next time interval. |
| 133 void UpdateBytesPerInterval(int64_t delta_time_in_ms) | 136 void UpdateBytesPerInterval(int64_t delta_time_in_ms) |
| 134 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 137 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 135 | 138 |
| 136 bool SendPacket(const paced_sender::Packet& packet, int probe_cluster_id) | 139 bool SendPacket(const paced_sender::Packet& packet, int probe_cluster_id) |
| 137 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 140 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 138 void SendPadding(size_t padding_needed, int probe_cluster_id) | 141 void SendPadding(size_t padding_needed, int probe_cluster_id) |
| 139 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 142 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 140 | 143 |
| 141 Clock* const clock_; | 144 Clock* const clock_; |
| 142 PacketSender* const packet_sender_; | 145 PacketSender* const packet_sender_; |
| 143 | 146 |
| 144 std::unique_ptr<CriticalSectionWrapper> critsect_; | 147 std::unique_ptr<CriticalSectionWrapper> critsect_; |
| 145 bool paused_ GUARDED_BY(critsect_); | 148 bool paused_ GUARDED_BY(critsect_); |
| 146 // This is the media budget, keeping track of how many bits of media | 149 // This is the media budget, keeping track of how many bits of media |
| 147 // we can pace out during the current interval. | 150 // we can pace out during the current interval. |
| 148 std::unique_ptr<paced_sender::IntervalBudget> media_budget_ | 151 std::unique_ptr<paced_sender::IntervalBudget> media_budget_ |
| 149 GUARDED_BY(critsect_); | 152 GUARDED_BY(critsect_); |
| 150 // This is the padding budget, keeping track of how many bits of padding we're | 153 // This is the padding budget, keeping track of how many bits of padding we're |
| 151 // allowed to send out during the current interval. This budget will be | 154 // allowed to send out during the current interval. This budget will be |
| 152 // utilized when there's no media to send. | 155 // utilized when there's no media to send. |
| 153 std::unique_ptr<paced_sender::IntervalBudget> padding_budget_ | 156 std::unique_ptr<paced_sender::IntervalBudget> padding_budget_ |
| 154 GUARDED_BY(critsect_); | 157 GUARDED_BY(critsect_); |
| 155 | 158 |
| 156 std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); | 159 std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); |
| 157 // Actual configured bitrates (media_budget_ may temporarily be higher in | 160 // Actual configured bitrates (media_budget_ may temporarily be higher in |
| 158 // order to meet pace time constraint). | 161 // order to meet pace time constraint). |
| 159 uint32_t estimated_bitrate_bps_ GUARDED_BY(critsect_); | 162 int estimated_bitrate_bps_ GUARDED_BY(critsect_); |
| 160 uint32_t min_send_bitrate_kbps_ GUARDED_BY(critsect_); | 163 int min_send_bitrate_kbps_ GUARDED_BY(critsect_); |
| 161 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_); | 164 int max_padding_bitrate_kbps_ GUARDED_BY(critsect_); |
| 162 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_); | 165 int pacing_bitrate_kbps_ GUARDED_BY(critsect_); |
| 163 | 166 |
| 164 int64_t time_last_update_us_ GUARDED_BY(critsect_); | 167 int64_t time_last_update_us_ GUARDED_BY(critsect_); |
| 165 | 168 |
| 166 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); | 169 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); |
| 167 uint64_t packet_counter_; | 170 uint64_t packet_counter_; |
| 168 }; | 171 }; |
| 169 } // namespace webrtc | 172 } // namespace webrtc |
| 170 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_ | 173 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_ |
| OLD | NEW |