Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
receiver_session_group.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_session_group.h
10//! @brief Receiver session group.
11
12#ifndef ROC_PIPELINE_RECEIVER_SESSION_GROUP_H_
13#define ROC_PIPELINE_RECEIVER_SESSION_GROUP_H_
14
16#include "roc_audio/mixer.h"
17#include "roc_core/iarena.h"
18#include "roc_core/list.h"
27#include "roc_rtcp/composer.h"
29#include "roc_rtp/identity.h"
30
31namespace roc {
32namespace pipeline {
33
34//! Receiver session group.
35//!
36//! Contains:
37//! - a set of related receiver sessions
38//!
39//! Session group corresponds to all sessions handled by one receiver slot - a set of
40//! related complementary endpoints, e.g. one endpoint for audio, one for repair, and one
41//! for control packets.
42//!
43//! Session group creates and removes sessions and routes packets from endpoints to
44//! sessions with the help of ReceiverSessionRouter.
45//!
46//! It also exchanges control information with remote senders using rtcp::Communicator
47//! and updates routing based on that control information.
49public:
50 //! Initialize.
52 const ReceiverSlotConfig& slot_config,
53 StateTracker& state_tracker,
54 audio::Mixer& mixer,
55 const rtp::EncodingMap& encoding_map,
56 packet::PacketFactory& packet_factory,
57 audio::FrameFactory& frame_factory,
58 core::IArena& arena);
59
61
62 //! Check if pipeline was succefully constructed.
63 bool is_valid() const;
64
65 //! Create control sub-pipeline.
66 //! @note
67 //! Control sub-pipeline is shared among all sessions in same group, so
68 //! it's created separately using this method. On the other hand,
69 //! transport sub-pipeline is per-session and is created automatically
70 //! when a session is created within group.
72
73 //! Route packet to session.
75 core::nanoseconds_t current_time);
76
77 //! Refresh pipeline according to current time.
78 //! @returns
79 //! deadline (absolute time) when refresh should be invoked again
80 //! if there are no frames
82
83 //! Adjust session clock to match consumer clock.
84 //! @remarks
85 //! @p playback_time specified absolute time when first sample of last frame
86 //! retrieved from pipeline will be actually played on sink
88
89 //! Get number of sessions in group.
90 size_t num_sessions() const;
91
92 //! Get slot metrics.
93 //! @remarks
94 //! These metrics are for the whole slot.
95 //! For metrics for specific participant, see get_participant_metrics().
96 void get_slot_metrics(ReceiverSlotMetrics& slot_metrics) const;
97
98 //! Get metrics for remote participants.
99 //! @remarks
100 //! On receiver, one participant corresponds to one ReceiverSession inside
101 //! ReceiverSessionGroup, because we create a separate session for every
102 //! connected participant (remote sender).
103 //! @note
104 //! @p party_metrics points to array of metrics structs, and @p party_count
105 //! defines number of array elements. Metrics are written to given array,
106 //! and @p party_count is updated of actual number of elements written.
107 //! If there is not enough space for all metrics, result is truncated.
109 size_t* party_count) const;
110
111private:
112 // Implementation of rtcp::IParticipant interface.
113 // These methods are invoked by rtcp::Communicator.
114 virtual rtcp::ParticipantInfo participant_info();
115 virtual void change_source_id();
116 virtual size_t num_recv_streams();
117 virtual void query_recv_streams(rtcp::RecvReport* reports,
118 size_t n_reports,
119 core::nanoseconds_t report_time);
120 virtual status::StatusCode notify_recv_stream(packet::stream_source_t send_source_id,
121 const rtcp::SendReport& send_report);
122 virtual void halt_recv_stream(packet::stream_source_t send_source_id);
123
124 status::StatusCode route_transport_packet_(const packet::PacketPtr& packet);
125 status::StatusCode route_control_packet_(const packet::PacketPtr& packet,
126 core::nanoseconds_t current_time);
127
128 bool can_create_session_(const packet::PacketPtr& packet);
129
130 status::StatusCode create_session_(const packet::PacketPtr& packet);
131 void remove_session_(core::SharedPtr<ReceiverSession> sess);
132 void remove_all_sessions_();
133
134 ReceiverSessionConfig make_session_config_(const packet::PacketPtr& packet) const;
135
136 const ReceiverSourceConfig source_config_;
137 const ReceiverSlotConfig slot_config_;
138
139 StateTracker& state_tracker_;
140 audio::Mixer& mixer_;
141
142 const rtp::EncodingMap& encoding_map_;
143
144 core::IArena& arena_;
145 packet::PacketFactory& packet_factory_;
146 audio::FrameFactory& frame_factory_;
147
149
150 core::Optional<rtcp::Communicator> rtcp_communicator_;
151 address::SocketAddr rtcp_inbound_addr_;
152
154 ReceiverSessionRouter session_router_;
155
156 bool valid_;
157};
158
159} // namespace pipeline
160} // namespace roc
161
162#endif // ROC_PIPELINE_RECEIVER_SESSION_GROUP_H_
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Mixer. Mixes multiple input streams into one output stream.
Definition mixer.h:46
Memory arena interface.
Definition iarena.h:23
Base class for non-copyable objects.
Definition noncopyable.h:23
Receiver endpoint sub-pipeline.
core::nanoseconds_t refresh_sessions(core::nanoseconds_t current_time)
Refresh pipeline according to current time.
void get_participant_metrics(ReceiverParticipantMetrics *party_metrics, size_t *party_count) const
Get metrics for remote participants.
void get_slot_metrics(ReceiverSlotMetrics &slot_metrics) const
Get slot metrics.
size_t num_sessions() const
Get number of sessions in group.
bool is_valid() const
Check if pipeline was succefully constructed.
void reclock_sessions(core::nanoseconds_t playback_time)
Adjust session clock to match consumer clock.
status::StatusCode route_packet(const packet::PacketPtr &packet, core::nanoseconds_t current_time)
Route packet to session.
ReceiverSessionGroup(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 create_control_pipeline(ReceiverEndpoint *control_endpoint)
Create control sub-pipeline.
Pipeline state tracker.
RTCP participant.
RTP encoding map. Thread-safe. Returned encodings are immutable and can be safely used from any threa...
RTCP communicator.
Frame factory.
Memory arena interface.
RTP participant identity.
RTCP participant.
Intrusive doubly-linked list.
Pipeline metrics.
Mixer.
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
uint32_t stream_source_t
Packet stream identifier.
Definition units.h:27
StatusCode
Status code.
Definition status_code.h:19
Root namespace.
Non-copyable object.
Packet factory.
Receiver endpoint pipeline.
Receiver session pipeline.
Receiver session router.
RTCP packet composer.
Pipeline state tracker.
Receiver-side metrics specific to one participant (remote sender).
Definition metrics.h:54
Parameters of receiver session.
Definition config.h:154
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
Receiver report, for inspection on sender.
Definition reports.h:94
Sender report, for inspection on receiver.
Definition reports.h:27