Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
frame_factory.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2024 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_audio/frame_factory.h
10
//! @brief Frame factory.
11
12
#ifndef ROC_AUDIO_FRAME_FACTORY_H_
13
#define ROC_AUDIO_FRAME_FACTORY_H_
14
15
#include "
roc_audio/frame.h
"
16
#include "
roc_audio/sample.h
"
17
#include "
roc_core/buffer.h
"
18
#include "
roc_core/iarena.h
"
19
#include "
roc_core/ipool.h
"
20
#include "
roc_core/noncopyable.h
"
21
#include "
roc_core/optional.h
"
22
#include "
roc_core/slab_pool.h
"
23
#include "
roc_core/slice.h
"
24
25
namespace
roc
{
26
namespace
audio
{
27
28
//! Frame factory.
29
//!
30
//! Allows allocating frames and frame buffers (byte buffers of appropriate size
31
//! that should be attached to frame to hold payload).
32
//!
33
//! Serves several purposes:
34
//! - implements convenient and type-safe wrapper on top of memory pools
35
//! - combines two related pools (frame pool and buffer pool) in one class
36
//! - detaches pipeline logic from memory management interface, so that it can
37
//! change independently without affecting every pipeline element
38
class
FrameFactory
:
public
core::NonCopyable
<> {
39
public
:
40
//! Initialize with default pools.
41
//! @p buffer_size defines number of bytes in frame buffer.
42
FrameFactory
(
core::IArena
& arena,
size_t
buffer_size);
43
44
//! Initialize with custom pools.
45
//! @p buffer_pool is a pool of core::Buffer objects.
46
FrameFactory
(
core::IPool
& buffer_pool);
47
48
//! Get number of bytes in byte buffer.
49
size_t
byte_buffer_size
()
const
;
50
51
//! Allocate byte buffer.
52
core::Slice<uint8_t>
new_byte_buffer
();
53
54
//! Get number of samples in raw sample buffer.
55
size_t
raw_buffer_size
()
const
;
56
57
//! Allocate raw sample buffer.
58
core::Slice<sample_t>
new_raw_buffer
();
59
60
private
:
61
// used if factory is created with default pools
62
core::Optional<core::SlabPool<core::Buffer>
> default_buffer_pool_;
63
64
core::IPool
* buffer_pool_;
65
size_t
buffer_size_;
66
};
67
68
}
// namespace audio
69
}
// namespace roc
70
71
#endif
// ROC_AUDIO_FRAME_FACTORY_H_
buffer.h
Buffer.
roc::audio::FrameFactory::new_raw_buffer
core::Slice< sample_t > new_raw_buffer()
Allocate raw sample buffer.
roc::audio::FrameFactory::new_byte_buffer
core::Slice< uint8_t > new_byte_buffer()
Allocate byte buffer.
roc::audio::FrameFactory::FrameFactory
FrameFactory(core::IArena &arena, size_t buffer_size)
Initialize with default pools. buffer_size defines number of bytes in frame buffer.
roc::audio::FrameFactory::raw_buffer_size
size_t raw_buffer_size() const
Get number of samples in raw sample buffer.
roc::audio::FrameFactory::byte_buffer_size
size_t byte_buffer_size() const
Get number of bytes in byte buffer.
roc::audio::FrameFactory::FrameFactory
FrameFactory(core::IPool &buffer_pool)
Initialize with custom pools. buffer_pool is a pool of core::Buffer objects.
roc::core::IArena
Memory arena interface.
Definition
iarena.h:23
roc::core::IPool
Memory pool interface.
Definition
ipool.h:23
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
roc::core::Optional
Optionally constructed object.
Definition
optional.h:25
roc::core::Slice
Slice.
Definition
slice.h:55
frame.h
Audio frame.
iarena.h
Memory arena interface.
ipool.h
Memory pool interface.
roc::audio
Audio frames and audio processing.
roc
Root namespace.
noncopyable.h
Non-copyable object.
optional.h
Optionally constructed object.
sample.h
Audio sample.
slab_pool.h
Memory pool.
slice.h
Slice.
roc_audio
frame_factory.h
Generated by
1.17.0