libflute
EncodingSymbol.h
Go to the documentation of this file.
1 // libflute - FLUTE/ALC library
2 //
3 // Copyright (C) 2021 Klaus Kühnhammer (Österreichische Rundfunksender GmbH & Co KG)
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Affero General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Affero General Public License for more details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 #pragma once
19 #include <stddef.h>
20 #include <stdint.h>
21 #include <vector>
22 #include "flute_types.h"
23 
24 namespace LibFlute {
29  public:
33  static std::vector<EncodingSymbol> from_payload(char* encoded_data, size_t data_len, const FecOti& fec_oti, ContentEncoding encoding);
34 
38  static size_t to_payload(const std::vector<EncodingSymbol>&, char* encoded_data, size_t data_len, const FecOti& fec_oti, ContentEncoding encoding);
39 
49  EncodingSymbol(uint32_t id, uint32_t source_block_number, char* encoded_data, size_t data_len, FecScheme fec_scheme)
50  : _id(id)
51  , _source_block_number(source_block_number)
52  , _encoded_data(encoded_data)
53  , _data_len(data_len)
54  , _fec_scheme(fec_scheme) {}
55 
59  virtual ~EncodingSymbol() {};
60 
64  uint32_t id() const { return _id; };
65 
69  uint32_t source_block_number() const { return _source_block_number; };
70 
74  void decode_to(char* buffer, size_t max_length) const;
75 
79  size_t encode_to(char* buffer, size_t max_length) const;
80 
84  size_t len() const { return _data_len; };
85 
86  private:
87  uint32_t _id = 0;
88  uint32_t _source_block_number = 0;
89  FecScheme _fec_scheme;
90  char* _encoded_data;
91  size_t _data_len;
92  };
93 };
A class for handling FEC encoding symbols.
EncodingSymbol(uint32_t id, uint32_t source_block_number, char *encoded_data, size_t data_len, FecScheme fec_scheme)
Default constructor.
uint32_t source_block_number() const
Get the source block number.
virtual ~EncodingSymbol()
Default destructor.
static size_t to_payload(const std::vector< EncodingSymbol > &, char *encoded_data, size_t data_len, const FecOti &fec_oti, ContentEncoding encoding)
Write encoding symbols to a packet payload buffer.
uint32_t id() const
Get the encoding symbol ID.
size_t encode_to(char *buffer, size_t max_length) const
Encode to a buffer.
size_t len() const
Get the data length.
static std::vector< EncodingSymbol > from_payload(char *encoded_data, size_t data_len, const FecOti &fec_oti, ContentEncoding encoding)
Parse and construct all encoding symbols from a payload data buffer.
void decode_to(char *buffer, size_t max_length) const
Decode to a buffer.
FecScheme
Error correction schemes.
Definition: flute_types.h:46
ContentEncoding
Content Encodings.
Definition: flute_types.h:36
OTI values struct.
Definition: flute_types.h:53