Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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
19#include "roc_core/iarena.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
26namespace roc {
27namespace audio {
28
29//! Factory class for IResampler objects, according to the ResamplerBackend input
31public:
32 //! Get instance.
36
37 //! Get number of backends.
38 size_t num_backends() const;
39
40 //! Get backend ID by number.
42
43 //! Check if given backend is supported.
44 bool is_supported(ResamplerBackend backend_id) const;
45
46 //! Instantiate IResampler for given backend ID.
48 FrameFactory& frame_factory,
49 const ResamplerConfig& config,
50 const SampleSpec& in_spec,
51 const SampleSpec& out_spec);
52
53private:
54 friend class core::Singleton<ResamplerMap>;
55
56 enum { MaxBackends = 4 };
57
58 struct Backend {
59 Backend()
60 : id()
61 , ctor(NULL) {
62 }
63
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_
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(core::IArena &arena, FrameFactory &frame_factory, const ResamplerConfig &config, const SampleSpec &in_spec, const 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:30
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
Frame factory.
Memory arena interface.
Audio resampler interface.
ResamplerBackend
Resampler backends.
ResamplerProfile
Resampler parameters presets.
Root namespace.
Non-copyable object.
Resampler config.
Sample specifications.
Shared ownership intrusive pointer.
Singleton.
Commonly used types and functions.
Various units used in packets.