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
19#include "roc_core/iallocator.h"
21#include "roc_core/singleton.h"
22#include "roc_core/stddefs.h"
23#include "roc_packet/units.h"
24
25namespace roc {
26namespace audio {
27
28//! Factory class for IResampler objects, according to the ResamplerBackend input
30public:
31 //! Get instance.
34 }
35
36 //! Get number of backends.
37 size_t num_backends() const;
38
39 //! Get backend ID by number.
41
42 //! Method to instantiate and return a pointer to a IResampler object.
44 core::IAllocator& allocator,
45 core::BufferFactory<sample_t>& buffer_factory,
46 ResamplerProfile profile,
47 core::nanoseconds_t frame_length,
48 const audio::SampleSpec& sample_spec);
49
50private:
51 friend class core::Singleton<ResamplerMap>;
52
53 enum { MaxBackends = 2 };
54
55 struct Backend {
56 Backend()
57 : id()
58 , ctor(NULL) {
59 }
60
62 IResampler* (*ctor)(core::IAllocator& allocator,
63 core::BufferFactory<sample_t>& buffer_factory,
64 ResamplerProfile profile,
65 core::nanoseconds_t frame_length,
66 const audio::SampleSpec& sample_spec);
67 };
68
69 ResamplerMap();
70
71 void add_backend_(const Backend& backend);
72 const Backend* find_backend_(ResamplerBackend) const;
73
74 Backend backends_[MaxBackends];
75 size_t n_backends_;
76};
77
78} // namespace audio
79} // namespace roc
80
81#endif // ROC_AUDIO_RESAMPLER_MAP_H_
Audio writer interface.
Definition: iresampler.h:23
Factory class for IResampler objects, according to the ResamplerBackend input.
Definition: resampler_map.h:29
ResamplerBackend nth_backend(size_t n) const
Get backend ID by number.
IResampler * new_resampler(ResamplerBackend resampler_backend, core::IAllocator &allocator, core::BufferFactory< sample_t > &buffer_factory, ResamplerProfile profile, core::nanoseconds_t frame_length, const audio::SampleSpec &sample_spec)
Method to instantiate and return a pointer to a IResampler object.
static ResamplerMap & instance()
Get instance.
Definition: resampler_map.h:32
size_t num_backends() const
Get number of backends.
Sample stream specification. Defines sample rate and channel layout.
Definition: sample_spec.h:24
Memory allocator interface.
Definition: iallocator.h:23
Base class for non-copyable objects.
Definition: noncopyable.h:23
static T & instance()
Get singleton instance.
Definition: singleton.h:29
Memory allocator interface.
Audio resampler interface.
ResamplerBackend
Resampler backends.
ResamplerProfile
Resampler parameters presets.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
Root namespace.
Non-copyable object.
Resampler backend.
Resampler profile.
Sample specifications.
Singleton.
Commonly used types and functions.
Various units used in packets.