Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
transcoder_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/transcoder_source.h
10 //! @brief Transcoder source pipeline.
11 
12 #ifndef ROC_PIPELINE_TRANSCODER_SOURCE_H_
13 #define ROC_PIPELINE_TRANSCODER_SOURCE_H_
14 
16 #include "roc_audio/iresampler.h"
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 
28 namespace roc {
29 namespace pipeline {
30 
31 //! Transcoder source pipeline.
32 //! @remarks
33 //! - input: frames
34 //! - output: frames
36 public:
37  //! Initialize.
39  sndio::ISource& input_source,
41  core::IArena& arena);
42 
43  //! Check if the pipeline was successfully constructed.
44  bool is_valid();
45 
46  //! Get device type.
47  virtual sndio::DeviceType type() const;
48 
49  //! Get device state.
50  virtual sndio::DeviceState state() const;
51 
52  //! Pause reading.
53  virtual void pause();
54 
55  //! Resume paused reading.
56  virtual bool resume();
57 
58  //! Restart reading from the beginning.
59  virtual bool restart();
60 
61  //! Get sample specification of the source.
62  virtual audio::SampleSpec sample_spec() const;
63 
64  //! Get latency of the source.
65  virtual core::nanoseconds_t latency() const;
66 
67  //! Check if the source supports latency reports.
68  virtual bool has_latency() const;
69 
70  //! Check if the sink has own clock.
71  virtual bool has_clock() const;
72 
73  //! Adjust source clock to match consumer clock.
75 
76  //! Read frame.
77  virtual bool read(audio::Frame&);
78 
79 private:
80  core::Optional<audio::ChannelMapperReader> channel_mapper_reader_;
81 
82  core::Optional<audio::PoisonReader> resampler_poisoner_;
85 
86  core::Optional<audio::PoisonReader> pipeline_poisoner_;
88 
89  sndio::ISource& input_source_;
90  audio::IFrameReader* audio_reader_;
91 
92  TranscoderConfig config_;
93 };
94 
95 } // namespace pipeline
96 } // namespace roc
97 
98 #endif // ROC_PIPELINE_TRANSCODER_SOURCE_H_
Buffer factory.
Channel mapper reader.
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
Memory arena interface.
Definition: iarena.h:23
Base class for non-copyable objects.
Definition: noncopyable.h:23
Optionally constructed object.
Definition: optional.h:25
Shared ownership intrusive pointer.
Definition: shared_ptr.h:32
Transcoder source pipeline.
virtual sndio::DeviceState state() const
Get device state.
virtual void pause()
Pause reading.
virtual sndio::DeviceType type() const
Get device type.
virtual audio::SampleSpec sample_spec() const
Get sample specification of the source.
virtual bool resume()
Resume paused reading.
bool is_valid()
Check if the pipeline was successfully constructed.
virtual core::nanoseconds_t latency() const
Get latency of the source.
virtual void reclock(core::nanoseconds_t timestamp)
Adjust source clock to match consumer clock.
virtual bool read(audio::Frame &)
Read frame.
TranscoderSource(const TranscoderConfig &config, sndio::ISource &input_source, core::BufferFactory< audio::sample_t > &buffer_factory, core::IArena &arena)
Initialize.
virtual bool has_clock() const
Check if the sink has own clock.
virtual bool restart()
Restart reading from the beginning.
virtual bool has_latency() const
Check if the source supports latency reports.
Source interface.
Definition: isource.h:23
Audio resampler interface.
Source interface.
nanoseconds_t timestamp(clock_t clock)
Get current timestamp in nanoseconds.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
DeviceType
Device type.
Definition: device_type.h:19
DeviceState
Device state.
Definition: device_state.h:19
Root namespace.
Optionally constructed object.
Poison reader.
Profiling reader.
Resampler map.
Resampler profile.
Pipeline config.
Unique ownrship pointer.
Converter parameters.
Definition: config.h:250