Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::audio::IFrameDecoder Class Referenceabstract

Audio frame decoder interface. More...

#include <iframe_decoder.h>

Inheritance diagram for roc::audio::IFrameDecoder:

Public Member Functions

virtual packet::stream_timestamp_t position () const =0
 Get decoded stream position. More...
 
virtual packet::stream_timestamp_t available () const =0
 Get number of samples available for decoding. More...
 
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. More...
 
virtual void begin (packet::stream_timestamp_t frame_position, const void *frame_data, size_t frame_size)=0
 Start decoding a new frame. More...
 
virtual size_t read (sample_t *samples, size_t n_samples)=0
 Read samples from current frame. More...
 
virtual size_t shift (size_t n_samples)=0
 Shift samples from current frame. More...
 
virtual void end ()=0
 Finish decoding current frame. More...
 

Detailed Description

Audio frame decoder interface.

Definition at line 24 of file iframe_decoder.h.

Member Function Documentation

◆ available()

virtual packet::stream_timestamp_t roc::audio::IFrameDecoder::available ( ) const
pure virtual

Get number of samples available for decoding.

Returns
number of available samples per channel, or zero if there are no more samples in the current frame, or if begin() was not called yet.
Remarks
The number of samples available is affected by begin(), read(), and shift(), and end() methods. begin() resets it according to the provided frame size, however it depends on the implementation how exactly. end() resets it to zero. read() and shift() decrease it by the number of samples they returned.

Implemented in roc::audio::PcmDecoder.

◆ begin()

virtual void roc::audio::IFrameDecoder::begin ( packet::stream_timestamp_t  frame_position,
const void *  frame_data,
size_t  frame_size 
)
pure virtual

Start decoding a new frame.

Remarks
After this call, read() will retrieve samples from given frame_data, until frame_size bytes are read or end() is called.
Note
frame_position defines the position of the frame in the encoded stream. Decoder updates the decoded stream position according to frame_position, but not necessary to the same value. Encoded and decoded stream positions may be slightly different, depending on the codec implementation.

Implemented in roc::audio::PcmDecoder.

◆ decoded_sample_count()

virtual size_t roc::audio::IFrameDecoder::decoded_sample_count ( const void *  frame_data,
size_t  frame_size 
) const
pure virtual

Get number of samples per channel that can be decoded from given frame.

Implemented in roc::audio::PcmDecoder.

◆ end()

virtual void roc::audio::IFrameDecoder::end ( )
pure virtual

Finish decoding current frame.

Remarks
After this call, the frame can't be read or shifted anymore. A new frame should be started by calling begin().

Implemented in roc::audio::PcmDecoder.

◆ position()

virtual packet::stream_timestamp_t roc::audio::IFrameDecoder::position ( ) const
pure virtual

Get decoded stream position.

Returns
the position of the next sample that will be retrieved by read().
Remarks
The decoded stream position is affected by begin(), read(), and shift() methods. begin() changes it according to the provided frame position, however it depends on the implementation how exactly. read() and shift() increase it by the number of samples they returned.

Implemented in roc::audio::PcmDecoder.

◆ read()

virtual size_t roc::audio::IFrameDecoder::read ( sample_t samples,
size_t  n_samples 
)
pure virtual

Read samples from current frame.

Parameters

  • samples - buffer to write decoded samples to
  • n_samples - number of samples to be decoded per channel
Remarks
Decodes samples from the current frame and writes them to the provided buffer.
Returns
number of samples decoded per channel. The returned value can be fewer than n_samples if there are no more samples in the current frame.
Precondition
This method may be called only between begin() and end() calls.

Implemented in roc::audio::PcmDecoder.

◆ shift()

virtual size_t roc::audio::IFrameDecoder::shift ( size_t  n_samples)
pure virtual

Shift samples from current frame.

Parameters

  • n_samples - number of samples to shift per channel
Remarks
Shifts the given number of samples from the left, as if read() was called and the result was dropped.
Returns
number of samples shifted per channel. The returned value can be fewer than n_samples if there are no more samples in the current frame.
Precondition
This method may be called only between begin() and end() calls.

Implemented in roc::audio::PcmDecoder.


The documentation for this class was generated from the following file: