Arduino LibHelix
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
libhelix::AACDecoderHelix Class Reference

A simple Arduino API for the libhelix AAC decoder. The data us provided with the help of write() calls. The decoded result is available either via a callback method or via an output stream. More...

#include <AACDecoderHelix.h>

Inheritance diagram for libhelix::AACDecoderHelix:
libhelix::CommonHelix

Public Member Functions

 AACDecoderHelix (Print &output)
 
 AACDecoderHelix (AACDataCallback dataCallback)
 
void setInfoCallback (AACInfoCallback cb, void *caller=nullptr)
 
void setDataCallback (AACDataCallback cb)
 
_AACFrameInfo audioInfo ()
 Provides the last available _AACFrameInfo_t.
 
virtual void end () override
 Releases the reserved memory.
 
size_t maxFrameSize () override
 
size_t maxPCMSize () override
 
void setAudioInfo (int channels, int samplerate)
 Used by M3A format.
 
void setOutput (Print &output)
 
virtual bool begin ()
 Starts the processing.
 
virtual size_t write (const void *in_ptr, size_t in_size)
 decodes the next segments from the input. The data can be provided in one short or in small incremental pieces. It is suggested to be called in the Arduino Loop. If the provided data does not fit into the buffer it is split up into small pieces that fit
 
 operator bool ()
 returns true if active
 
virtual void setDelay (int delayMs)
 Defines the delay that is added at each segment.
 
uint64_t timeOfLastWrite ()
 Provides the timestamp in ms of last write.
 
uint64_t timeOfLastResult ()
 Provides the timestamp in ms of last decoded result.
 
void flush ()
 Decode open packets.
 
void setMaxFrameSize (size_t len)
 Define your optimized maximum frame size in bytes.
 
void setMaxPCMSize (size_t len)
 Define your optimized maximum pcm buffer size in bytes.
 
void setRaw (bool)
 Obsolete!
 

Protected Member Functions

int minFrameBufferSize () override
 Prevent error in underflow detection of decode.
 
virtual bool allocateDecoder () override
 Allocate the decoder.
 
int findSynchWord (int offset=0) override
 finds the sync word in the buffer
 
int decode () override
 decods the data and removes the decoded frame from the buffer
 
void provideResult (_AACFrameInfo &info)
 
bool presync ()
 make sure that we start with a valid sync: remove ID3 data
 
bool resynch (int rc)
 
bool removeInvalidData (int pos)
 
virtual size_t writeChunk (const void *in_ptr, size_t in_size)
 

Protected Attributes

HAACDecoder decoder = nullptr
 
AACDataCallback pcmCallback = nullptr
 
AACInfoCallback infoCallback = nullptr
 
_AACFrameInfo aacFrameInfo
 
void * p_caller_ref = nullptr
 
void * p_caller_data = nullptr
 
bool active = false
 
bool is_raw = false
 
Vector< uint8_t > pcm_buffer {0}
 
SingleBuffer< uint8_t > frame_buffer {0}
 
size_t max_frame_size = 0
 
size_t max_pcm_size = 0
 
size_t frame_counter = 0
 
int delay_ms = -1
 
uint64_t time_last_write = 0
 
uint64_t time_last_result = 0
 
Print * out = nullptr
 

Detailed Description

A simple Arduino API for the libhelix AAC decoder. The data us provided with the help of write() calls. The decoded result is available either via a callback method or via an output stream.

Author
Phil Schatzmann

Member Function Documentation

◆ maxFrameSize()

size_t libhelix::AACDecoderHelix::maxFrameSize ( )
inlineoverridevirtual

Provides the maximum frame size in bytes - this is allocated on the heap and you can reduce the heap size my minimizing this value

Implements libhelix::CommonHelix.

◆ maxPCMSize()

size_t libhelix::AACDecoderHelix::maxPCMSize ( )
inlineoverridevirtual

Provides the maximum pcm buffer size in bytes - this is allocated on the heap and you can reduce the heap size my minimizing this value

Implements libhelix::CommonHelix.

◆ removeInvalidData()

bool libhelix::CommonHelix::removeInvalidData ( int  pos)
inlineprotectedinherited

removes invalid data not starting with a synch word.

Returns
Returns true if we still have data to be played

◆ resynch()

bool libhelix::CommonHelix::resynch ( int  rc)
inlineprotectedinherited

advance on invalid data, returns true if we need to continue the processing

◆ writeChunk()

virtual size_t libhelix::CommonHelix::writeChunk ( const void *  in_ptr,
size_t  in_size 
)
inlineprotectedvirtualinherited

Prevent bug in underflow detection for AAC


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