Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
fec.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Roc authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_packet/fec.h
10 //! @brief FEC packet.
11 
12 #ifndef ROC_PACKET_FEC_H_
13 #define ROC_PACKET_FEC_H_
14 
15 #include "roc_core/slice.h"
16 #include "roc_core/stddefs.h"
17 #include "roc_packet/units.h"
18 
19 namespace roc {
20 namespace packet {
21 
22 //! FECFRAME scheme.
23 enum FECScheme {
24  //! No FEC.
26 
27  //! Reed-Solomon (m=8).
29 
30  //! LDPC-Staircase.
32 };
33 
34 //! FECFRAME packet.
35 struct FEC {
36  //! The FEC scheme to which the packet belongs to.
37  //!
38  //! @remarks
39  //! Defines both FEC header or footer format and FEC payalod format.
41 
42  //! The index number of packet in a block.
43  //!
44  //! @remarks
45  //! Source packets are numbered in range [0; k).
46  //! Repair packets are numbered in range [k; k + n), where
47  //! k is a number of source packets per block (source_block_length)
48  //! n is a number of repair packets per block.
50 
51  //! Number of a source block in a packet stream.
52  //!
53  //! @remarks
54  //! Source block is formed from the source packets.
55  //! Blocks are numbered sequentially starting from a random number.
56  //! Block number can wrap.
58 
59  //! Number of source packets in the block to which this packet belongs to.
60  //!
61  //! @remarks
62  //! Different blocks can have different number of source packets.
64 
65  //! Number of source packets and repair in the block to which this packet belongs to.
66  //!
67  //! @remarks
68  //! Different blocks can have different number of packets.
69  //! Always larger than source_block_length.
70  //! This field is not supported on all FEC schemes.
71  size_t block_length;
72 
73  //! FECFRAME header or footer.
75 
76  //! FECFRAME payload.
77  //! @remarks
78  //! Doesn't include FECFRAME header or footer.
80 
81  //! Construct zero FEC packet.
82  FEC();
83 
84  //! Determine packet order.
85  int compare(const FEC&) const;
86 };
87 
88 } // namespace packet
89 } // namespace roc
90 
91 #endif // ROC_PACKET_FEC_H_
Reed-Solomon (m=8).
Definition: fec.h:28
Root namespace.
uint16_t blknum_t
FEC block number in a packet stream.
Definition: units.h:91
FECFRAME packet.
Definition: fec.h:35
LDPC-Staircase.
Definition: fec.h:31
Commonly used types and functions.
int compare(const FEC &) const
Determine packet order.
size_t source_block_length
Number of source packets in the block to which this packet belongs to.
Definition: fec.h:63
FEC()
Construct zero FEC packet.
size_t encoding_symbol_id
The index number of packet in a block.
Definition: fec.h:49
No FEC.
Definition: fec.h:25
Slice.
FECScheme fec_scheme
The FEC scheme to which the packet belongs to.
Definition: fec.h:40
FECScheme
FECFRAME scheme.
Definition: fec.h:23
Various units used in packets.
core::Slice< uint8_t > payload_id
FECFRAME header or footer.
Definition: fec.h:74
core::Slice< uint8_t > payload
FECFRAME payload.
Definition: fec.h:79
size_t block_length
Number of source packets and repair in the block to which this packet belongs to. ...
Definition: fec.h:71
blknum_t source_block_number
Number of a source block in a packet stream.
Definition: fec.h:57