Arduino LibHelix
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
libhelix::CommonHelix Class Referenceabstract

Common Simple Arduino API. More...

#include <CommonHelix.h>

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

Public Member Functions

void setOutput (Print &output)
 
virtual bool begin ()
 Starts the processing.
 
virtual void end ()
 Releases the reserved memory.
 
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 big 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
 
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 ()
 Decodes all open packets, including the last frame. Call it at the end of the stream. A frame is only decoded when a sync word follows it, so flush() appends an end marker (a valid frame header) for the decoding and removes it again. A partially received frame is not decoded.
 
virtual size_t maxFrameSize ()=0
 
void setMaxFrameSize (size_t len)
 Define your optimized maximum frame size in bytes.
 
virtual size_t maxPCMSize ()=0
 
void setMaxPCMSize (size_t len)
 Define your optimized maximum pcm buffer size in bytes.
 
void setReference (void *ref)
 
void setMaxPCMWriteSize (int size)
 Defines the max chunk size that is wrtten to out (Arduino only)
 

Protected Member Functions

int decodableBytes ()
 the bytes that the decoders may use for a frame
 
virtual const uint8_t * endSyncWord ()
 the end marker appended by flush(): a valid ADTS header (AAC)
 
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)
 Decoding Loop: We decode the procided data until we run out of data.
 
void decodeAvailable ()
 Decodes all frames that are complete enough to be decoded.
 
void discardUnusableData ()
 
size_t writeToOut (uint8_t *data, size_t len)
 
virtual int decode ()=0
 Decode w/o parsing.
 
virtual bool allocateDecoder ()=0
 Allocate the decoder.
 
virtual int findSynchWord (int offset=0)=0
 
virtual int minFrameBufferSize ()
 Provides the actual minimum frame buffer size.
 
virtual void setMinFrameBufferSize (int size)
 

Protected Attributes

int reserved_tail = 0
 
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
 
size_t max_write_size = 1024
 
int delay_ms = -1
 
int parse_0_count = 0
 
int min_frame_buffer_size = 0
 
uint64_t time_last_write = 0
 
uint64_t time_last_result = 0
 
void * p_caller_ref = nullptr
 
Print * out = nullptr
 

Static Protected Attributes

static const int END_MARKER_LEN = 4
 

Detailed Description

Common Simple Arduino API.

Author
Phil Schatzmann

Member Function Documentation

◆ allocateDecoder()

virtual bool libhelix::CommonHelix::allocateDecoder ( )
protectedpure virtual

Allocate the decoder.

Implemented in libhelix::AACDecoderHelix, and libhelix::MP3DecoderHelix.

◆ decode()

virtual int libhelix::CommonHelix::decode ( )
protectedpure virtual

Decode w/o parsing.

Implemented in libhelix::AACDecoderHelix, and libhelix::MP3DecoderHelix.

◆ discardUnusableData()

void libhelix::CommonHelix::discardUnusableData ( )
inlineprotected

Removes the data up to the next sync word after the first byte. If there is no further sync word the whole buffer is dropped.

◆ end()

virtual void libhelix::CommonHelix::end ( )
inlinevirtual

Releases the reserved memory.

Reimplemented in libhelix::AACDecoderHelix, and libhelix::MP3DecoderHelix.

◆ endSyncWord()

virtual const uint8_t * libhelix::CommonHelix::endSyncWord ( )
inlineprotectedvirtual

the end marker appended by flush(): a valid ADTS header (AAC)

Reimplemented in libhelix::MP3DecoderHelix.

◆ findSynchWord()

virtual int libhelix::CommonHelix::findSynchWord ( int  offset = 0)
protectedpure virtual

Finds the synchronization word in the frame buffer (starting from the indicated offset)

Implemented in libhelix::AACDecoderHelix, and libhelix::MP3DecoderHelix.

◆ maxFrameSize()

virtual size_t libhelix::CommonHelix::maxFrameSize ( )
pure virtual

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

Implemented in libhelix::AACDecoderHelix, and libhelix::MP3DecoderHelix.

◆ maxPCMSize()

virtual size_t libhelix::CommonHelix::maxPCMSize ( )
pure virtual

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

Implemented in libhelix::AACDecoderHelix, and libhelix::MP3DecoderHelix.

◆ removeInvalidData()

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

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)
inlineprotected

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

◆ setMinFrameBufferSize()

virtual void libhelix::CommonHelix::setMinFrameBufferSize ( int  size)
inlineprotectedvirtual

Defines the minimum frame buffer size which is required before starting the decoding

◆ setReference()

void libhelix::CommonHelix::setReference ( void *  ref)
inline

Define some additional information which will be provided back in the callbacks


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