Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
context.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_node/context.h
10
//! @brief Node context.
11
12
#ifndef ROC_NODE_CONTEXT_H_
13
#define ROC_NODE_CONTEXT_H_
14
15
#include "
roc_audio/sample.h
"
16
#include "
roc_core/allocation_policy.h
"
17
#include "
roc_core/atomic.h
"
18
#include "
roc_core/iarena.h
"
19
#include "
roc_core/ref_counted.h
"
20
#include "
roc_core/slab_pool.h
"
21
#include "
roc_ctl/control_loop.h
"
22
#include "
roc_netio/network_loop.h
"
23
#include "
roc_packet/packet_factory.h
"
24
#include "
roc_rtp/encoding_map.h
"
25
26
namespace
roc
{
27
namespace
node
{
28
29
//! Node context config.
30
struct
ContextConfig {
31
//! Maximum size in bytes of a network packet.
32
size_t
max_packet_size
;
33
34
//! Maximum size in bytes of an audio frame.
35
size_t
max_frame_size
;
36
37
ContextConfig()
38
:
max_packet_size
(2048)
39
,
max_frame_size
(4096) {
40
}
41
};
42
43
//! Node context.
44
class
Context
:
public
core::RefCounted
<Context, core::ManualAllocation> {
45
public
:
46
//! Initialize.
47
explicit
Context
(
const
ContextConfig
& config,
core::IArena
&
arena
);
48
49
//! Deinitialize.
50
~Context
();
51
52
//! Check if successfully constructed.
53
bool
is_valid
();
54
55
//! Get arena.
56
core::IArena
&
arena
();
57
58
//! Get packet pool.
59
core::IPool
&
packet_pool
();
60
61
//! Get packet buffer pool.
62
core::IPool
&
packet_buffer_pool
();
63
64
//! Get frame buffer pool.
65
core::IPool
&
frame_buffer_pool
();
66
67
//! Get encoding map.
68
rtp::EncodingMap
&
encoding_map
();
69
70
//! Get network event loop.
71
netio::NetworkLoop
&
network_loop
();
72
73
//! Get control event loop.
74
ctl::ControlLoop
&
control_loop
();
75
76
private
:
77
core::IArena
& arena_;
78
79
core::SlabPool<packet::Packet>
packet_pool_;
80
core::SlabPool<core::Buffer>
packet_buffer_pool_;
81
core::SlabPool<core::Buffer>
frame_buffer_pool_;
82
83
rtp::EncodingMap
encoding_map_;
84
85
netio::NetworkLoop
network_loop_;
86
ctl::ControlLoop
control_loop_;
87
};
88
89
}
// namespace node
90
}
// namespace roc
91
92
#endif
// ROC_NODE_CONTEXT_H_
allocation_policy.h
Allocation policies.
atomic.h
Atomic.
roc::core::IArena
Memory arena interface.
Definition
iarena.h:23
roc::core::IPool
Memory pool interface.
Definition
ipool.h:23
roc::core::RefCounted
Base class for object with reference counter.
Definition
ref_counted.h:40
roc::core::SlabPool
Memory pool.
Definition
slab_pool.h:72
roc::ctl::ControlLoop
Control loop thread.
Definition
control_loop.h:33
roc::netio::NetworkLoop
Network event loop thread.
Definition
network_loop.h:52
roc::node::Context::packet_buffer_pool
core::IPool & packet_buffer_pool()
Get packet buffer pool.
roc::node::Context::is_valid
bool is_valid()
Check if successfully constructed.
roc::node::Context::encoding_map
rtp::EncodingMap & encoding_map()
Get encoding map.
roc::node::Context::frame_buffer_pool
core::IPool & frame_buffer_pool()
Get frame buffer pool.
roc::node::Context::arena
core::IArena & arena()
Get arena.
roc::node::Context::~Context
~Context()
Deinitialize.
roc::node::Context::network_loop
netio::NetworkLoop & network_loop()
Get network event loop.
roc::node::Context::control_loop
ctl::ControlLoop & control_loop()
Get control event loop.
roc::node::Context::Context
Context(const ContextConfig &config, core::IArena &arena)
Initialize.
roc::node::Context::packet_pool
core::IPool & packet_pool()
Get packet pool.
roc::rtp::EncodingMap
RTP encoding map. Thread-safe. Returned encodings are immutable and can be safely used from any threa...
Definition
encoding_map.h:33
control_loop.h
Control loop thread.
encoding_map.h
RTP encoding map.
iarena.h
Memory arena interface.
roc::node
High-level sender and receiver nodes.
roc
Root namespace.
network_loop.h
Network event loop thread.
packet_factory.h
Packet factory.
ref_counted.h
Base class for object with reference counter.
sample.h
Audio sample.
slab_pool.h
Memory pool.
roc::node::ContextConfig
Node context config.
Definition
context.h:30
roc::node::ContextConfig::max_frame_size
size_t max_frame_size
Maximum size in bytes of an audio frame.
Definition
context.h:35
roc::node::ContextConfig::max_packet_size
size_t max_packet_size
Maximum size in bytes of a network packet.
Definition
context.h:32
roc_node
context.h
Generated by
1.17.0