Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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
16#include "roc_audio/mixer.h"
20#include "roc_core/iallocator.h"
21#include "roc_core/mutex.h"
22#include "roc_core/optional.h"
23#include "roc_core/stddefs.h"
24#include "roc_packet/ireader.h"
25#include "roc_packet/iwriter.h"
27#include "roc_pipeline/config.h"
31#include "roc_rtp/format_map.h"
32#include "roc_sndio/isource.h"
33
34namespace roc {
35namespace pipeline {
36
37//! Receiver source pipeline.
38//!
39//! Contains:
40//! - one or more receiver slots
41//! - mixer, to mix audio from all slots
42//!
43//! Pipeline:
44//! - input: packets
45//! - output: frames
47public:
48 //! Initialize.
50 const rtp::FormatMap& format_map,
51 packet::PacketFactory& packet_factory,
52 core::BufferFactory<uint8_t>& byte_buffer_factory,
53 core::BufferFactory<audio::sample_t>& sample_buffer_factory,
54 core::IAllocator& allocator);
55
56 //! Check if the pipeline was successfully constructed.
57 bool valid() const;
58
59 //! Create slot.
61
62 //! Get number of connected sessions.
63 size_t num_sessions() const;
64
65 //! Get sample specification of the source.
67
68 //! Get latency of the source.
70
71 //! Check if the source has own clock.
72 virtual bool has_clock() const;
73
74 //! Get current receiver state.
75 virtual State state() const;
76
77 //! Pause reading.
78 virtual void pause();
79
80 //! Resume paused reading.
81 virtual bool resume();
82
83 //! Restart reading from the beginning.
84 virtual bool restart();
85
86 //! Adjust source clock to match consumer clock.
87 virtual void reclock(packet::ntp_timestamp_t timestamp);
88
89 //! Read audio frame.
90 virtual bool read(audio::Frame&);
91
92private:
93 const rtp::FormatMap& format_map_;
94
95 packet::PacketFactory& packet_factory_;
96 core::BufferFactory<uint8_t>& byte_buffer_factory_;
97 core::BufferFactory<audio::sample_t>& sample_buffer_factory_;
98 core::IAllocator& allocator_;
99
100 ReceiverState state_;
102
106
107 audio::IFrameReader* audio_reader_;
108
109 ReceiverConfig config_;
110
111 packet::timestamp_t timestamp_;
112};
113
114} // namespace pipeline
115} // namespace roc
116
117#endif // ROC_PIPELINE_RECEIVER_SOURCE_H_
Buffer factory.
Audio frame.
Definition frame.h:22
Frame reader interface.
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
Receiver source pipeline.
virtual void pause()
Pause reading.
virtual core::nanoseconds_t latency() const
Get latency of the source.
virtual bool restart()
Restart reading from the beginning.
virtual bool resume()
Resume paused reading.
virtual State state() const
Get current receiver state.
bool valid() const
Check if the pipeline was successfully constructed.
virtual bool has_clock() const
Check if the source has own clock.
virtual audio::SampleSpec sample_spec() const
Get sample specification of the source.
ReceiverSlot * create_slot()
Create slot.
ReceiverSource(const ReceiverConfig &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.
virtual bool read(audio::Frame &)
Read audio frame.
virtual void reclock(packet::ntp_timestamp_t timestamp)
Adjust source clock to match consumer clock.
size_t num_sessions() const
Get number of connected sessions.
Receiver pipeline state. Thread-safe.
RTP payload format map.
Definition format_map.h:22
Source interface.
Definition isource.h:23
State
Source state.
Definition isource.h:28
RTP payload format map.
Memory allocator interface.
Frame reader interface.
Packet reader interface.
Source interface.
Packet writer interface.
Mixer.
Mutex.
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
uint32_t timestamp_t
Audio packet timestamp.
Definition units.h:25
uint64_t ntp_timestamp_t
NTP timestamp.
Definition units.h:91
Root namespace.
Optionally constructed object.
Packet factory.
Poison reader.
Profiling reader.
Receiver endpoint pipeline.
Receiver slot.
Receiver pipeline state.
Pipeline config.
Commonly used types and functions.
Receiver parameters.
Definition config.h:247