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 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
16#include "roc_audio/pcm_funcs.h"
18
19namespace roc {
20namespace audio {
21
22//! PCM decoder.
23class PCMDecoder : public IFrameDecoder, public core::NonCopyable<> {
24public:
25 //! Initialize.
26 explicit PCMDecoder(const PCMFuncs& funcs);
27
28 //! Get current stream position.
30
31 //! Get number of samples available for decoding.
33
34 //! Start decoding a new frame.
35 virtual void
36 begin(packet::timestamp_t frame_position, const void* frame_data, size_t frame_size);
37
38 //! Read samples from current frame.
39 virtual size_t
40 read(sample_t* samples, size_t n_samples, packet::channel_mask_t channels);
41
42 //! Shift samples from current frame.
43 virtual size_t shift(size_t n_samples);
44
45 //! Finish decoding current frame.
46 virtual void end();
47
48private:
49 const PCMFuncs& funcs_;
50
51 packet::timestamp_t stream_pos_;
52 packet::timestamp_t stream_avail_;
53
54 const void* frame_data_;
55 size_t frame_size_;
56 size_t frame_pos_;
57};
58
59} // namespace audio
60} // namespace roc
61
62#endif // ROC_AUDIO_PCM_DECODER_H_
Audio frame decoder interface.
virtual size_t shift(size_t n_samples)
Shift samples from current frame.
virtual packet::timestamp_t position() const
Get current stream position.
PCMDecoder(const PCMFuncs &funcs)
Initialize.
virtual void begin(packet::timestamp_t frame_position, const void *frame_data, size_t frame_size)
Start decoding a new frame.
virtual packet::timestamp_t available() const
Get number of samples available for decoding.
virtual size_t read(sample_t *samples, size_t n_samples, packet::channel_mask_t channels)
Read samples from current frame.
virtual void end()
Finish decoding current frame.
Base class for non-copyable objects.
Definition: noncopyable.h:23
Audio frame decoder interface.
float sample_t
Audio sample.
Definition: units.h:21
uint32_t timestamp_t
Audio packet timestamp.
Definition: units.h:46
uint32_t channel_mask_t
Bitmask of channels present in audio packet.
Definition: units.h:77
Root namespace.
Non-copyable object.
RTP PCM functions.
PCM function table.
Definition: pcm_funcs.h:23