ulpfec_header_reader_writer.h (2632B)
1 /* 2 * Copyright (c) 2016 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_ULPFEC_HEADER_READER_WRITER_H_ 12 #define MODULES_RTP_RTCP_SOURCE_ULPFEC_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 // FEC Level 0 Header, 10 bytes. 23 // 0 1 2 3 24 // 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 25 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 // |E|L|P|X| CC |M| PT recovery | SN base | 27 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 // | TS recovery | 29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 30 // | length recovery | 31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 // 33 // FEC Level 1 Header, 4 bytes (L = 0) or 8 bytes (L = 1). 34 // 0 1 2 3 35 // 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 36 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 // | Protection Length | mask | 38 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 // | mask cont. (present only when L = 1) | 40 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 class UlpfecHeaderReader : public FecHeaderReader { 42 public: 43 UlpfecHeaderReader(); 44 ~UlpfecHeaderReader() override; 45 46 bool ReadFecHeader( 47 ForwardErrorCorrection::ReceivedFecPacket* fec_packet) const override; 48 }; 49 50 class UlpfecHeaderWriter : public FecHeaderWriter { 51 public: 52 UlpfecHeaderWriter(); 53 ~UlpfecHeaderWriter() override; 54 55 size_t MinPacketMaskSize(const uint8_t* packet_mask, 56 size_t packet_mask_size) const override; 57 58 size_t FecHeaderSize(size_t packet_mask_row_size) const override; 59 60 void FinalizeFecHeader( 61 ArrayView<const ProtectedStream> protected_streams, 62 ForwardErrorCorrection::Packet& fec_packet) const override; 63 }; 64 65 } // namespace webrtc 66 67 #endif // MODULES_RTP_RTCP_SOURCE_ULPFEC_HEADER_READER_WRITER_H_