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

Audio frame encoder interface. More...

#include <iframe_encoder.h>

Inheritance diagram for roc::audio::IFrameEncoder:

Public Member Functions

virtual size_t encoded_size (size_t num_samples) const =0
 Get encoded frame size for given number of samples per channel. More...
virtual void begin (void *frame_data, size_t frame_size)=0
 Start encoding a new frame. More...
virtual size_t write (const sample_t *samples, size_t n_samples, packet::channel_mask_t channels)=0
 Write samples into current frame. More...
virtual void end ()=0
 Finish encoding current frame. More...

Detailed Description

Audio frame encoder interface.

Definition at line 24 of file iframe_encoder.h.

Member Function Documentation

virtual void roc::audio::IFrameEncoder::begin ( void *  frame_data,
size_t  frame_size 
pure virtual

Start encoding a new frame.

After this call, write() will store samples to the given frame_data until frame_size bytes are written or end() is called.

Implemented in roc::audio::PCMEncoder.

virtual size_t roc::audio::IFrameEncoder::encoded_size ( size_t  num_samples) const
pure virtual

Get encoded frame size for given number of samples per channel.

Implemented in roc::audio::PCMEncoder.

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

Finish encoding current frame.

After this call, the frame is fully encoded and no more samples will be written to the frame. A new frame should be started by calling begin().

Implemented in roc::audio::PCMEncoder.

virtual size_t roc::audio::IFrameEncoder::write ( const sample_t samples,
size_t  n_samples,
packet::channel_mask_t  channels 
pure virtual

Write samples into current frame.


  • samples - samples to be encoded
  • n_samples - number of samples to be encoded per channel
  • channels - channel mask of the samples to be encoded
Encodes samples and writes to the current frame.
number of samples encoded per channel. The returned value can be fewer than n_samples if the frame is full and no more samples can be written to it.
This method may be called only between begin() and end() calls.
Encoded and decoded channel masks may differ. If the provided samples have extra channels, they are ignored. If they don't have some channels, these channels are filled with zeros.

Implemented in roc::audio::PCMEncoder.

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