Index: webrtc/modules/rtp_rtcp/source/producer_fec.cc |
diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec.cc b/webrtc/modules/rtp_rtcp/source/producer_fec.cc |
index b928020df3211d33c7a9be5c838b39f49708faa9..277067ca1cf3666c928698342c4c72001a573bc5 100644 |
--- a/webrtc/modules/rtp_rtcp/source/producer_fec.cc |
+++ b/webrtc/modules/rtp_rtcp/source/producer_fec.cc |
@@ -24,12 +24,12 @@ namespace webrtc { |
constexpr size_t kRedForFecHeaderLength = 1; |
// This controls the maximum amount of excess overhead (actual - target) |
-// allowed in order to trigger GenerateFec(), before |params_.max_fec_frames| |
+// allowed in order to trigger EncodeFec(), before |params_.max_fec_frames| |
// is reached. Overhead here is defined as relative to number of media packets. |
constexpr int kMaxExcessOverhead = 50; // Q8. |
// This is the minimum number of media packets required (above some protection |
-// level) in order to trigger GenerateFec(), before |params_.max_fec_frames| is |
+// level) in order to trigger EncodeFec(), before |params_.max_fec_frames| is |
// reached. |
constexpr size_t kMinMediaPackets = 4; |
@@ -92,8 +92,8 @@ size_t RedPacket::length() const { |
return length_; |
} |
-ProducerFec::ProducerFec(ForwardErrorCorrection* fec) |
- : fec_(fec), |
+ProducerFec::ProducerFec() |
+ : fec_(ForwardErrorCorrection::CreateUlpfec()), |
media_packets_(), |
generated_fec_packets_(), |
num_protected_frames_(0), |
@@ -129,9 +129,8 @@ void ProducerFec::SetFecParameters(const FecProtectionParams* params, |
// protection in 'unequal protection mode') cannot exceed kMaxMediaPackets. |
RTC_DCHECK_GE(params->fec_rate, 0); |
RTC_DCHECK_LE(params->fec_rate, 255); |
- if (num_important_packets > |
- static_cast<int>(ForwardErrorCorrection::kMaxMediaPackets)) { |
- num_important_packets = ForwardErrorCorrection::kMaxMediaPackets; |
+ 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. |
@@ -153,8 +152,8 @@ int ProducerFec::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, |
} |
bool complete_frame = false; |
const bool marker_bit = (data_buffer[1] & kRtpMarkerBitMask) ? true : false; |
- if (media_packets_.size() < ForwardErrorCorrection::kMaxMediaPackets) { |
- // Generic FEC can only protect up to |kMaxMediaPackets| packets. |
+ if (media_packets_.size() < kUlpfecMaxMediaPackets) { |
+ // Generic FEC can only protect up to kMaxMediaPackets packets. |
std::unique_ptr<ForwardErrorCorrection::Packet> packet( |
new ForwardErrorCorrection::Packet()); |
packet->length = payload_length + rtp_header_length; |
@@ -173,16 +172,16 @@ int ProducerFec::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer, |
(num_protected_frames_ == params_.max_fec_frames || |
(ExcessOverheadBelowMax() && MinimumMediaPacketsReached()))) { |
RTC_DCHECK_LE(num_important_packets_, |
- static_cast<int>(ForwardErrorCorrection::kMaxMediaPackets)); |
+ 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(). |
constexpr bool kUseUnequalProtection = false; |
- int ret = fec_->GenerateFec(media_packets_, params_.fec_rate, |
- num_important_packets_, kUseUnequalProtection, |
- params_.fec_mask_type, &generated_fec_packets_); |
+ int ret = fec_.EncodeFec(media_packets_, params_.fec_rate, |
+ num_important_packets_, kUseUnequalProtection, |
+ params_.fec_mask_type, &generated_fec_packets_); |
if (generated_fec_packets_.empty()) { |
num_protected_frames_ = 0; |
DeleteMediaPackets(); |
@@ -217,6 +216,10 @@ size_t ProducerFec::NumAvailableFecPackets() const { |
return generated_fec_packets_.size(); |
} |
+size_t ProducerFec::MaxPacketOverhead() const { |
+ return fec_.MaxPacketOverhead(); |
+} |
+ |
std::vector<std::unique_ptr<RedPacket>> ProducerFec::GetFecPacketsAsRed( |
int red_payload_type, |
int ulpfec_payload_type, |
@@ -239,15 +242,12 @@ std::vector<std::unique_ptr<RedPacket>> ProducerFec::GetFecPacketsAsRed( |
red_packet->SetSeqNum(seq_num++); |
red_packet->ClearMarkerBit(); |
red_packet->AssignPayload(fec_packet->data, fec_packet->length); |
- |
red_packets.push_back(std::move(red_packet)); |
} |
- |
// Reset state. |
DeleteMediaPackets(); |
generated_fec_packets_.clear(); |
num_protected_frames_ = 0; |
- |
return red_packets; |
} |
@@ -258,7 +258,7 @@ int ProducerFec::Overhead() const { |
// generation is implemented. |
RTC_DCHECK(!media_packets_.empty()); |
int num_fec_packets = |
- fec_->GetNumberOfFecPackets(media_packets_.size(), params_.fec_rate); |
+ fec_.NumFecPackets(media_packets_.size(), params_.fec_rate); |
// Return the overhead in Q8. |
return (num_fec_packets << 8) / media_packets_.size(); |
} |