Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
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
15
#include "
roc_audio/frame_factory.h
"
16
#include "
roc_audio/iframe_reader.h
"
17
#include "
roc_audio/mixer.h
"
18
#include "
roc_audio/pcm_mapper_reader.h
"
19
#include "
roc_audio/profiling_reader.h
"
20
#include "
roc_core/iarena.h
"
21
#include "
roc_core/optional.h
"
22
#include "
roc_core/stddefs.h
"
23
#include "
roc_packet/packet_factory.h
"
24
#include "
roc_pipeline/config.h
"
25
#include "
roc_pipeline/receiver_endpoint.h
"
26
#include "
roc_pipeline/receiver_slot.h
"
27
#include "
roc_pipeline/state_tracker.h
"
28
#include "
roc_rtp/encoding_map.h
"
29
#include "
roc_sndio/isource.h
"
30
31
namespace
roc
{
32
namespace
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
43
class
ReceiverSource
:
public
sndio::ISource
,
public
core::NonCopyable
<> {
44
public
:
45
//! Initialize.
46
ReceiverSource
(
const
ReceiverSourceConfig
& source_config,
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.
57
ReceiverSlot
*
create_slot
(
const
ReceiverSlotConfig
& slot_config);
58
59
//! Delete slot.
60
void
delete_slot
(
ReceiverSlot
* 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
73
core::nanoseconds_t
refresh
(
core::nanoseconds_t
current_time);
74
75
//! Cast IDevice to ISink.
76
virtual
sndio::ISink
*
to_sink
();
77
78
//! Cast IDevice to ISink.
79
virtual
sndio::ISource
*
to_source
();
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.
97
virtual
audio::SampleSpec
sample_spec
()
const
;
98
99
//! Get latency of the source.
100
virtual
core::nanoseconds_t
latency
()
const
;
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
117
private
:
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
128
core::Optional<audio::Mixer>
mixer_;
129
core::Optional<audio::ProfilingReader>
profiler_;
130
core::Optional<audio::PcmMapperReader>
pcm_mapper_;
131
132
core::List<ReceiverSlot>
slots_;
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_
roc::audio::FrameFactory
Frame factory.
Definition
frame_factory.h:38
roc::audio::Frame
Audio frame.
Definition
frame.h:25
roc::audio::IFrameReader
Frame reader interface.
Definition
iframe_reader.h:22
roc::audio::SampleSpec
Sample specification. Describes sample rate and channels.
Definition
sample_spec.h:30
roc::core::IArena
Memory arena interface.
Definition
iarena.h:23
roc::core::IPool
Memory pool interface.
Definition
ipool.h:23
roc::core::List
Intrusive doubly-linked list.
Definition
list.h:40
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
roc::core::Optional
Optionally constructed object.
Definition
optional.h:25
roc::packet::PacketFactory
Packet factory.
Definition
packet_factory.h:36
roc::pipeline::ReceiverSlot
Receiver slot.
Definition
receiver_slot.h:38
roc::pipeline::ReceiverSource::is_valid
bool is_valid() const
Check if the pipeline was successfully constructed.
roc::pipeline::ReceiverSource::reclock
virtual void reclock(core::nanoseconds_t playback_time)
Adjust sessions clock to match consumer clock.
roc::pipeline::ReceiverSource::pause
virtual void pause()
Pause reading.
roc::pipeline::ReceiverSource::state
virtual sndio::DeviceState state() const
Get current receiver state.
roc::pipeline::ReceiverSource::latency
virtual core::nanoseconds_t latency() const
Get latency of the source.
roc::pipeline::ReceiverSource::restart
virtual bool restart()
Restart reading from the beginning.
roc::pipeline::ReceiverSource::to_sink
virtual sndio::ISink * to_sink()
Cast IDevice to ISink.
roc::pipeline::ReceiverSource::to_source
virtual sndio::ISource * to_source()
Cast IDevice to ISink.
roc::pipeline::ReceiverSource::resume
virtual bool resume()
Resume paused reading.
roc::pipeline::ReceiverSource::delete_slot
void delete_slot(ReceiverSlot *slot)
Delete slot.
roc::pipeline::ReceiverSource::create_slot
ReceiverSlot * create_slot(const ReceiverSlotConfig &slot_config)
Create slot.
roc::pipeline::ReceiverSource::has_clock
virtual bool has_clock() const
Check if the source has own clock.
roc::pipeline::ReceiverSource::sample_spec
virtual audio::SampleSpec sample_spec() const
Get sample specification of the source.
roc::pipeline::ReceiverSource::has_latency
virtual bool has_latency() const
Check if the source supports latency reports.
roc::pipeline::ReceiverSource::read
virtual bool read(audio::Frame &)
Read audio frame.
roc::pipeline::ReceiverSource::num_sessions
size_t num_sessions() const
Get number of active sessions.
roc::pipeline::ReceiverSource::type
virtual sndio::DeviceType type() const
Get device type.
roc::pipeline::ReceiverSource::ReceiverSource
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.
roc::pipeline::ReceiverSource::refresh
core::nanoseconds_t refresh(core::nanoseconds_t current_time)
Pull packets and refresh pipeline according to current time.
roc::pipeline::StateTracker
Pipeline state tracker.
Definition
state_tracker.h:30
roc::rtp::EncodingMap
RTP encoding map. Thread-safe. Returned encodings are immutable and can be safely used from any threa...
Definition
encoding_map.h:33
roc::sndio::ISink
Sink interface.
Definition
isink.h:22
roc::sndio::ISource
Source interface.
Definition
isource.h:23
encoding_map.h
RTP encoding map.
frame_factory.h
Frame factory.
iarena.h
Memory arena interface.
iframe_reader.h
Frame reader interface.
isource.h
Source interface.
mixer.h
Mixer.
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc::pipeline
Sender and receiver processing pipelines.
roc::sndio::DeviceType
DeviceType
Device type.
Definition
device_type.h:19
roc::sndio::DeviceState
DeviceState
Device state.
Definition
device_state.h:19
roc
Root namespace.
optional.h
Optionally constructed object.
packet_factory.h
Packet factory.
pcm_mapper_reader.h
Pcm mapper reader.
profiling_reader.h
Profiling reader.
receiver_endpoint.h
Receiver endpoint pipeline.
receiver_slot.h
Receiver slot.
config.h
Pipeline config.
state_tracker.h
Pipeline state tracker.
stddefs.h
Commonly used types and functions.
roc::pipeline::ReceiverSlotConfig
Parameters of receiver slot.
Definition
config.h:202
roc::pipeline::ReceiverSourceConfig
Parameters of receiver session.
Definition
config.h:184
roc_pipeline
receiver_source.h
Generated by
1.17.0