Chromium Code Reviews| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 | 248 |
| 249 PacedSender::PacedSender(Clock* clock, PacketSender* packet_sender) | 249 PacedSender::PacedSender(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 estimated_bitrate_bps_(0), | 259 estimated_bitrate_bps_(0), |
| 259 min_send_bitrate_kbps_(0u), | 260 min_send_bitrate_kbps_(0u), |
| 260 max_padding_bitrate_kbps_(0u), | 261 max_padding_bitrate_kbps_(0u), |
| 261 pacing_bitrate_kbps_(0), | 262 pacing_bitrate_kbps_(0), |
| 262 time_last_update_us_(clock->TimeInMicroseconds()), | 263 time_last_update_us_(clock->TimeInMicroseconds()), |
| 263 packets_(new paced_sender::PacketQueue(clock)), | 264 packets_(new paced_sender::PacketQueue(clock)), |
| 264 packet_counter_(0) { | 265 packet_counter_(0) { |
| 265 UpdateBudgetWithElapsedTime(kMinPacketLimitMs); | 266 UpdateBudgetWithElapsedTime(kMinPacketLimitMs); |
| 266 } | 267 } |
| 267 | 268 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 int64_t PacedSender::AverageQueueTimeMs() { | 368 int64_t PacedSender::AverageQueueTimeMs() { |
| 368 CriticalSectionScoped cs(critsect_.get()); | 369 CriticalSectionScoped cs(critsect_.get()); |
| 369 packets_->UpdateQueueTime(clock_->TimeInMilliseconds()); | 370 packets_->UpdateQueueTime(clock_->TimeInMilliseconds()); |
| 370 return packets_->AverageQueueTimeMs(); | 371 return packets_->AverageQueueTimeMs(); |
| 371 } | 372 } |
| 372 | 373 |
| 373 int64_t PacedSender::TimeUntilNextProcess() { | 374 int64_t PacedSender::TimeUntilNextProcess() { |
| 374 CriticalSectionScoped cs(critsect_.get()); | 375 CriticalSectionScoped cs(critsect_.get()); |
| 375 if (prober_->IsProbing()) { | 376 if (prober_->IsProbing()) { |
| 376 int64_t ret = prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds()); | 377 int64_t ret = prober_->TimeUntilNextProbe(clock_->TimeInMilliseconds()); |
| 377 if (ret >= 0) | 378 if (ret > 0 || (ret == 0 && !probing_send_failure_)) |
| 378 return ret; | 379 return ret; |
| 379 } | 380 } |
| 380 int64_t elapsed_time_us = clock_->TimeInMicroseconds() - time_last_update_us_; | 381 int64_t elapsed_time_us = clock_->TimeInMicroseconds() - time_last_update_us_; |
| 381 int64_t elapsed_time_ms = (elapsed_time_us + 500) / 1000; | 382 int64_t elapsed_time_ms = (elapsed_time_us + 500) / 1000; |
| 382 return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0); | 383 return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0); |
| 383 } | 384 } |
| 384 | 385 |
| 385 void PacedSender::Process() { | 386 void PacedSender::Process() { |
| 386 int64_t now_us = clock_->TimeInMicroseconds(); | 387 int64_t now_us = clock_->TimeInMicroseconds(); |
| 387 CriticalSectionScoped cs(critsect_.get()); | 388 CriticalSectionScoped cs(critsect_.get()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 // do, timestamps get messed up. | 442 // do, timestamps get messed up. |
| 442 if (packet_counter_ > 0) { | 443 if (packet_counter_ > 0) { |
| 443 int padding_needed = | 444 int padding_needed = |
| 444 static_cast<int>(is_probing ? (recommended_probe_size - bytes_sent) | 445 static_cast<int>(is_probing ? (recommended_probe_size - bytes_sent) |
| 445 : padding_budget_->bytes_remaining()); | 446 : padding_budget_->bytes_remaining()); |
| 446 | 447 |
| 447 if (padding_needed > 0) | 448 if (padding_needed > 0) |
| 448 bytes_sent += SendPadding(padding_needed, pacing_info); | 449 bytes_sent += SendPadding(padding_needed, pacing_info); |
| 449 } | 450 } |
| 450 } | 451 } |
| 451 if (is_probing && bytes_sent > 0) | 452 if (is_probing) { |
| 452 prober_->ProbeSent(clock_->TimeInMilliseconds(), bytes_sent); | 453 probing_send_failure_ = bytes_sent == 0; |
|
stefan-webrtc
2017/02/28 14:23:41
Why do we fail to send?
| |
| 454 if (!probing_send_failure_) | |
| 455 prober_->ProbeSent(clock_->TimeInMilliseconds(), bytes_sent); | |
| 456 } | |
| 453 alr_detector_->OnBytesSent(bytes_sent, now_us / 1000); | 457 alr_detector_->OnBytesSent(bytes_sent, now_us / 1000); |
| 454 } | 458 } |
| 455 | 459 |
| 456 bool PacedSender::SendPacket(const paced_sender::Packet& packet, | 460 bool PacedSender::SendPacket(const paced_sender::Packet& packet, |
| 457 const PacedPacketInfo& pacing_info) { | 461 const PacedPacketInfo& pacing_info) { |
| 458 if (paused_) | 462 if (paused_) |
| 459 return false; | 463 return false; |
| 460 if (media_budget_->bytes_remaining() == 0 && | 464 if (media_budget_->bytes_remaining() == 0 && |
| 461 pacing_info.probe_cluster_id == PacedPacketInfo::kNotAProbe) { | 465 pacing_info.probe_cluster_id == PacedPacketInfo::kNotAProbe) { |
| 462 return false; | 466 return false; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { | 500 void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { |
| 497 media_budget_->IncreaseBudget(delta_time_ms); | 501 media_budget_->IncreaseBudget(delta_time_ms); |
| 498 padding_budget_->IncreaseBudget(delta_time_ms); | 502 padding_budget_->IncreaseBudget(delta_time_ms); |
| 499 } | 503 } |
| 500 | 504 |
| 501 void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { | 505 void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { |
| 502 media_budget_->UseBudget(bytes_sent); | 506 media_budget_->UseBudget(bytes_sent); |
| 503 padding_budget_->UseBudget(bytes_sent); | 507 padding_budget_->UseBudget(bytes_sent); |
| 504 } | 508 } |
| 505 } // namespace webrtc | 509 } // namespace webrtc |
| OLD | NEW |