flexfec_header_reader_writer.h (2695B)
1 /* 2 * Copyright (c) 2023 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_RTP_RTCP_SOURCE_FLEXFEC_HEADER_READER_WRITER_H_ 12 #define MODULES_RTP_RTCP_SOURCE_FLEXFEC_HEADER_READER_WRITER_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include "api/array_view.h" 18 #include "modules/rtp_rtcp/source/forward_error_correction.h" 19 20 namespace webrtc { 21 22 // FlexFEC header in flexible mode (R=0, F=0), minimum 12 bytes. 23 // https://datatracker.ietf.org/doc/html/rfc8627#section-4.2.2.1 24 // 25 // 0 1 2 3 26 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 27 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 // 0 |0|0|P|X| CC |M| PT recovery | length recovery | 29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 30 // 4 | TS recovery | 31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 // 8 | SN base_i |k| Mask [0-14] | 33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 34 // 12 |k| Mask [15-45] (optional) | 35 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 // 16 | Mask [46-109] (optional) | 37 // 20 | | 38 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 // | ... next SN base and Mask for CSRC_i in CSRC list ... | 40 // 41 42 class FlexfecHeaderReader : public FecHeaderReader { 43 public: 44 FlexfecHeaderReader(); 45 ~FlexfecHeaderReader() override; 46 47 bool ReadFecHeader( 48 ForwardErrorCorrection::ReceivedFecPacket* fec_packet) const override; 49 }; 50 51 class FlexfecHeaderWriter : public FecHeaderWriter { 52 public: 53 FlexfecHeaderWriter(); 54 ~FlexfecHeaderWriter() override; 55 56 size_t MinPacketMaskSize(const uint8_t* packet_mask, 57 size_t packet_mask_size) const override; 58 59 size_t FecHeaderSize(size_t packet_mask_row_size) const override; 60 61 void FinalizeFecHeader( 62 ArrayView<const ProtectedStream> protected_streams, 63 ForwardErrorCorrection::Packet& fec_packet) const override; 64 }; 65 66 } // namespace webrtc 67 68 #endif // MODULES_RTP_RTCP_SOURCE_FLEXFEC_HEADER_READER_WRITER_H_