Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
converter_source.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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_pipeline/converter_source.h
10//! @brief Converter source pipeline.
11
12#ifndef ROC_PIPELINE_CONVERTER_SOURCE_H_
13#define ROC_PIPELINE_CONVERTER_SOURCE_H_
14
23#include "roc_core/optional.h"
24#include "roc_core/scoped_ptr.h"
25#include "roc_pipeline/config.h"
26#include "roc_sndio/isource.h"
27
28namespace roc {
29namespace pipeline {
30
31//! Converter source pipeline.
32//! @remarks
33//! - input: frames
34//! - output: frames
36public:
37 //! Initialize.
39 sndio::ISource& input_source,
41 core::IAllocator& allocator);
42
43 //! Check if the pipeline was successfully constructed.
44 bool valid();
45
46 //! Get sample specification of the source.
48
49 //! Get latency of the source.
51
52 //! Check if the sink has own clock.
53 virtual bool has_clock() const;
54
55 //! Get current source state.
56 virtual State state() const;
57
58 //! Pause reading.
59 virtual void pause();
60
61 //! Resume paused reading.
62 virtual bool resume();
63
64 //! Restart reading from the beginning.
65 virtual bool restart();
66
67 //! Adjust source clock to match consumer clock.
68 virtual void reclock(packet::ntp_timestamp_t timestamp);
69
70 //! Read frame.
71 virtual bool read(audio::Frame&);
72
73private:
74 core::Optional<audio::ChannelMapperReader> channel_mapper_reader_;
75
76 core::Optional<audio::PoisonReader> resampler_poisoner_;
79
80 core::Optional<audio::PoisonReader> pipeline_poisoner_;
82
83 sndio::ISource& input_source_;
84 audio::IFrameReader* audio_reader_;
85
86 ConverterConfig config_;
87};
88
89} // namespace pipeline
90} // namespace roc
91
92#endif // ROC_PIPELINE_CONVERTER_SOURCE_H_
Buffer factory.
Channel mapper reader.
Audio frame.
Definition: frame.h:22
Frame reader interface.
Definition: iframe_reader.h:22
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
Optionally constructed object.
Definition: optional.h:25
Unique ownrship pointer.
Definition: scoped_ptr.h:32
Converter source pipeline.
virtual core::nanoseconds_t latency() const
Get latency of the source.
virtual bool resume()
Resume paused reading.
virtual State state() const
Get current source state.
bool valid()
Check if the pipeline was successfully constructed.
virtual void pause()
Pause reading.
ConverterSource(const ConverterConfig &config, sndio::ISource &input_source, core::BufferFactory< audio::sample_t > &buffer_factory, core::IAllocator &allocator)
Initialize.
virtual void reclock(packet::ntp_timestamp_t timestamp)
Adjust source clock to match consumer clock.
virtual audio::SampleSpec sample_spec() const
Get sample specification of the source.
virtual bool read(audio::Frame &)
Read frame.
virtual bool has_clock() const
Check if the sink has own clock.
virtual bool restart()
Restart reading from the beginning.
Source interface.
Definition: isource.h:23
State
Source state.
Definition: isource.h:28
Audio resampler interface.
Source interface.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
uint64_t ntp_timestamp_t
NTP timestamp.
Definition: units.h:91
Root namespace.
Optionally constructed object.
Poison reader.
Profiling reader.
Resampler map.
Resampler profile.
Pipeline config.
Unique ownrship pointer.
Converter parameters.
Definition: config.h:259