Fixes to padding when driven by encoder.

- Allow padding to be sent on an ssrc which doesn't produce video, therefore
  never having the last_packet_marker_bit_ set.
- Add the random timestamp offset to all padding packets.
- Store the capture time of padding packets to properly create an offset.

BUG=2258
TEST=trybots and a new test which will be committed separately.
R=mflodman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2060005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4566 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org 2013-08-19 15:55:01 +00:00
parent 32fe90b3f9
commit d4f607e70a
2 changed files with 16 additions and 6 deletions

View File

@ -408,8 +408,17 @@ bool RTPSender::SendPaddingAccordingToBitrate(
bytes = bytes_cap; bytes = bytes_cap;
} }
} }
int bytes_sent = SendPadData(payload_type, capture_timestamp, capture_time_ms, uint32_t timestamp;
bytes, kDontRetransmit, false); {
CriticalSectionScoped cs(send_critsect_);
// Add the random RTP timestamp offset and store the capture time for
// later calculation of the send time offset.
timestamp = start_time_stamp_ + capture_timestamp;
timestamp_ = timestamp;
capture_time_ms_ = capture_time_ms;
}
int bytes_sent = SendPadData(payload_type, timestamp, capture_time_ms,
bytes, kDontRetransmit, false, false);
// We did not manage to send all bytes. Comparing with 31 due to modulus 32. // We did not manage to send all bytes. Comparing with 31 due to modulus 32.
return bytes - bytes_sent < 31; return bytes - bytes_sent < 31;
} }
@ -435,7 +444,8 @@ int RTPSender::BuildPaddingPacket(uint8_t* packet, int header_length,
int RTPSender::SendPadData(int payload_type, uint32_t timestamp, int RTPSender::SendPadData(int payload_type, uint32_t timestamp,
int64_t capture_time_ms, int32_t bytes, int64_t capture_time_ms, int32_t bytes,
StorageType store, bool force_full_size_packets) { StorageType store, bool force_full_size_packets,
bool only_pad_after_markerbit) {
// Drop this packet if we're not sending media packets. // Drop this packet if we're not sending media packets.
if (!sending_media_) { if (!sending_media_) {
return bytes; return bytes;
@ -464,7 +474,7 @@ int RTPSender::SendPadData(int payload_type, uint32_t timestamp,
CriticalSectionScoped cs(send_critsect_); CriticalSectionScoped cs(send_critsect_);
// Only send padding packets following the last packet of a frame, // Only send padding packets following the last packet of a frame,
// indicated by the marker bit. // indicated by the marker bit.
if (!last_packet_marker_bit_) if (only_pad_after_markerbit && !last_packet_marker_bit_)
return bytes_sent; return bytes_sent;
if (rtx_ == kRtxOff) { if (rtx_ == kRtxOff) {
ssrc = ssrc_; ssrc = ssrc_;
@ -750,7 +760,7 @@ int RTPSender::TimeToSendPadding(int bytes) {
capture_time_ms = capture_time_ms_; capture_time_ms = capture_time_ms_;
} }
return SendPadData(payload_type, timestamp, capture_time_ms, bytes, return SendPadData(payload_type, timestamp, capture_time_ms, bytes,
kDontStore, true); kDontStore, true, true);
} }
// TODO(pwestin): send in the RTPHeaderParser to avoid parsing it again. // TODO(pwestin): send in the RTPHeaderParser to avoid parsing it again.

View File

@ -137,7 +137,7 @@ class RTPSender : public Bitrate, public RTPSenderInterface {
int BuildPaddingPacket(uint8_t* packet, int header_length, int32_t bytes); int BuildPaddingPacket(uint8_t* packet, int header_length, int32_t bytes);
int SendPadData(int payload_type, uint32_t timestamp, int64_t capture_time_ms, int SendPadData(int payload_type, uint32_t timestamp, int64_t capture_time_ms,
int32_t bytes, StorageType store, int32_t bytes, StorageType store,
bool force_full_size_packets); bool force_full_size_packets, bool only_pad_after_markerbit);
// RTP header extension // RTP header extension
int32_t SetTransmissionTimeOffset( int32_t SetTransmissionTimeOffset(
const int32_t transmission_time_offset); const int32_t transmission_time_offset);