Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
receiver_source.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 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/receiver_source.h
10//! @brief Receiver source pipeline.
11
12#ifndef ROC_PIPELINE_RECEIVER_SOURCE_H_
13#define ROC_PIPELINE_RECEIVER_SOURCE_H_
14
17#include "roc_audio/mixer.h"
20#include "roc_core/iarena.h"
21#include "roc_core/optional.h"
22#include "roc_core/stddefs.h"
24#include "roc_pipeline/config.h"
29#include "roc_sndio/isource.h"
30
31namespace roc {
32namespace pipeline {
33
34//! Receiver source pipeline.
35//!
36//! Contains:
37//! - one or more receiver slots
38//! - mixer, to mix audio from all slots
39//!
40//! Pipeline:
41//! - input: packets
42//! - output: frames
44public:
45 //! Initialize.
47 const rtp::EncodingMap& encoding_map,
48 core::IPool& packet_pool,
49 core::IPool& packet_buffer_pool,
50 core::IPool& frame_buffer_pool,
51 core::IArena& arena);
52
53 //! Check if the pipeline was successfully constructed.
54 bool is_valid() const;
55
56 //! Create slot.
58
59 //! Delete slot.
61
62 //! Get number of active sessions.
63 size_t num_sessions() const;
64
65 //! Pull packets and refresh pipeline according to current time.
66 //! @remarks
67 //! Should be invoked before reading each frame.
68 //! Also should be invoked after provided deadline if no frames were
69 //! read until that deadline expires.
70 //! @returns
71 //! deadline (absolute time) when refresh should be invoked again
72 //! if there are no frames
74
75 //! Cast IDevice to ISink.
77
78 //! Cast IDevice to ISink.
80
81 //! Get device type.
82 virtual sndio::DeviceType type() const;
83
84 //! Get current receiver state.
85 virtual sndio::DeviceState state() const;
86
87 //! Pause reading.
88 virtual void pause();
89
90 //! Resume paused reading.
91 virtual bool resume();
92
93 //! Restart reading from the beginning.
94 virtual bool restart();
95
96 //! Get sample specification of the source.
98
99 //! Get latency of the source.
101
102 //! Check if the source supports latency reports.
103 virtual bool has_latency() const;
104
105 //! Check if the source has own clock.
106 virtual bool has_clock() const;
107
108 //! Adjust sessions clock to match consumer clock.
109 //! @remarks
110 //! @p playback_time specified absolute time when first sample of last frame
111 //! retrieved from pipeline will be actually played on sink
112 virtual void reclock(core::nanoseconds_t playback_time);
113
114 //! Read audio frame.
115 virtual bool read(audio::Frame&);
116
117private:
118 ReceiverSourceConfig source_config_;
119
120 const rtp::EncodingMap& encoding_map_;
121
122 packet::PacketFactory packet_factory_;
123 audio::FrameFactory frame_factory_;
124 core::IArena& arena_;
125
126 StateTracker state_tracker_;
127
131
133
134 audio::IFrameReader* frame_reader_;
135
136 bool valid_;
137};
138
139} // namespace pipeline
140} // namespace roc
141
142#endif // ROC_PIPELINE_RECEIVER_SOURCE_H_
Audio frame.
Definition frame.h:25
Frame reader interface.
Sample specification. Describes sample rate and channels.
Definition sample_spec.h:30
Memory arena interface.
Definition iarena.h:23
Memory pool interface.
Definition ipool.h:23
Base class for non-copyable objects.
Definition noncopyable.h:23
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Receiver source pipeline.
bool is_valid() const
Check if the pipeline was successfully constructed.
virtual void reclock(core::nanoseconds_t playback_time)
Adjust sessions clock to match consumer clock.
virtual void pause()
Pause reading.
virtual sndio::DeviceState state() const
Get current receiver state.
virtual core::nanoseconds_t latency() const
Get latency of the source.
virtual bool restart()
Restart reading from the beginning.
virtual sndio::ISink * to_sink()
Cast IDevice to ISink.
virtual sndio::ISource * to_source()
Cast IDevice to ISink.
virtual bool resume()
Resume paused reading.
void delete_slot(ReceiverSlot *slot)
Delete slot.
ReceiverSlot * create_slot(const ReceiverSlotConfig &slot_config)
Create slot.
virtual bool has_clock() const
Check if the source has own clock.
virtual audio::SampleSpec sample_spec() const
Get sample specification of the source.
virtual bool has_latency() const
Check if the source supports latency reports.
virtual bool read(audio::Frame &)
Read audio frame.
size_t num_sessions() const
Get number of active sessions.
virtual sndio::DeviceType type() const
Get device type.
ReceiverSource(const ReceiverSourceConfig &source_config, const rtp::EncodingMap &encoding_map, core::IPool &packet_pool, core::IPool &packet_buffer_pool, core::IPool &frame_buffer_pool, core::IArena &arena)
Initialize.
core::nanoseconds_t refresh(core::nanoseconds_t current_time)
Pull packets and refresh pipeline according to current time.
Pipeline state tracker.
RTP encoding map. Thread-safe. Returned encodings are immutable and can be safely used from any threa...
Sink interface.
Definition isink.h:22
Source interface.
Definition isource.h:23
RTP encoding map.
Frame factory.
Memory arena interface.
Frame reader interface.
Source interface.
Mixer.
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
DeviceType
Device type.
Definition device_type.h:19
DeviceState
Device state.
Root namespace.
Optionally constructed object.
Packet factory.
Pcm mapper reader.
Profiling reader.
Receiver endpoint pipeline.
Receiver slot.
Pipeline config.
Pipeline state tracker.
Commonly used types and functions.
Parameters of receiver slot.
Definition config.h:202
Parameters of receiver session.
Definition config.h:184