Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sender_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/sender_slot.h
10//! @brief Sender slot.
11
12#ifndef ROC_PIPELINE_SENDER_SLOT_H_
13#define ROC_PIPELINE_SENDER_SLOT_H_
14
17#include "roc_audio/fanout.h"
19#include "roc_core/iarena.h"
21#include "roc_core/optional.h"
24#include "roc_pipeline/config.h"
29
30namespace roc {
31namespace pipeline {
32
33//! Sender slot.
34//!
35//! Contains:
36//! - one or more related sender endpoints, one per each type
37//! - one session associated with those endpoints
38class SenderSlot : public core::RefCounted<SenderSlot, core::ArenaAllocation>,
39 public core::ListNode<> {
40public:
41 //! Initialize.
42 SenderSlot(const SenderSinkConfig& sink_config,
43 const SenderSlotConfig& slot_config,
44 StateTracker& state_tracker,
45 const rtp::EncodingMap& encoding_map,
46 audio::Fanout& fanout,
47 packet::PacketFactory& packet_factory,
48 audio::FrameFactory& frame_factory,
50
52
53 //! Check if the slot was successfully constructed.
54 bool is_valid() const;
55
56 //! Add endpoint.
59 const address::SocketAddr& outbound_address,
60 packet::IWriter& outbound_writer);
61
62 //! Refresh pipeline according to current time.
63 //! @returns
64 //! deadline (absolute time) when refresh should be invoked again
65 //! if there are no frames
67
68 //! Get metrics for slot and its participants.
69 void get_metrics(SenderSlotMetrics& slot_metrics,
70 SenderParticipantMetrics* party_metrics,
71 size_t* party_count) const;
72
73private:
74 SenderEndpoint* create_source_endpoint_(address::Protocol proto,
75 const address::SocketAddr& outbound_address,
76 packet::IWriter& outbound_writer);
77 SenderEndpoint* create_repair_endpoint_(address::Protocol proto,
78 const address::SocketAddr& outbound_address,
79 packet::IWriter& outbound_writer);
80 SenderEndpoint* create_control_endpoint_(address::Protocol proto,
81 const address::SocketAddr& outbound_address,
82 packet::IWriter& outbound_writer);
83
84 const SenderSinkConfig sink_config_;
85
86 audio::Fanout& fanout_;
87
88 core::Optional<SenderEndpoint> source_endpoint_;
89 core::Optional<SenderEndpoint> repair_endpoint_;
90 core::Optional<SenderEndpoint> control_endpoint_;
91
92 StateTracker& state_tracker_;
93 SenderSession session_;
94
95 bool valid_;
96};
97
98} // namespace pipeline
99} // namespace roc
100
101#endif // ROC_PIPELINE_SENDER_SLOT_H_
Fanout. Duplicates audio stream to multiple output writers.
Definition fanout.h:26
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
Sender endpoint sub-pipeline.
Sender session sub-pipeline.
SenderEndpoint * add_endpoint(address::Interface iface, address::Protocol proto, const address::SocketAddr &outbound_address, packet::IWriter &outbound_writer)
Add endpoint.
bool is_valid() const
Check if the slot was successfully constructed.
SenderSlot(const SenderSinkConfig &sink_config, const SenderSlotConfig &slot_config, StateTracker &state_tracker, const rtp::EncodingMap &encoding_map, audio::Fanout &fanout, packet::PacketFactory &packet_factory, audio::FrameFactory &frame_factory, core::IArena &arena)
Initialize.
void get_metrics(SenderSlotMetrics &slot_metrics, SenderParticipantMetrics *party_metrics, size_t *party_count) const
Get metrics for slot and its participants.
core::nanoseconds_t refresh(core::nanoseconds_t current_time)
Refresh pipeline according to current time.
Pipeline state tracker.
RTP encoding map. Thread-safe. Returned encodings are immutable and can be safely used from any threa...
Fanout.
Frame factory.
Memory arena interface.
Interface ID.
Pipeline metrics.
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.
Non-copyable object.
Optionally constructed object.
Packet factory.
Protocol ID.
Base class for object with reference counter.
Pipeline config.
Sender endpoint pipeline.
Sender session.
Pipeline state tracker.
Sender-side metrics specific to one participant (remote receiver).
Definition metrics.h:24
Parameters of sender sink and sender session.
Definition config.h:58
Parameters of sender slot.
Definition config.h:115
Sender-side metrics of the whole slot.
Definition metrics.h:36