Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
converter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Roc 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_pipeline/converter.h
10 //! @brief Converter pipeline.
11 
12 #ifndef ROC_PIPELINE_CONVERTER_H_
13 #define ROC_PIPELINE_CONVERTER_H_
14 
15 #include "roc_audio/null_writer.h"
20 #include "roc_core/buffer_pool.h"
21 #include "roc_core/unique_ptr.h"
22 #include "roc_pipeline/config.h"
23 #include "roc_sndio/isink.h"
24 
25 namespace roc {
26 namespace pipeline {
27 
28 //! Converter pipeline.
29 class Converter : public sndio::ISink, public core::NonCopyable<> {
30 public:
31  //! Initialize.
32  Converter(const ConverterConfig& config,
33  audio::IWriter* output_writer,
35  core::IAllocator& allocator);
36 
37  //! Check if the pipeline was successfully constructed.
38  bool valid();
39 
40  //! Get sink sample rate.
41  virtual size_t sample_rate() const;
42 
43  //! Check if the sink has own clock.
44  virtual bool has_clock() const;
45 
46  //! Write audio frame.
47  virtual void write(audio::Frame& frame);
48 
49 private:
50  audio::NullWriter null_writer_;
51 
52  core::UniquePtr<audio::PoisonWriter> resampler_poisoner_;
54 
56 
57  core::UniquePtr<audio::PoisonWriter> pipeline_poisoner_;
58 
59  audio::IWriter* audio_writer_;
60 
61  ConverterConfig config_;
62 };
63 
64 } // namespace pipeline
65 } // namespace roc
66 
67 #endif // ROC_PIPELINE_CONVERTER_H_
Audio writer interface.
Definition: iwriter.h:21
Sink interface.
Definition: isink.h:21
Profiling writer.
Memory allocator interface.
Definition: iallocator.h:23
Pipeline config.
Sink interface.
Resampler profile.
Converter parameters.
Definition: config.h:205
Root namespace.
Converter pipeline.
Definition: converter.h:29
virtual void write(audio::Frame &frame)
Write audio frame.
bool valid()
Check if the pipeline was successfully constructed.
Audio frame.
Definition: frame.h:22
Converter(const ConverterConfig &config, audio::IWriter *output_writer, core::BufferPool< audio::sample_t > &pool, core::IAllocator &allocator)
Initialize.
virtual bool has_clock() const
Check if the sink has own clock.
Base class for non-copyable objects.
Definition: noncopyable.h:23
Null writer.
Buffer pool.
Unique ownrship pointer.
virtual size_t sample_rate() const
Get sink sample rate.
Poison writer.