Fix TimeToSendPadding return to be 0 if no padding bytes are sent.
BUG=3694 R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/15149005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6900 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -451,7 +451,13 @@ int32_t RTPSender::SendOutgoingData(
|
|||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RTPSender::SendRedundantPayloads(int payload_type, int bytes_to_send) {
|
int RTPSender::TrySendRedundantPayloads(int bytes_to_send) {
|
||||||
|
{
|
||||||
|
CriticalSectionScoped cs(send_critsect_);
|
||||||
|
if ((rtx_ & kRtxRedundantPayloads) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t buffer[IP_PACKET_SIZE];
|
uint8_t buffer[IP_PACKET_SIZE];
|
||||||
int bytes_left = bytes_to_send;
|
int bytes_left = bytes_to_send;
|
||||||
while (bytes_left > 0) {
|
while (bytes_left > 0) {
|
||||||
@@ -490,14 +496,26 @@ int RTPSender::BuildPaddingPacket(uint8_t* packet, int header_length,
|
|||||||
return padding_bytes_in_packet;
|
return padding_bytes_in_packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RTPSender::SendPadData(int payload_type,
|
int RTPSender::TrySendPadData(int bytes) {
|
||||||
uint32_t timestamp,
|
int64_t capture_time_ms;
|
||||||
|
uint32_t timestamp;
|
||||||
|
{
|
||||||
|
CriticalSectionScoped cs(send_critsect_);
|
||||||
|
timestamp = timestamp_;
|
||||||
|
capture_time_ms = capture_time_ms_;
|
||||||
|
if (last_timestamp_time_ms_ > 0) {
|
||||||
|
timestamp +=
|
||||||
|
(clock_->TimeInMilliseconds() - last_timestamp_time_ms_) * 90;
|
||||||
|
capture_time_ms +=
|
||||||
|
(clock_->TimeInMilliseconds() - last_timestamp_time_ms_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SendPadData(timestamp, capture_time_ms, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
int RTPSender::SendPadData(uint32_t timestamp,
|
||||||
int64_t capture_time_ms,
|
int64_t capture_time_ms,
|
||||||
int32_t bytes) {
|
int32_t bytes) {
|
||||||
// Drop this packet if we're not sending media packets.
|
|
||||||
if (!SendingMedia()) {
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
int padding_bytes_in_packet = 0;
|
int padding_bytes_in_packet = 0;
|
||||||
int bytes_sent = 0;
|
int bytes_sent = 0;
|
||||||
for (; bytes > 0; bytes -= padding_bytes_in_packet) {
|
for (; bytes > 0; bytes -= padding_bytes_in_packet) {
|
||||||
@@ -507,6 +525,7 @@ int RTPSender::SendPadData(int payload_type,
|
|||||||
|
|
||||||
uint32_t ssrc;
|
uint32_t ssrc;
|
||||||
uint16_t sequence_number;
|
uint16_t sequence_number;
|
||||||
|
int payload_type;
|
||||||
bool over_rtx;
|
bool over_rtx;
|
||||||
{
|
{
|
||||||
CriticalSectionScoped cs(send_critsect_);
|
CriticalSectionScoped cs(send_critsect_);
|
||||||
@@ -515,20 +534,23 @@ int RTPSender::SendPadData(int payload_type,
|
|||||||
if (rtx_ == kRtxOff) {
|
if (rtx_ == kRtxOff) {
|
||||||
// Without RTX we can't send padding in the middle of frames.
|
// Without RTX we can't send padding in the middle of frames.
|
||||||
if (!last_packet_marker_bit_)
|
if (!last_packet_marker_bit_)
|
||||||
return bytes_sent;
|
return 0;
|
||||||
ssrc = ssrc_;
|
ssrc = ssrc_;
|
||||||
sequence_number = sequence_number_;
|
sequence_number = sequence_number_;
|
||||||
++sequence_number_;
|
++sequence_number_;
|
||||||
|
payload_type = payload_type_;
|
||||||
over_rtx = false;
|
over_rtx = false;
|
||||||
} else {
|
} else {
|
||||||
// Without abs-send-time a media packet must be sent before padding so
|
// Without abs-send-time a media packet must be sent before padding so
|
||||||
// that the timestamps used for estimation are correct.
|
// that the timestamps used for estimation are correct.
|
||||||
if (!media_has_been_sent_ && !rtp_header_extension_map_.IsRegistered(
|
if (!media_has_been_sent_ && !rtp_header_extension_map_.IsRegistered(
|
||||||
kRtpExtensionAbsoluteSendTime))
|
kRtpExtensionAbsoluteSendTime))
|
||||||
return bytes_sent;
|
return 0;
|
||||||
ssrc = ssrc_rtx_;
|
ssrc = ssrc_rtx_;
|
||||||
sequence_number = sequence_number_rtx_;
|
sequence_number = sequence_number_rtx_;
|
||||||
++sequence_number_rtx_;
|
++sequence_number_rtx_;
|
||||||
|
payload_type = ((rtx_ & kRtxRedundantPayloads) > 0) ? payload_type_rtx_
|
||||||
|
: payload_type_;
|
||||||
over_rtx = true;
|
over_rtx = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -867,38 +889,16 @@ bool RTPSender::IsFecPacket(const uint8_t* buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int RTPSender::TimeToSendPadding(int bytes) {
|
int RTPSender::TimeToSendPadding(int bytes) {
|
||||||
assert(bytes > 0);
|
|
||||||
int payload_type;
|
|
||||||
int64_t capture_time_ms;
|
|
||||||
uint32_t timestamp;
|
|
||||||
int rtx;
|
|
||||||
{
|
{
|
||||||
CriticalSectionScoped cs(send_critsect_);
|
CriticalSectionScoped cs(send_critsect_);
|
||||||
if (!sending_media_) {
|
if (!sending_media_) return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
payload_type = ((rtx_ & kRtxRedundantPayloads) > 0) ? payload_type_rtx_ :
|
|
||||||
payload_type_;
|
|
||||||
timestamp = timestamp_;
|
|
||||||
capture_time_ms = capture_time_ms_;
|
|
||||||
if (last_timestamp_time_ms_ > 0) {
|
|
||||||
timestamp +=
|
|
||||||
(clock_->TimeInMilliseconds() - last_timestamp_time_ms_) * 90;
|
|
||||||
capture_time_ms +=
|
|
||||||
(clock_->TimeInMilliseconds() - last_timestamp_time_ms_);
|
|
||||||
}
|
|
||||||
rtx = rtx_;
|
|
||||||
}
|
}
|
||||||
int bytes_sent = 0;
|
int available_bytes = bytes;
|
||||||
if ((rtx & kRtxRedundantPayloads) != 0)
|
if (available_bytes > 0)
|
||||||
bytes_sent = SendRedundantPayloads(payload_type, bytes);
|
available_bytes -= TrySendRedundantPayloads(available_bytes);
|
||||||
bytes -= bytes_sent;
|
if (available_bytes > 0)
|
||||||
if (bytes > 0) {
|
available_bytes -= TrySendPadData(available_bytes);
|
||||||
int padding_sent =
|
return bytes - available_bytes;
|
||||||
SendPadData(payload_type, timestamp, capture_time_ms, bytes);
|
|
||||||
bytes_sent += padding_sent;
|
|
||||||
}
|
|
||||||
return bytes_sent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again.
|
// TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again.
|
||||||
|
|||||||
@@ -264,8 +264,7 @@ class RTPSender : public RTPSenderInterface, public Bitrate::Observer {
|
|||||||
int32_t SetFecParameters(const FecProtectionParams *delta_params,
|
int32_t SetFecParameters(const FecProtectionParams *delta_params,
|
||||||
const FecProtectionParams *key_params);
|
const FecProtectionParams *key_params);
|
||||||
|
|
||||||
int SendPadData(int payload_type,
|
int SendPadData(uint32_t timestamp,
|
||||||
uint32_t timestamp,
|
|
||||||
int64_t capture_time_ms,
|
int64_t capture_time_ms,
|
||||||
int32_t bytes);
|
int32_t bytes);
|
||||||
|
|
||||||
@@ -305,7 +304,9 @@ class RTPSender : public RTPSenderInterface, public Bitrate::Observer {
|
|||||||
bool send_over_rtx,
|
bool send_over_rtx,
|
||||||
bool is_retransmit);
|
bool is_retransmit);
|
||||||
|
|
||||||
int SendRedundantPayloads(int payload_type, int bytes);
|
// Return the number of bytes sent.
|
||||||
|
int TrySendRedundantPayloads(int bytes);
|
||||||
|
int TrySendPadData(int bytes);
|
||||||
|
|
||||||
int BuildPaddingPacket(uint8_t* packet, int header_length, int32_t bytes);
|
int BuildPaddingPacket(uint8_t* packet, int header_length, int32_t bytes);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user