Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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
20#include "roc_core/iarena.h"
22#include "roc_core/shared_ptr.h"
23#include "roc_core/singleton.h"
24#include "roc_core/stddefs.h"
25#include "roc_packet/units.h"
26
27namespace roc {
28namespace audio {
29
30//! Factory class for IResampler objects, according to the ResamplerBackend input
32public:
33 //! Get instance.
37
38 //! Get number of backends.
39 size_t num_backends() const;
40
41 //! Get backend ID by number.
43
44 //! Check if given backend is supported.
45 bool is_supported(ResamplerBackend backend_id) const;
46
47 //! Instantiate IResampler for given backend ID.
50 core::IArena& arena,
51 core::BufferFactory<sample_t>& buffer_factory,
52 ResamplerProfile profile,
53 const audio::SampleSpec& in_spec,
54 const audio::SampleSpec& out_spec);
55
56private:
57 friend class core::Singleton<ResamplerMap>;
58
59 enum { MaxBackends = 4 };
60
61 struct Backend {
62 Backend()
63 : id()
64 , ctor(NULL) {
65 }
66
69 core::BufferFactory<sample_t>& buffer_factory,
70 ResamplerProfile profile,
71 const audio::SampleSpec& in_spec,
72 const audio::SampleSpec& out_spec);
73 };
74
75 ResamplerMap();
76
77 void add_backend_(const Backend& backend);
78 const Backend* find_backend_(ResamplerBackend) const;
79
80 Backend backends_[MaxBackends];
81 size_t n_backends_;
82};
83
84} // namespace audio
85} // namespace roc
86
87#endif // ROC_AUDIO_RESAMPLER_MAP_H_
Buffer factory.
Factory class for IResampler objects, according to the ResamplerBackend input.
ResamplerBackend nth_backend(size_t n) const
Get backend ID by number.
core::SharedPtr< IResampler > new_resampler(ResamplerBackend backend_id, core::IArena &arena, core::BufferFactory< sample_t > &buffer_factory, ResamplerProfile profile, const audio::SampleSpec &in_spec, const audio::SampleSpec &out_spec)
Instantiate IResampler for given backend ID.
static ResamplerMap & instance()
Get instance.
size_t num_backends() const
Get number of backends.
bool is_supported(ResamplerBackend backend_id) const
Check if given backend is supported.
Sample specification. Describes sample rate and channels.
Definition sample_spec.h:26
Buffer factory. Allows to instantiate fixed-size buffers.
Memory arena interface.
Definition iarena.h:23
Base class for non-copyable objects.
Definition noncopyable.h:23
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
static T & instance()
Get singleton instance.
Definition singleton.h:29
Memory arena interface.
Audio resampler interface.
ResamplerBackend
Resampler backends.
ResamplerProfile
Resampler parameters presets.
Root namespace.
Non-copyable object.
Resampler backend.
Resampler profile.
Sample specifications.
Shared ownership intrusive pointer.
Singleton.
Commonly used types and functions.
Various units used in packets.