Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
sender_encoder.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023 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_node/sender_encoder.h
10
//! @brief Sender encoder node.
11
12
#ifndef ROC_NODE_SENDER_ENCODER_H_
13
#define ROC_NODE_SENDER_ENCODER_H_
14
15
#include "
roc_address/interface.h
"
16
#include "
roc_address/protocol.h
"
17
#include "
roc_address/socket_addr.h
"
18
#include "
roc_core/atomic.h
"
19
#include "
roc_core/attributes.h
"
20
#include "
roc_core/mutex.h
"
21
#include "
roc_core/optional.h
"
22
#include "
roc_node/context.h
"
23
#include "
roc_node/node.h
"
24
#include "
roc_packet/concurrent_queue.h
"
25
#include "
roc_packet/ireader.h
"
26
#include "
roc_packet/packet_factory.h
"
27
#include "
roc_pipeline/ipipeline_task_scheduler.h
"
28
#include "
roc_pipeline/sender_loop.h
"
29
30
namespace
roc
{
31
namespace
node
{
32
33
//! Sender encoder node.
34
class
SenderEncoder
:
public
Node
,
private
pipeline::IPipelineTaskScheduler
{
35
public
:
36
//! Initialize.
37
SenderEncoder
(
Context
&
context
,
const
pipeline::SenderSinkConfig
& pipeline_config);
38
39
//! Deinitialize.
40
~SenderEncoder
();
41
42
//! Check if successfully constructed.
43
bool
is_valid
()
const
;
44
45
//! Get packet factory.
46
packet::PacketFactory
&
packet_factory
();
47
48
//! Activate interface.
49
ROC_ATTR_NODISCARD
bool
activate
(
address::Interface
iface,
address::Protocol
proto);
50
51
//! Callback for slot metrics.
52
typedef
void (*
slot_metrics_func_t
)(
const
pipeline::SenderSlotMetrics
& slot_metrics,
53
void
* slot_arg);
54
55
//! Callback for participant metrics.
56
typedef
void (*
party_metrics_func_t
)(
57
const
pipeline::SenderParticipantMetrics
& party_metrics,
58
size_t
party_index,
59
void
* party_arg);
60
61
//! Get metrics.
62
ROC_ATTR_NODISCARD
bool
get_metrics
(
slot_metrics_func_t
slot_metrics_func,
63
void
* slot_metrics_arg,
64
party_metrics_func_t
party_metrics_func,
65
void
* party_metrics_arg);
66
67
//! Check if everything is connected.
68
bool
is_complete
();
69
70
//! Read encoded packet.
71
ROC_ATTR_NODISCARD
status::StatusCode
read_packet
(
address::Interface
iface,
72
packet::PacketPtr
&
packet
);
73
74
//! Write packet for decoding.
75
//! @note
76
//! Typically used to deliver control packets with receiver feedback.
77
ROC_ATTR_NODISCARD
status::StatusCode
write_packet
(
address::Interface
iface,
78
const
packet::PacketPtr
&
packet
);
79
80
//! Sink for writing frames for encoding.
81
sndio::ISink
&
sink
();
82
83
private
:
84
virtual
void
schedule_task_processing(
pipeline::PipelineLoop
&,
85
core::nanoseconds_t
delay);
86
virtual
void
cancel_task_processing(
pipeline::PipelineLoop
&);
87
88
core::Mutex
mutex_;
89
90
address::SocketAddr
dest_address_;
91
92
core::Optional<packet::ConcurrentQueue>
endpoint_queues_[
address::Iface_Max
];
93
core::Atomic<packet::IReader*>
endpoint_readers_[
address::Iface_Max
];
94
core::Atomic<packet::IWriter*>
endpoint_writers_[
address::Iface_Max
];
95
96
packet::PacketFactory
packet_factory_;
97
98
pipeline::SenderLoop
pipeline_;
99
pipeline::SenderLoop::SlotHandle
slot_;
100
ctl::ControlLoop::Tasks::PipelineProcessing
processing_task_;
101
102
bool
valid_;
103
};
104
105
}
// namespace node
106
}
// namespace roc
107
108
#endif
// ROC_NODE_SENDER_ENCODER_H_
atomic.h
Atomic.
attributes.h
Compiler attributes.
ROC_ATTR_NODISCARD
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition
attributes.h:31
roc::address::SocketAddr
Socket address.
Definition
socket_addr.h:26
roc::core::Atomic
Atomic integer. Provides sequential consistency. For a fine-grained memory order control,...
Definition
atomic.h:26
roc::core::Mutex
Mutex.
Definition
mutex.h:31
roc::core::Optional
Optionally constructed object.
Definition
optional.h:25
roc::ctl::ControlLoop::Tasks::PipelineProcessing
Process pending pipeline tasks on control thread.
Definition
control_loop.h:164
roc::node::Context
Node context.
Definition
context.h:44
roc::node::Node::context
Context & context()
All nodes hold reference to context.
roc::node::Node::Node
Node(Context &context)
Initialize.
roc::node::SenderEncoder::activate
ROC_ATTR_NODISCARD bool activate(address::Interface iface, address::Protocol proto)
Activate interface.
roc::node::SenderEncoder::get_metrics
ROC_ATTR_NODISCARD bool get_metrics(slot_metrics_func_t slot_metrics_func, void *slot_metrics_arg, party_metrics_func_t party_metrics_func, void *party_metrics_arg)
Get metrics.
roc::node::SenderEncoder::SenderEncoder
SenderEncoder(Context &context, const pipeline::SenderSinkConfig &pipeline_config)
Initialize.
roc::node::SenderEncoder::read_packet
ROC_ATTR_NODISCARD status::StatusCode read_packet(address::Interface iface, packet::PacketPtr &packet)
Read encoded packet.
roc::node::SenderEncoder::sink
sndio::ISink & sink()
Sink for writing frames for encoding.
roc::node::SenderEncoder::is_valid
bool is_valid() const
Check if successfully constructed.
roc::node::SenderEncoder::party_metrics_func_t
void(* party_metrics_func_t)(const pipeline::SenderParticipantMetrics &party_metrics, size_t party_index, void *party_arg)
Callback for participant metrics.
Definition
sender_encoder.h:56
roc::node::SenderEncoder::slot_metrics_func_t
void(* slot_metrics_func_t)(const pipeline::SenderSlotMetrics &slot_metrics, void *slot_arg)
Callback for slot metrics.
Definition
sender_encoder.h:52
roc::node::SenderEncoder::write_packet
ROC_ATTR_NODISCARD status::StatusCode write_packet(address::Interface iface, const packet::PacketPtr &packet)
Write packet for decoding.
roc::node::SenderEncoder::is_complete
bool is_complete()
Check if everything is connected.
roc::node::SenderEncoder::packet_factory
packet::PacketFactory & packet_factory()
Get packet factory.
roc::node::SenderEncoder::~SenderEncoder
~SenderEncoder()
Deinitialize.
roc::packet::PacketFactory
Packet factory.
Definition
packet_factory.h:36
roc::pipeline::IPipelineTaskScheduler
Pipeline task scheduler interface. PipelineLoop uses this interface to schedule asynchronous work....
Definition
ipipeline_task_scheduler.h:25
roc::pipeline::PipelineLoop
Base class for task-based pipelines.
Definition
pipeline_loop.h:236
roc::pipeline::SenderLoop
Sender pipeline loop.
Definition
sender_loop.h:44
roc::pipeline::SenderLoop::SlotHandle
struct SlotHandle * SlotHandle
Opaque slot handle.
Definition
sender_loop.h:47
roc::sndio::ISink
Sink interface.
Definition
isink.h:22
concurrent_queue.h
Concurrent blocking packet queue.
context.h
Node context.
interface.h
Interface ID.
ipipeline_task_scheduler.h
Pipeline task scheduler interface.
ireader.h
Packet reader interface.
mutex.h
Mutex.
roc::address::Interface
Interface
Interface ID.
Definition
interface.h:19
roc::address::Iface_Max
@ Iface_Max
Number of interfaces.
Definition
interface.h:36
roc::address::Protocol
Protocol
Protocol ID.
Definition
protocol.h:19
roc::core::nanoseconds_t
int64_t nanoseconds_t
Nanoseconds.
Definition
time.h:58
roc::node
High-level sender and receiver nodes.
roc::packet
Network packets and packet processing.
roc::packet::PacketPtr
core::SharedPtr< Packet > PacketPtr
Packet smart pointer.
Definition
packet.h:34
roc
Root namespace.
node.h
Base class for nodes.
optional.h
Optionally constructed object.
packet_factory.h
Packet factory.
protocol.h
Protocol ID.
sender_loop.h
Sender pipeline loop.
socket_addr.h
Socket address.
roc::status::StatusCode
StatusCode
Status code.
Definition
status_code.h:19
roc::pipeline::SenderParticipantMetrics
Sender-side metrics specific to one participant (remote receiver).
Definition
metrics.h:24
roc::pipeline::SenderSinkConfig
Parameters of sender sink and sender session.
Definition
config.h:58
roc::pipeline::SenderSlotMetrics
Sender-side metrics of the whole slot.
Definition
metrics.h:36
roc_node
sender_encoder.h
Generated by
1.17.0