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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 int64_t elapsed_time_ms = (elapsed_time_us + 500) / 1000; | 372 int64_t elapsed_time_ms = (elapsed_time_us + 500) / 1000; |
373 return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0); | 373 return std::max<int64_t>(kMinPacketLimitMs - elapsed_time_ms, 0); |
374 } | 374 } |
375 | 375 |
376 void PacedSender::Process() { | 376 void PacedSender::Process() { |
377 int64_t now_us = clock_->TimeInMicroseconds(); | 377 int64_t now_us = clock_->TimeInMicroseconds(); |
378 CriticalSectionScoped cs(critsect_.get()); | 378 CriticalSectionScoped cs(critsect_.get()); |
379 int64_t elapsed_time_ms = (now_us - time_last_update_us_ + 500) / 1000; | 379 int64_t elapsed_time_ms = (now_us - time_last_update_us_ + 500) / 1000; |
380 time_last_update_us_ = now_us; | 380 time_last_update_us_ = now_us; |
381 int target_bitrate_kbps = max_bitrate_kbps_; | 381 int target_bitrate_kbps = max_bitrate_kbps_; |
382 // TODO(holmer): Remove the !paused_ check when issue 5307 has been fixed. | 382 // TODO(skvlad): Remove the !paused_ check when media channel state tracking |
| 383 // is correctly implemented in call.cc |
383 if (!paused_ && elapsed_time_ms > 0) { | 384 if (!paused_ && elapsed_time_ms > 0) { |
384 size_t queue_size_bytes = packets_->SizeInBytes(); | 385 size_t queue_size_bytes = packets_->SizeInBytes(); |
385 if (queue_size_bytes > 0) { | 386 if (queue_size_bytes > 0) { |
386 // Assuming equal size packets and input/output rate, the average packet | 387 // Assuming equal size packets and input/output rate, the average packet |
387 // has avg_time_left_ms left to get queue_size_bytes out of the queue, if | 388 // has avg_time_left_ms left to get queue_size_bytes out of the queue, if |
388 // time constraint shall be met. Determine bitrate needed for that. | 389 // time constraint shall be met. Determine bitrate needed for that. |
389 packets_->UpdateQueueTime(clock_->TimeInMilliseconds()); | 390 packets_->UpdateQueueTime(clock_->TimeInMilliseconds()); |
390 int64_t avg_time_left_ms = std::max<int64_t>( | 391 int64_t avg_time_left_ms = std::max<int64_t>( |
391 1, kMaxQueueLengthMs - packets_->AverageQueueTimeMs()); | 392 1, kMaxQueueLengthMs - packets_->AverageQueueTimeMs()); |
392 int min_bitrate_needed_kbps = | 393 int min_bitrate_needed_kbps = |
(...skipping 21 matching lines...) Expand all Loading... |
414 packets_->FinalizePop(packet); | 415 packets_->FinalizePop(packet); |
415 if (prober_->IsProbing()) | 416 if (prober_->IsProbing()) |
416 return; | 417 return; |
417 } else { | 418 } else { |
418 // Send failed, put it back into the queue. | 419 // Send failed, put it back into the queue. |
419 packets_->CancelPop(packet); | 420 packets_->CancelPop(packet); |
420 return; | 421 return; |
421 } | 422 } |
422 } | 423 } |
423 | 424 |
424 // TODO(holmer): Remove the paused_ check when issue 5307 has been fixed. | 425 // TODO(skvlad): Remove the paused_ check when media channel state tracking |
| 426 // is correctly implemented in call.cc |
425 if (paused_ || !packets_->Empty()) | 427 if (paused_ || !packets_->Empty()) |
426 return; | 428 return; |
427 | 429 |
428 size_t padding_needed; | 430 size_t padding_needed; |
429 if (prober_->IsProbing()) { | 431 if (prober_->IsProbing()) { |
430 padding_needed = prober_->RecommendedPacketSize(); | 432 padding_needed = prober_->RecommendedPacketSize(); |
431 } else { | 433 } else { |
432 padding_needed = padding_budget_->bytes_remaining(); | 434 padding_needed = padding_budget_->bytes_remaining(); |
433 } | 435 } |
434 | 436 |
435 if (padding_needed > 0) | 437 if (padding_needed > 0) |
436 SendPadding(static_cast<size_t>(padding_needed)); | 438 SendPadding(static_cast<size_t>(padding_needed)); |
437 } | 439 } |
438 | 440 |
439 bool PacedSender::SendPacket(const paced_sender::Packet& packet) { | 441 bool PacedSender::SendPacket(const paced_sender::Packet& packet) { |
440 // TODO(holmer): Because of this bug issue 5307 we have to send audio | 442 // TODO(skvlad): Even though issue 5307 is fixed, we're keeping the |
441 // packets even when the pacer is paused. Here we assume audio packets are | 443 // workaround to send audio packets when the pacer is paused until accurate |
442 // always high priority and that they are the only high priority packets. | 444 // tracking of the state of audio and video MediaChannels is implemented in |
| 445 // call.cc. |
| 446 // Here we assume audio packets are always high priority and that they are |
| 447 // the only high priority packets. |
443 if (paused_ && packet.priority != kHighPriority) | 448 if (paused_ && packet.priority != kHighPriority) |
444 return false; | 449 return false; |
445 critsect_->Leave(); | 450 critsect_->Leave(); |
446 const bool success = callback_->TimeToSendPacket(packet.ssrc, | 451 const bool success = callback_->TimeToSendPacket(packet.ssrc, |
447 packet.sequence_number, | 452 packet.sequence_number, |
448 packet.capture_time_ms, | 453 packet.capture_time_ms, |
449 packet.retransmission); | 454 packet.retransmission); |
450 critsect_->Enter(); | 455 critsect_->Enter(); |
451 | 456 |
452 // TODO(holmer): High priority packets should only be accounted for if we are | 457 // TODO(holmer): High priority packets should only be accounted for if we are |
(...skipping 18 matching lines...) Expand all Loading... |
471 media_budget_->UseBudget(bytes_sent); | 476 media_budget_->UseBudget(bytes_sent); |
472 padding_budget_->UseBudget(bytes_sent); | 477 padding_budget_->UseBudget(bytes_sent); |
473 } | 478 } |
474 } | 479 } |
475 | 480 |
476 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { | 481 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { |
477 media_budget_->IncreaseBudget(delta_time_ms); | 482 media_budget_->IncreaseBudget(delta_time_ms); |
478 padding_budget_->IncreaseBudget(delta_time_ms); | 483 padding_budget_->IncreaseBudget(delta_time_ms); |
479 } | 484 } |
480 } // namespace webrtc | 485 } // namespace webrtc |
OLD | NEW |