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 // Licensed under the License terms and conditions for use, reproduction, and
6 // distribution of 5G-MAG software (the “License”). You may not use this file
7 // except in compliance with the License. You may obtain a copy of the License at
8 // https://www.5g-mag.com/reference-tools. Unless required by applicable law or
9 // agreed to in writing, software distributed under the License is distributed on
10 // an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 // or implied.
12 //
13 // See the License for the specific language governing permissions and limitations
14 // under the License.
15 //
16 #pragma once
17 #include <stddef.h>
18 #include <stdint.h>
19 #include <vector>
20 #include "flute_types.h"
21 
22 namespace LibFlute {
27  public:
31  static std::vector<EncodingSymbol> from_payload(char* encoded_data, size_t data_len, const FecOti& fec_oti, ContentEncoding encoding);
32 
36  static size_t to_payload(const std::vector<EncodingSymbol>&, char* encoded_data, size_t data_len, const FecOti& fec_oti, ContentEncoding encoding);
37 
47  EncodingSymbol(uint32_t id, uint32_t source_block_number, char* encoded_data, size_t data_len, FecScheme fec_scheme)
48  : _id(id)
49  , _source_block_number(source_block_number)
50  , _fec_scheme(fec_scheme)
51  , _encoded_data(encoded_data)
52  , _data_len(data_len)
53  {};
54 
58  virtual ~EncodingSymbol() {};
59 
63  uint32_t id() const { return _id; };
64 
68  uint32_t source_block_number() const { return _source_block_number; };
69 
73  void decode_to(char* buffer, size_t max_length) const;
74 
78  size_t encode_to(char* buffer, size_t max_length) const;
79 
83  size_t len() const { return _data_len; };
84 
85  private:
86  uint32_t _id = 0;
87  uint32_t _source_block_number = 0;
88  FecScheme _fec_scheme;
89  char* _encoded_data;
90  size_t _data_len;
91  };
92 };
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:44
ContentEncoding
Content Encodings.
Definition: flute_types.h:34
OTI values struct.
Definition: flute_types.h:51