diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec.cc b/webrtc/modules/rtp_rtcp/source/producer_fec.cc index 2a2327cd94..f96437698b 100644 --- a/webrtc/modules/rtp_rtcp/source/producer_fec.cc +++ b/webrtc/modules/rtp_rtcp/source/producer_fec.cc @@ -99,7 +99,6 @@ size_t RedPacket::length() const { ProducerFec::ProducerFec() : fec_(ForwardErrorCorrection::CreateUlpfec()), num_protected_frames_(0), - num_important_packets_(0), min_num_media_packets_(1) { memset(¶ms_, 0, sizeof(params_)); memset(&new_params_, 0, sizeof(new_params_)); @@ -121,19 +120,12 @@ std::unique_ptr ProducerFec::BuildRedPacket( return red_packet; } -void ProducerFec::SetFecParameters(const FecProtectionParams* params, - int num_important_packets) { - // Number of important packets (i.e. number of packets receiving additional - // protection in 'unequal protection mode') cannot exceed kMaxMediaPackets. +void ProducerFec::SetFecParameters(const FecProtectionParams* params) { RTC_DCHECK_GE(params->fec_rate, 0); RTC_DCHECK_LE(params->fec_rate, 255); - if (num_important_packets > static_cast(kUlpfecMaxMediaPackets)) { - num_important_packets = kUlpfecMaxMediaPackets; - } // Store the new params and apply them for the next set of FEC packets being // produced. new_params_ = *params; - num_important_packets_ = num_important_packets; if (params->fec_rate > kHighProtectionThreshold) { min_num_media_packets_ = kMinMediaPackets; } else { @@ -169,16 +161,11 @@ int ProducerFec::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, if (complete_frame && (num_protected_frames_ == params_.max_fec_frames || (ExcessOverheadBelowMax() && MinimumMediaPacketsReached()))) { - RTC_DCHECK_LE(num_important_packets_, - static_cast(kUlpfecMaxMediaPackets)); - // TODO(pbos): Consider whether unequal protection should be enabled or not, - // it is currently always disabled. - // - // Since unequal protection is disabled, the value of - // |num_important_packets_| has no importance when calling GenerateFec(). + // We are not using Unequal Protection feature of the parity erasure code. + constexpr int kNumImportantPackets = 0; constexpr bool kUseUnequalProtection = false; int ret = fec_->EncodeFec(media_packets_, params_.fec_rate, - num_important_packets_, kUseUnequalProtection, + kNumImportantPackets, kUseUnequalProtection, params_.fec_mask_type, &generated_fec_packets_); if (generated_fec_packets_.empty()) { ResetState(); diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec.h b/webrtc/modules/rtp_rtcp/source/producer_fec.h index d52b4ed8f8..35bb7dafbf 100644 --- a/webrtc/modules/rtp_rtcp/source/producer_fec.h +++ b/webrtc/modules/rtp_rtcp/source/producer_fec.h @@ -49,8 +49,7 @@ class ProducerFec { size_t rtp_header_length, int red_payload_type); - void SetFecParameters(const FecProtectionParams* params, - int num_first_partition); + void SetFecParameters(const FecProtectionParams* params); // Adds a media packet to the internal buffer. When enough media packets // have been added, the FEC packets are generated and stored internally. @@ -100,7 +99,6 @@ class ProducerFec { ForwardErrorCorrection::PacketList media_packets_; std::list generated_fec_packets_; int num_protected_frames_; - int num_important_packets_; int min_num_media_packets_; FecProtectionParams params_; FecProtectionParams new_params_; diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc b/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc index d705bd0475..810785acde 100644 --- a/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc @@ -81,7 +81,7 @@ TEST_F(ProducerFecTest, NoEmptyFecWithSeqNumGaps) { protected_packets.push_back({21, 0, 55, 0}); protected_packets.push_back({13, 3, 57, 1}); FecProtectionParams params = {117, 3, kFecMaskBursty}; - producer_.SetFecParameters(¶ms, 0); + producer_.SetFecParameters(¶ms); uint8_t packet[28] = {0}; for (Packet p : protected_packets) { if (p.marker_bit) { @@ -111,7 +111,7 @@ TEST_F(ProducerFecTest, OneFrameFec) { constexpr size_t kNumPackets = 4; FecProtectionParams params = {15, 3, kFecMaskRandom}; packet_generator_.NewFrame(kNumPackets); - producer_.SetFecParameters(¶ms, 0); // Expecting one FEC packet. + producer_.SetFecParameters(¶ms); // Expecting one FEC packet. uint32_t last_timestamp = 0; for (size_t i = 0; i < kNumPackets; ++i) { std::unique_ptr packet = @@ -143,7 +143,7 @@ TEST_F(ProducerFecTest, TwoFrameFec) { constexpr size_t kNumFrames = 2; FecProtectionParams params = {15, 3, kFecMaskRandom}; - producer_.SetFecParameters(¶ms, 0); // Expecting one FEC packet. + producer_.SetFecParameters(¶ms); // Expecting one FEC packet. uint32_t last_timestamp = 0; for (size_t i = 0; i < kNumFrames; ++i) { packet_generator_.NewFrame(kNumPackets); diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc index 722a484a87..bb41b83aaa 100644 --- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -273,11 +273,7 @@ bool RTPSenderVideo::SendVideo(RtpVideoCodecTypes video_type, rtc::CritScope cs(&crit_); FecProtectionParams* fec_params = frame_type == kVideoFrameKey ? &key_fec_params_ : &delta_fec_params_; - // We currently do not use unequal protection in the FEC. - // This is signalled both here (by setting the number of important - // packets to zero), as well as in ProducerFec::AddRtpPacketAndGenerateFec. - constexpr int kNumImportantPackets = 0; - producer_fec_.SetFecParameters(fec_params, kNumImportantPackets); + producer_fec_.SetFecParameters(fec_params); storage = packetizer->GetStorageType(retransmission_settings_); red_payload_type = red_payload_type_; } diff --git a/webrtc/test/fuzzers/producer_fec_fuzzer.cc b/webrtc/test/fuzzers/producer_fec_fuzzer.cc index 269b4a1cd6..fcf5df534a 100644 --- a/webrtc/test/fuzzers/producer_fec_fuzzer.cc +++ b/webrtc/test/fuzzers/producer_fec_fuzzer.cc @@ -29,7 +29,7 @@ void FuzzOneInput(const uint8_t* data, size_t size) { return; FecProtectionParams params = { data[i++] % 128, static_cast(data[i++] % 10), kFecMaskBursty}; - producer.SetFecParameters(¶ms, 0); + producer.SetFecParameters(¶ms); uint16_t seq_num = data[i++]; while (i + 3 < size) {