| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 probing_send_failure_(false), | 249 probing_send_failure_(false), |
| 250 estimated_bitrate_bps_(0), | 250 estimated_bitrate_bps_(0), |
| 251 min_send_bitrate_kbps_(0u), | 251 min_send_bitrate_kbps_(0u), |
| 252 max_padding_bitrate_kbps_(0u), | 252 max_padding_bitrate_kbps_(0u), |
| 253 pacing_bitrate_kbps_(0), | 253 pacing_bitrate_kbps_(0), |
| 254 time_last_update_us_(clock->TimeInMicroseconds()), | 254 time_last_update_us_(clock->TimeInMicroseconds()), |
| 255 first_sent_packet_ms_(-1), | 255 first_sent_packet_ms_(-1), |
| 256 packets_(new paced_sender::PacketQueue(clock)), | 256 packets_(new paced_sender::PacketQueue(clock)), |
| 257 packet_counter_(0), | 257 packet_counter_(0), |
| 258 pacing_factor_(kDefaultPaceMultiplier), | 258 pacing_factor_(kDefaultPaceMultiplier), |
| 259 queue_time_limit(kMaxQueueLengthMs) { | 259 queue_time_limit(kMaxQueueLengthMs), |
| 260 account_for_audio_(false) { |
| 260 UpdateBudgetWithElapsedTime(kMinPacketLimitMs); | 261 UpdateBudgetWithElapsedTime(kMinPacketLimitMs); |
| 261 } | 262 } |
| 262 | 263 |
| 263 PacedSender::~PacedSender() {} | 264 PacedSender::~PacedSender() {} |
| 264 | 265 |
| 265 void PacedSender::CreateProbeCluster(int bitrate_bps) { | 266 void PacedSender::CreateProbeCluster(int bitrate_bps) { |
| 266 rtc::CritScope cs(&critsect_); | 267 rtc::CritScope cs(&critsect_); |
| 267 prober_->CreateProbeCluster(bitrate_bps, clock_->TimeInMilliseconds()); | 268 prober_->CreateProbeCluster(bitrate_bps, clock_->TimeInMilliseconds()); |
| 268 } | 269 } |
| 269 | 270 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 prober_->OnIncomingPacket(bytes); | 341 prober_->OnIncomingPacket(bytes); |
| 341 | 342 |
| 342 if (capture_time_ms < 0) | 343 if (capture_time_ms < 0) |
| 343 capture_time_ms = now_ms; | 344 capture_time_ms = now_ms; |
| 344 | 345 |
| 345 packets_->Push(paced_sender::Packet(priority, ssrc, sequence_number, | 346 packets_->Push(paced_sender::Packet(priority, ssrc, sequence_number, |
| 346 capture_time_ms, now_ms, bytes, | 347 capture_time_ms, now_ms, bytes, |
| 347 retransmission, packet_counter_++)); | 348 retransmission, packet_counter_++)); |
| 348 } | 349 } |
| 349 | 350 |
| 351 void PacedSender::SetAccountForAudioPackets(bool account_for_audio) { |
| 352 rtc::CritScope cs(&critsect_); |
| 353 account_for_audio_ = account_for_audio; |
| 354 } |
| 355 |
| 350 int64_t PacedSender::ExpectedQueueTimeMs() const { | 356 int64_t PacedSender::ExpectedQueueTimeMs() const { |
| 351 rtc::CritScope cs(&critsect_); | 357 rtc::CritScope cs(&critsect_); |
| 352 RTC_DCHECK_GT(pacing_bitrate_kbps_, 0); | 358 RTC_DCHECK_GT(pacing_bitrate_kbps_, 0); |
| 353 return static_cast<int64_t>(packets_->SizeInBytes() * 8 / | 359 return static_cast<int64_t>(packets_->SizeInBytes() * 8 / |
| 354 pacing_bitrate_kbps_); | 360 pacing_bitrate_kbps_); |
| 355 } | 361 } |
| 356 | 362 |
| 357 rtc::Optional<int64_t> PacedSender::GetApplicationLimitedRegionStartTime() | 363 rtc::Optional<int64_t> PacedSender::GetApplicationLimitedRegionStartTime() |
| 358 const { | 364 const { |
| 359 rtc::CritScope cs(&critsect_); | 365 rtc::CritScope cs(&critsect_); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return false; | 511 return false; |
| 506 } | 512 } |
| 507 | 513 |
| 508 critsect_.Leave(); | 514 critsect_.Leave(); |
| 509 const bool success = packet_sender_->TimeToSendPacket( | 515 const bool success = packet_sender_->TimeToSendPacket( |
| 510 packet.ssrc, packet.sequence_number, packet.capture_time_ms, | 516 packet.ssrc, packet.sequence_number, packet.capture_time_ms, |
| 511 packet.retransmission, pacing_info); | 517 packet.retransmission, pacing_info); |
| 512 critsect_.Enter(); | 518 critsect_.Enter(); |
| 513 | 519 |
| 514 if (success) { | 520 if (success) { |
| 515 // TODO(holmer): High priority packets should only be accounted for if we | 521 if (packet.priority != kHighPriority || account_for_audio_) { |
| 516 // are allocating bandwidth for audio. | |
| 517 if (packet.priority != kHighPriority) { | |
| 518 // Update media bytes sent. | 522 // Update media bytes sent. |
| 519 // TODO(eladalon): TimeToSendPacket() can also return |true| in some | 523 // TODO(eladalon): TimeToSendPacket() can also return |true| in some |
| 520 // situations where nothing actually ended up being sent to the network, | 524 // situations where nothing actually ended up being sent to the network, |
| 521 // and we probably don't want to update the budget in such cases. | 525 // and we probably don't want to update the budget in such cases. |
| 522 // https://bugs.chromium.org/p/webrtc/issues/detail?id=8052 | 526 // https://bugs.chromium.org/p/webrtc/issues/detail?id=8052 |
| 523 UpdateBudgetWithBytesSent(packet.bytes); | 527 UpdateBudgetWithBytesSent(packet.bytes); |
| 524 } | 528 } |
| 525 } | 529 } |
| 526 | 530 |
| 527 return success; | 531 return success; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 555 rtc::CritScope cs(&critsect_); | 559 rtc::CritScope cs(&critsect_); |
| 556 pacing_factor_ = pacing_factor; | 560 pacing_factor_ = pacing_factor; |
| 557 } | 561 } |
| 558 | 562 |
| 559 void PacedSender::SetQueueTimeLimit(int limit_ms) { | 563 void PacedSender::SetQueueTimeLimit(int limit_ms) { |
| 560 rtc::CritScope cs(&critsect_); | 564 rtc::CritScope cs(&critsect_); |
| 561 queue_time_limit = limit_ms; | 565 queue_time_limit = limit_ms; |
| 562 } | 566 } |
| 563 | 567 |
| 564 } // namespace webrtc | 568 } // namespace webrtc |
| OLD | NEW |