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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 rtc::CritScope lock(&send_critsect_); | 448 rtc::CritScope lock(&send_critsect_); |
| 449 if (!sending_media_) | 449 if (!sending_media_) |
| 450 return 0; | 450 return 0; |
| 451 if ((rtx_ & kRtxRedundantPayloads) == 0) | 451 if ((rtx_ & kRtxRedundantPayloads) == 0) |
| 452 return 0; | 452 return 0; |
| 453 } | 453 } |
| 454 | 454 |
| 455 int bytes_left = static_cast<int>(bytes_to_send); | 455 int bytes_left = static_cast<int>(bytes_to_send); |
| 456 while (bytes_left > 0) { | 456 while (bytes_left > 0) { |
| 457 std::unique_ptr<RtpPacketToSend> packet = | 457 std::unique_ptr<RtpPacketToSend> packet = |
| 458 packet_history_.GetBestFittingPacket(bytes_left); | 458 packet_history_.GetBestFittingPacket(bytes_left, |
| 459 send_side_bwe_with_overhead_); | |
| 459 if (!packet) | 460 if (!packet) |
| 460 break; | 461 break; |
| 461 size_t payload_size = packet->payload_size(); | 462 // When WebRTC-SendSideBwe-WithOverhead is enabled, the padding budget |
| 463 // includes overhead. | |
| 464 const size_t used_bytes = | |
| 465 send_side_bwe_with_overhead_ | |
| 466 ? packet->size() | |
| 467 : packet->payload_size() - packet->headers_size(); | |
|
michaelt
2017/03/29 14:45:21
Why "payload_size - headers_size", i don't underst
minyue-webrtc
2017/03/29 18:52:33
neither do I understand it :) will fix. Thanks.
| |
| 462 if (!PrepareAndSendPacket(std::move(packet), true, false, pacing_info)) | 468 if (!PrepareAndSendPacket(std::move(packet), true, false, pacing_info)) |
| 463 break; | 469 break; |
| 464 bytes_left -= payload_size; | 470 bytes_left -= used_bytes; |
| 465 } | 471 } |
| 466 return bytes_to_send - bytes_left; | 472 return bytes_to_send - bytes_left; |
| 467 } | 473 } |
| 468 | 474 |
| 469 size_t RTPSender::SendPadData(size_t bytes, | 475 size_t RTPSender::SendPadData(size_t bytes, |
| 470 const PacedPacketInfo& pacing_info) { | 476 const PacedPacketInfo& pacing_info) { |
| 471 size_t padding_bytes_in_packet; | 477 // Always send full padding packets. This is accounted for by the |
| 478 // RtpPacketSender, which will make sure we don't send too much padding even | |
| 479 // if a single packet is larger than requested. | |
| 480 // We do this to avoid frequently sending small packets on higher bitrates. | |
| 481 size_t padding_bytes_in_packet = | |
| 482 std::min(MaxPayloadSize(), kMaxPaddingLength); | |
| 483 | |
| 472 if (audio_configured_) { | 484 if (audio_configured_) { |
| 473 // Allow smaller padding packets for audio. | 485 // Allow smaller padding packets for audio. |
| 486 | |
| 487 // When WebRTC-SendSideBwe-WithOverhead is enabled, the padding budget | |
| 488 // includes overhead. | |
| 489 const size_t padding_bytes_if_one_packet = | |
| 490 send_side_bwe_with_overhead_ ? bytes - RtpHeaderLength() : bytes; | |
| 474 padding_bytes_in_packet = | 491 padding_bytes_in_packet = |
| 475 std::min(std::max(bytes, kMinAudioPaddingLength), MaxPayloadSize()); | 492 std::min(padding_bytes_in_packet, |
| 476 if (padding_bytes_in_packet > kMaxPaddingLength) | 493 std::max(padding_bytes_if_one_packet, kMinAudioPaddingLength)); |
| 477 padding_bytes_in_packet = kMaxPaddingLength; | |
| 478 } else { | |
| 479 // Always send full padding packets. This is accounted for by the | |
| 480 // RtpPacketSender, which will make sure we don't send too much padding even | |
| 481 // if a single packet is larger than requested. | |
| 482 // We do this to avoid frequently sending small packets on higher bitrates. | |
| 483 padding_bytes_in_packet = std::min(MaxPayloadSize(), kMaxPaddingLength); | |
| 484 } | 494 } |
| 495 | |
| 485 size_t bytes_sent = 0; | 496 size_t bytes_sent = 0; |
| 486 while (bytes_sent < bytes) { | 497 while (bytes_sent < bytes) { |
|
michaelt
2017/03/29 14:45:21
if we define packet size before the loop. Will not
minyue-webrtc
2017/03/29 18:52:33
I have not looked into this. will do
danilchap
2017/03/30 11:58:08
Might not be important (for same reason padding mi
stefan-webrtc
2017/03/30 12:09:03
This is exactly why we do it this way. We want to
| |
| 487 int64_t now_ms = clock_->TimeInMilliseconds(); | 498 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 488 uint32_t ssrc; | 499 uint32_t ssrc; |
| 489 uint32_t timestamp; | 500 uint32_t timestamp; |
| 490 int64_t capture_time_ms; | 501 int64_t capture_time_ms; |
| 491 uint16_t sequence_number; | 502 uint16_t sequence_number; |
| 492 int payload_type; | 503 int payload_type; |
| 493 bool over_rtx; | 504 bool over_rtx; |
| 494 { | 505 { |
| 495 rtc::CritScope lock(&send_critsect_); | 506 rtc::CritScope lock(&send_critsect_); |
| 496 if (!sending_media_) | 507 if (!sending_media_) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 padding_packet.SetSsrc(ssrc); | 570 padding_packet.SetSsrc(ssrc); |
| 560 | 571 |
| 561 if (capture_time_ms > 0) { | 572 if (capture_time_ms > 0) { |
| 562 padding_packet.SetExtension<TransmissionOffset>( | 573 padding_packet.SetExtension<TransmissionOffset>( |
| 563 (now_ms - capture_time_ms) * kTimestampTicksPerMs); | 574 (now_ms - capture_time_ms) * kTimestampTicksPerMs); |
| 564 } | 575 } |
| 565 padding_packet.SetExtension<AbsoluteSendTime>(now_ms); | 576 padding_packet.SetExtension<AbsoluteSendTime>(now_ms); |
| 566 PacketOptions options; | 577 PacketOptions options; |
| 567 bool has_transport_seq_num = | 578 bool has_transport_seq_num = |
| 568 UpdateTransportSequenceNumber(&padding_packet, &options.packet_id); | 579 UpdateTransportSequenceNumber(&padding_packet, &options.packet_id); |
| 580 | |
| 569 padding_packet.SetPadding(padding_bytes_in_packet, &random_); | 581 padding_packet.SetPadding(padding_bytes_in_packet, &random_); |
| 570 | 582 |
| 571 if (has_transport_seq_num) { | 583 if (has_transport_seq_num) { |
| 572 AddPacketToTransportFeedback(options.packet_id, padding_packet, | 584 AddPacketToTransportFeedback(options.packet_id, padding_packet, |
| 573 pacing_info); | 585 pacing_info); |
| 574 } | 586 } |
| 575 | 587 |
| 576 if (!SendPacketToNetwork(padding_packet, options, pacing_info)) | 588 if (!SendPacketToNetwork(padding_packet, options, pacing_info)) |
| 577 break; | 589 break; |
| 578 | 590 |
| 579 bytes_sent += padding_bytes_in_packet; | 591 // When WebRTC-SendSideBwe-WithOverhead is enabled, the padding budget |
| 592 // includes overhead. | |
| 593 bytes_sent += send_side_bwe_with_overhead_ ? padding_packet.padding_size() | |
| 594 : padding_packet.size(); | |
| 580 UpdateRtpStats(padding_packet, over_rtx, false); | 595 UpdateRtpStats(padding_packet, over_rtx, false); |
| 581 } | 596 } |
| 582 | 597 |
| 583 return bytes_sent; | 598 return bytes_sent; |
| 584 } | 599 } |
| 585 | 600 |
| 586 void RTPSender::SetStorePacketsStatus(bool enable, uint16_t number_to_store) { | 601 void RTPSender::SetStorePacketsStatus(bool enable, uint16_t number_to_store) { |
| 587 packet_history_.SetStorePacketsStatus(enable, number_to_store); | 602 packet_history_.SetStorePacketsStatus(enable, number_to_store); |
| 588 } | 603 } |
| 589 | 604 |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1270 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { | 1285 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { |
| 1271 return; | 1286 return; |
| 1272 } | 1287 } |
| 1273 rtp_overhead_bytes_per_packet_ = packet.headers_size(); | 1288 rtp_overhead_bytes_per_packet_ = packet.headers_size(); |
| 1274 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; | 1289 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; |
| 1275 } | 1290 } |
| 1276 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); | 1291 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); |
| 1277 } | 1292 } |
| 1278 | 1293 |
| 1279 } // namespace webrtc | 1294 } // namespace webrtc |
| OLD | NEW |