[Feature Request] Custom AAC bitrate and band limit
The AAC Bluetooth codec appears to be defaulting to a default band limit of 17 kHz and bitrate of 256 kbps.
I was able to get the band limit up to 20 kHz and bitrate up to 320 kbps using AirPods Pro with the example code change below.
I am thinking a good way to integrate this would be to add a bitrate and band limit override option. I would encourage defaulting to a 20 kHz band limit, as there is more than enough bitrate even at the default to allow this.
diff --git a/spa/plugins/bluez5/a2dp-codec-aac.c b/spa/plugins/bluez5/a2dp-codec-aac.c
index 27b4cfbb8..685dc355d 100644
--- a/spa/plugins/bluez5/a2dp-codec-aac.c
+++ b/spa/plugins/bluez5/a2dp-codec-aac.c
@@ -115,12 +115,12 @@ aac_channel_modes[] = {
static int get_valid_aac_bitrate(a2dp_aac_t *conf)
{
- if (AAC_GET_BITRATE(*conf) < MIN_AAC_BITRATE) {
+ //if (AAC_GET_BITRATE(*conf) < MIN_AAC_BITRATE) {
/* Unknown (0) or bogus bitrate */
return DEFAULT_AAC_BITRATE;
- } else {
- return SPA_MIN(AAC_GET_BITRATE(*conf), DEFAULT_AAC_BITRATE);
- }
+ //} else {
+ // return SPA_MIN(AAC_GET_BITRATE(*conf), DEFAULT_AAC_BITRATE);
+ //}
}
static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags,
@@ -309,6 +309,11 @@ static void *codec_init(const struct a2dp_codec *codec, uint32_t flags,
if (res != AACENC_OK)
goto error;
+ res = aacEncoder_SetParam(this->aacenc, AACENC_BANDWIDTH,
+ 20000);
+ if (res != AACENC_OK)
+ goto error;
+
if (conf->vbr) {
res = aacEncoder_SetParam(this->aacenc, AACENC_BITRATEMODE,
bitratemode);