Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
pcm_mapper_reader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 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/pcm_mapper_reader.h
10 //! @brief Pcm mapper reader.
11 
12 #ifndef ROC_AUDIO_PCM_MAPPER_READER_H_
13 #define ROC_AUDIO_PCM_MAPPER_READER_H_
14 
17 #include "roc_audio/pcm_mapper.h"
18 #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 #include "roc_core/time.h"
23 
24 namespace roc {
25 namespace audio {
26 
27 //! Pcm mapper reader.
28 //! Reads frames from nested reader and maps them to another pcm mask.
30 public:
31  //! Initialize.
33  FrameFactory& frame_factory,
34  const SampleSpec& in_spec,
35  const SampleSpec& out_spec);
36 
37  //! Check if the object was succefully constructed.
38  bool is_valid() const;
39 
40  //! Read audio frame.
41  virtual bool read(Frame& frame);
42 
43 private:
44  PcmMapper mapper_;
45 
46  IFrameReader& in_reader_;
47  core::Slice<uint8_t> in_buf_;
48 
49  const SampleSpec in_spec_;
50  const SampleSpec out_spec_;
51 
52  const size_t num_ch_;
53 
54  bool valid_;
55 };
56 
57 } // namespace audio
58 } // namespace roc
59 
60 #endif // ROC_AUDIO_PCM_MAPPER_READER_H_
Audio frame.
Definition: frame.h:25
Frame reader interface.
Definition: iframe_reader.h:22
Pcm mapper reader. Reads frames from nested reader and maps them to another pcm mask.
bool is_valid() const
Check if the object was succefully constructed.
virtual bool read(Frame &frame)
Read audio frame.
PcmMapperReader(IFrameReader &reader, FrameFactory &frame_factory, const SampleSpec &in_spec, const SampleSpec &out_spec)
Initialize.
PCM format mapper. Convert between PCM formats.
Definition: pcm_mapper.h:24
Sample specification. Describes sample rate and channels.
Definition: sample_spec.h:30
Base class for non-copyable objects.
Definition: noncopyable.h:23
Frame factory.
Frame reader interface.
Root namespace.
Non-copyable object.
PCM format mapper.
Sample specifications.
Slice.
Commonly used types and functions.
Time definitions.