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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 paused_(false), | 255 paused_(false), |
256 media_budget_(new paced_sender::IntervalBudget(0)), | 256 media_budget_(new paced_sender::IntervalBudget(0)), |
257 padding_budget_(new paced_sender::IntervalBudget(0)), | 257 padding_budget_(new paced_sender::IntervalBudget(0)), |
258 prober_(new BitrateProber(event_log)), | 258 prober_(new BitrateProber(event_log)), |
259 probing_send_failure_(false), | 259 probing_send_failure_(false), |
260 estimated_bitrate_bps_(0), | 260 estimated_bitrate_bps_(0), |
261 min_send_bitrate_kbps_(0u), | 261 min_send_bitrate_kbps_(0u), |
262 max_padding_bitrate_kbps_(0u), | 262 max_padding_bitrate_kbps_(0u), |
263 pacing_bitrate_kbps_(0), | 263 pacing_bitrate_kbps_(0), |
264 time_last_update_us_(clock->TimeInMicroseconds()), | 264 time_last_update_us_(clock->TimeInMicroseconds()), |
| 265 first_sent_packet_ms_(-1), |
265 packets_(new paced_sender::PacketQueue(clock)), | 266 packets_(new paced_sender::PacketQueue(clock)), |
266 packet_counter_(0) { | 267 packet_counter_(0) { |
267 UpdateBudgetWithElapsedTime(kMinPacketLimitMs); | 268 UpdateBudgetWithElapsedTime(kMinPacketLimitMs); |
268 } | 269 } |
269 | 270 |
270 PacedSender::~PacedSender() {} | 271 PacedSender::~PacedSender() {} |
271 | 272 |
272 void PacedSender::CreateProbeCluster(int bitrate_bps) { | 273 void PacedSender::CreateProbeCluster(int bitrate_bps) { |
273 rtc::CritScope cs(&critsect_); | 274 rtc::CritScope cs(&critsect_); |
274 prober_->CreateProbeCluster(bitrate_bps, clock_->TimeInMilliseconds()); | 275 prober_->CreateProbeCluster(bitrate_bps, clock_->TimeInMilliseconds()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 const { | 362 const { |
362 rtc::CritScope cs(&critsect_); | 363 rtc::CritScope cs(&critsect_); |
363 return alr_detector_->GetApplicationLimitedRegionStartTime(); | 364 return alr_detector_->GetApplicationLimitedRegionStartTime(); |
364 } | 365 } |
365 | 366 |
366 size_t PacedSender::QueueSizePackets() const { | 367 size_t PacedSender::QueueSizePackets() const { |
367 rtc::CritScope cs(&critsect_); | 368 rtc::CritScope cs(&critsect_); |
368 return packets_->SizeInPackets(); | 369 return packets_->SizeInPackets(); |
369 } | 370 } |
370 | 371 |
| 372 int64_t PacedSender::FirstSentPacketTimeMs() const { |
| 373 rtc::CritScope cs(&critsect_); |
| 374 return first_sent_packet_ms_; |
| 375 } |
| 376 |
371 int64_t PacedSender::QueueInMs() const { | 377 int64_t PacedSender::QueueInMs() const { |
372 rtc::CritScope cs(&critsect_); | 378 rtc::CritScope cs(&critsect_); |
373 | 379 |
374 int64_t oldest_packet = packets_->OldestEnqueueTimeMs(); | 380 int64_t oldest_packet = packets_->OldestEnqueueTimeMs(); |
375 if (oldest_packet == 0) | 381 if (oldest_packet == 0) |
376 return 0; | 382 return 0; |
377 | 383 |
378 return clock_->TimeInMilliseconds() - oldest_packet; | 384 return clock_->TimeInMilliseconds() - oldest_packet; |
379 } | 385 } |
380 | 386 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 recommended_probe_size = prober_->RecommendedMinProbeSize(); | 441 recommended_probe_size = prober_->RecommendedMinProbeSize(); |
436 } | 442 } |
437 while (!packets_->Empty()) { | 443 while (!packets_->Empty()) { |
438 // Since we need to release the lock in order to send, we first pop the | 444 // Since we need to release the lock in order to send, we first pop the |
439 // element from the priority queue but keep it in storage, so that we can | 445 // element from the priority queue but keep it in storage, so that we can |
440 // reinsert it if send fails. | 446 // reinsert it if send fails. |
441 const paced_sender::Packet& packet = packets_->BeginPop(); | 447 const paced_sender::Packet& packet = packets_->BeginPop(); |
442 | 448 |
443 if (SendPacket(packet, pacing_info)) { | 449 if (SendPacket(packet, pacing_info)) { |
444 // Send succeeded, remove it from the queue. | 450 // Send succeeded, remove it from the queue. |
| 451 if (first_sent_packet_ms_ == -1) |
| 452 first_sent_packet_ms_ = clock_->TimeInMilliseconds(); |
445 bytes_sent += packet.bytes; | 453 bytes_sent += packet.bytes; |
446 packets_->FinalizePop(packet); | 454 packets_->FinalizePop(packet); |
447 if (is_probing && bytes_sent > recommended_probe_size) | 455 if (is_probing && bytes_sent > recommended_probe_size) |
448 break; | 456 break; |
449 } else { | 457 } else { |
450 // Send failed, put it back into the queue. | 458 // Send failed, put it back into the queue. |
451 packets_->CancelPop(packet); | 459 packets_->CancelPop(packet); |
452 break; | 460 break; |
453 } | 461 } |
454 } | 462 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { | 529 void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { |
522 media_budget_->IncreaseBudget(delta_time_ms); | 530 media_budget_->IncreaseBudget(delta_time_ms); |
523 padding_budget_->IncreaseBudget(delta_time_ms); | 531 padding_budget_->IncreaseBudget(delta_time_ms); |
524 } | 532 } |
525 | 533 |
526 void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { | 534 void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { |
527 media_budget_->UseBudget(bytes_sent); | 535 media_budget_->UseBudget(bytes_sent); |
528 padding_budget_->UseBudget(bytes_sent); | 536 padding_budget_->UseBudget(bytes_sent); |
529 } | 537 } |
530 } // namespace webrtc | 538 } // namespace webrtc |
OLD | NEW |