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 72425671599b06321eeae1ae56e1de20a2a505d9..12a0160012be0e94085fec0e966664307760532e 100644 |
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc |
@@ -130,7 +130,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) |
@@ -170,36 +170,52 @@ void RTPSenderVideo::SendVideoPacketAsRed( |
} |
} |
-void RTPSenderVideo::SetUlpfecConfig(bool enabled, |
- int red_payload_type, |
+bool RTPSenderVideo::RedEnabled() const { |
+ rtc::CritScope cs(&crit_); |
danilchap
2016/10/28 09:29:43
do not (re)take lock, instead annotate these funct
brandtr
2016/10/28 11:05:06
Got it! Done. Also changed name to cheap_accessor_
|
+ return red_payload_type_ >= 0; |
+} |
+ |
+bool RTPSenderVideo::UlpfecEnabled() const { |
+ rtc::CritScope cs(&crit_); |
+ return ulpfec_payload_type_ >= 0; |
+} |
+ |
+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(RedEnabled() || !UlpfecEnabled()); |
// 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 (RedEnabled()) { |
// 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 |
@@ -208,7 +224,7 @@ size_t RTPSenderVideo::FecPacketOverhead() const { |
return producer_fec_.MaxPacketOverhead() + kRedForFecHeaderLength + |
(rtp_sender_->RtpHeaderLength() - kRtpHeaderSize); |
} |
- if (fec_enabled_) |
+ if (UlpfecEnabled()) |
overhead += producer_fec_.MaxPacketOverhead(); |
return overhead; |
} |
@@ -218,7 +234,7 @@ void RTPSenderVideo::SetFecParameters(const FecProtectionParams* delta_params, |
rtc::CritScope cs(&crit_); |
RTC_DCHECK(delta_params); |
RTC_DCHECK(key_params); |
- if (fec_enabled_) { |
+ if (UlpfecEnabled()) { |
delta_fec_params_ = *delta_params; |
key_fec_params_ = *key_params; |
} |
@@ -272,7 +288,7 @@ bool RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, |
video_header ? &(video_header->codecHeader) : nullptr, frame_type)); |
StorageType storage; |
- int red_payload_type; |
+ bool red_enabled; |
bool first_frame = first_frame_sent_(); |
{ |
rtc::CritScope cs(&crit_); |
@@ -280,7 +296,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 = RedEnabled(); |
} |
// TODO(changbin): we currently don't support to configure the codec to |
@@ -307,7 +323,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 { |