From 63a34f4f29eccf7082a3d708cf4662136678daa6 Mon Sep 17 00:00:00 2001 From: "asapersson@webrtc.org" Date: Fri, 20 Apr 2012 13:20:27 +0000 Subject: [PATCH] Fix in SendPadData. Do not increase sequence number if packet is "empty" and not sent. Review URL: https://webrtc-codereview.appspot.com/508001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2083 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/rtp_rtcp/source/rtp_sender.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/modules/rtp_rtcp/source/rtp_sender.cc b/src/modules/rtp_rtcp/source/rtp_sender.cc index 64837bfbd6..0115a0d83b 100644 --- a/src/modules/rtp_rtcp/source/rtp_sender.cc +++ b/src/modules/rtp_rtcp/source/rtp_sender.cc @@ -546,6 +546,15 @@ WebRtc_Word32 RTPSender::SendPadData(WebRtc_Word8 payload_type, WebRtc_UWord8 data_buffer[IP_PACKET_SIZE]; for (; bytes > 0; bytes -= max_length) { + int padding_bytes_in_packet = max_length; + if (bytes < max_length) { + padding_bytes_in_packet = (bytes + 16) & 0xffe0; // Keep our modulus 32. + } + if (padding_bytes_in_packet < 32) { + // Sanity don't send empty packets. + break; + } + WebRtc_Word32 header_length; { // Correct seq num, timestamp and payload type. @@ -560,14 +569,6 @@ WebRtc_Word32 RTPSender::SendPadData(WebRtc_Word8 payload_type, WebRtc_Word32* data = reinterpret_cast(&(data_buffer[header_length])); - int padding_bytes_in_packet = max_length; - if (bytes < max_length) { - padding_bytes_in_packet = (bytes + 16) & 0xffe0; // Keep our modulus 32. - } - if (padding_bytes_in_packet < 32) { - // Sanity don't send empty packets. - break; - } // Fill data buffer with random data. for(int j = 0; j < (padding_bytes_in_packet >> 2); j++) { data[j] = rand();