Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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
17#include "roc_core/attributes.h"
18#include "roc_core/mutex.h"
19#include "roc_node/context.h"
20#include "roc_node/node.h"
26
27namespace roc {
28namespace node {
29
30//! Receiver decoder node.
32public:
33 //! Initialize.
35 const pipeline::ReceiverSourceConfig& pipeline_config);
36
37 //! Deinitialize.
39
40 //! Check if successfully constructed.
41 bool is_valid();
42
43 //! Get packet factory.
45
46 //! Activate interface.
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.
61 void* slot_metrics_arg,
62 party_metrics_func_t party_metrics_func,
63 void* party_metrics_arg);
64
65 //! Write packet for decoding.
67 const packet::PacketPtr& packet);
68
69 //! Read encoded packet.
70 //! @note
71 //! Typically used to generate control packets with feedback for sender.
73 packet::PacketPtr& packet);
74
75 //! Source for reading decoded frames.
77
78private:
79 virtual void schedule_task_processing(pipeline::PipelineLoop&,
81 virtual void cancel_task_processing(pipeline::PipelineLoop&);
82
83 core::Mutex mutex_;
84
85 address::SocketAddr bind_address_;
86
90
91 packet::PacketFactory packet_factory_;
92
93 pipeline::ReceiverLoop pipeline_;
96
97 bool valid_;
98};
99
100} // namespace node
101} // namespace roc
102
103#endif // ROC_NODE_RECEIVER_DECODER_H_
Compiler attributes.
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Definition attributes.h:31
Process pending pipeline tasks on control thread.
Node context.
Definition context.h:44
Base class for nodes.
Definition node.h:23
Context & context()
All nodes hold reference to context.
Receiver decoder node.
void(* slot_metrics_func_t)(const pipeline::ReceiverSlotMetrics &slot_metrics, void *slot_arg)
Callback for slot metrics.
bool activate(address::Interface iface, address::Protocol proto)
Activate interface.
bool is_valid()
Check if successfully constructed.
sndio::ISource & source()
Source for reading decoded frames.
status::StatusCode read_packet(address::Interface iface, packet::PacketPtr &packet)
Read encoded packet.
ReceiverDecoder(Context &context, const pipeline::ReceiverSourceConfig &pipeline_config)
Initialize.
packet::PacketFactory & packet_factory()
Get packet factory.
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.
~ReceiverDecoder()
Deinitialize.
status::StatusCode write_packet(address::Interface iface, const packet::PacketPtr &packet)
Write packet for decoding.
void(* party_metrics_func_t)(const pipeline::ReceiverParticipantMetrics &party_metrics, size_t party_index, void *party_arg)
Callback for participant metrics.
Pipeline task scheduler interface. PipelineLoop uses this interface to schedule asynchronous work....
Base class for task-based pipelines.
Receiver pipeline loop.
struct SlotHandle * SlotHandle
Opaque slot handle.
Source interface.
Definition isource.h:23
Concurrent blocking packet queue.
Node context.
Interface ID.
Pipeline task scheduler interface.
Mutex.
Interface
Interface ID.
Definition interface.h:19
@ Iface_Max
Number of interfaces.
Definition interface.h:36
Protocol
Protocol ID.
Definition protocol.h:19
int64_t nanoseconds_t
Nanoseconds.
Definition time.h:58
StatusCode
Status code.
Definition status_code.h:19
Root namespace.
Base class for nodes.
Packet factory.
Protocol ID.
Receiver pipeline loop.
Status codes.
Receiver-side metrics specific to one participant (remote sender).
Definition metrics.h:54
Receiver-side metrics of the whole slot.
Definition metrics.h:66
Parameters of receiver session.
Definition config.h:184