/* * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "modules/rtp_rtcp/source/flexfec_header_reader_writer.h" #include <string.h> #include "api/scoped_refptr.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/forward_error_correction_internal.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" namespace webrtc { namespace { // Maximum number of media packets that can be protected in one batch. constexpr size_t kMaxMediaPackets = …; // Since we are reusing ULPFEC masks. // Maximum number of media packets tracked by FEC decoder. // Maintain a sufficiently larger tracking window than `kMaxMediaPackets` // to account for packet reordering in pacer/ network. constexpr size_t kMaxTrackedMediaPackets = …; // Maximum number of FEC packets stored inside ForwardErrorCorrection. constexpr size_t kMaxFecPackets = …; // Size (in bytes) of packet masks, given number of K bits set. constexpr size_t kFlexfecPacketMaskSizes[] = …; // Size (in bytes) of part of header which is not packet mask specific. constexpr size_t kBaseHeaderSize = …; // Size (in bytes) of part of header which is stream specific. constexpr size_t kStreamSpecificHeaderSize = …; // Size (in bytes) of header, given the single stream packet mask size, i.e. // the number of K-bits set. constexpr size_t kHeaderSizes[] = …; // Here we count the K-bits as belonging to the packet mask. // This can be used in conjunction with FlexfecHeaderWriter::MinPacketMaskSize, // which calculates a bound on the needed packet mask size including K-bits, // given a packet mask without K-bits. size_t FlexfecHeaderSize(size_t packet_mask_size) { … } } // namespace FlexfecHeaderReader::FlexfecHeaderReader() : … { … } FlexfecHeaderReader::~FlexfecHeaderReader() = default; // TODO(brandtr): Update this function when we support flexible masks, // and retransmissions. bool FlexfecHeaderReader::ReadFecHeader( ForwardErrorCorrection::ReceivedFecPacket* fec_packet) const { … } FlexfecHeaderWriter::FlexfecHeaderWriter() : … { … } FlexfecHeaderWriter::~FlexfecHeaderWriter() = default; size_t FlexfecHeaderWriter::MinPacketMaskSize(const uint8_t* packet_mask, size_t packet_mask_size) const { … } size_t FlexfecHeaderWriter::FecHeaderSize(size_t packet_mask_size) const { … } // This function adapts the precomputed ULPFEC packet masks to the // FlexFEC header standard. Note that the header size is computed by // FecHeaderSize(), so in this function we can be sure that we are // writing in space that is intended for the header. // // TODO(brandtr): Update this function when we support offset-based masks // and retransmissions. void FlexfecHeaderWriter::FinalizeFecHeader( rtc::ArrayView<const ProtectedStream> protected_streams, ForwardErrorCorrection::Packet& fec_packet) const { … } } // namespace webrtc