arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
ContainerM4A Class Reference

M4A Demuxer that extracts audio from M4A/MP4 containers. The audio is decoded into pcm with the help of the provided decoder. format. More...

#include <ContainerM4A.h>

Inheritance diagram for ContainerM4A:
ContainerDecoder AudioDecoder AudioWriter AudioInfoSource AudioInfoSupport

Public Member Functions

 ContainerM4A ()
 Default constructor: If no decoder is provided, the raw audio data is provided to the defined output.
 
 ContainerM4A (MultiDecoder &decoder)
 Constructor with decoder. Sets up the demuxer and decoder notification.
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
bool begin () override
 Initialize the demuxer and decoder.
 
virtual bool begin (AudioInfo info) override
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
void end () override
 End the demuxer and decoder, releasing resources.
 
M4AAudioDemuxergetDemuxer ()
 
PrintgetOutput ()
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
bool isResultPCM () override
 Returns true if the result is PCM (decoder is present).
 
 operator bool () override
 Returns true if the demuxer is active.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
void setAudioInfo (AudioInfo from) override
 for most decoders this is not needed
 
virtual void setChunkOffsetsBuffer (BaseBuffer< uint32_t > &buffer)
 Sets the buffer to use for sample sizes. This is currently not used!
 
virtual bool setCodecConfig (const uint8_t *data, size_t len)
 Some decoders need e.g. a magic cookie to provide the relevant info for decoding.
 
bool setDecoder (MultiDecoder &decoder)
 Sets the decoder to use for audio frames.
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
virtual void setOutput (AudioOutput &out_stream)
 Defines where the decoded result is written to.
 
virtual void setOutput (AudioStream &out_stream)
 Defines where the decoded result is written to.
 
void setOutput (Print &out_stream) override
 Set the output stream for decoded or raw audio.
 
virtual void setSampleSizesBuffer (BaseBuffer< stsz_sample_size_t > &buffer)
 Sets the buffer to use for sample sizes. You can use this to provide a custom buffer that does not rely on RAM (e.g a file based buffer or one using Redis)
 
size_t write (const uint8_t *data, size_t len) override
 Feed data to the demuxer for parsing.
 

Public Attributes

int id
 custom id to be used by application
 

Protected Member Functions

void notifyAudioChange (AudioInfo info)
 
void writeBlocking (Print *out, uint8_t *data, size_t len)
 

Static Protected Member Functions

static void decodeAudio (const M4AAudioDemuxer::Frame &frame, void *ref)
 Static callback for demuxed audio frames. Handles decoder selection and magic cookie for ALAC.
 

Protected Attributes

M4AAudioDemuxer demux
 Internal demuxer instance.
 
AudioInfo info
 
bool is_active = false
 True if demuxer is active.
 
bool is_magic_cookie_processed
 True if ALAC magic cookie has been processed.
 
bool is_notify_active = true
 
Vector< AudioInfoSupport * > notify_vector
 
MultiDecoderp_decoder = nullptr
 Pointer to the MultiDecoder.
 
Printp_print = nullptr
 

Detailed Description

M4A Demuxer that extracts audio from M4A/MP4 containers. The audio is decoded into pcm with the help of the provided decoder. format.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ ContainerM4A()

ContainerM4A ( MultiDecoder decoder)
inline

Constructor with decoder. Sets up the demuxer and decoder notification.

Parameters
decoderReference to a MultiDecoder for PCM output.

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ begin() [1/2]

bool begin ( )
inlineoverridevirtual

Initialize the demuxer and decoder.

Returns
true on success.

Reimplemented from AudioDecoder.

◆ begin() [2/2]

virtual bool begin ( AudioInfo  info)
inlineoverridevirtualinherited

Reimplemented from AudioWriter.

◆ decodeAudio()

static void decodeAudio ( const M4AAudioDemuxer::Frame frame,
void *  ref 
)
inlinestaticprotected

Static callback for demuxed audio frames. Handles decoder selection and magic cookie for ALAC.

Parameters
frameThe demuxed audio frame.
refReference to the ContainerM4A instance.

◆ end()

void end ( )
inlineoverridevirtual

End the demuxer and decoder, releasing resources.

Reimplemented from AudioDecoder.

◆ isResultPCM()

bool isResultPCM ( )
inlineoverridevirtual

Returns true if the result is PCM (decoder is present).

Returns
true if PCM output, false otherwise.

Reimplemented from ContainerDecoder.

◆ operator bool()

operator bool ( )
inlineoverridevirtual

Returns true if the demuxer is active.

Returns
true if active, false otherwise.

Implements AudioWriter.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  from)
inlineoverridevirtualinherited

for most decoders this is not needed

Implements AudioWriter.

Reimplemented in GGWaveDecoder, DecoderALAC, DecoderL8, OpusAudioDecoder, CodecNOP, and G7xxDecoder.

◆ setChunkOffsetsBuffer()

virtual void setChunkOffsetsBuffer ( BaseBuffer< uint32_t > &  buffer)
inlinevirtual

Sets the buffer to use for sample sizes. This is currently not used!

Parameters
bufferReference to the buffer to use.

◆ setCodecConfig()

virtual bool setCodecConfig ( const uint8_t *  data,
size_t  len 
)
inlinevirtualinherited

Some decoders need e.g. a magic cookie to provide the relevant info for decoding.

Reimplemented in DecoderALAC, and MultiDecoder.

◆ setDecoder()

bool setDecoder ( MultiDecoder decoder)
inline

Sets the decoder to use for audio frames.

Parameters
decoderReference to a MultiDecoder for PCM output.
Returns
true if set successfully, false otherwise.

◆ setOutput() [1/3]

virtual void setOutput ( AudioOutput out_stream)
inlinevirtualinherited

Defines where the decoded result is written to.

Reimplemented in ADTSDecoder, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.

◆ setOutput() [2/3]

virtual void setOutput ( AudioStream out_stream)
inlinevirtualinherited

Defines where the decoded result is written to.

Reimplemented in ADTSDecoder, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.

◆ setOutput() [3/3]

void setOutput ( Print out_stream)
inlineoverridevirtual

Set the output stream for decoded or raw audio.

Parameters
out_streamOutput AudioStream.

Reimplemented from AudioDecoder.

◆ setSampleSizesBuffer()

virtual void setSampleSizesBuffer ( BaseBuffer< stsz_sample_size_t > &  buffer)
inlinevirtual

Sets the buffer to use for sample sizes. You can use this to provide a custom buffer that does not rely on RAM (e.g a file based buffer or one using Redis)

Parameters
bufferReference to the buffer to use.

◆ write()

size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Feed data to the demuxer for parsing.

Parameters
dataPointer to input data.
lenLength of input data.
Returns
Number of bytes processed (always len).

Implements AudioWriter.

Member Data Documentation

◆ is_magic_cookie_processed

bool is_magic_cookie_processed
protected
Initial value:
=
false

True if ALAC magic cookie has been processed.


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