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"
21#include "roc_core/iarena.h"
23#include "roc_core/optional.h"
25#include "roc_fec/writer.h"
28#include "roc_packet/router.h"
29#include "roc_pipeline/config.h"
32#include "roc_rtp/format_map.h"
33#include "roc_sndio/isink.h"
34
35namespace roc {
36namespace pipeline {
37
38//! Sender sink pipeline.
39//!
40//! Contains:
41//! - one or more sender slots
42//! - fanout, to duplicate audio to all slots
43//!
44//! Pipeline:
45//! - input: frames
46//! - output: packets
47class SenderSink : public sndio::ISink, public core::NonCopyable<> {
48public:
49 //! Initialize.
50 SenderSink(const SenderConfig& config,
51 const rtp::FormatMap& format_map,
52 packet::PacketFactory& packet_factory,
53 core::BufferFactory<uint8_t>& byte_buffer_factory,
54 core::BufferFactory<audio::sample_t>& sample_buffer_factory,
55 core::IArena& arena);
56
57 //! Check if the pipeline was successfully constructed.
58 bool is_valid() const;
59
60 //! Create slot.
62
63 //! Delete slot.
65
66 //! Refresh pipeline according to current time.
67 //! @remarks
68 //! Should be invoked after writing each frame.
69 //! Also should be invoked after provided deadline if no frames were
70 //! written until that deadline expires.
71 //! @returns
72 //! deadline (absolute time) when refresh should be invoked again
73 //! if there are no frames
75
76 //! Get device type.
77 virtual sndio::DeviceType type() const;
78
79 //! Get current receiver state.
80 virtual sndio::DeviceState state() const;
81
82 //! Pause reading.
83 virtual void pause();
84
85 //! Resume paused reading.
86 virtual bool resume();
87
88 //! Restart reading from the beginning.
89 virtual bool restart();
90
91 //! Get sample specification of the sink.
93
94 //! Get latency of the sink.
96
97 //! Check if the sink supports latency reports.
98 virtual bool has_latency() const;
99
100 //! Check if the sink has own clock.
101 virtual bool has_clock() const;
102
103 //! Write audio frame.
104 virtual void write(audio::Frame& frame);
105
106private:
107 const SenderConfig config_;
108
109 const rtp::FormatMap& format_map_;
110
111 packet::PacketFactory& packet_factory_;
112 core::BufferFactory<uint8_t>& byte_buffer_factory_;
113 core::BufferFactory<audio::sample_t>& sample_buffer_factory_;
114
115 core::IArena& arena_;
116
117 audio::Fanout fanout_;
118
120
122
123 audio::IFrameWriter* audio_writer_;
124};
125
126} // namespace pipeline
127} // namespace roc
128
129#endif // ROC_PIPELINE_SENDER_SINK_H_
Buffer factory.
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:26
Memory arena interface.
Definition iarena.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:47
virtual audio::SampleSpec sample_spec() const
Get sample specification of the sink.
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 core::nanoseconds_t latency() const
Get latency of the sink.
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.
SenderSlot * create_slot()
Create slot.
virtual bool resume()
Resume paused reading.
void delete_slot(SenderSlot *slot)
Delete slot.
bool is_valid() const
Check if the pipeline was successfully constructed.
SenderSink(const SenderConfig &config, const rtp::FormatMap &format_map, packet::PacketFactory &packet_factory, core::BufferFactory< uint8_t > &byte_buffer_factory, core::BufferFactory< audio::sample_t > &sample_buffer_factory, core::IArena &arena)
Initialize.
RTP payload format map. Thread-safe. Returned formats are immutable and can be safely used from any t...
Definition format_map.h:33
Sink interface.
Definition isink.h:22
Fanout.
RTP payload format map.
Memory arena interface.
FEC block encoder interface.
Audio frame encoder interface.
Interleaves packets before transmit.
Audio resampler interface.
Sink interface.
DeviceType
Device type.
Definition device_type.h:19
DeviceState
Device state.
Root namespace.
Non-copyable object.
Optionally constructed object.
Packet factory.
Packetizer.
Profiling writer.
Pipeline config.
Route packets to writers.
Sender endpoint pipeline.
Sender slot.
Sender parameters.
Definition config.h:102
FEC writer.