Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
receiver_slot.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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_slot.h
10//! @brief Receiver slot.
11
12#ifndef ROC_PIPELINE_RECEIVER_SLOT_H_
13#define ROC_PIPELINE_RECEIVER_SLOT_H_
14
18#include "roc_audio/mixer.h"
19#include "roc_core/iarena.h"
20#include "roc_core/list_node.h"
28
29namespace roc {
30namespace pipeline {
31
32//! Receiver slot.
33//!
34//! Contains:
35//! - one or more related receiver endpoints, one per each type
36//! - one session group associated with those endpoints
37class ReceiverSlot : public core::RefCounted<ReceiverSlot, core::ArenaAllocation>,
38 public core::ListNode<> {
39public:
40 //! Initialize.
41 ReceiverSlot(const ReceiverSourceConfig& source_config,
42 const ReceiverSlotConfig& slot_config,
43 StateTracker& state_tracker,
44 audio::Mixer& mixer,
45 const rtp::EncodingMap& encoding_map,
46 packet::PacketFactory& packet_factory,
47 audio::FrameFactory& frame_factory,
49
50 //! Check if the slot was succefully constructed.
51 bool is_valid() const;
52
53 //! Add endpoint.
56 const address::SocketAddr& inbound_address,
57 packet::IWriter* outbound_writer);
58
59 //! Pull packets and refresh sessions according to current time.
60 //! @returns
61 //! deadline (absolute time) when refresh should be invoked again
62 //! if there are no frames
64
65 //! Adjust sessions clock to match consumer clock.
66 //! @remarks
67 //! @p playback_time specified absolute time when first sample of last frame
68 //! retrieved from pipeline will be actually played on sink
69 void reclock(core::nanoseconds_t playback_time);
70
71 //! Get number of alive sessions.
72 size_t num_sessions() const;
73
74 //! Get metrics for slot and its participants.
75 void get_metrics(ReceiverSlotMetrics& slot_metrics,
76 ReceiverParticipantMetrics* party_metrics,
77 size_t* party_count) const;
78
79private:
80 ReceiverEndpoint* create_source_endpoint_(address::Protocol proto,
81 const address::SocketAddr& inbound_address,
82 packet::IWriter* outbound_writer);
83 ReceiverEndpoint* create_repair_endpoint_(address::Protocol proto,
84 const address::SocketAddr& inbound_address,
85 packet::IWriter* outbound_writer);
86 ReceiverEndpoint* create_control_endpoint_(address::Protocol proto,
87 const address::SocketAddr& inbound_address,
88 packet::IWriter* outbound_writer);
89
90 const rtp::EncodingMap& encoding_map_;
91
92 StateTracker& state_tracker_;
93 ReceiverSessionGroup session_group_;
94
95 core::Optional<ReceiverEndpoint> source_endpoint_;
96 core::Optional<ReceiverEndpoint> repair_endpoint_;
97 core::Optional<ReceiverEndpoint> control_endpoint_;
98
99 bool valid_;
100};
101
102} // namespace pipeline
103} // namespace roc
104
105#endif // ROC_PIPELINE_RECEIVER_SLOT_H_
Mixer. Mixes multiple input streams into one output stream.
Definition mixer.h:46
IArena & arena() const
Get arena.
Memory arena interface.
Definition iarena.h:23
Base class for List element.
Definition list_node.h:48
Base class for object with reference counter.
Definition ref_counted.h:40
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Packet writer interface.
Definition iwriter.h:23
Receiver endpoint sub-pipeline.
core::nanoseconds_t refresh(core::nanoseconds_t current_time)
Pull packets and refresh sessions according to current time.
void get_metrics(ReceiverSlotMetrics &slot_metrics, ReceiverParticipantMetrics *party_metrics, size_t *party_count) const
Get metrics for slot and its participants.
ReceiverSlot(const ReceiverSourceConfig &source_config, const ReceiverSlotConfig &slot_config, StateTracker &state_tracker, audio::Mixer &mixer, const rtp::EncodingMap &encoding_map, packet::PacketFactory &packet_factory, audio::FrameFactory &frame_factory, core::IArena &arena)
Initialize.
bool is_valid() const
Check if the slot was succefully constructed.
void reclock(core::nanoseconds_t playback_time)
Adjust sessions clock to match consumer clock.
size_t num_sessions() const
Get number of alive sessions.
ReceiverEndpoint * add_endpoint(address::Interface iface, address::Protocol proto, const address::SocketAddr &inbound_address, packet::IWriter *outbound_writer)
Add endpoint.
Pipeline state tracker.
RTP encoding map. Thread-safe. Returned encodings are immutable and can be safely used from any threa...
RTP encoding map.
Frame factory.
Memory arena interface.
Interface ID.
Linked list node.
Pipeline metrics.
Mixer.
Interface
Interface ID.
Definition interface.h:19
Protocol
Protocol ID.
Definition protocol.h:19
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
Root namespace.
Packet factory.
Protocol ID.
Receiver endpoint pipeline.
Receiver session group.
Base class for object with reference counter.
Pipeline state tracker.
Receiver-side metrics specific to one participant (remote sender).
Definition metrics.h:54
Parameters of receiver slot.
Definition config.h:202
Receiver-side metrics of the whole slot.
Definition metrics.h:66
Parameters of receiver session.
Definition config.h:184