| 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 28 matching lines...) Expand all Loading... |
| 39 class PacketSender { | 39 class PacketSender { |
| 40 public: | 40 public: |
| 41 // 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 |
| 42 // module again. | 42 // module again. |
| 43 // Called when it's time to send a queued packet. | 43 // Called when it's time to send a queued packet. |
| 44 // Returns false if packet cannot be sent. | 44 // Returns false if packet cannot be sent. |
| 45 virtual bool TimeToSendPacket(uint32_t ssrc, | 45 virtual bool TimeToSendPacket(uint32_t ssrc, |
| 46 uint16_t sequence_number, | 46 uint16_t sequence_number, |
| 47 int64_t capture_time_ms, | 47 int64_t capture_time_ms, |
| 48 bool retransmission, | 48 bool retransmission, |
| 49 int probe_cluster_id) = 0; | 49 const PacedPacketInfo& cluster_info) = 0; |
| 50 // Called when it's a good time to send a padding data. | 50 // Called when it's a good time to send a padding data. |
| 51 // Returns the number of bytes sent. | 51 // Returns the number of bytes sent. |
| 52 virtual size_t TimeToSendPadding(size_t bytes, int probe_cluster_id) = 0; | 52 virtual size_t TimeToSendPadding(size_t bytes, |
| 53 const PacedPacketInfo& cluster_info) = 0; |
| 53 | 54 |
| 54 protected: | 55 protected: |
| 55 virtual ~PacketSender() {} | 56 virtual ~PacketSender() {} |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 // Expected max pacer delay in ms. If ExpectedQueueTimeMs() is higher than | 59 // Expected max pacer delay in ms. If ExpectedQueueTimeMs() is higher than |
| 59 // this value, the packet producers should wait (eg drop frames rather than | 60 // this value, the packet producers should wait (eg drop frames rather than |
| 60 // encoding them). Bitrate sent may temporarily exceed target set by | 61 // encoding them). Bitrate sent may temporarily exceed target set by |
| 61 // UpdateBitrate() so that this limit will be upheld. | 62 // UpdateBitrate() so that this limit will be upheld. |
| 62 static const int64_t kMaxQueueLengthMs; | 63 static const int64_t kMaxQueueLengthMs; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // Process any pending packets in the queue(s). | 139 // Process any pending packets in the queue(s). |
| 139 void Process() override; | 140 void Process() override; |
| 140 | 141 |
| 141 private: | 142 private: |
| 142 // Updates the number of bytes that can be sent for the next time interval. | 143 // Updates the number of bytes that can be sent for the next time interval. |
| 143 void UpdateBudgetWithElapsedTime(int64_t delta_time_in_ms) | 144 void UpdateBudgetWithElapsedTime(int64_t delta_time_in_ms) |
| 144 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 145 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 145 void UpdateBudgetWithBytesSent(size_t bytes) | 146 void UpdateBudgetWithBytesSent(size_t bytes) |
| 146 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 147 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 147 | 148 |
| 148 bool SendPacket(const paced_sender::Packet& packet, int probe_cluster_id) | 149 bool SendPacket(const paced_sender::Packet& packet, |
| 150 const PacedPacketInfo& cluster_info) |
| 149 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 151 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 150 size_t SendPadding(size_t padding_needed, int probe_cluster_id) | 152 size_t SendPadding(size_t padding_needed, const PacedPacketInfo& cluster_info) |
| 151 EXCLUSIVE_LOCKS_REQUIRED(critsect_); | 153 EXCLUSIVE_LOCKS_REQUIRED(critsect_); |
| 152 | 154 |
| 153 Clock* const clock_; | 155 Clock* const clock_; |
| 154 PacketSender* const packet_sender_; | 156 PacketSender* const packet_sender_; |
| 155 std::unique_ptr<AlrDetector> alr_detector_ GUARDED_BY(critsect_); | 157 std::unique_ptr<AlrDetector> alr_detector_ GUARDED_BY(critsect_); |
| 156 | 158 |
| 157 std::unique_ptr<CriticalSectionWrapper> critsect_; | 159 std::unique_ptr<CriticalSectionWrapper> critsect_; |
| 158 bool paused_ GUARDED_BY(critsect_); | 160 bool paused_ GUARDED_BY(critsect_); |
| 159 // 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 |
| 160 // we can pace out during the current interval. | 162 // we can pace out during the current interval. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 174 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_); | 176 uint32_t max_padding_bitrate_kbps_ GUARDED_BY(critsect_); |
| 175 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_); | 177 uint32_t pacing_bitrate_kbps_ GUARDED_BY(critsect_); |
| 176 | 178 |
| 177 int64_t time_last_update_us_ GUARDED_BY(critsect_); | 179 int64_t time_last_update_us_ GUARDED_BY(critsect_); |
| 178 | 180 |
| 179 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); | 181 std::unique_ptr<paced_sender::PacketQueue> packets_ GUARDED_BY(critsect_); |
| 180 uint64_t packet_counter_; | 182 uint64_t packet_counter_; |
| 181 }; | 183 }; |
| 182 } // namespace webrtc | 184 } // namespace webrtc |
| 183 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_ | 185 #endif // WEBRTC_MODULES_PACING_PACED_SENDER_H_ |
| OLD | NEW |