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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (!packet) | 459 if (!packet) |
460 break; | 460 break; |
461 size_t payload_size = packet->payload_size(); | 461 size_t payload_size = packet->payload_size(); |
462 if (!PrepareAndSendPacket(std::move(packet), true, false, pacing_info)) | 462 if (!PrepareAndSendPacket(std::move(packet), true, false, pacing_info)) |
463 break; | 463 break; |
464 bytes_left -= payload_size; | 464 bytes_left -= payload_size; |
465 if (send_side_bwe_with_overhead_) { | |
466 // When WebRTC-SendSideBwe-WithOverhead is enabled, the padding budget | |
467 // includes overhead. | |
468 bytes_left -= packet->headers_size(); | |
danilchap
2017/03/24 08:47:20
packet was moved, so you should not use it.
save t
minyue-webrtc
2017/03/24 09:08:54
Thanks! of course
| |
469 } | |
465 } | 470 } |
466 return bytes_to_send - bytes_left; | 471 return bytes_to_send - bytes_left; |
467 } | 472 } |
468 | 473 |
469 size_t RTPSender::SendPadData(size_t bytes, | 474 size_t RTPSender::SendPadData(size_t bytes, |
470 const PacedPacketInfo& pacing_info) { | 475 const PacedPacketInfo& pacing_info) { |
471 size_t padding_bytes_in_packet; | 476 size_t padding_bytes_in_packet; |
472 if (audio_configured_) { | 477 if (audio_configured_) { |
473 // Allow smaller padding packets for audio. | 478 // Allow smaller padding packets for audio. |
474 padding_bytes_in_packet = | 479 padding_bytes_in_packet = |
michaelt
2017/03/27 14:25:01
Shouldn't we calculate padding_bytes_in_packet ins
| |
475 std::min(std::max(bytes, kMinAudioPaddingLength), MaxPayloadSize()); | 480 std::min(std::max(bytes, kMinAudioPaddingLength), MaxPayloadSize()); |
476 if (padding_bytes_in_packet > kMaxPaddingLength) | 481 if (padding_bytes_in_packet > kMaxPaddingLength) |
477 padding_bytes_in_packet = kMaxPaddingLength; | 482 padding_bytes_in_packet = kMaxPaddingLength; |
478 } else { | 483 } else { |
479 // Always send full padding packets. This is accounted for by the | 484 // 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 | 485 // RtpPacketSender, which will make sure we don't send too much padding even |
481 // if a single packet is larger than requested. | 486 // if a single packet is larger than requested. |
482 // We do this to avoid frequently sending small packets on higher bitrates. | 487 // We do this to avoid frequently sending small packets on higher bitrates. |
483 padding_bytes_in_packet = std::min(MaxPayloadSize(), kMaxPaddingLength); | 488 padding_bytes_in_packet = std::min(MaxPayloadSize(), kMaxPaddingLength); |
484 } | 489 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 padding_packet.SetSsrc(ssrc); | 564 padding_packet.SetSsrc(ssrc); |
560 | 565 |
561 if (capture_time_ms > 0) { | 566 if (capture_time_ms > 0) { |
562 padding_packet.SetExtension<TransmissionOffset>( | 567 padding_packet.SetExtension<TransmissionOffset>( |
563 (now_ms - capture_time_ms) * kTimestampTicksPerMs); | 568 (now_ms - capture_time_ms) * kTimestampTicksPerMs); |
564 } | 569 } |
565 padding_packet.SetExtension<AbsoluteSendTime>(now_ms); | 570 padding_packet.SetExtension<AbsoluteSendTime>(now_ms); |
566 PacketOptions options; | 571 PacketOptions options; |
567 bool has_transport_seq_num = | 572 bool has_transport_seq_num = |
568 UpdateTransportSequenceNumber(&padding_packet, &options.packet_id); | 573 UpdateTransportSequenceNumber(&padding_packet, &options.packet_id); |
569 padding_packet.SetPadding(padding_bytes_in_packet, &random_); | 574 padding_packet.SetPadding(padding_bytes_in_packet, &random_); |
philipel
2017/03/27 10:55:38
Is this really correct? When you call SendPadData
danilchap
2017/03/27 11:20:23
I think this is correct:
here you set number of p
philipel
2017/03/27 11:38:49
I agree that we want to terminate the loop as earl
danilchap
2017/03/27 12:23:00
sorry, I forgout about audio case where we want sm
michaelt
2017/03/27 14:25:01
Acknowledged.
| |
570 | 575 |
571 if (has_transport_seq_num) { | 576 if (has_transport_seq_num) { |
572 AddPacketToTransportFeedback(options.packet_id, padding_packet, | 577 AddPacketToTransportFeedback(options.packet_id, padding_packet, |
573 pacing_info); | 578 pacing_info); |
574 } | 579 } |
575 | 580 |
576 if (!SendPacketToNetwork(padding_packet, options, pacing_info)) | 581 if (!SendPacketToNetwork(padding_packet, options, pacing_info)) |
577 break; | 582 break; |
578 | 583 |
579 bytes_sent += padding_bytes_in_packet; | 584 bytes_sent += padding_bytes_in_packet; |
585 if (send_side_bwe_with_overhead_) { | |
586 // When WebRTC-SendSideBwe-WithOverhead is enabled, the padding budget | |
587 // includes overhead. | |
588 bytes_sent += padding_packet.headers_size(); | |
danilchap
2017/03/24 08:47:20
may be if else is better:
if (with_overhead_) {
minyue-webrtc
2017/03/24 09:08:54
I like that too.
| |
589 } | |
580 UpdateRtpStats(padding_packet, over_rtx, false); | 590 UpdateRtpStats(padding_packet, over_rtx, false); |
581 } | 591 } |
582 | 592 |
583 return bytes_sent; | 593 return bytes_sent; |
584 } | 594 } |
585 | 595 |
586 void RTPSender::SetStorePacketsStatus(bool enable, uint16_t number_to_store) { | 596 void RTPSender::SetStorePacketsStatus(bool enable, uint16_t number_to_store) { |
587 packet_history_.SetStorePacketsStatus(enable, number_to_store); | 597 packet_history_.SetStorePacketsStatus(enable, number_to_store); |
588 } | 598 } |
589 | 599 |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1270 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { | 1280 if (rtp_overhead_bytes_per_packet_ == packet.headers_size()) { |
1271 return; | 1281 return; |
1272 } | 1282 } |
1273 rtp_overhead_bytes_per_packet_ = packet.headers_size(); | 1283 rtp_overhead_bytes_per_packet_ = packet.headers_size(); |
1274 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; | 1284 overhead_bytes_per_packet = rtp_overhead_bytes_per_packet_; |
1275 } | 1285 } |
1276 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); | 1286 overhead_observer_->OnOverheadChanged(overhead_bytes_per_packet); |
1277 } | 1287 } |
1278 | 1288 |
1279 } // namespace webrtc | 1289 } // namespace webrtc |
OLD | NEW |