/* * Copyright (c) 2016 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_03_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[] = …; // Flexfec03 implementation only support single-stream protection. // For multi-stream protection use implementation of the FlexFEC final standard. constexpr uint8_t kSsrcCount = …; // There are three reserved bytes that MUST be set to zero in the header. constexpr uint32_t kReservedBits = …; constexpr size_t kPacketMaskOffset = …; // Here we count the K-bits as belonging to the packet mask. // This can be used in conjunction with // Flexfec03HeaderWriter::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 Flexfec03HeaderReader::Flexfec03HeaderReader() : … { … } Flexfec03HeaderReader::~Flexfec03HeaderReader() = default; // Flexfec03 implementation doesn't support retransmission and flexible masks. // When that features are desired, they should be implemented in the class that // follows final version of the FlexFEC standard. bool Flexfec03HeaderReader::ReadFecHeader( ForwardErrorCorrection::ReceivedFecPacket* fec_packet) const { … } Flexfec03HeaderWriter::Flexfec03HeaderWriter() : … { … } Flexfec03HeaderWriter::~Flexfec03HeaderWriter() = default; size_t Flexfec03HeaderWriter::MinPacketMaskSize(const uint8_t* packet_mask, size_t packet_mask_size) const { … } size_t Flexfec03HeaderWriter::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. void Flexfec03HeaderWriter::FinalizeFecHeader( rtc::ArrayView<const ProtectedStream> protected_streams, ForwardErrorCorrection::Packet& fec_packet) const { … } } // namespace webrtc