Centralize deactivation of Unequal Protection.
This CL introduces changes that clearly demarcate where we disable Unequal Protection in the FEC. No functional changes are expected. BUG=webrtc:5654 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/2314743002 . Cr-Commit-Position: refs/heads/master@{#14496}
This commit is contained in:
parent
9f38c218ee
commit
3821399075
@ -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<RedPacket> 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<int>(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<int>(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();
|
||||
|
||||
@ -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<ForwardErrorCorrection::Packet*> generated_fec_packets_;
|
||||
int num_protected_frames_;
|
||||
int num_important_packets_;
|
||||
int min_num_media_packets_;
|
||||
FecProtectionParams params_;
|
||||
FecProtectionParams new_params_;
|
||||
|
||||
@ -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<AugmentedPacket> 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);
|
||||
|
||||
@ -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_;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
return;
|
||||
FecProtectionParams params = {
|
||||
data[i++] % 128, static_cast<int>(data[i++] % 10), kFecMaskBursty};
|
||||
producer.SetFecParameters(¶ms, 0);
|
||||
producer.SetFecParameters(¶ms);
|
||||
uint16_t seq_num = data[i++];
|
||||
|
||||
while (i + 3 < size) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user