Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
resampler_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_audio/resampler_map.h
10
//! @brief Resampler map.
11
12
#ifndef ROC_AUDIO_RESAMPLER_MAP_H_
13
#define ROC_AUDIO_RESAMPLER_MAP_H_
14
15
#include "
roc_audio/frame_factory.h
"
16
#include "
roc_audio/iresampler.h
"
17
#include "
roc_audio/resampler_config.h
"
18
#include "
roc_audio/sample_spec.h
"
19
#include "
roc_core/iarena.h
"
20
#include "
roc_core/noncopyable.h
"
21
#include "
roc_core/shared_ptr.h
"
22
#include "
roc_core/singleton.h
"
23
#include "
roc_core/stddefs.h
"
24
#include "
roc_packet/units.h
"
25
26
namespace
roc
{
27
namespace
audio
{
28
29
//! Factory class for IResampler objects, according to the ResamplerBackend input
30
class
ResamplerMap :
public
core::NonCopyable
<> {
31
public
:
32
//! Get instance.
33
static
ResamplerMap&
instance
() {
34
return
core::Singleton<ResamplerMap>::instance
();
35
}
36
37
//! Get number of backends.
38
size_t
num_backends
()
const
;
39
40
//! Get backend ID by number.
41
ResamplerBackend
nth_backend
(
size_t
n)
const
;
42
43
//! Check if given backend is supported.
44
bool
is_supported
(
ResamplerBackend
backend_id)
const
;
45
46
//! Instantiate IResampler for given backend ID.
47
core::SharedPtr<IResampler>
new_resampler
(
core::IArena
& arena,
48
FrameFactory
& frame_factory,
49
const
ResamplerConfig
& config,
50
const
SampleSpec
& in_spec,
51
const
SampleSpec
& out_spec);
52
53
private
:
54
friend
class
core::Singleton
<ResamplerMap>;
55
56
enum
{ MaxBackends = 4 };
57
58
struct
Backend {
59
Backend()
60
: id()
61
, ctor(NULL) {
62
}
63
64
ResamplerBackend
id;
65
core::SharedPtr<IResampler>
(*ctor)(
core::IArena
& arena,
66
FrameFactory& frame_factory,
67
ResamplerProfile
profile,
68
const
SampleSpec& in_spec,
69
const
SampleSpec& out_spec);
70
};
71
72
ResamplerMap();
73
74
void
add_backend_(
const
Backend& backend);
75
const
Backend* find_backend_(
ResamplerBackend
)
const
;
76
77
Backend backends_[MaxBackends];
78
size_t
n_backends_;
79
};
80
81
}
// namespace audio
82
}
// namespace roc
83
84
#endif
// ROC_AUDIO_RESAMPLER_MAP_H_
roc::audio::FrameFactory
Frame factory.
Definition
frame_factory.h:38
roc::audio::ResamplerMap::nth_backend
ResamplerBackend nth_backend(size_t n) const
Get backend ID by number.
roc::audio::ResamplerMap::new_resampler
core::SharedPtr< IResampler > new_resampler(core::IArena &arena, FrameFactory &frame_factory, const ResamplerConfig &config, const SampleSpec &in_spec, const SampleSpec &out_spec)
Instantiate IResampler for given backend ID.
roc::audio::ResamplerMap::instance
static ResamplerMap & instance()
Get instance.
Definition
resampler_map.h:33
roc::audio::ResamplerMap::num_backends
size_t num_backends() const
Get number of backends.
roc::audio::ResamplerMap::is_supported
bool is_supported(ResamplerBackend backend_id) const
Check if given backend is supported.
roc::audio::SampleSpec
Sample specification. Describes sample rate and channels.
Definition
sample_spec.h:30
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::SharedPtr
Shared ownership intrusive pointer.
Definition
shared_ptr.h:32
roc::core::Singleton
Singleton.
Definition
singleton.h:26
roc::core::Singleton::instance
static T & instance()
Get singleton instance.
Definition
singleton.h:29
frame_factory.h
Frame factory.
iarena.h
Memory arena interface.
iresampler.h
Audio resampler interface.
roc::audio
Audio frames and audio processing.
roc::audio::ResamplerBackend
ResamplerBackend
Resampler backends.
Definition
resampler_config.h:21
roc::audio::ResamplerProfile
ResamplerProfile
Resampler parameters presets.
Definition
resampler_config.h:43
roc
Root namespace.
noncopyable.h
Non-copyable object.
resampler_config.h
Resampler config.
sample_spec.h
Sample specifications.
shared_ptr.h
Shared ownership intrusive pointer.
singleton.h
Singleton.
stddefs.h
Commonly used types and functions.
roc::audio::ResamplerConfig
Resampler config.
Definition
resampler_config.h:55
units.h
Various units used in packets.
roc_audio
resampler_map.h
Generated by
1.17.0