Arduino A2DP
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
A2DPDecoder Class Referenceabstract

Base class for a single A2DP codec's decode support: pairs an A2DP codec type and its SEP capability advertisement with an audio_tools::AudioDecoder that performs the actual decoding. Provide one concrete subclass per codec (see A2DPDecoderSBC, A2DPDecoderAAC) and register instances via BluetoothA2DPSink::add_decoder() - stream endpoint registration is driven entirely by what gets registered here. More...

#include <A2DPDecoder.h>

Inheritance diagram for A2DPDecoder:
A2DPDecoderAAC A2DPDecoderSBC

Public Member Functions

 A2DPDecoder (audio_tools::AudioDecoder &decoder)
 
virtual bool begin (const esp_a2d_mcc_t &mcc)
 
virtual void build_capability (esp_a2d_mcc_t &mcc)=0
 Fills in the SEP capability advertised for this codec at registration.
 
virtual esp_a2d_mct_t codec_type ()=0
 A2DP codec type this decoder handles (e.g. ESP_A2D_MCT_SBC)
 
virtual void end ()
 Closes the wrapped audio_tools decoder.
 
audio_tools::AudioInfo get_audio_info ()
 
virtual const char * mime ()=0
 MIME type of the codec this decoder handles (e.g. "audio/sbc")
 
virtual size_t write (const uint8_t *data, size_t len)
 

Protected Member Functions

virtual void parse_audio_info (const esp_a2d_mcc_t &mcc)=0
 

Protected Attributes

int bits_per_sample = 16
 
int channels = 2
 
audio_tools::AudioDecoder * p_decoder
 
audio_tools::CallbackStream pcm_stream
 
int sample_rate = 44100
 

Detailed Description

Base class for a single A2DP codec's decode support: pairs an A2DP codec type and its SEP capability advertisement with an audio_tools::AudioDecoder that performs the actual decoding. Provide one concrete subclass per codec (see A2DPDecoderSBC, A2DPDecoderAAC) and register instances via BluetoothA2DPSink::add_decoder() - stream endpoint registration is driven entirely by what gets registered here.

Author
Phil Schatzmann

Member Function Documentation

◆ begin()

virtual bool A2DPDecoder::begin ( const esp_a2d_mcc_t &  mcc)
inlinevirtual

Opens the wrapped audio_tools decoder for the negotiated SEP capability: calls parse_audio_info(mcc) (implemented per codec - most decoders self-detect sample rate/channels from the encoded stream and can leave sample_rate/channels at their defaults, but codecs whose wire format doesn't carry that info per-frame, e.g. AAC, need it to synthesize the framing their decoder expects - see A2DPDecoderAAC), then wires up the PCM output and audio-info-change notification and starts the decoder.

◆ build_capability()

virtual void A2DPDecoder::build_capability ( esp_a2d_mcc_t &  mcc)
pure virtual

Fills in the SEP capability advertised for this codec at registration.

Implemented in A2DPDecoderAAC, and A2DPDecoderSBC.

◆ codec_type()

virtual esp_a2d_mct_t A2DPDecoder::codec_type ( )
pure virtual

A2DP codec type this decoder handles (e.g. ESP_A2D_MCT_SBC)

Implemented in A2DPDecoderAAC, and A2DPDecoderSBC.

◆ get_audio_info()

audio_tools::AudioInfo A2DPDecoder::get_audio_info ( )
inline

Returns the most recently detected sample rate/channels (default AudioInfo values until the wrapped decoder has actually parsed them from the encoded stream)

◆ mime()

virtual const char * A2DPDecoder::mime ( )
pure virtual

MIME type of the codec this decoder handles (e.g. "audio/sbc")

Implemented in A2DPDecoderAAC, and A2DPDecoderSBC.

◆ parse_audio_info()

virtual void A2DPDecoder::parse_audio_info ( const esp_a2d_mcc_t &  mcc)
protectedpure virtual

Implemented in A2DPDecoderAAC, and A2DPDecoderSBC.

◆ write()

virtual size_t A2DPDecoder::write ( const uint8_t *  data,
size_t  len 
)
inlinevirtual

Feeds raw encoded bytes to the wrapped decoder; decoded PCM is forwarded automatically via pcm_stream

Reimplemented in A2DPDecoderAAC.


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