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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 first_sent_packet_ms_(-1), |
266 packets_(new paced_sender::PacketQueue(clock)), | 266 packets_(new paced_sender::PacketQueue(clock)), |
267 packet_counter_(0) { | 267 packet_counter_(0), |
| 268 account_for_audio_(false) { |
268 UpdateBudgetWithElapsedTime(kMinPacketLimitMs); | 269 UpdateBudgetWithElapsedTime(kMinPacketLimitMs); |
269 } | 270 } |
270 | 271 |
271 PacedSender::~PacedSender() {} | 272 PacedSender::~PacedSender() {} |
272 | 273 |
273 void PacedSender::CreateProbeCluster(int bitrate_bps) { | 274 void PacedSender::CreateProbeCluster(int bitrate_bps) { |
274 rtc::CritScope cs(&critsect_); | 275 rtc::CritScope cs(&critsect_); |
275 prober_->CreateProbeCluster(bitrate_bps, clock_->TimeInMilliseconds()); | 276 prober_->CreateProbeCluster(bitrate_bps, clock_->TimeInMilliseconds()); |
276 } | 277 } |
277 | 278 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 prober_->OnIncomingPacket(bytes); | 345 prober_->OnIncomingPacket(bytes); |
345 | 346 |
346 if (capture_time_ms < 0) | 347 if (capture_time_ms < 0) |
347 capture_time_ms = now_ms; | 348 capture_time_ms = now_ms; |
348 | 349 |
349 packets_->Push(paced_sender::Packet(priority, ssrc, sequence_number, | 350 packets_->Push(paced_sender::Packet(priority, ssrc, sequence_number, |
350 capture_time_ms, now_ms, bytes, | 351 capture_time_ms, now_ms, bytes, |
351 retransmission, packet_counter_++)); | 352 retransmission, packet_counter_++)); |
352 } | 353 } |
353 | 354 |
| 355 void PacedSender::AccountForAudioPackets(bool account_for_audio) { |
| 356 rtc::CritScope cs(&critsect_); |
| 357 account_for_audio_ = account_for_audio; |
| 358 } |
| 359 |
354 int64_t PacedSender::ExpectedQueueTimeMs() const { | 360 int64_t PacedSender::ExpectedQueueTimeMs() const { |
355 rtc::CritScope cs(&critsect_); | 361 rtc::CritScope cs(&critsect_); |
356 RTC_DCHECK_GT(pacing_bitrate_kbps_, 0); | 362 RTC_DCHECK_GT(pacing_bitrate_kbps_, 0); |
357 return static_cast<int64_t>(packets_->SizeInBytes() * 8 / | 363 return static_cast<int64_t>(packets_->SizeInBytes() * 8 / |
358 pacing_bitrate_kbps_); | 364 pacing_bitrate_kbps_); |
359 } | 365 } |
360 | 366 |
361 rtc::Optional<int64_t> PacedSender::GetApplicationLimitedRegionStartTime() | 367 rtc::Optional<int64_t> PacedSender::GetApplicationLimitedRegionStartTime() |
362 const { | 368 const { |
363 rtc::CritScope cs(&critsect_); | 369 rtc::CritScope cs(&critsect_); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 return false; | 501 return false; |
496 } | 502 } |
497 | 503 |
498 critsect_.Leave(); | 504 critsect_.Leave(); |
499 const bool success = packet_sender_->TimeToSendPacket( | 505 const bool success = packet_sender_->TimeToSendPacket( |
500 packet.ssrc, packet.sequence_number, packet.capture_time_ms, | 506 packet.ssrc, packet.sequence_number, packet.capture_time_ms, |
501 packet.retransmission, pacing_info); | 507 packet.retransmission, pacing_info); |
502 critsect_.Enter(); | 508 critsect_.Enter(); |
503 | 509 |
504 if (success) { | 510 if (success) { |
505 // TODO(holmer): High priority packets should only be accounted for if we | 511 if (packet.priority != kHighPriority || account_for_audio_) { |
506 // are allocating bandwidth for audio. | |
507 if (packet.priority != kHighPriority) { | |
508 // Update media bytes sent. | 512 // Update media bytes sent. |
509 UpdateBudgetWithBytesSent(packet.bytes); | 513 UpdateBudgetWithBytesSent(packet.bytes); |
510 } | 514 } |
511 } | 515 } |
512 | 516 |
513 return success; | 517 return success; |
514 } | 518 } |
515 | 519 |
516 size_t PacedSender::SendPadding(size_t padding_needed, | 520 size_t PacedSender::SendPadding(size_t padding_needed, |
517 const PacedPacketInfo& pacing_info) { | 521 const PacedPacketInfo& pacing_info) { |
(...skipping 11 matching lines...) Expand all Loading... |
529 void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { | 533 void PacedSender::UpdateBudgetWithElapsedTime(int64_t delta_time_ms) { |
530 media_budget_->IncreaseBudget(delta_time_ms); | 534 media_budget_->IncreaseBudget(delta_time_ms); |
531 padding_budget_->IncreaseBudget(delta_time_ms); | 535 padding_budget_->IncreaseBudget(delta_time_ms); |
532 } | 536 } |
533 | 537 |
534 void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { | 538 void PacedSender::UpdateBudgetWithBytesSent(size_t bytes_sent) { |
535 media_budget_->UseBudget(bytes_sent); | 539 media_budget_->UseBudget(bytes_sent); |
536 padding_budget_->UseBudget(bytes_sent); | 540 padding_budget_->UseBudget(bytes_sent); |
537 } | 541 } |
538 } // namespace webrtc | 542 } // namespace webrtc |
OLD | NEW |