Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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"
17#include "roc_core/atomic.h"
18#include "roc_core/iarena.h"
20#include "roc_core/slab_pool.h"
25
26namespace roc {
27namespace node {
28
29//! Node context config.
31 //! Maximum size in bytes of a network packet.
33
34 //! Maximum size in bytes of an audio frame.
36
38 : max_packet_size(2048)
39 , max_frame_size(4096) {
40 }
41};
42
43//! Node context.
44class Context : public core::RefCounted<Context, core::ManualAllocation> {
45public:
46 //! Initialize.
47 explicit Context(const ContextConfig& config, core::IArena& arena);
48
49 //! Deinitialize.
51
52 //! Check if successfully constructed.
53 bool is_valid();
54
55 //! Get arena.
57
58 //! Get packet pool.
60
61 //! Get packet buffer pool.
63
64 //! Get frame buffer pool.
66
67 //! Get encoding map.
69
70 //! Get network event loop.
72
73 //! Get control event loop.
75
76private:
77 core::IArena& arena_;
78
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 policies.
Atomic.
Memory arena interface.
Definition iarena.h:23
Memory pool interface.
Definition ipool.h:23
Base class for object with reference counter.
Definition ref_counted.h:40
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Control loop thread.
Network event loop thread.
Node context.
Definition context.h:44
core::IPool & packet_buffer_pool()
Get packet buffer pool.
bool is_valid()
Check if successfully constructed.
rtp::EncodingMap & encoding_map()
Get encoding map.
core::IPool & frame_buffer_pool()
Get frame buffer pool.
core::IArena & arena()
Get arena.
~Context()
Deinitialize.
netio::NetworkLoop & network_loop()
Get network event loop.
ctl::ControlLoop & control_loop()
Get control event loop.
Context(const ContextConfig &config, core::IArena &arena)
Initialize.
core::IPool & packet_pool()
Get packet pool.
RTP encoding map. Thread-safe. Returned encodings are immutable and can be safely used from any threa...
Control loop thread.
RTP encoding map.
Memory arena interface.
Root namespace.
Network event loop thread.
Packet factory.
Base class for object with reference counter.
Audio sample.
Memory pool.
Node context config.
Definition context.h:30
size_t max_frame_size
Maximum size in bytes of an audio frame.
Definition context.h:35
size_t max_packet_size
Maximum size in bytes of a network packet.
Definition context.h:32