Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
iframe_decoder.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_decoder.h
10
//! @brief Audio frame decoder interface.
11
12
#ifndef ROC_AUDIO_IFRAME_DECODER_H_
13
#define ROC_AUDIO_IFRAME_DECODER_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 decoder interface.
24
class
IFrameDecoder
{
25
public
:
26
virtual
~IFrameDecoder
();
27
28
//! Get decoded stream position.
29
//!
30
//! @returns
31
//! the position of the next sample that will be retrieved by read().
32
//!
33
//! @remarks
34
//! The decoded stream position is affected by begin(), read(), and shift() methods.
35
//! begin() changes it according to the provided frame position, however it depends
36
//! on the implementation how exactly. read() and shift() increase it by the number
37
//! of samples they returned.
38
virtual
packet::stream_timestamp_t
position
()
const
= 0;
39
40
//! Get number of samples available for decoding.
41
//!
42
//! @returns
43
//! number of available samples per channel, or zero if there are no more
44
//! samples in the current frame, or if begin() was not called yet.
45
//!
46
//! @remarks
47
//! The number of samples available is affected by begin(), read(), and shift(),
48
//! and end() methods. begin() resets it according to the provided frame size,
49
//! however it depends on the implementation how exactly. end() resets it to zero.
50
//! read() and shift() decrease it by the number of samples they returned.
51
virtual
packet::stream_timestamp_t
available
()
const
= 0;
52
53
//! Get number of samples per channel that can be decoded from given frame.
54
virtual
size_t
decoded_sample_count
(
const
void
* frame_data,
55
size_t
frame_size)
const
= 0;
56
57
//! Start decoding a new frame.
58
//!
59
//! @remarks
60
//! After this call, read() will retrieve samples from given @p frame_data, until
61
//! @p frame_size bytes are read or end() is called.
62
//!
63
//! @note
64
//! @p frame_position defines the position of the frame in the encoded stream.
65
//! Decoder updates the decoded stream position according to @p frame_position,
66
//! but not necessary to the same value. Encoded and decoded stream positions
67
//! may be slightly different, depending on the codec implementation.
68
virtual
void
begin
(
packet::stream_timestamp_t
frame_position,
69
const
void
* frame_data,
70
size_t
frame_size) = 0;
71
72
//! Read samples from current frame.
73
//!
74
//! @b Parameters
75
//! - @p samples - buffer to write decoded samples to
76
//! - @p n_samples - number of samples to be decoded per channel
77
//!
78
//! @remarks
79
//! Decodes samples from the current frame and writes them to the provided buffer.
80
//!
81
//! @returns
82
//! number of samples decoded per channel. The returned value can be fewer than
83
//! @p n_samples if there are no more samples in the current frame.
84
//!
85
//! @pre
86
//! This method may be called only between begin() and end() calls.
87
virtual
size_t
read
(
sample_t
* samples,
size_t
n_samples) = 0;
88
89
//! Shift samples from current frame.
90
//!
91
//! @b Parameters
92
//! - @p n_samples - number of samples to shift per channel
93
//!
94
//! @remarks
95
//! Shifts the given number of samples from the left, as if read() was called
96
//! and the result was dropped.
97
//!
98
//! @returns
99
//! number of samples shifted per channel. The returned value can be fewer than
100
//! @p n_samples if there are no more samples in the current frame.
101
//!
102
//! @pre
103
//! This method may be called only between begin() and end() calls.
104
virtual
size_t
shift
(
size_t
n_samples) = 0;
105
106
//! Finish decoding current frame.
107
//!
108
//! @remarks
109
//! After this call, the frame can't be read or shifted anymore. A new frame
110
//! should be started by calling begin().
111
virtual
void
end
() = 0;
112
};
113
114
}
// namespace audio
115
}
// namespace roc
116
117
#endif
// ROC_AUDIO_IFRAME_DECODER_H_
roc::audio::IFrameDecoder
Audio frame decoder interface.
Definition
iframe_decoder.h:24
roc::audio::IFrameDecoder::decoded_sample_count
virtual size_t decoded_sample_count(const void *frame_data, size_t frame_size) const =0
Get number of samples per channel that can be decoded from given frame.
roc::audio::IFrameDecoder::position
virtual packet::stream_timestamp_t position() const =0
Get decoded stream position.
roc::audio::IFrameDecoder::read
virtual size_t read(sample_t *samples, size_t n_samples)=0
Read samples from current frame.
roc::audio::IFrameDecoder::available
virtual packet::stream_timestamp_t available() const =0
Get number of samples available for decoding.
roc::audio::IFrameDecoder::shift
virtual size_t shift(size_t n_samples)=0
Shift samples from current frame.
roc::audio::IFrameDecoder::end
virtual void end()=0
Finish decoding current frame.
roc::audio::IFrameDecoder::begin
virtual void begin(packet::stream_timestamp_t frame_position, const void *frame_data, size_t frame_size)=0
Start decoding a new frame.
roc::audio
Audio frames and audio processing.
roc::audio::sample_t
float sample_t
Raw audio sample.
Definition
sample.h:22
roc::packet::stream_timestamp_t
uint32_t stream_timestamp_t
Packet stream timestamp.
Definition
units.h:36
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_decoder.h
Generated by
1.17.0