Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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"
17#include "roc_core/singleton.h"
22
23namespace roc {
24namespace fec {
25
26//! FEC codec map.
27class CodecMap : public core::NonCopyable<> {
28public:
29 //! Get instance.
30 static 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.
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.
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.
62 packet::PacketFactory& packet_factory,
63 core::IArena& arena) const;
64
65private:
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_
Memory arena interface.
Definition iarena.h:23
Base class for non-copyable objects.
Definition noncopyable.h:23
static T & instance()
Get singleton instance.
Definition singleton.h:29
packet::FecScheme nth_scheme(size_t n) const
Get FEC scheme ID by index.
static CodecMap & instance()
Get instance.
Definition codec_map.h:30
size_t num_schemes() const
Get number of supported FEC schemes.
bool is_supported(packet::FecScheme scheme) const
Check whether given FEC scheme is supported.
IBlockEncoder * new_encoder(const CodecConfig &config, packet::PacketFactory &packet_factory, core::IArena &arena) const
Create a new block encoder.
IBlockDecoder * new_decoder(const CodecConfig &config, packet::PacketFactory &packet_factory, core::IArena &arena) const
Create a new block decoder.
FEC block decoder interface.
FEC block encoder interface.
FEC codec parameters.
Memory arena interface.
FEC block decoder interface.
FEC block encoder interface.
FEC support.
FecScheme
FECFRAME scheme.
Definition fec.h:23
Root namespace.
Non-copyable object.
Packet factory.
Singleton.
FEC codec parameters.