Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
channel_mapper_reader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 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/channel_mapper_reader.h
10 //! @brief Channel mapper reader.
11 
12 #ifndef ROC_AUDIO_CHANNEL_MAPPER_READER_H_
13 #define ROC_AUDIO_CHANNEL_MAPPER_READER_H_
14 
17 #include "roc_audio/sample_spec.h"
19 #include "roc_core/noncopyable.h"
20 #include "roc_core/slice.h"
21 #include "roc_core/stddefs.h"
22 
23 namespace roc {
24 namespace audio {
25 
26 //! Channel mapper reader.
27 //! Reads frames from nested reader and maps them to another channel mask.
29 public:
30  //! Initialize.
32  core::BufferFactory<sample_t>& buffer_factory,
33  const SampleSpec& in_spec,
34  const SampleSpec& out_spec);
35 
36  //! Check if the object was succefully constructed.
37  bool is_valid() const;
38 
39  //! Read audio frame.
40  virtual bool read(Frame& frame);
41 
42 private:
43  bool read_(sample_t* out_samples,
44  size_t n_samples,
45  unsigned& flags,
46  core::nanoseconds_t& capt_ts);
47 
48  IFrameReader& input_reader_;
49  core::Slice<sample_t> input_buf_;
50 
51  ChannelMapper mapper_;
52 
53  const SampleSpec in_spec_;
54  const SampleSpec out_spec_;
55 
56  bool valid_;
57 };
58 
59 } // namespace audio
60 } // namespace roc
61 
62 #endif // ROC_AUDIO_CHANNEL_MAPPER_READER_H_
Buffer factory.
Channel mapper reader. Reads frames from nested reader and maps them to another channel mask.
bool is_valid() const
Check if the object was succefully constructed.
virtual bool read(Frame &frame)
Read audio frame.
ChannelMapperReader(IFrameReader &reader, core::BufferFactory< sample_t > &buffer_factory, const SampleSpec &in_spec, const SampleSpec &out_spec)
Initialize.
Channel mapper. Converts between frames with specified channel masks.
Audio frame.
Definition: frame.h:25
Frame reader interface.
Definition: iframe_reader.h:22
Sample specification. Describes sample rate and channels.
Definition: sample_spec.h:26
Buffer factory. Allows to instantiate fixed-size buffers.
Base class for non-copyable objects.
Definition: noncopyable.h:23
Frame reader interface.
float sample_t
Audio sample.
Definition: sample.h:22
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
Root namespace.
Non-copyable object.
Sample specifications.
Slice.
Commonly used types and functions.