Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(857)

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_sender.cc

Issue 2766323006: Correcting the amount of padding when send side bwe includes RTP overhead.
Patch Set: on comments` Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/rtp_sender.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
index 52b0891ea7390bcd7f8f04c3df56bd86b99a573f..7e0852fe78a23ba579b81bfa7c04c3c81692eff6 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
@@ -455,33 +455,43 @@ size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send,
int bytes_left = static_cast<int>(bytes_to_send);
while (bytes_left > 0) {
std::unique_ptr<RtpPacketToSend> packet =
- packet_history_.GetBestFittingPacket(bytes_left);
+ packet_history_.GetBestFittingPacket(bytes_left,
+ send_side_bwe_with_overhead_);
if (!packet)
break;
- size_t payload_size = packet->payload_size();
+ // When WebRTC-SendSideBwe-WithOverhead is enabled, the padding budget
+ // includes overhead.
+ const size_t used_bytes = send_side_bwe_with_overhead_
+ ? packet->size()
+ : packet->size() - packet->headers_size();
if (!PrepareAndSendPacket(std::move(packet), true, false, pacing_info))
break;
- bytes_left -= payload_size;
+ bytes_left -= used_bytes;
}
return bytes_to_send - bytes_left;
}
size_t RTPSender::SendPadData(size_t bytes,
const PacedPacketInfo& pacing_info) {
- size_t padding_bytes_in_packet;
+ // Always send full padding packets. This is accounted for by the
+ // RtpPacketSender, which will make sure we don't send too much padding even
+ // if a single packet is larger than requested.
+ // We do this to avoid frequently sending small packets on higher bitrates.
+ size_t padding_bytes_in_packet =
+ std::min(MaxPayloadSize(), kMaxPaddingLength);
+
if (audio_configured_) {
// Allow smaller padding packets for audio.
+
+ // When WebRTC-SendSideBwe-WithOverhead is enabled, the padding budget
+ // includes overhead.
+ const size_t padding_bytes_if_one_packet =
+ send_side_bwe_with_overhead_ ? bytes - RtpHeaderLength() : bytes;
padding_bytes_in_packet =
- std::min(std::max(bytes, kMinAudioPaddingLength), MaxPayloadSize());
- if (padding_bytes_in_packet > kMaxPaddingLength)
- padding_bytes_in_packet = kMaxPaddingLength;
- } else {
- // Always send full padding packets. This is accounted for by the
- // RtpPacketSender, which will make sure we don't send too much padding even
- // if a single packet is larger than requested.
- // We do this to avoid frequently sending small packets on higher bitrates.
- padding_bytes_in_packet = std::min(MaxPayloadSize(), kMaxPaddingLength);
+ std::min(padding_bytes_in_packet,
+ std::max(padding_bytes_if_one_packet, kMinAudioPaddingLength));
}
+
size_t bytes_sent = 0;
while (bytes_sent < bytes) {
int64_t now_ms = clock_->TimeInMilliseconds();
@@ -566,6 +576,7 @@ size_t RTPSender::SendPadData(size_t bytes,
PacketOptions options;
bool has_transport_seq_num =
UpdateTransportSequenceNumber(&padding_packet, &options.packet_id);
+
padding_packet.SetPadding(padding_bytes_in_packet, &random_);
if (has_transport_seq_num) {
@@ -576,7 +587,10 @@ size_t RTPSender::SendPadData(size_t bytes,
if (!SendPacketToNetwork(padding_packet, options, pacing_info))
break;
- bytes_sent += padding_bytes_in_packet;
+ // When WebRTC-SendSideBwe-WithOverhead is enabled, the padding budget
+ // includes overhead.
+ bytes_sent += send_side_bwe_with_overhead_ ? padding_packet.size()
+ : padding_packet.padding_size();
stefan-webrtc 2017/04/04 08:13:38 Maybe for consistency use: packet->size() - packet
minyue-webrtc 2017/04/11 09:35:14 I would rather do padding_size + headers_size I h
danilchap 2017/04/11 14:25:18 personally prefer size() function too: size_t pack
minyue-webrtc 2017/04/11 14:30:51 You are right here. I realized that we should incl
UpdateRtpStats(padding_packet, over_rtx, false);
}
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698