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"
22#include "roc_core/iallocator.h"
24#include "roc_core/optional.h"
26#include "roc_fec/writer.h"
29#include "roc_packet/router.h"
30#include "roc_pipeline/config.h"
33#include "roc_rtp/format_map.h"
34#include "roc_sndio/isink.h"
35
36namespace roc {
37namespace pipeline {
38
39//! Sender sink pipeline.
40//!
41//! Contains:
42//! - one or more sender slots
43//! - fanout, to duplicate audio to all slots
44//!
45//! Pipeline:
46//! - input: frames
47//! - output: packets
48class SenderSink : public sndio::ISink, public core::NonCopyable<> {
49public:
50 //! Initialize.
51 SenderSink(const SenderConfig& config,
52 const rtp::FormatMap& format_map,
53 packet::PacketFactory& packet_factory,
54 core::BufferFactory<uint8_t>& byte_buffer_factory,
55 core::BufferFactory<audio::sample_t>& sample_buffer_factory,
56 core::IAllocator& allocator);
57
58 //! Check if the pipeline was successfully constructed.
59 bool valid() const;
60
61 //! Create slot.
63
64 //! Get deadline when the pipeline should be updated.
66
67 //! Update pipeline.
68 void update();
69
70 //! Get sample specification of the sink.
72
73 //! Get latency of the sink.
75
76 //! Check if the sink has own clock.
77 virtual bool has_clock() const;
78
79 //! Write audio frame.
80 virtual void write(audio::Frame& frame);
81
82private:
83 void compute_update_deadline_();
84 void invalidate_update_deadline_();
85
86 const SenderConfig config_;
87
88 const rtp::FormatMap& format_map_;
89
90 packet::PacketFactory& packet_factory_;
91 core::BufferFactory<uint8_t>& byte_buffer_factory_;
92 core::BufferFactory<audio::sample_t>& sample_buffer_factory_;
93
94 core::IAllocator& allocator_;
95
97
98 audio::Fanout fanout_;
99
100 core::Optional<audio::PoisonWriter> pipeline_poisoner_;
102
103 audio::IFrameWriter* audio_writer_;
104
105 bool update_deadline_valid_;
106 core::nanoseconds_t update_deadline_;
107};
108
109} // namespace pipeline
110} // namespace roc
111
112#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:22
Frame writer interface.
Definition: iframe_writer.h:22
Sample stream specification. Defines sample rate and channel layout.
Definition: sample_spec.h:24
Memory allocator interface.
Definition: iallocator.h:23
Intrusive doubly-linked list.
Definition: list.h:35
Base class for non-copyable objects.
Definition: noncopyable.h:23
Optionally constructed object.
Definition: optional.h:25
Sender sink pipeline.
Definition: sender_sink.h:48
virtual audio::SampleSpec sample_spec() const
Get sample specification of the sink.
void update()
Update pipeline.
virtual void write(audio::Frame &frame)
Write audio frame.
virtual core::nanoseconds_t latency() const
Get latency of the sink.
virtual bool has_clock() const
Check if the sink has own clock.
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::IAllocator &allocator)
Initialize.
SenderSlot * create_slot()
Create slot.
core::nanoseconds_t get_update_deadline()
Get deadline when the pipeline should be updated.
bool valid() const
Check if the pipeline was successfully constructed.
RTP payload format map.
Definition: format_map.h:22
Sink interface.
Definition: isink.h:22
Fanout.
RTP payload format map.
Memory allocator interface.
FEC block encoder interface.
Audio frame encoder interface.
Interleaves packets before transmit.
Audio resampler interface.
Sink interface.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:58
Root namespace.
Non-copyable object.
Optionally constructed object.
Packet factory.
Packetizer.
Poison writer.
Profiling writer.
Pipeline config.
Route packets to writers.
Sender endpoint pipeline.
Sender slot.
Sender parameters.
Definition: config.h:101
FEC writer.