Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
pcm_decoder.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 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/pcm_decoder.h
10
//! @brief PCM decoder.
11
12
#ifndef ROC_AUDIO_PCM_DECODER_H_
13
#define ROC_AUDIO_PCM_DECODER_H_
14
15
#include "
roc_audio/iframe_decoder.h
"
16
#include "
roc_audio/pcm_mapper.h
"
17
#include "
roc_audio/sample_spec.h
"
18
#include "
roc_core/noncopyable.h
"
19
20
namespace
roc
{
21
namespace
audio
{
22
23
//! PCM decoder.
24
class
PcmDecoder
:
public
IFrameDecoder
,
public
core::NonCopyable
<> {
25
public
:
26
//! Construction function.
27
static
IFrameDecoder
*
construct
(
core::IArena
& arena,
const
SampleSpec
& sample_spec);
28
29
//! Initialize.
30
PcmDecoder
(
const
SampleSpec
& sample_spec);
31
32
//! Get current stream position.
33
virtual
packet::stream_timestamp_t
position
()
const
;
34
35
//! Get number of samples available for decoding.
36
virtual
packet::stream_timestamp_t
available
()
const
;
37
38
//! Get number of samples per channel, that can be decoded from given frame.
39
virtual
size_t
decoded_sample_count
(
const
void
* frame_data,
size_t
frame_size)
const
;
40
41
//! Start decoding a new frame.
42
virtual
void
begin
(
packet::stream_timestamp_t
frame_position,
43
const
void
* frame_data,
44
size_t
frame_size);
45
46
//! Read samples from current frame.
47
virtual
size_t
read
(
sample_t
* samples,
size_t
n_samples);
48
49
//! Shift samples from current frame.
50
virtual
size_t
shift
(
size_t
n_samples);
51
52
//! Finish decoding current frame.
53
virtual
void
end
();
54
55
private
:
56
PcmMapper
pcm_mapper_;
57
const
size_t
n_chans_;
58
59
packet::stream_timestamp_t
stream_pos_;
60
packet::stream_timestamp_t
stream_avail_;
61
62
const
void
* frame_data_;
63
size_t
frame_byte_size_;
64
size_t
frame_bit_off_;
65
};
66
67
}
// namespace audio
68
}
// namespace roc
69
70
#endif
// ROC_AUDIO_PCM_DECODER_H_
roc::audio::IFrameDecoder
Audio frame decoder interface.
Definition
iframe_decoder.h:24
roc::audio::PcmDecoder::available
virtual packet::stream_timestamp_t available() const
Get number of samples available for decoding.
roc::audio::PcmDecoder::PcmDecoder
PcmDecoder(const SampleSpec &sample_spec)
Initialize.
roc::audio::PcmDecoder::shift
virtual size_t shift(size_t n_samples)
Shift samples from current frame.
roc::audio::PcmDecoder::read
virtual size_t read(sample_t *samples, size_t n_samples)
Read samples from current frame.
roc::audio::PcmDecoder::begin
virtual void begin(packet::stream_timestamp_t frame_position, const void *frame_data, size_t frame_size)
Start decoding a new frame.
roc::audio::PcmDecoder::position
virtual packet::stream_timestamp_t position() const
Get current stream position.
roc::audio::PcmDecoder::end
virtual void end()
Finish decoding current frame.
roc::audio::PcmDecoder::decoded_sample_count
virtual size_t decoded_sample_count(const void *frame_data, size_t frame_size) const
Get number of samples per channel, that can be decoded from given frame.
roc::audio::PcmDecoder::construct
static IFrameDecoder * construct(core::IArena &arena, const SampleSpec &sample_spec)
Construction function.
roc::audio::PcmMapper
PCM format mapper. Convert between PCM formats.
Definition
pcm_mapper.h:24
roc::audio::SampleSpec
Sample specification. Describes sample rate and channels.
Definition
sample_spec.h:30
roc::core::IArena
Memory arena interface.
Definition
iarena.h:23
roc::core::NonCopyable
Base class for non-copyable objects.
Definition
noncopyable.h:23
iframe_decoder.h
Audio frame decoder interface.
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.
noncopyable.h
Non-copyable object.
pcm_mapper.h
PCM format mapper.
sample_spec.h
Sample specifications.
roc_audio
pcm_decoder.h
Generated by
1.17.0