Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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"
19#include "roc_core/iarena.h"
20#include "roc_core/ipool.h"
22#include "roc_core/optional.h"
24#include "roc_pipeline/config.h"
29#include "roc_sndio/isink.h"
30
31namespace roc {
32namespace 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
43class SenderSink : public sndio::ISink, public core::NonCopyable<> {
44public:
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.
58
59 //! Delete 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
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 sink.
98
99 //! Get latency of the sink.
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
111private:
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_;
125
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_
Fanout. Duplicates audio stream to multiple output writers.
Definition fanout.h:26
Audio frame.
Definition frame.h:25
Frame writer 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
Sender sink pipeline.
Definition sender_sink.h:43
virtual audio::SampleSpec sample_spec() const
Get sample specification of the sink.
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.
virtual void pause()
Pause reading.
virtual sndio::DeviceState state() const
Get current receiver state.
virtual void write(audio::Frame &frame)
Write audio frame.
virtual bool restart()
Restart reading from the beginning.
virtual sndio::ISink * to_sink()
Cast IDevice to ISink.
virtual core::nanoseconds_t latency() const
Get latency of the sink.
virtual sndio::ISource * to_source()
Cast IDevice to ISink.
virtual bool has_clock() const
Check if the sink has own clock.
virtual bool has_latency() const
Check if the sink supports latency reports.
virtual sndio::DeviceType type() const
Get device type.
core::nanoseconds_t refresh(core::nanoseconds_t current_time)
Refresh pipeline according to current time.
virtual bool resume()
Resume paused reading.
size_t num_sessions() const
Get number of active sessions.
void delete_slot(SenderSlot *slot)
Delete slot.
bool is_valid() const
Check if the pipeline was successfully constructed.
SenderSlot * create_slot(const SenderSlotConfig &slot_config)
Create slot.
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.
Fanout.
Frame factory.
Memory arena interface.
Memory pool interface.
Sink interface.
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
DeviceType
Device type.
Definition device_type.h:19
DeviceState
Device state.
Root namespace.
Non-copyable object.
Optionally constructed object.
Packet factory.
Pcm mapper writer.
Profiling writer.
Pipeline config.
Sender endpoint pipeline.
Sender slot.
Pipeline state tracker.
Parameters of sender sink and sender session.
Definition config.h:58
Parameters of sender slot.
Definition config.h:115