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 d6bafe3a6555eae07b3ac42fe98b9c12b98f33a1..8f14d653687ddd1bebe0228664af951863313623 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
@@ -132,7 +132,7 @@ void RTPSenderVideo::SendVideoPacketAsRed( |
uint16_t first_fec_sequence_number = |
rtp_sender_->AllocateSequenceNumber(num_fec_packets); |
fec_packets = producer_fec_.GetUlpfecPacketsAsRed( |
- red_payload_type_, fec_payload_type_, first_fec_sequence_number, |
+ red_payload_type_, ulpfec_payload_type_, first_fec_sequence_number, |
media_packet->headers_size()); |
RTC_DCHECK_EQ(num_fec_packets, fec_packets.size()); |
if (retransmission_settings_ & kRetransmitFECPackets) |
@@ -172,36 +172,42 @@ void RTPSenderVideo::SendVideoPacketAsRed( |
} |
} |
-void RTPSenderVideo::SetUlpfecConfig(bool enabled, |
- int red_payload_type, |
+void RTPSenderVideo::SetUlpfecConfig(int red_payload_type, |
int ulpfec_payload_type) { |
- RTC_DCHECK(!enabled || red_payload_type > 0); |
+ // Sanity check. Per the definition of UlpfecConfig (see config.h), |
+ // a payload type of -1 means that the corresponding feature is |
+ // turned off. |
+ RTC_DCHECK_GE(red_payload_type, -1); |
RTC_DCHECK_LE(red_payload_type, 127); |
+ RTC_DCHECK_GE(ulpfec_payload_type, -1); |
RTC_DCHECK_LE(ulpfec_payload_type, 127); |
rtc::CritScope cs(&crit_); |
- fec_enabled_ = enabled; |
red_payload_type_ = red_payload_type; |
- fec_payload_type_ = ulpfec_payload_type; |
+ ulpfec_payload_type_ = ulpfec_payload_type; |
+ |
+ // Must not enable ULPFEC without RED. |
+ // TODO(brandtr): We currently support enabling RED without ULPFEC. Change |
+ // this when we have removed the RED/RTX send-side workaround, so that we |
+ // ensure that RED and ULPFEC are only enabled together. |
+ RTC_DCHECK(red_enabled() || !ulpfec_enabled()); |
// Reset FEC rates. |
delta_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom}; |
key_fec_params_ = FecProtectionParams{0, 1, kFecMaskRandom}; |
} |
-void RTPSenderVideo::UlpfecConfig(bool* enabled, |
- int* red_payload_type, |
+void RTPSenderVideo::UlpfecConfig(int* red_payload_type, |
int* ulpfec_payload_type) const { |
rtc::CritScope cs(&crit_); |
- *enabled = fec_enabled_; |
*red_payload_type = red_payload_type_; |
- *ulpfec_payload_type = fec_payload_type_; |
+ *ulpfec_payload_type = ulpfec_payload_type_; |
} |
size_t RTPSenderVideo::FecPacketOverhead() const { |
rtc::CritScope cs(&crit_); |
size_t overhead = 0; |
- if (red_payload_type_ != -1) { |
+ if (red_enabled()) { |
// 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 |
@@ -210,7 +216,7 @@ size_t RTPSenderVideo::FecPacketOverhead() const { |
return producer_fec_.MaxPacketOverhead() + kRedForFecHeaderLength + |
(rtp_sender_->RtpHeaderLength() - kRtpHeaderSize); |
} |
- if (fec_enabled_) |
+ if (ulpfec_enabled()) |
overhead += producer_fec_.MaxPacketOverhead(); |
return overhead; |
} |
@@ -220,7 +226,7 @@ void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, |
rtc::CritScope cs(&crit_); |
RTC_DCHECK(delta_params); |
RTC_DCHECK(key_params); |
- if (fec_enabled_) { |
+ if (ulpfec_enabled()) { |
delta_fec_params_ = *delta_params; |
key_fec_params_ = *key_params; |
} |
@@ -276,7 +282,7 @@ bool RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, |
video_header ? &(video_header->codecHeader) : nullptr, frame_type)); |
StorageType storage; |
- int red_payload_type; |
+ bool _red_enabled; |
danilchap
2016/10/28 11:35:46
may be name it 'is_red_enabled' or 'send_as_red'
p
brandtr
2016/10/28 12:11:45
Going with 'red_enabled'. This is symmetric with '
|
bool first_frame = first_frame_sent_(); |
{ |
rtc::CritScope cs(&crit_); |
@@ -284,7 +290,7 @@ bool RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, |
frame_type == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; |
producer_fec_.SetFecParameters(fec_params); |
storage = packetizer->GetStorageType(retransmission_settings_); |
- red_payload_type = red_payload_type_; |
+ _red_enabled = red_enabled(); |
} |
// TODO(changbin): we currently don't support to configure the codec to |
@@ -311,7 +317,7 @@ bool RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, |
if (!rtp_sender_->AssignSequenceNumber(packet.get())) |
return false; |
- if (red_payload_type != -1) { |
+ if (_red_enabled) { |
SendVideoPacketAsRed(std::move(packet), storage, |
packetizer->GetProtectionType() == kProtectedPacket); |
} else { |