| 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/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 26 matching lines...) Expand all Loading... |
| 60 // Pacing-rate relative to our target send rate. | 61 // Pacing-rate relative to our target send rate. |
| 61 // Multiplicative factor that is applied to the target bitrate to calculate | 62 // Multiplicative factor that is applied to the target bitrate to calculate |
| 62 // the number of bytes that can be transmitted per interval. | 63 // the number of bytes that can be transmitted per interval. |
| 63 // Increasing this factor will result in lower delays in cases of bitrate | 64 // Increasing this factor will result in lower delays in cases of bitrate |
| 64 // overshoots from the encoder. | 65 // overshoots from the encoder. |
| 65 static const float kDefaultPaceMultiplier; | 66 static const float kDefaultPaceMultiplier; |
| 66 | 67 |
| 67 static const size_t kMinProbePacketSize = 200; | 68 static const size_t kMinProbePacketSize = 200; |
| 68 | 69 |
| 69 PacedSender(Clock* clock, | 70 PacedSender(Clock* clock, |
| 70 PacketSender* packet_sender); | 71 PacketSender* packet_sender, |
| 72 AlrDetector* alr_detector); |
| 71 | 73 |
| 72 virtual ~PacedSender(); | 74 virtual ~PacedSender(); |
| 73 | 75 |
| 74 virtual void CreateProbeCluster(int bitrate_bps, int num_packets); | 76 virtual void CreateProbeCluster(int bitrate_bps, int num_packets); |
| 75 | 77 |
| 76 // Temporarily pause all sending. | 78 // Temporarily pause all sending. |
| 77 void Pause(); | 79 void Pause(); |
| 78 | 80 |
| 79 // Resume sending packets. | 81 // Resume sending packets. |
| 80 void Resume(); | 82 void Resume(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 127 |
| 126 // Returns the number of milliseconds until the module want a worker thread | 128 // Returns the number of milliseconds until the module want a worker thread |
| 127 // to call Process. | 129 // to call Process. |
| 128 int64_t TimeUntilNextProcess() override; | 130 int64_t TimeUntilNextProcess() override; |
| 129 | 131 |
| 130 // Process any pending packets in the queue(s). | 132 // Process any pending packets in the queue(s). |
| 131 void Process() override; | 133 void Process() override; |
| 132 | 134 |
| 133 private: | 135 private: |
| 134 // Updates the number of bytes that can be sent for the next time interval. | 136 // Updates the number of bytes that can be sent for the next time interval. |
| 135 void UpdateBytesPerInterval(int64_t delta_time_in_ms) | 137 void UpdateBudgetWithElapsedTime(int64_t delta_time_in_ms) |
| 138 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 139 void UpdateBudgetWithBytesSent(size_t bytes) |
| 136 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 140 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 137 | 141 |
| 138 bool SendPacket(const paced_sender::Packet& packet, int probe_cluster_id) | 142 bool SendPacket(const paced_sender::Packet& packet, int probe_cluster_id) |
| 139 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 143 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 140 void SendPadding(size_t padding_needed, int probe_cluster_id) | 144 void SendPadding(size_t padding_needed, int probe_cluster_id) |
| 141 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 145 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 142 | 146 |
| 143 Clock* const clock_; | 147 Clock* const clock_; |
| 144 PacketSender* const packet_sender_; | 148 PacketSender* const packet_sender_; |
| 149 AlrDetector* const alr_detector_ GUARDED_BY(critsect_); |
| 145 | 150 |
| 146 std::unique_ptr<CriticalSectionWrapper> critsect_; | 151 std::unique_ptr<CriticalSectionWrapper> critsect_; |
| 147 bool paused_ GUARDED_BY(critsect_); | 152 bool paused_ GUARDED_BY(critsect_); |
| 148 // This is the media budget, keeping track of how many bits of media | 153 // This is the media budget, keeping track of how many bits of media |
| 149 // we can pace out during the current interval. | 154 // we can pace out during the current interval. |
| 150 std::unique_ptr<paced_sender::IntervalBudget> media_budget_ | 155 std::unique_ptr<paced_sender::IntervalBudget> media_budget_ |
| 151 GUARDED_BY(critsect_); | 156 GUARDED_BY(critsect_); |
| 152 // This is the padding budget, keeping track of how many bits of padding we're | 157 // 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 | 158 // allowed to send out during the current interval. This budget will be |
| 154 // utilized when there's no media to send. | 159 // utilized when there's no media to send. |
| 155 std::unique_ptr<paced_sender::IntervalBudget> padding_budget_ | 160 std::unique_ptr<paced_sender::IntervalBudget> padding_budget_ |
| 156 GUARDED_BY(critsect_); | 161 GUARDED_BY(critsect_); |
| 157 | 162 |
| 158 std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); | 163 std::unique_ptr<BitrateProber> prober_ GUARDED_BY(critsect_); |
| 159 // Actual configured bitrates (media_budget_ may temporarily be higher in | 164 // Actual configured bitrates (media_budget_ may temporarily be higher in |
| 160 // order to meet pace time constraint). | 165 // order to meet pace time constraint). |
| 161 uint32_t estimated_bitrate_bps_ GUARDED_BY(critsect_); | 166 uint32_t estimated_bitrate_bps_ GUARDED_BY(critsect_); |
| 162 uint32_t min_send_bitrate_kbps_ GUARDED_BY(critsect_); | 167 uint32_t min_send_bitrate_kbps_ GUARDED_BY(critsect_); |
| 163 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_); | 168 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_); |
| 164 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_); | 169 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_); |
| 165 | 170 |
| 166 int64_t time_last_update_us_ GUARDED_BY(critsect_); | 171 int64_t time_last_update_us_ GUARDED_BY(critsect_); |
| 167 | 172 |
| 168 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); | 173 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); |
| 169 uint64_t packet_counter_; | 174 uint64_t packet_counter_; |
| 170 }; | 175 }; |
| 171 } // namespace webrtc | 176 } // namespace webrtc |
| 172 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_ | 177 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_ |
| OLD | NEW |