| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 if (first->capture_time_ms != second->capture_time_ms) | 84 if (first->capture_time_ms != second->capture_time_ms) |
| 85 return first->capture_time_ms > second->capture_time_ms; | 85 return first->capture_time_ms > second->capture_time_ms; |
| 86 | 86 |
| 87 return first->enqueue_order > second->enqueue_order; | 87 return first->enqueue_order > second->enqueue_order; |
| 88 } | 88 } |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // Class encapsulating a priority queue with some extensions. | 91 // Class encapsulating a priority queue with some extensions. |
| 92 class PacketQueue { | 92 class PacketQueue { |
| 93 public: | 93 public: |
| 94 explicit PacketQueue(Clock* clock) | 94 explicit PacketQueue(const Clock* clock) |
| 95 : bytes_(0), | 95 : bytes_(0), |
| 96 clock_(clock), | 96 clock_(clock), |
| 97 queue_time_sum_(0), | 97 queue_time_sum_(0), |
| 98 time_last_updated_(clock_->TimeInMilliseconds()) {} | 98 time_last_updated_(clock_->TimeInMilliseconds()) {} |
| 99 virtual ~PacketQueue() {} | 99 virtual ~PacketQueue() {} |
| 100 | 100 |
| 101 void Push(const Packet& packet) { | 101 void Push(const Packet& packet) { |
| 102 if (!AddToDupeSet(packet)) | 102 if (!AddToDupeSet(packet)) |
| 103 return; | 103 return; |
| 104 | 104 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // occur out of order, use list instead of vector. | 189 // occur out of order, use list instead of vector. |
| 190 std::list<Packet> packet_list_; | 190 std::list<Packet> packet_list_; |
| 191 // Priority queue of the packets, sorted according to Comparator. | 191 // Priority queue of the packets, sorted according to Comparator. |
| 192 // Use pointers into list, to avoid moving whole struct within heap. | 192 // Use pointers into list, to avoid moving whole struct within heap. |
| 193 std::priority_queue<Packet*, std::vector<Packet*>, Comparator> prio_queue_; | 193 std::priority_queue<Packet*, std::vector<Packet*>, Comparator> prio_queue_; |
| 194 // Total number of bytes in the queue. | 194 // Total number of bytes in the queue. |
| 195 uint64_t bytes_; | 195 uint64_t bytes_; |
| 196 // Map<ssrc, std::set<seq_no> >, for checking duplicates. | 196 // Map<ssrc, std::set<seq_no> >, for checking duplicates. |
| 197 typedef std::map<uint32_t, std::set<uint16_t> > SsrcSeqNoMap; | 197 typedef std::map<uint32_t, std::set<uint16_t> > SsrcSeqNoMap; |
| 198 SsrcSeqNoMap dupe_map_; | 198 SsrcSeqNoMap dupe_map_; |
| 199 Clock* const clock_; | 199 const Clock* const clock_; |
| 200 int64_t queue_time_sum_; | 200 int64_t queue_time_sum_; |
| 201 int64_t time_last_updated_; | 201 int64_t time_last_updated_; |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 class IntervalBudget { | 204 class IntervalBudget { |
| 205 public: | 205 public: |
| 206 explicit IntervalBudget(int initial_target_rate_kbps) | 206 explicit IntervalBudget(int initial_target_rate_kbps) |
| 207 : target_rate_kbps_(initial_target_rate_kbps), | 207 : target_rate_kbps_(initial_target_rate_kbps), |
| 208 bytes_remaining_(0) {} | 208 bytes_remaining_(0) {} |
| 209 | 209 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 239 static const int kWindowMs = 500; | 239 static const int kWindowMs = 500; |
| 240 | 240 |
| 241 int target_rate_kbps_; | 241 int target_rate_kbps_; |
| 242 int bytes_remaining_; | 242 int bytes_remaining_; |
| 243 }; | 243 }; |
| 244 } // namespace paced_sender | 244 } // namespace paced_sender |
| 245 | 245 |
| 246 const int64_t PacedSender::kMaxQueueLengthMs = 2000; | 246 const int64_t PacedSender::kMaxQueueLengthMs = 2000; |
| 247 const float PacedSender::kDefaultPaceMultiplier = 2.5f; | 247 const float PacedSender::kDefaultPaceMultiplier = 2.5f; |
| 248 | 248 |
| 249 PacedSender::PacedSender(Clock* clock, PacketSender* packet_sender) | 249 PacedSender::PacedSender(const Clock* clock, PacketSender* packet_sender) |
| 250 : clock_(clock), | 250 : clock_(clock), |
| 251 packet_sender_(packet_sender), | 251 packet_sender_(packet_sender), |
| 252 alr_detector_(new AlrDetector()), | 252 alr_detector_(new AlrDetector()), |
| 253 critsect_(CriticalSectionWrapper::CreateCriticalSection()), | 253 critsect_(CriticalSectionWrapper::CreateCriticalSection()), |
| 254 paused_(false), | 254 paused_(false), |
| 255 media_budget_(new paced_sender::IntervalBudget(0)), | 255 media_budget_(new paced_sender::IntervalBudget(0)), |
| 256 padding_budget_(new paced_sender::IntervalBudget(0)), | 256 padding_budget_(new paced_sender::IntervalBudget(0)), |
| 257 prober_(new BitrateProber()), | 257 prober_(new BitrateProber()), |
| 258 probing_send_failure_(false), | 258 probing_send_failure_(false), |
| 259 estimated_bitrate_bps_(0), | 259 estimated_bitrate_bps_(0), |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { | 500 void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { |
| 501 media_budget_->IncreaseBudget(delta_time_ms); | 501 media_budget_->IncreaseBudget(delta_time_ms); |
| 502 padding_budget_->IncreaseBudget(delta_time_ms); | 502 padding_budget_->IncreaseBudget(delta_time_ms); |
| 503 } | 503 } |
| 504 | 504 |
| 505 void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { | 505 void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { |
| 506 media_budget_->UseBudget(bytes_sent); | 506 media_budget_->UseBudget(bytes_sent); |
| 507 padding_budget_->UseBudget(bytes_sent); | 507 padding_budget_->UseBudget(bytes_sent); |
| 508 } | 508 } |
| 509 } // namespace webrtc | 509 } // namespace webrtc |
| OLD | NEW |