Index: webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
index 0bf95b7fe4b14f10d60d4cea44504d5a2083ee0e..e10b5b2edab45b98689b1d1fec6346bd1115f3b9 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
@@ -36,8 +36,8 @@ RTPSenderVideo::RTPSenderVideo(Clock* clock, RTPSenderInterface* rtpSender) |
// Generic FEC |
fec_(), |
fec_enabled_(false), |
- red_payload_type_(-1), |
- fec_payload_type_(-1), |
+ red_payload_type_(0), |
+ fec_payload_type_(0), |
delta_fec_params_(), |
key_fec_params_(), |
producer_fec_(&fec_), |
@@ -191,16 +191,19 @@ void RTPSenderVideo::GenericFECStatus(bool* enable, |
size_t RTPSenderVideo::FECPacketOverhead() const { |
rtc::CritScope cs(&crit_); |
- if (fec_enabled_) { |
+ size_t overhead = 0; |
+ if (red_payload_type_ != 0) { |
// Overhead is FEC headers plus RED for FEC header plus anything in RTP |
// header beyond the 12 bytes base header (CSRC list, extensions...) |
// This reason for the header extensions to be included here is that |
// from an FEC viewpoint, they are part of the payload to be protected. |
// (The base RTP header is already protected by the FEC header.) |
- return ForwardErrorCorrection::PacketOverhead() + REDForFECHeaderLength + |
- (_rtpSender.RTPHeaderLength() - kRtpHeaderSize); |
+ overhead = REDForFECHeaderLength + (_rtpSender.RTPHeaderLength() - |
+ kRtpHeaderSize); |
} |
- return 0; |
+ if (fec_enabled_) |
+ overhead += ForwardErrorCorrection::PacketOverhead(); |
+ return overhead; |
} |
void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, |
@@ -208,8 +211,10 @@ void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, |
rtc::CritScope cs(&crit_); |
RTC_DCHECK(delta_params); |
RTC_DCHECK(key_params); |
- delta_fec_params_ = *delta_params; |
- key_fec_params_ = *key_params; |
+ if (fec_enabled_) { |
+ delta_fec_params_ = *delta_params; |
+ key_fec_params_ = *key_params; |
+ } |
} |
int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, |
@@ -230,7 +235,7 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, |
video_header ? &(video_header->codecHeader) : nullptr, frameType)); |
StorageType storage; |
- bool fec_enabled; |
+ int red_payload_type; |
bool first_frame = first_frame_sent_(); |
{ |
rtc::CritScope cs(&crit_); |
@@ -238,7 +243,7 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, |
frameType == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; |
producer_fec_.SetFecParameters(fec_params, 0); |
storage = packetizer->GetStorageType(_retransmissionSettings); |
- fec_enabled = fec_enabled_; |
+ red_payload_type = red_payload_type_; |
} |
// Register CVO rtp header extension at the first time when we receive a frame |
@@ -301,7 +306,7 @@ int32_t RTPSenderVideo::SendVideo(const RtpVideoCodecTypes videoType, |
_rtpSender.UpdateVideoRotation(dataBuffer, packetSize, rtp_header, |
video_header->rotation); |
} |
- if (fec_enabled) { |
+ if (red_payload_type != 0) { |
SendVideoPacketAsRed(dataBuffer, payload_bytes_in_packet, |
rtp_header_length, _rtpSender.SequenceNumber(), |
captureTimeStamp, capture_time_ms, storage, |