Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
openfec_encoder.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 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_fec/target_openfec/roc_fec/openfec_encoder.h
10
//! @brief Encoder implementation using OpenFEC library.
11
12
#ifndef ROC_FEC_OPENFEC_ENCODER_H_
13
#define ROC_FEC_OPENFEC_ENCODER_H_
14
15
#include "
roc_core/array.h
"
16
#include "
roc_core/iarena.h
"
17
#include "
roc_core/noncopyable.h
"
18
#include "
roc_core/slice.h
"
19
#include "
roc_fec/codec_config.h
"
20
#include "
roc_fec/iblock_encoder.h
"
21
#include "
roc_packet/packet_factory.h
"
22
#include "
roc_packet/units.h
"
23
24
extern
"C"
{
25
#include <of_openfec_api.h>
26
}
27
28
#ifndef OF_USE_ENCODER
29
#error "OF_USE_ENCODER undefined"
30
#endif
31
32
#ifndef OF_USE_LDPC_STAIRCASE_CODEC
33
#error "OF_USE_LDPC_STAIRCASE_CODEC undefined"
34
#endif
35
36
namespace
roc
{
37
namespace
fec
{
38
39
//! Encoder implementation using OpenFEC library.
40
class
OpenfecEncoder
:
public
IBlockEncoder
,
public
core::NonCopyable
<> {
41
public
:
42
//! Initialize.
43
explicit
OpenfecEncoder
(
const
CodecConfig
& config,
44
packet::PacketFactory
& packet_factory,
45
core::IArena
& arena);
46
47
virtual
~OpenfecEncoder
();
48
49
//! Check if object is successfully constructed.
50
bool
is_valid
()
const
;
51
52
//! Get buffer alignment requirement.
53
virtual
size_t
alignment
()
const
;
54
55
//! Get the maximum number of encoding symbols for the scheme being used.
56
virtual
size_t
max_block_length
()
const
;
57
58
//! Start block.
59
//!
60
//! @remarks
61
//! Performs an initial setup for a block. Should be called before
62
//! any operations for the block.
63
virtual
bool
begin
(
size_t
sblen,
size_t
rblen,
size_t
payload_size);
64
65
//! Store packet data for current block.
66
virtual
void
set
(
size_t
index,
const
core::Slice<uint8_t>
& buffer);
67
68
//! Fill repair packets.
69
virtual
void
fill
();
70
71
//! Finish block.
72
//!
73
//! @remarks
74
//! Cleanups the resources allocated for the block. Should be called after
75
//! all operations for the block.
76
virtual
void
end
();
77
78
private
:
79
bool
resize_tabs_(
size_t
size);
80
void
reset_session_();
81
void
update_session_params_(
size_t
sblen,
size_t
rblen,
size_t
payload_size);
82
83
enum
{ Alignment = 8 };
84
85
size_t
sblen_;
86
size_t
rblen_;
87
88
size_t
payload_size_;
89
90
of_session_t* of_sess_;
91
of_parameters_t* of_sess_params_;
92
93
of_codec_id_t codec_id_;
94
union
{
95
of_ldpc_parameters ldpc_params_;
96
of_rs_2_m_parameters_t rs_params_;
97
} codec_params_;
98
99
core::Array<core::Slice<uint8_t>
> buff_tab_;
100
core::Array<void*>
data_tab_;
101
102
size_t
max_block_length_;
103
104
bool
valid_;
105
};
106
107
}
// namespace fec
108
}
// namespace roc
109
110
#endif
// ROC_FEC_OPENFEC_ENCODER_H_
array.h
Dynamic array.
roc::core::Array
Dynamic array.
Definition
array.h:40
roc::core::IArena
Memory arena interface.
Definition
iarena.h:23
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
roc::core::Slice
Slice.
Definition
slice.h:55
roc::fec::IBlockEncoder
FEC block encoder interface.
Definition
iblock_encoder.h:22
roc::fec::OpenfecEncoder::begin
virtual bool begin(size_t sblen, size_t rblen, size_t payload_size)
Start block.
roc::fec::OpenfecEncoder::set
virtual void set(size_t index, const core::Slice< uint8_t > &buffer)
Store packet data for current block.
roc::fec::OpenfecEncoder::max_block_length
virtual size_t max_block_length() const
Get the maximum number of encoding symbols for the scheme being used.
roc::fec::OpenfecEncoder::is_valid
bool is_valid() const
Check if object is successfully constructed.
roc::fec::OpenfecEncoder::OpenfecEncoder
OpenfecEncoder(const CodecConfig &config, packet::PacketFactory &packet_factory, core::IArena &arena)
Initialize.
roc::fec::OpenfecEncoder::end
virtual void end()
Finish block.
roc::fec::OpenfecEncoder::fill
virtual void fill()
Fill repair packets.
roc::fec::OpenfecEncoder::alignment
virtual size_t alignment() const
Get buffer alignment requirement.
roc::packet::PacketFactory
Packet factory.
Definition
packet_factory.h:36
codec_config.h
FEC codec parameters.
iarena.h
Memory arena interface.
iblock_encoder.h
FEC block encoder interface.
roc::fec
FEC support.
roc
Root namespace.
noncopyable.h
Non-copyable object.
packet_factory.h
Packet factory.
slice.h
Slice.
roc::fec::CodecConfig
FEC codec parameters.
Definition
codec_config.h:22
units.h
Various units used in packets.
roc_fec
target_openfec
roc_fec
openfec_encoder.h
Generated by
1.17.0