A class for handling FEC encoding symbols.
More...
#include <EncodingSymbol.h>
A class for handling FEC encoding symbols.
Definition at line 28 of file EncodingSymbol.h.
◆ EncodingSymbol()
LibFlute::EncodingSymbol::EncodingSymbol |
( |
uint32_t |
id, |
|
|
uint32_t |
source_block_number, |
|
|
char * |
encoded_data, |
|
|
size_t |
data_len, |
|
|
FecScheme |
fec_scheme |
|
) |
| |
|
inline |
Default constructor.
- Parameters
-
id | Encoding symbol ID |
source_block_number | Source BLock Number of the symbol |
encoded_data | Encoded content data |
data_len | Length of the encoded data |
fec_scheme | FEC scheme to use |
Definition at line 49 of file EncodingSymbol.h.
52 , _encoded_data(encoded_data)
54 , _fec_scheme(fec_scheme) {}
uint32_t source_block_number() const
Get the source block number.
◆ ~EncodingSymbol()
virtual LibFlute::EncodingSymbol::~EncodingSymbol |
( |
| ) |
|
|
inlinevirtual |
◆ decode_to()
auto LibFlute::EncodingSymbol::decode_to |
( |
char * |
buffer, |
|
|
size_t |
max_length |
|
) |
| const |
Decode to a buffer.
Definition at line 83 of file EncodingSymbol.cpp.
85 if (_data_len <= max_length) {
86 memcpy(buffer, _encoded_data, _data_len);
◆ encode_to()
auto LibFlute::EncodingSymbol::encode_to |
( |
char * |
buffer, |
|
|
size_t |
max_length |
|
) |
| const |
Encode to a buffer.
Definition at line 91 of file EncodingSymbol.cpp.
93 if (_data_len <= max_length) {
94 memcpy(buffer, _encoded_data, _data_len);
◆ from_payload()
auto LibFlute::EncodingSymbol::from_payload |
( |
char * |
encoded_data, |
|
|
size_t |
data_len, |
|
|
const FecOti & |
fec_oti, |
|
|
ContentEncoding |
encoding |
|
) |
| |
|
static |
Parse and construct all encoding symbols from a payload data buffer.
Definition at line 25 of file EncodingSymbol.cpp.
28 auto encoding_symbol_id = 0;
29 std::vector<EncodingSymbol> symbols;
32 throw "Only unencoded content is supported";
38 encoding_symbol_id = ntohs(*(uint16_t*)encoded_data);
42 throw "Only compact no-code FEC is supported";
45 int nof_symbols = std::ceil((
float)data_len / (
float)fec_oti.encoding_symbol_length);
46 for (
int i = 0; i < nof_symbols; i++) {
48 symbols.emplace_back(encoding_symbol_id,
source_block_number, encoded_data, std::min(data_len, (
size_t)fec_oti.encoding_symbol_length), fec_oti.encoding_id);
50 encoded_data += fec_oti.encoding_symbol_length;
◆ id()
uint32_t LibFlute::EncodingSymbol::id |
( |
| ) |
const |
|
inline |
◆ len()
size_t LibFlute::EncodingSymbol::len |
( |
| ) |
const |
|
inline |
Get the data length.
Definition at line 84 of file EncodingSymbol.h.
84 {
return _data_len; };
◆ source_block_number()
uint32_t LibFlute::EncodingSymbol::source_block_number |
( |
| ) |
const |
|
inline |
Get the source block number.
Definition at line 69 of file EncodingSymbol.h.
69 {
return _source_block_number; };
◆ to_payload()
auto LibFlute::EncodingSymbol::to_payload |
( |
const std::vector< EncodingSymbol > & |
symbols, |
|
|
char * |
encoded_data, |
|
|
size_t |
data_len, |
|
|
const FecOti & |
fec_oti, |
|
|
ContentEncoding |
encoding |
|
) |
| |
|
static |
Write encoding symbols to a packet payload buffer.
Definition at line 57 of file EncodingSymbol.cpp.
60 auto ptr = encoded_data;
61 auto first_symbol = symbols.begin();
63 *((uint16_t*)ptr) = htons(first_symbol->source_block_number());
65 *((uint16_t*)ptr) = htons(first_symbol->id());
69 throw "Only compact no-code FEC is supported";
72 for (
const auto& symbol : symbols) {
73 if (symbol.len() <= data_len) {
74 auto symbol_len = symbol.encode_to(ptr, data_len);
75 data_len -= symbol_len;
76 encoded_data += symbol_len;
size_t len() const
Get the data length.
The documentation for this class was generated from the following files: