bluez5: add AAC-ELD vendor codec used by Airpods

Add AAC-ELD vendor codec.

This is based on the documentation by Sa Xiao:

Link: https://github.com/wasdwasd0105/PicoW-usb2bt-audio/blob/main/aac-eld-apple.md
This commit is contained in:
Pauli Virtanen 2026-04-26 14:01:31 +03:00
parent 0f8d5c6e57
commit f06f0db31b
8 changed files with 901 additions and 0 deletions

View file

@ -307,6 +307,25 @@
(a).data = ((freq) & OPUS_G_FREQUENCY_MASK) | ((dur) & OPUS_G_DURATION_MASK) | ((ch) & OPUS_G_CHANNELS_MASK)
#define AAC_ELD_A_VENDOR_ID 0x0000004C
#define AAC_ELD_A_CODEC_ID 0x8001
#define AAC_ELD_A_GET_AOT(a) ((a).aot[0] << 8 | (a).aot[1])
#define AAC_ELD_A_GET_FREQ(a) (((a).freq[0] << 8 | (a).freq[1]) >> 4)
#define AAC_ELD_A_GET_CH(a) ((a).freq[1] & 0x0f)
#define AAC_ELD_A_GET_FLAGS(a) ((a).bitrate[0] & 0x80)
#define AAC_ELD_A_GET_BITRATE(a) (((a).bitrate[0] & 0x7f) << 16 | (a).bitrate[1] << 8 | (a).bitrate[0])
#define AAC_ELD_A_INIT_AOT(b) .aot = { ((b) >> 8), (b) & 0xff }
#define AAC_ELD_A_INIT_FREQ_CH(f, ch) .freq = { ((f) >> 4), (((f) << 4) & 0xf0) | ((ch) & 0x0f) }
#define AAC_ELD_A_INIT_FLAGS_BITRATE(f, br) .bitrate = { ((f) & 0x80) | (((br) >> 16) & 0x7f), ((br) >> 8) & 0xff, ((br) & 0xff) }
#define AAC_ELD_A_AOT_AAC_ELD 0x0080
#define AAC_ELD_A_FREQ_48000 0x008
#define AAC_ELD_A_CH_MONO 0x8
#define AAC_ELD_A_CH_STEREO 0x4
#define AAC_ELD_A_FLAG_VBR 0x80
typedef struct {
uint32_t vendor_id;
uint16_t codec_id;
@ -486,6 +505,14 @@ typedef struct {
uint8_t data;
} __attribute__ ((packed)) a2dp_opus_g_t;
typedef struct {
a2dp_vendor_codec_t info;
uint8_t aot[2];
uint8_t freq[2];
uint8_t reserved;
uint8_t bitrate[3];
} __attribute__ ((packed)) a2dp_aac_eld_a_t;
#define ASHA_CODEC_G722 0x63
#endif