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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 if (!PrepareAndSendPacket(std::move(packet), true, false, pacing_info)) | 457 if (!PrepareAndSendPacket(std::move(packet), true, false, pacing_info)) |
458 break; | 458 break; |
459 bytes_left -= payload_size; | 459 bytes_left -= payload_size; |
460 } | 460 } |
461 return bytes_to_send - bytes_left; | 461 return bytes_to_send - bytes_left; |
462 } | 462 } |
463 | 463 |
464 size_t RTPSender::SendPadData(size_t bytes, | 464 size_t RTPSender::SendPadData(size_t bytes, |
465 const PacedPacketInfo& pacing_info) { | 465 const PacedPacketInfo& pacing_info) { |
466 size_t padding_bytes_in_packet; | 466 size_t padding_bytes_in_packet; |
| 467 size_t max_payload_size = max_packet_size_ - RtpHeaderLength(); |
467 | 468 |
468 if (audio_configured_) { | 469 if (audio_configured_) { |
469 // Allow smaller padding packets for audio. | 470 // Allow smaller padding packets for audio. |
470 size_t max_payload_size = max_packet_size_ - RtpHeaderLength(); | |
471 padding_bytes_in_packet = | 471 padding_bytes_in_packet = |
472 std::min(std::max(bytes, kMinAudioPaddingLength), max_payload_size); | 472 std::min(std::max(bytes, kMinAudioPaddingLength), max_payload_size); |
473 if (padding_bytes_in_packet > kMaxPaddingLength) | 473 if (padding_bytes_in_packet > kMaxPaddingLength) |
474 padding_bytes_in_packet = kMaxPaddingLength; | 474 padding_bytes_in_packet = kMaxPaddingLength; |
475 } else { | 475 } else { |
476 // Always send full padding packets. This is accounted for by the | 476 // Always send full padding packets. This is accounted for by the |
477 // RtpPacketSender, which will make sure we don't send too much padding even | 477 // RtpPacketSender, which will make sure we don't send too much padding even |
478 // if a single packet is larger than requested. | 478 // if a single packet is larger than requested. |
479 // We do this to avoid frequently sending small packets on higher bitrates. | 479 // We do this to avoid frequently sending small packets on higher bitrates. |
480 size_t max_payload_size = | |
481 max_packet_size_ - RtpHeaderLength() // RTP overhead. | |
482 - video_->FecPacketOverhead() // FEC/ULP/RED overhead. | |
483 - (RtxStatus() ? kRtxHeaderSize : 0); // RTX overhead. | |
484 padding_bytes_in_packet = std::min(max_payload_size, kMaxPaddingLength); | 480 padding_bytes_in_packet = std::min(max_payload_size, kMaxPaddingLength); |
485 } | 481 } |
486 size_t bytes_sent = 0; | 482 size_t bytes_sent = 0; |
487 while (bytes_sent < bytes) { | 483 while (bytes_sent < bytes) { |
488 int64_t now_ms = clock_->TimeInMilliseconds(); | 484 int64_t now_ms = clock_->TimeInMilliseconds(); |
489 uint32_t ssrc; | 485 uint32_t ssrc; |
490 uint32_t timestamp; | 486 uint32_t timestamp; |
491 int64_t capture_time_ms; | 487 int64_t capture_time_ms; |
492 uint16_t sequence_number; | 488 uint16_t sequence_number; |
493 int payload_type; | 489 int payload_type; |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { | 1268 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { |
1273 return; | 1269 return; |
1274 } | 1270 } |
1275 rtp_overhead_bytes_per_packet_ = packet.headers_size(); | 1271 rtp_overhead_bytes_per_packet_ = packet.headers_size(); |
1276 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; | 1272 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; |
1277 } | 1273 } |
1278 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); | 1274 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); |
1279 } | 1275 } |
1280 | 1276 |
1281 } // namespace webrtc | 1277 } // namespace webrtc |
OLD | NEW |