Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
iframe_encoder.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 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/iframe_encoder.h
10
//! @brief Audio frame encoder interface.
11
12
#ifndef ROC_AUDIO_IFRAME_ENCODER_H_
13
#define ROC_AUDIO_IFRAME_ENCODER_H_
14
15
#include "
roc_audio/sample.h
"
16
#include "
roc_core/stddefs.h
"
17
#include "
roc_packet/packet.h
"
18
#include "
roc_packet/units.h
"
19
20
namespace
roc
{
21
namespace
audio
{
22
23
//! Audio frame encoder interface.
24
class
IFrameEncoder
{
25
public
:
26
virtual
~IFrameEncoder
();
27
28
//! Get encoded frame size in bytes for given number of samples per channel.
29
virtual
size_t
encoded_byte_count
(
size_t
num_samples)
const
= 0;
30
31
//! Start encoding a new frame.
32
//!
33
//! @remarks
34
//! After this call, write() will store samples to the given @p frame_data
35
//! until @p frame_size bytes are written or end() is called.
36
virtual
void
begin
(
void
* frame_data,
size_t
frame_size) = 0;
37
38
//! Write samples into current frame.
39
//!
40
//! @b Parameters
41
//! - @p samples - samples to be encoded
42
//! - @p n_samples - number of samples to be encoded, for all channel
43
//!
44
//! @remarks
45
//! Encodes samples and writes to the current frame.
46
//!
47
//! @returns
48
//! number of samples encoded per channel. The returned value can be fewer than
49
//! @p n_samples if the frame is full and no more samples can be written to it.
50
//!
51
//! @pre
52
//! This method may be called only between begin() and end() calls.
53
virtual
size_t
write
(
const
sample_t
* samples,
size_t
n_samples) = 0;
54
55
//! Finish encoding current frame.
56
//!
57
//! @remarks
58
//! After this call, the frame is fully encoded and no more samples will be
59
//! written to the frame. A new frame should be started by calling begin().
60
virtual
void
end
() = 0;
61
};
62
63
}
// namespace audio
64
}
// namespace roc
65
66
#endif
// ROC_AUDIO_IFRAME_ENCODER_H_
roc::audio::IFrameEncoder
Audio frame encoder interface.
Definition
iframe_encoder.h:24
roc::audio::IFrameEncoder::begin
virtual void begin(void *frame_data, size_t frame_size)=0
Start encoding a new frame.
roc::audio::IFrameEncoder::encoded_byte_count
virtual size_t encoded_byte_count(size_t num_samples) const =0
Get encoded frame size in bytes for given number of samples per channel.
roc::audio::IFrameEncoder::end
virtual void end()=0
Finish encoding current frame.
roc::audio::IFrameEncoder::write
virtual size_t write(const sample_t *samples, size_t n_samples)=0
Write samples into current frame.
roc::audio
Audio frames and audio processing.
roc::audio::sample_t
float sample_t
Raw audio sample.
Definition
sample.h:22
roc
Root namespace.
packet.h
Packet.
sample.h
Audio sample.
stddefs.h
Commonly used types and functions.
units.h
Various units used in packets.
roc_audio
iframe_encoder.h
Generated by
1.17.0