Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
sender_sink.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/sender_sink.h
10
//! @brief Sender sink pipeline.
11
12
#ifndef ROC_PIPELINE_SENDER_SINK_H_
13
#define ROC_PIPELINE_SENDER_SINK_H_
14
15
#include "
roc_audio/fanout.h
"
16
#include "
roc_audio/frame_factory.h
"
17
#include "
roc_audio/pcm_mapper_writer.h
"
18
#include "
roc_audio/profiling_writer.h
"
19
#include "
roc_core/iarena.h
"
20
#include "
roc_core/ipool.h
"
21
#include "
roc_core/noncopyable.h
"
22
#include "
roc_core/optional.h
"
23
#include "
roc_packet/packet_factory.h
"
24
#include "
roc_pipeline/config.h
"
25
#include "
roc_pipeline/sender_endpoint.h
"
26
#include "
roc_pipeline/sender_slot.h
"
27
#include "
roc_pipeline/state_tracker.h
"
28
#include "
roc_rtp/encoding_map.h
"
29
#include "
roc_sndio/isink.h
"
30
31
namespace
roc
{
32
namespace
pipeline
{
33
34
//! Sender sink pipeline.
35
//!
36
//! Contains:
37
//! - one or more sender slots
38
//! - fanout, to duplicate audio to all slots
39
//!
40
//! Pipeline:
41
//! - input: frames
42
//! - output: packets
43
class
SenderSink
:
public
sndio::ISink
,
public
core::NonCopyable
<> {
44
public
:
45
//! Initialize.
46
SenderSink
(
const
SenderSinkConfig
& sink_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
SenderSlot
*
create_slot
(
const
SenderSlotConfig
& slot_config);
58
59
//! Delete slot.
60
void
delete_slot
(
SenderSlot
* slot);
61
62
//! Get number of active sessions.
63
size_t
num_sessions
()
const
;
64
65
//! Refresh pipeline according to current time.
66
//! @remarks
67
//! Should be invoked after writing each frame.
68
//! Also should be invoked after provided deadline if no frames were
69
//! written 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 sink.
97
virtual
audio::SampleSpec
sample_spec
()
const
;
98
99
//! Get latency of the sink.
100
virtual
core::nanoseconds_t
latency
()
const
;
101
102
//! Check if the sink supports latency reports.
103
virtual
bool
has_latency
()
const
;
104
105
//! Check if the sink has own clock.
106
virtual
bool
has_clock
()
const
;
107
108
//! Write audio frame.
109
virtual
void
write
(
audio::Frame
& frame);
110
111
private
:
112
SenderSinkConfig
sink_config_;
113
114
const
rtp::EncodingMap
& encoding_map_;
115
116
packet::PacketFactory
packet_factory_;
117
audio::FrameFactory
frame_factory_;
118
core::IArena
& arena_;
119
120
StateTracker
state_tracker_;
121
122
audio::Fanout
fanout_;
123
core::Optional<audio::ProfilingWriter>
profiler_;
124
core::Optional<audio::PcmMapperWriter>
pcm_mapper_;
125
126
core::List<SenderSlot>
slots_;
127
128
audio::IFrameWriter
* frame_writer_;
129
130
bool
valid_;
131
};
132
133
}
// namespace pipeline
134
}
// namespace roc
135
136
#endif
// ROC_PIPELINE_SENDER_SINK_H_
roc::audio::Fanout
Fanout. Duplicates audio stream to multiple output writers.
Definition
fanout.h:26
roc::audio::FrameFactory
Frame factory.
Definition
frame_factory.h:38
roc::audio::Frame
Audio frame.
Definition
frame.h:25
roc::audio::IFrameWriter
Frame writer interface.
Definition
iframe_writer.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::SenderSink::sample_spec
virtual audio::SampleSpec sample_spec() const
Get sample specification of the sink.
roc::pipeline::SenderSink::SenderSink
SenderSink(const SenderSinkConfig &sink_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::SenderSink::pause
virtual void pause()
Pause reading.
roc::pipeline::SenderSink::state
virtual sndio::DeviceState state() const
Get current receiver state.
roc::pipeline::SenderSink::write
virtual void write(audio::Frame &frame)
Write audio frame.
roc::pipeline::SenderSink::restart
virtual bool restart()
Restart reading from the beginning.
roc::pipeline::SenderSink::to_sink
virtual sndio::ISink * to_sink()
Cast IDevice to ISink.
roc::pipeline::SenderSink::latency
virtual core::nanoseconds_t latency() const
Get latency of the sink.
roc::pipeline::SenderSink::to_source
virtual sndio::ISource * to_source()
Cast IDevice to ISink.
roc::pipeline::SenderSink::has_clock
virtual bool has_clock() const
Check if the sink has own clock.
roc::pipeline::SenderSink::has_latency
virtual bool has_latency() const
Check if the sink supports latency reports.
roc::pipeline::SenderSink::type
virtual sndio::DeviceType type() const
Get device type.
roc::pipeline::SenderSink::refresh
core::nanoseconds_t refresh(core::nanoseconds_t current_time)
Refresh pipeline according to current time.
roc::pipeline::SenderSink::resume
virtual bool resume()
Resume paused reading.
roc::pipeline::SenderSink::num_sessions
size_t num_sessions() const
Get number of active sessions.
roc::pipeline::SenderSink::delete_slot
void delete_slot(SenderSlot *slot)
Delete slot.
roc::pipeline::SenderSink::is_valid
bool is_valid() const
Check if the pipeline was successfully constructed.
roc::pipeline::SenderSink::create_slot
SenderSlot * create_slot(const SenderSlotConfig &slot_config)
Create slot.
roc::pipeline::SenderSlot
Sender slot.
Definition
sender_slot.h:39
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.
fanout.h
Fanout.
frame_factory.h
Frame factory.
iarena.h
Memory arena interface.
ipool.h
Memory pool interface.
isink.h
Sink interface.
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.
noncopyable.h
Non-copyable object.
optional.h
Optionally constructed object.
packet_factory.h
Packet factory.
pcm_mapper_writer.h
Pcm mapper writer.
profiling_writer.h
Profiling writer.
config.h
Pipeline config.
sender_endpoint.h
Sender endpoint pipeline.
sender_slot.h
Sender slot.
state_tracker.h
Pipeline state tracker.
roc::pipeline::SenderSinkConfig
Parameters of sender sink and sender session.
Definition
config.h:58
roc::pipeline::SenderSlotConfig
Parameters of sender slot.
Definition
config.h:115
roc_pipeline
sender_sink.h
Generated by
1.17.0