#include "modules/rtp_rtcp/source/forward_error_correction.h"
#include <string.h>
#include <algorithm>
#include <utility>
#include "absl/algorithm/container.h"
#include "modules/include/module_common_types_public.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/flexfec_03_header_reader_writer.h"
#include "modules/rtp_rtcp/source/forward_error_correction_internal.h"
#include "modules/rtp_rtcp/source/ulpfec_header_reader_writer.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/numerics/mod_ops.h"
namespace webrtc {
namespace {
constexpr size_t kTransportOverhead = …;
constexpr uint16_t kOldSequenceThreshold = …;
}
ForwardErrorCorrection::Packet::Packet() : … { … }
ForwardErrorCorrection::Packet::~Packet() = default;
int32_t ForwardErrorCorrection::Packet::AddRef() { … }
int32_t ForwardErrorCorrection::Packet::Release() { … }
template <typename S, typename T>
bool ForwardErrorCorrection::SortablePacket::LessThan::operator()(
const S& first,
const T& second) { … }
ForwardErrorCorrection::ReceivedPacket::ReceivedPacket() = default;
ForwardErrorCorrection::ReceivedPacket::~ReceivedPacket() = default;
ForwardErrorCorrection::RecoveredPacket::RecoveredPacket() = default;
ForwardErrorCorrection::RecoveredPacket::~RecoveredPacket() = default;
ForwardErrorCorrection::ProtectedPacket::ProtectedPacket() = default;
ForwardErrorCorrection::ProtectedPacket::~ProtectedPacket() = default;
ForwardErrorCorrection::ReceivedFecPacket::ReceivedFecPacket() = default;
ForwardErrorCorrection::ReceivedFecPacket::~ReceivedFecPacket() = default;
ForwardErrorCorrection::ForwardErrorCorrection(
std::unique_ptr<FecHeaderReader> fec_header_reader,
std::unique_ptr<FecHeaderWriter> fec_header_writer,
uint32_t ssrc,
uint32_t protected_media_ssrc)
: … { … }
ForwardErrorCorrection::~ForwardErrorCorrection() = default;
std::unique_ptr<ForwardErrorCorrection> ForwardErrorCorrection::CreateUlpfec(
uint32_t ssrc) { … }
std::unique_ptr<ForwardErrorCorrection> ForwardErrorCorrection::CreateFlexfec(
uint32_t ssrc,
uint32_t protected_media_ssrc) { … }
int ForwardErrorCorrection::EncodeFec(const PacketList& media_packets,
uint8_t protection_factor,
int num_important_packets,
bool use_unequal_protection,
FecMaskType fec_mask_type,
std::list<Packet*>* fec_packets) { … }
int ForwardErrorCorrection::NumFecPackets(int num_media_packets,
int protection_factor) { … }
void ForwardErrorCorrection::GenerateFecPayloads(
const PacketList& media_packets,
size_t num_fec_packets) { … }
int ForwardErrorCorrection::InsertZerosInPacketMasks(
const PacketList& media_packets,
size_t num_fec_packets) { … }
void ForwardErrorCorrection::FinalizeFecHeaders(size_t num_fec_packets,
uint32_t media_ssrc,
uint16_t seq_num_base) { … }
void ForwardErrorCorrection::ResetState(
RecoveredPacketList* recovered_packets) { … }
void ForwardErrorCorrection::InsertMediaPacket(
RecoveredPacketList* recovered_packets,
const ReceivedPacket& received_packet) { … }
void ForwardErrorCorrection::UpdateCoveringFecPackets(
const RecoveredPacket& packet) { … }
void ForwardErrorCorrection::InsertFecPacket(
const RecoveredPacketList& recovered_packets,
const ReceivedPacket& received_packet) { … }
void ForwardErrorCorrection::AssignRecoveredPackets(
const RecoveredPacketList& recovered_packets,
ReceivedFecPacket* fec_packet) { … }
void ForwardErrorCorrection::InsertPacket(
const ReceivedPacket& received_packet,
RecoveredPacketList* recovered_packets) { … }
bool ForwardErrorCorrection::StartPacketRecovery(
const ReceivedFecPacket& fec_packet,
RecoveredPacket* recovered_packet) { … }
bool ForwardErrorCorrection::FinishPacketRecovery(
const ReceivedFecPacket& fec_packet,
RecoveredPacket* recovered_packet) { … }
void ForwardErrorCorrection::XorHeaders(const Packet& src, Packet* dst) { … }
void ForwardErrorCorrection::XorPayloads(const Packet& src,
size_t payload_length,
size_t dst_offset,
Packet* dst) { … }
bool ForwardErrorCorrection::RecoverPacket(const ReceivedFecPacket& fec_packet,
RecoveredPacket* recovered_packet) { … }
size_t ForwardErrorCorrection::AttemptRecovery(
RecoveredPacketList* recovered_packets) { … }
int ForwardErrorCorrection::NumCoveredPacketsMissing(
const ReceivedFecPacket& fec_packet) { … }
void ForwardErrorCorrection::DiscardOldRecoveredPackets(
RecoveredPacketList* recovered_packets) { … }
bool ForwardErrorCorrection::IsOldFecPacket(
const ReceivedFecPacket& fec_packet,
const RecoveredPacketList* recovered_packets) { … }
uint16_t ForwardErrorCorrection::ParseSequenceNumber(const uint8_t* packet) { … }
uint32_t ForwardErrorCorrection::ParseSsrc(const uint8_t* packet) { … }
ForwardErrorCorrection::DecodeFecResult ForwardErrorCorrection::DecodeFec(
const ReceivedPacket& received_packet,
RecoveredPacketList* recovered_packets) { … }
size_t ForwardErrorCorrection::MaxPacketOverhead() const { … }
FecHeaderReader::FecHeaderReader(size_t max_media_packets,
size_t max_fec_packets)
: … { … }
FecHeaderReader::~FecHeaderReader() = default;
size_t FecHeaderReader::MaxMediaPackets() const { … }
size_t FecHeaderReader::MaxFecPackets() const { … }
FecHeaderWriter::FecHeaderWriter(size_t max_media_packets,
size_t max_fec_packets,
size_t max_packet_overhead)
: … { … }
FecHeaderWriter::~FecHeaderWriter() = default;
size_t FecHeaderWriter::MaxMediaPackets() const { … }
size_t FecHeaderWriter::MaxFecPackets() const { … }
size_t FecHeaderWriter::MaxPacketOverhead() const { … }
}