Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
receiver_decoder.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/receiver_decoder.h
10
//! @brief Receiver decoder node.
11
12
#ifndef ROC_NODE_RECEIVER_DECODER_H_
13
#define ROC_NODE_RECEIVER_DECODER_H_
14
15
#include "
roc_address/interface.h
"
16
#include "
roc_address/protocol.h
"
17
#include "
roc_core/attributes.h
"
18
#include "
roc_core/mutex.h
"
19
#include "
roc_node/context.h
"
20
#include "
roc_node/node.h
"
21
#include "
roc_packet/concurrent_queue.h
"
22
#include "
roc_packet/packet_factory.h
"
23
#include "
roc_pipeline/ipipeline_task_scheduler.h
"
24
#include "
roc_pipeline/receiver_loop.h
"
25
#include "
roc_status/status_code.h
"
26
27
namespace
roc
{
28
namespace
node
{
29
30
//! Receiver decoder node.
31
class
ReceiverDecoder
:
public
Node
,
private
pipeline::IPipelineTaskScheduler
{
32
public
:
33
//! Initialize.
34
ReceiverDecoder
(
Context
&
context
,
35
const
pipeline::ReceiverSourceConfig
& pipeline_config);
36
37
//! Deinitialize.
38
~ReceiverDecoder
();
39
40
//! Check if successfully constructed.
41
bool
is_valid
();
42
43
//! Get packet factory.
44
packet::PacketFactory
&
packet_factory
();
45
46
//! Activate interface.
47
ROC_ATTR_NODISCARD
bool
activate
(
address::Interface
iface,
address::Protocol
proto);
48
49
//! Callback for slot metrics.
50
typedef
void (*
slot_metrics_func_t
)(
const
pipeline::ReceiverSlotMetrics
& slot_metrics,
51
void
* slot_arg);
52
53
//! Callback for participant metrics.
54
typedef
void (*
party_metrics_func_t
)(
55
const
pipeline::ReceiverParticipantMetrics
& party_metrics,
56
size_t
party_index,
57
void
* party_arg);
58
59
//! Get metrics.
60
ROC_ATTR_NODISCARD
bool
get_metrics
(
slot_metrics_func_t
slot_metrics_func,
61
void
* slot_metrics_arg,
62
party_metrics_func_t
party_metrics_func,
63
void
* party_metrics_arg);
64
65
//! Write packet for decoding.
66
ROC_ATTR_NODISCARD
status::StatusCode
write_packet
(
address::Interface
iface,
67
const
packet::PacketPtr
&
packet
);
68
69
//! Read encoded packet.
70
//! @note
71
//! Typically used to generate control packets with feedback for sender.
72
ROC_ATTR_NODISCARD
status::StatusCode
read_packet
(
address::Interface
iface,
73
packet::PacketPtr
&
packet
);
74
75
//! Source for reading decoded frames.
76
sndio::ISource
&
source
();
77
78
private
:
79
virtual
void
schedule_task_processing(
pipeline::PipelineLoop
&,
80
core::nanoseconds_t
delay);
81
virtual
void
cancel_task_processing(
pipeline::PipelineLoop
&);
82
83
core::Mutex
mutex_;
84
85
address::SocketAddr
bind_address_;
86
87
core::Optional<packet::ConcurrentQueue>
endpoint_queues_[
address::Iface_Max
];
88
core::Atomic<packet::IReader*>
endpoint_readers_[
address::Iface_Max
];
89
core::Atomic<packet::IWriter*>
endpoint_writers_[
address::Iface_Max
];
90
91
packet::PacketFactory
packet_factory_;
92
93
pipeline::ReceiverLoop
pipeline_;
94
pipeline::ReceiverLoop::SlotHandle
slot_;
95
ctl::ControlLoop::Tasks::PipelineProcessing
processing_task_;
96
97
bool
valid_;
98
};
99
100
}
// namespace node
101
}
// namespace roc
102
103
#endif
// ROC_NODE_RECEIVER_DECODER_H_
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::ReceiverDecoder::slot_metrics_func_t
void(* slot_metrics_func_t)(const pipeline::ReceiverSlotMetrics &slot_metrics, void *slot_arg)
Callback for slot metrics.
Definition
receiver_decoder.h:50
roc::node::ReceiverDecoder::is_valid
bool is_valid()
Check if successfully constructed.
roc::node::ReceiverDecoder::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::ReceiverDecoder::source
sndio::ISource & source()
Source for reading decoded frames.
roc::node::ReceiverDecoder::ReceiverDecoder
ReceiverDecoder(Context &context, const pipeline::ReceiverSourceConfig &pipeline_config)
Initialize.
roc::node::ReceiverDecoder::activate
ROC_ATTR_NODISCARD bool activate(address::Interface iface, address::Protocol proto)
Activate interface.
roc::node::ReceiverDecoder::packet_factory
packet::PacketFactory & packet_factory()
Get packet factory.
roc::node::ReceiverDecoder::~ReceiverDecoder
~ReceiverDecoder()
Deinitialize.
roc::node::ReceiverDecoder::write_packet
ROC_ATTR_NODISCARD status::StatusCode write_packet(address::Interface iface, const packet::PacketPtr &packet)
Write packet for decoding.
roc::node::ReceiverDecoder::read_packet
ROC_ATTR_NODISCARD status::StatusCode read_packet(address::Interface iface, packet::PacketPtr &packet)
Read encoded packet.
roc::node::ReceiverDecoder::party_metrics_func_t
void(* party_metrics_func_t)(const pipeline::ReceiverParticipantMetrics &party_metrics, size_t party_index, void *party_arg)
Callback for participant metrics.
Definition
receiver_decoder.h:54
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::ReceiverLoop
Receiver pipeline loop.
Definition
receiver_loop.h:46
roc::pipeline::ReceiverLoop::SlotHandle
struct SlotHandle * SlotHandle
Opaque slot handle.
Definition
receiver_loop.h:49
roc::sndio::ISource
Source interface.
Definition
isource.h:23
concurrent_queue.h
Concurrent blocking packet queue.
context.h
Node context.
interface.h
Interface ID.
ipipeline_task_scheduler.h
Pipeline task scheduler 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.
packet_factory.h
Packet factory.
protocol.h
Protocol ID.
receiver_loop.h
Receiver pipeline loop.
status_code.h
Status codes.
roc::status::StatusCode
StatusCode
Status code.
Definition
status_code.h:19
roc::pipeline::ReceiverParticipantMetrics
Receiver-side metrics specific to one participant (remote sender).
Definition
metrics.h:54
roc::pipeline::ReceiverSlotMetrics
Receiver-side metrics of the whole slot.
Definition
metrics.h:66
roc::pipeline::ReceiverSourceConfig
Parameters of receiver session.
Definition
config.h:184
roc_node
receiver_decoder.h
Generated by
1.17.0