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 Streaming 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  //! @remarks
38  //! Defines both FEC header or footer format and FEC payalod format.
40 
41  //! The index number of packet in a block ("esi").
42  //! @remarks
43  //! Source packets are numbered in range [0; k).
44  //! Repair packets are numbered in range [k; k + n), where
45  //! k is a number of source packets per block (source_block_length)
46  //! n is a number of repair packets per block.
48 
49  //! Number of a source block in a packet stream ("sbn").
50  //! @remarks
51  //! Source block is formed from the source packets.
52  //! Blocks are numbered sequentially starting from a random number.
53  //! Block number can wrap.
55 
56  //! Number of source packets in block to which this packet belongs ("sblen").
57  //! @remarks
58  //! Different blocks can have different number of source packets.
60 
61  //! Number of source + repair packets in block to which this packet belongs ("blen").
62  //! @remarks
63  //! Different blocks can have different number of packets.
64  //! Always larger than source_block_length.
65  //! This field is not supported on all FEC schemes.
66  size_t block_length;
67 
68  //! FECFRAME header or footer.
70 
71  //! FECFRAME payload.
72  //! @remarks
73  //! Doesn't include FECFRAME header or footer.
75 
76  //! Construct zero FEC packet.
77  FEC();
78 
79  //! Determine packet order.
80  int compare(const FEC&) const;
81 };
82 
83 } // namespace packet
84 } // namespace roc
85 
86 #endif // ROC_PACKET_FEC_H_
uint16_t blknum_t
FEC packet block number.
Definition: units.h:91
FecScheme
FECFRAME scheme.
Definition: fec.h:23
@ FEC_ReedSolomon_M8
Reed-Solomon (m=8).
Definition: fec.h:28
@ FEC_LDPC_Staircase
LDPC-Staircase.
Definition: fec.h:31
@ FEC_None
No FEC.
Definition: fec.h:25
Root namespace.
Slice.
Commonly used types and functions.
FECFRAME packet.
Definition: fec.h:35
core::Slice< uint8_t > payload
FECFRAME payload.
Definition: fec.h:74
size_t encoding_symbol_id
The index number of packet in a block ("esi").
Definition: fec.h:47
size_t source_block_length
Number of source packets in block to which this packet belongs ("sblen").
Definition: fec.h:59
FecScheme fec_scheme
The FEC scheme to which the packet belongs to.
Definition: fec.h:39
FEC()
Construct zero FEC packet.
size_t block_length
Number of source + repair packets in block to which this packet belongs ("blen").
Definition: fec.h:66
blknum_t source_block_number
Number of a source block in a packet stream ("sbn").
Definition: fec.h:54
core::Slice< uint8_t > payload_id
FECFRAME header or footer.
Definition: fec.h:69
int compare(const FEC &) const
Determine packet order.
Various units used in packets.