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 //! Initialize.
27 explicit PcmDecoder(const PcmFormat& pcm_format, const SampleSpec& sample_spec);
28
29 //! Get current stream position.
31
32 //! Get number of samples available for decoding.
34
35 //! Get number of samples per channel, that can be decoded from given frame.
36 virtual size_t decoded_sample_count(const void* frame_data, size_t frame_size) const;
37
38 //! Start decoding a new frame.
39 virtual void
40 begin(packet::timestamp_t frame_position, const void* frame_data, size_t frame_size);
41
42 //! Read samples from current frame.
43 virtual size_t read(sample_t* samples, size_t n_samples);
44
45 //! Shift samples from current frame.
46 virtual size_t shift(size_t n_samples);
47
48 //! Finish decoding current frame.
49 virtual void end();
50
51private:
52 PcmMapper pcm_mapper_;
53 const size_t n_chans_;
54
55 packet::timestamp_t stream_pos_;
56 packet::timestamp_t stream_avail_;
57
58 const void* frame_data_;
59 size_t frame_byte_size_;
60 size_t frame_bit_off_;
61};
62
63} // namespace audio
64} // namespace roc
65
66#endif // ROC_AUDIO_PCM_DECODER_H_
Audio frame decoder interface.
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 packet::timestamp_t available() const
Get number of samples available for decoding.
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.
virtual packet::timestamp_t position() const
Get current stream position.
virtual void begin(packet::timestamp_t frame_position, const void *frame_data, size_t frame_size)
Start decoding a new frame.
PcmDecoder(const PcmFormat &pcm_format, const SampleSpec &sample_spec)
Initialize.
PCM format mapper. Convert between PCM formats.
Definition pcm_mapper.h:23
Sample stream specification. Defines sample rate and channel layout.
Definition sample_spec.h:24
Base class for non-copyable objects.
Definition noncopyable.h:23
Audio frame decoder interface.
float sample_t
Audio sample.
Definition sample.h:22
uint32_t timestamp_t
Audio packet timestamp.
Definition units.h:25
Root namespace.
Non-copyable object.
PCM format mapper.
Sample specifications.
PCM format description.
Definition pcm_format.h:58