Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
codec_map.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 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/codec_map.h
10
//! @brief FEC codec map.
11
12
#ifndef ROC_FEC_CODEC_MAP_H_
13
#define ROC_FEC_CODEC_MAP_H_
14
15
#include "
roc_core/iarena.h
"
16
#include "
roc_core/noncopyable.h
"
17
#include "
roc_core/singleton.h
"
18
#include "
roc_fec/codec_config.h
"
19
#include "
roc_fec/iblock_decoder.h
"
20
#include "
roc_fec/iblock_encoder.h
"
21
#include "
roc_packet/packet_factory.h
"
22
23
namespace
roc
{
24
namespace
fec
{
25
26
//! FEC codec map.
27
class
CodecMap :
public
core::NonCopyable
<> {
28
public
:
29
//! Get instance.
30
static
CodecMap&
instance
() {
31
return
core::Singleton<CodecMap>::instance
();
32
}
33
34
//! Check whether given FEC scheme is supported.
35
bool
is_supported
(
packet::FecScheme
scheme)
const
;
36
37
//! Get number of supported FEC schemes.
38
size_t
num_schemes
()
const
;
39
40
//! Get FEC scheme ID by index.
41
packet::FecScheme
nth_scheme
(
size_t
n)
const
;
42
43
//! Create a new block encoder.
44
//!
45
//! @remarks
46
//! The codec type is determined by @p config.
47
//!
48
//! @returns
49
//! NULL if parameters are invalid or given codec support is not enabled.
50
IBlockEncoder
*
new_encoder
(
const
CodecConfig
& config,
51
packet::PacketFactory
& packet_factory,
52
core::IArena
& arena)
const
;
53
54
//! Create a new block decoder.
55
//!
56
//! @remarks
57
//! The codec type is determined by @p config.
58
//!
59
//! @returns
60
//! NULL if parameters are invalid or given codec support is not enabled.
61
IBlockDecoder
*
new_decoder
(
const
CodecConfig
& config,
62
packet::PacketFactory
& packet_factory,
63
core::IArena
& arena)
const
;
64
65
private
:
66
friend
class
core::Singleton
<CodecMap>;
67
68
enum
{ MaxCodecs = 2 };
69
70
struct
Codec {
71
packet::FecScheme
scheme;
72
73
IBlockEncoder
* (*encoder_ctor)(
const
CodecConfig
& config,
74
packet::PacketFactory
& packet_factory,
75
core::IArena
& arena);
76
77
IBlockDecoder
* (*decoder_ctor)(
const
CodecConfig
& config,
78
packet::PacketFactory
& packet_factory,
79
core::IArena
& arena);
80
};
81
82
CodecMap();
83
84
void
add_codec_(
const
Codec& codec);
85
const
Codec* find_codec_(
packet::FecScheme
scheme)
const
;
86
87
size_t
n_codecs_;
88
Codec codecs_[MaxCodecs];
89
};
90
91
}
// namespace fec
92
}
// namespace roc
93
94
#endif
// ROC_FEC_CODEC_MAP_H_
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::Singleton
Singleton.
Definition
singleton.h:26
roc::core::Singleton::instance
static T & instance()
Get singleton instance.
Definition
singleton.h:29
roc::fec::CodecMap::nth_scheme
packet::FecScheme nth_scheme(size_t n) const
Get FEC scheme ID by index.
roc::fec::CodecMap::instance
static CodecMap & instance()
Get instance.
Definition
codec_map.h:30
roc::fec::CodecMap::num_schemes
size_t num_schemes() const
Get number of supported FEC schemes.
roc::fec::CodecMap::is_supported
bool is_supported(packet::FecScheme scheme) const
Check whether given FEC scheme is supported.
roc::fec::CodecMap::new_encoder
IBlockEncoder * new_encoder(const CodecConfig &config, packet::PacketFactory &packet_factory, core::IArena &arena) const
Create a new block encoder.
roc::fec::CodecMap::new_decoder
IBlockDecoder * new_decoder(const CodecConfig &config, packet::PacketFactory &packet_factory, core::IArena &arena) const
Create a new block decoder.
roc::fec::IBlockDecoder
FEC block decoder interface.
Definition
iblock_decoder.h:22
roc::fec::IBlockEncoder
FEC block encoder interface.
Definition
iblock_encoder.h:22
roc::packet::PacketFactory
Packet factory.
Definition
packet_factory.h:36
codec_config.h
FEC codec parameters.
iarena.h
Memory arena interface.
iblock_decoder.h
FEC block decoder interface.
iblock_encoder.h
FEC block encoder interface.
roc::fec
FEC support.
roc::packet::FecScheme
FecScheme
FECFRAME scheme.
Definition
fec.h:23
roc
Root namespace.
noncopyable.h
Non-copyable object.
packet_factory.h
Packet factory.
singleton.h
Singleton.
roc::fec::CodecConfig
FEC codec parameters.
Definition
codec_config.h:22
roc_fec
codec_map.h
Generated by
1.17.0