Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
pcm_mapper_writer.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_writer.h
10 //! @brief Pcm mapper writer.
11 
12 #ifndef ROC_AUDIO_PCM_MAPPER_WRITER_H_
13 #define ROC_AUDIO_PCM_MAPPER_WRITER_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 writer.
28 //! Reads frames from nested writer 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 void write(Frame& frame);
42 
43 private:
44  PcmMapper mapper_;
45 
46  IFrameWriter& out_writer_;
47  core::Slice<uint8_t> out_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_WRITER_H_
Audio frame.
Definition: frame.h:25
Frame writer interface.
Definition: iframe_writer.h:22
Pcm mapper writer. Reads frames from nested writer and maps them to another pcm mask.
virtual void write(Frame &frame)
Read audio frame.
PcmMapperWriter(IFrameWriter &writer, FrameFactory &frame_factory, const SampleSpec &in_spec, const SampleSpec &out_spec)
Initialize.
bool is_valid() const
Check if the object was succefully constructed.
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 writer interface.
Root namespace.
Non-copyable object.
PCM format mapper.
Sample specifications.
Slice.
Commonly used types and functions.
Time definitions.