File pipewire-issue1482-use_fullband_in_aac.patch of Package pipewire

diff --git a/spa/plugins/bluez5/a2dp-codec-aac.c b/spa/plugins/bluez5/a2dp-codec-aac.c
index 27b4cfbb8..40a24b87b 100644
--- a/spa/plugins/bluez5/a2dp-codec-aac.c
+++ b/spa/plugins/bluez5/a2dp-codec-aac.c
@@ -64,9 +64,11 @@ static int codec_fill_caps(const struct a2dp_codec *codec, uint32_t flags,
 	static const a2dp_aac_t a2dp_aac = {
 		.object_type =
 			/* NOTE: AAC Long Term Prediction and AAC Scalable are
-			 *       not supported by the FDK-AAC library. */
-			AAC_OBJECT_TYPE_MPEG2_AAC_LC |
-			AAC_OBJECT_TYPE_MPEG4_AAC_LC,
+			 *       supported by the FDK-AAC library. */
+			AAC_OBJECT_TYPE_MPEG4_AAC_SCA |
+			AAC_OBJECT_TYPE_MPEG4_AAC_LTP |
+			AAC_OBJECT_TYPE_MPEG4_AAC_LC |
+			AAC_OBJECT_TYPE_MPEG2_AAC_LC,
 		AAC_INIT_FREQUENCY(
 			AAC_SAMPLING_FREQ_8000 |
 			AAC_SAMPLING_FREQ_11025 |
@@ -141,9 +143,9 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags,
 	else if (conf.object_type & AAC_OBJECT_TYPE_MPEG4_AAC_LC)
 		conf.object_type = AAC_OBJECT_TYPE_MPEG4_AAC_LC;
 	else if (conf.object_type & AAC_OBJECT_TYPE_MPEG4_AAC_LTP)
-		return -ENOTSUP;  /* Not supported by FDK-AAC */
+		conf.object_type = AAC_OBJECT_TYPE_MPEG4_AAC_LTP;
 	else if (conf.object_type & AAC_OBJECT_TYPE_MPEG4_AAC_SCA)
-		return -ENOTSUP;  /* Not supported by FDK-AAC */
+		conf.object_type = AAC_OBJECT_TYPE_MPEG4_AAC_SCA;
 	else
 		return -ENOTSUP;
 
@@ -250,7 +252,7 @@ static void *codec_init_props(const struct a2dp_codec *codec, const struct spa_d
 	if (settings == NULL || (str = spa_dict_lookup(settings, "bluez5.a2dp.aac.bitratemode")) == NULL)
 		str = "0";
 
-	p->bitratemode = SPA_CLAMP(atoi(str), 0, 5);
+	p->bitratemode = SPA_CLAMP(atoi(str), 0, 8);
 	return p;
 }
 
@@ -292,14 +294,32 @@ static void *codec_init(const struct a2dp_codec *codec, uint32_t flags,
 	if (res != AACENC_OK)
 		goto error;
 
-	if (conf->object_type != AAC_OBJECT_TYPE_MPEG2_AAC_LC &&
-	    conf->object_type != AAC_OBJECT_TYPE_MPEG4_AAC_LC) {
+	if (conf->object_type != AAC_OBJECT_TYPE_MPEG4_AAC_SCA &&
+	    conf->object_type != AAC_OBJECT_TYPE_MPEG4_AAC_LTP &&
+	    conf->object_type != AAC_OBJECT_TYPE_MPEG4_AAC_LC &&
+	    conf->object_type != AAC_OBJECT_TYPE_MPEG2_AAC_LC) {
 		res = -EINVAL;
 		goto error;
 	}
-	res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_AAC_LC);
-	if (res != AACENC_OK)
-		goto error;
+
+	if (conf->object_type != AAC_OBJECT_TYPE_MPEG4_AAC_SCA) {
+		res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_AAC_SCAL);
+		if (res != AACENC_OK)
+			goto error;
+	} else if (conf->object_type != AAC_OBJECT_TYPE_MPEG4_AAC_LTP) {
+		res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_AAC_LTP);
+		if (res != AACENC_OK)
+			goto error;
+	} else if (conf->object_type != AAC_OBJECT_TYPE_MPEG4_AAC_LC) {
+		res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_AAC_LC);
+		if (res != AACENC_OK)
+			goto error;
+	} else if (conf->object_type != AAC_OBJECT_TYPE_MPEG2_AAC_LC) {
+		res = aacEncoder_SetParam(this->aacenc, AACENC_AOT, AOT_AAC_LC);
+		if (res != AACENC_OK)
+			goto error;
+	} else
+		return -EINVAL;
 
 	res = aacEncoder_SetParam(this->aacenc, AACENC_SAMPLERATE, this->rate);
 	if (res != AACENC_OK)
@@ -309,6 +329,10 @@ 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);
openSUSE Build Service is sponsored by