Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
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
19
20namespace roc {
21namespace audio {
22
23//! PCM decoder.
24class PcmDecoder : public IFrameDecoder, public core::NonCopyable<> {
25public:
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.
34
35 //! Get number of samples available for decoding.
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
55private:
56 PcmMapper pcm_mapper_;
57 const size_t n_chans_;
58
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_
Audio frame decoder interface.
virtual packet::stream_timestamp_t available() const
Get number of samples available for decoding.
PcmDecoder(const SampleSpec &sample_spec)
Initialize.
virtual size_t shift(size_t n_samples)
Shift samples from current frame.
virtual size_t read(sample_t *samples, size_t n_samples)
Read samples from current frame.
virtual void begin(packet::stream_timestamp_t frame_position, const void *frame_data, size_t frame_size)
Start decoding a new frame.
virtual packet::stream_timestamp_t position() const
Get current stream position.
virtual void end()
Finish decoding current frame.
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.
static IFrameDecoder * construct(core::IArena &arena, const SampleSpec &sample_spec)
Construction function.
PCM format mapper. Convert between PCM formats.
Definition pcm_mapper.h:24
Sample specification. Describes sample rate and channels.
Definition sample_spec.h:30
Memory arena interface.
Definition iarena.h:23
Base class for non-copyable objects.
Definition noncopyable.h:23
Audio frame decoder interface.
float sample_t
Raw audio sample.
Definition sample.h:22
uint32_t stream_timestamp_t
Packet stream timestamp.
Definition units.h:36
Root namespace.
Non-copyable object.
PCM format mapper.
Sample specifications.