BT: AptxAdaptive LE/LEX codec and AAC ABR AIDL Changes
AptxAdaptive LE/LEX codec and AAC ABR AIDL side changes
Bug: 254567319
Tag: #feature
Test: m android.hardware.bluetooth.audio-freeze-api &&
m android.hardware.bluetooth.audio-update-api &&
atest VtsHalBluetoothAudioTargetTest
Change-Id: I74a2df64ba6ef2ae02e08850b0f6c7784b24b02b
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacCapabilities.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacCapabilities.aidl
index 899b8ca..e548cd3 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacCapabilities.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacCapabilities.aidl
@@ -39,4 +39,5 @@
android.hardware.bluetooth.audio.ChannelMode[] channelMode;
boolean variableBitRateSupported;
byte[] bitsPerSample;
+ boolean adaptiveBitRateSupported;
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacConfiguration.aidl
index 6adef6d..29ab8ce 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacConfiguration.aidl
@@ -39,4 +39,5 @@
android.hardware.bluetooth.audio.ChannelMode channelMode;
boolean variableBitRateEnabled;
byte bitsPerSample;
+ boolean adaptiveBitRateSupported;
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveLeCapabilities.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveLeCapabilities.aidl
new file mode 100644
index 0000000..c9d3cde
--- /dev/null
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveLeCapabilities.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.bluetooth.audio;
+@VintfStability
+parcelable AptxAdaptiveLeCapabilities {
+ byte[] pcmBitDepth;
+ int[] samplingFrequencyHz;
+ int[] frameDurationUs;
+ int[] octetsPerFrame;
+ byte[] blocksPerSdu;
+}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveLeConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveLeConfiguration.aidl
new file mode 100644
index 0000000..76df4ed
--- /dev/null
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveLeConfiguration.aidl
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.bluetooth.audio;
+@VintfStability
+parcelable AptxAdaptiveLeConfiguration {
+ byte pcmBitDepth;
+ int samplingFrequencyHz;
+ int frameDurationUs;
+ int octetsPerFrame;
+ byte blocksPerSdu;
+ int codecMode;
+}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
index d1723e6..3e204f9 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
@@ -44,4 +44,6 @@
VENDOR = 7,
APTX_ADAPTIVE = 8,
OPUS = 9,
+ APTX_ADAPTIVE_LE = 10,
+ APTX_ADAPTIVE_LEX = 11,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
index bb3d7e4..031ee67 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
@@ -36,6 +36,7 @@
union LeAudioCodecConfiguration {
android.hardware.bluetooth.audio.Lc3Configuration lc3Config;
android.hardware.bluetooth.audio.LeAudioCodecConfiguration.VendorConfiguration vendorConfig;
+ android.hardware.bluetooth.audio.AptxAdaptiveLeConfiguration aptxAdaptiveLeConfig;
@VintfStability
parcelable VendorConfiguration {
ParcelableHolder extension;
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
index 679655c..2d9ebae 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
@@ -38,6 +38,7 @@
android.hardware.bluetooth.audio.LeAudioConfiguration.StreamMap[] streamMap;
int peerDelayUs;
android.hardware.bluetooth.audio.LeAudioCodecConfiguration leAudioCodecConfig;
+ @nullable byte[] vendorSpecificMetadata;
@VintfStability
parcelable StreamMap {
char streamHandle;
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/OpusCapabilities.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/OpusCapabilities.aidl
index 2781893..2c04b0f 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/OpusCapabilities.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/OpusCapabilities.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 The Android Open Source Project
+ * Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/OpusConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/OpusConfiguration.aidl
index 067690e..811d32a 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/OpusConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/OpusConfiguration.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 The Android Open Source Project
+ * Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastCapability.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastCapability.aidl
index 130fef9..894a2f3 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastCapability.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastCapability.aidl
@@ -47,5 +47,6 @@
union LeAudioCodecCapabilities {
android.hardware.bluetooth.audio.Lc3Capabilities lc3Capabilities;
android.hardware.bluetooth.audio.UnicastCapability.VendorCapabilities vendorCapabillities;
+ android.hardware.bluetooth.audio.AptxAdaptiveLeCapabilities aptxAdaptiveLeCapabilities;
}
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacCapabilities.aidl
index c4153e9..d7d67de 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacCapabilities.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacCapabilities.aidl
@@ -29,4 +29,5 @@
ChannelMode[] channelMode;
boolean variableBitRateSupported;
byte[] bitsPerSample;
+ boolean adaptiveBitRateSupported;
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacConfiguration.aidl
index 30338e7..34998cd 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacConfiguration.aidl
@@ -29,4 +29,5 @@
ChannelMode channelMode;
boolean variableBitRateEnabled;
byte bitsPerSample;
+ boolean adaptiveBitRateSupported;
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeCapabilities.aidl
new file mode 100644
index 0000000..b3fe71c
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeCapabilities.aidl
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.bluetooth.audio;
+
+/**
+ * Used for Hardware Encoding/Decoding Aptx Adaptive LE codec capabilities.
+ */
+@VintfStability
+parcelable AptxAdaptiveLeCapabilities {
+ /*
+ * PCM is Input for encoder, Output for decoder
+ */
+ byte[] pcmBitDepth;
+ /*
+ * codec-specific parameters
+ */
+ int[] samplingFrequencyHz;
+ /*
+ * FrameDuration based on microseconds.
+ */
+ int[] frameDurationUs;
+ /*
+ * length in octets of a codec frame
+ */
+ int[] octetsPerFrame;
+ /*
+ * Number of blocks of codec frames per single SDU (Service Data Unit)
+ */
+ byte[] blocksPerSdu;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeConfiguration.aidl
new file mode 100644
index 0000000..060d5d5
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeConfiguration.aidl
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.bluetooth.audio;
+
+/**
+ * Used for Hardware Encoding/Decoding Aptx Adaptive LE/LEX codec configuration.
+ */
+@VintfStability
+parcelable AptxAdaptiveLeConfiguration {
+ /*
+ * PCM is Input for encoder, Output for decoder
+ */
+ byte pcmBitDepth;
+ /*
+ * codec-specific parameters
+ */
+ int samplingFrequencyHz;
+ /*
+ * FrameDuration based on microseconds.
+ */
+ int frameDurationUs;
+ /*
+ * length in octets of a codec frame
+ */
+ int octetsPerFrame;
+ /*
+ * Number of blocks of codec frames per single SDU (Service Data Unit)
+ */
+ byte blocksPerSdu;
+ /*
+ * Currently being used for Aptx Adaptive LEX,
+ * RFU for Aptx Adaptive LE
+ * Based on this value, the codec will determine the quality of stream
+ * during initialization for Music/Game
+ */
+ int codecMode;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl
index 3499155..1d8acdf 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl
@@ -29,4 +29,6 @@
VENDOR,
APTX_ADAPTIVE,
OPUS,
+ APTX_ADAPTIVE_LE,
+ APTX_ADAPTIVE_LEX,
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
index 421eeb2..7ce6ff3 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
@@ -17,6 +17,7 @@
package android.hardware.bluetooth.audio;
import android.hardware.bluetooth.audio.Lc3Configuration;
+import android.hardware.bluetooth.audio.AptxAdaptiveLeConfiguration;
@VintfStability
union LeAudioCodecConfiguration {
@@ -26,4 +27,5 @@
}
Lc3Configuration lc3Config;
VendorConfiguration vendorConfig;
+ AptxAdaptiveLeConfiguration aptxAdaptiveLeConfig;
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
index f22f309..7302aea 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
@@ -44,4 +44,16 @@
StreamMap[] streamMap;
int peerDelayUs;
LeAudioCodecConfiguration leAudioCodecConfig;
+
+ /*
+ * Bluetooth LTV format for vendor metadata is defined in the
+ * Section 6.12.6.9 Vendor_Specific of Bluetooth Assigned Numbers
+ *
+ * Octet 0 = Length
+ * Octet 1 = Type (Vendor specific - 0xFF)
+ * Octet 2-3 = Company_ID
+ * Company ID values are defined in Bluetooth Assigned Numbers.
+ * Octet 4 onwards = Vendor specific Metadata
+ */
+ @nullable byte[] vendorSpecificMetadata;
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl
index f8a924a..07688a7 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl
@@ -19,6 +19,7 @@
import android.hardware.bluetooth.audio.AudioLocation;
import android.hardware.bluetooth.audio.CodecType;
import android.hardware.bluetooth.audio.Lc3Capabilities;
+import android.hardware.bluetooth.audio.AptxAdaptiveLeCapabilities;
/**
* Used to specify the le audio unicast codec capabilities for hardware offload.
@@ -33,6 +34,7 @@
union LeAudioCodecCapabilities {
Lc3Capabilities lc3Capabilities;
VendorCapabilities vendorCapabillities;
+ AptxAdaptiveLeCapabilities aptxAdaptiveLeCapabilities;
}
CodecType codecType;
AudioLocation supportedChannel;
diff --git a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
index 6a913f7..858fa38 100644
--- a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
+++ b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
@@ -35,6 +35,8 @@
using aidl::android::hardware::audio::common::SourceMetadata;
using aidl::android::hardware::bluetooth::audio::AacCapabilities;
using aidl::android::hardware::bluetooth::audio::AacConfiguration;
+using aidl::android::hardware::bluetooth::audio::AptxAdaptiveLeCapabilities;
+using aidl::android::hardware::bluetooth::audio::AptxAdaptiveLeConfiguration;
using aidl::android::hardware::bluetooth::audio::AptxCapabilities;
using aidl::android::hardware::bluetooth::audio::AptxConfiguration;
using aidl::android::hardware::bluetooth::audio::AudioCapabilities;
@@ -87,10 +89,6 @@
static constexpr int8_t a2dp_bits_per_samples[] = {0, 16, 24, 32};
static constexpr ChannelMode a2dp_channel_modes[] = {
ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO};
-static constexpr CodecType a2dp_codec_types[] = {
- CodecType::UNKNOWN, CodecType::SBC, CodecType::AAC,
- CodecType::APTX, CodecType::APTX_HD, CodecType::LDAC,
- CodecType::LC3, CodecType::APTX_ADAPTIVE};
static std::vector<LatencyMode> latency_modes = {LatencyMode::FREE};
// Helpers
@@ -238,6 +236,8 @@
CodecCapabilities::Capabilities::opusCapabilities);
break;
case CodecType::APTX_ADAPTIVE:
+ case CodecType::APTX_ADAPTIVE_LE:
+ case CodecType::APTX_ADAPTIVE_LEX:
case CodecType::LC3:
case CodecType::VENDOR:
case CodecType::UNKNOWN:
@@ -387,6 +387,11 @@
variable_bit_rate_enableds.push_back(true);
}
+ std::vector<bool> adaptive_bit_rate_supporteds = {false};
+ if (aac_capability.adaptiveBitRateSupported) {
+ adaptive_bit_rate_supporteds.push_back(true);
+ }
+
// combine those parameters into one list of
// CodecConfiguration::CodecSpecific
for (auto object_type : aac_capability.objectType) {
@@ -394,14 +399,18 @@
for (auto channel_mode : aac_capability.channelMode) {
for (int8_t bits_per_sample : aac_capability.bitsPerSample) {
for (auto variable_bit_rate_enabled : variable_bit_rate_enableds) {
- AacConfiguration aac_data{
- .objectType = object_type,
- .sampleRateHz = sample_rate,
- .channelMode = channel_mode,
- .variableBitRateEnabled = variable_bit_rate_enabled,
- .bitsPerSample = bits_per_sample};
- aac_codec_specifics.push_back(
- CodecConfiguration::CodecSpecific(aac_data));
+ for (auto adaptive_bit_rate_supported :
+ adaptive_bit_rate_supporteds) {
+ AacConfiguration aac_data{
+ .objectType = object_type,
+ .sampleRateHz = sample_rate,
+ .channelMode = channel_mode,
+ .variableBitRateEnabled = variable_bit_rate_enabled,
+ .bitsPerSample = bits_per_sample,
+ .adaptiveBitRateSupported = adaptive_bit_rate_supported};
+ aac_codec_specifics.push_back(
+ CodecConfiguration::CodecSpecific(aac_data));
+ }
}
}
}
@@ -845,7 +854,7 @@
ASSERT_NE(audio_provider_, nullptr);
std::vector<CodecConfiguration::CodecSpecific> codec_specifics;
- for (auto codec_type : a2dp_codec_types) {
+ for (auto codec_type : ndk::enum_range<CodecType>()) {
switch (codec_type) {
case CodecType::SBC:
codec_specifics = GetSbcCodecSpecificSupportedList(false);
@@ -866,6 +875,8 @@
codec_specifics = GetOpusCodecSpecificSupportedList(false);
continue;
case CodecType::APTX_ADAPTIVE:
+ case CodecType::APTX_ADAPTIVE_LE:
+ case CodecType::APTX_ADAPTIVE_LEX:
case CodecType::LC3:
case CodecType::VENDOR:
case CodecType::UNKNOWN:
@@ -1192,6 +1203,73 @@
return le_audio_codec_configs;
}
+ static constexpr int32_t apx_adaptive_le_config_codec_modes[] = {0, 1, 2, 3};
+
+ std::vector<AptxAdaptiveLeConfiguration>
+ GetUnicastAptxAdaptiveLeSupportedList(bool decoding, bool supported,
+ bool is_le_extended) {
+ std::vector<AptxAdaptiveLeConfiguration> le_audio_codec_configs;
+ if (!supported) {
+ AptxAdaptiveLeConfiguration aptx_adaptive_le_config{
+ .pcmBitDepth = 0, .samplingFrequencyHz = 0};
+ le_audio_codec_configs.push_back(aptx_adaptive_le_config);
+ return le_audio_codec_configs;
+ }
+
+ // There might be more than one LeAudioCodecCapabilitiesSetting
+ std::vector<AptxAdaptiveLeCapabilities> aptx_adaptive_le_capabilities;
+ for (auto& capability : temp_provider_capabilities_) {
+ if (capability.getTag() != AudioCapabilities::leAudioCapabilities) {
+ continue;
+ }
+ auto& le_audio_capability =
+ capability.get<AudioCapabilities::leAudioCapabilities>();
+ auto& unicast_capability =
+ decoding ? le_audio_capability.unicastDecodeCapability
+ : le_audio_capability.unicastEncodeCapability;
+ if ((!is_le_extended &&
+ unicast_capability.codecType != CodecType::APTX_ADAPTIVE_LE) ||
+ (is_le_extended &&
+ unicast_capability.codecType != CodecType::APTX_ADAPTIVE_LEX)) {
+ continue;
+ }
+
+ auto& aptx_adaptive_le_capability =
+ unicast_capability.leAudioCodecCapabilities
+ .get<UnicastCapability::LeAudioCodecCapabilities::
+ aptxAdaptiveLeCapabilities>();
+
+ aptx_adaptive_le_capabilities.push_back(aptx_adaptive_le_capability);
+ }
+
+ for (auto& aptx_adaptive_le_capability : aptx_adaptive_le_capabilities) {
+ for (int32_t samplingFrequencyHz :
+ aptx_adaptive_le_capability.samplingFrequencyHz) {
+ for (int32_t frameDurationUs :
+ aptx_adaptive_le_capability.frameDurationUs) {
+ for (int32_t octetsPerFrame :
+ aptx_adaptive_le_capability.octetsPerFrame) {
+ for (int8_t blocksPerSdu :
+ aptx_adaptive_le_capability.blocksPerSdu) {
+ for (int32_t codecMode : apx_adaptive_le_config_codec_modes) {
+ AptxAdaptiveLeConfiguration aptx_adaptive_le_config = {
+ .samplingFrequencyHz = samplingFrequencyHz,
+ .frameDurationUs = frameDurationUs,
+ .octetsPerFrame = octetsPerFrame,
+ .blocksPerSdu = blocksPerSdu,
+ .codecMode = codecMode,
+ };
+ le_audio_codec_configs.push_back(aptx_adaptive_le_config);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return le_audio_codec_configs;
+ }
+
LeAudioCodecCapabilitiesSetting temp_le_audio_capabilities_;
};
@@ -1268,6 +1346,87 @@
}
}
+static std::vector<uint8_t> vendorMetadata = {0x0B, // Length
+ 0xFF, // Type: Vendor-specific
+ 0x0A, 0x00, // Company_ID
+ 0x01, 0x02, 0x03, 0x04, // Data
+ 0x05, 0x06, 0x07, 0x08};
+
+/**
+ * Test whether each provider of type
+ * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and
+ * stopped with Unicast hardware encoding config
+ */
+TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl,
+ StartAndEndLeAudioOutputSessionWithAptxAdaptiveLeUnicastConfig) {
+ if (!IsOffloadOutputSupported()) {
+ return;
+ }
+ for (auto codec_type :
+ {CodecType::APTX_ADAPTIVE_LE, CodecType::APTX_ADAPTIVE_LEX}) {
+ bool is_le_extended = (codec_type == CodecType::APTX_ADAPTIVE_LEX);
+ auto aptx_adaptive_le_codec_configs =
+ GetUnicastAptxAdaptiveLeSupportedList(false, true, is_le_extended);
+ LeAudioConfiguration le_audio_config = {
+ .codecType = codec_type,
+ .peerDelayUs = 0,
+ .vendorSpecificMetadata = vendorMetadata,
+ };
+
+ for (auto& aptx_adaptive_le_config : aptx_adaptive_le_codec_configs) {
+ le_audio_config.leAudioCodecConfig
+ .set<LeAudioCodecConfiguration::aptxAdaptiveLeConfig>(
+ aptx_adaptive_le_config);
+ DataMQDesc mq_desc;
+ auto aidl_retval = audio_provider_->startSession(
+ audio_port_, AudioConfiguration(le_audio_config), latency_modes,
+ &mq_desc);
+
+ ASSERT_TRUE(aidl_retval.isOk());
+ EXPECT_TRUE(audio_provider_->endSession().isOk());
+ }
+ }
+}
+
+/**
+ * Test whether each provider of type
+ * SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH can be started and
+ * stopped with Unicast hardware encoding config
+ */
+TEST_P(
+ BluetoothAudioProviderLeAudioOutputHardwareAidl,
+ BluetoothAudioProviderLeAudioOutputHardwareAidl_StartAndEndLeAudioOutputSessionWithInvalidAptxAdaptiveLeAudioConfiguration) {
+ if (!IsOffloadOutputSupported()) {
+ return;
+ }
+
+ for (auto codec_type :
+ {CodecType::APTX_ADAPTIVE_LE, CodecType::APTX_ADAPTIVE_LEX}) {
+ bool is_le_extended = (codec_type == CodecType::APTX_ADAPTIVE_LEX);
+ auto aptx_adaptive_le_codec_configs =
+ GetUnicastAptxAdaptiveLeSupportedList(false, true, is_le_extended);
+ LeAudioConfiguration le_audio_config = {
+ .codecType = codec_type,
+ .peerDelayUs = 0,
+ .vendorSpecificMetadata = vendorMetadata,
+ };
+
+ for (auto& aptx_adaptive_le_config : aptx_adaptive_le_codec_configs) {
+ le_audio_config.leAudioCodecConfig
+ .set<LeAudioCodecConfiguration::aptxAdaptiveLeConfig>(
+ aptx_adaptive_le_config);
+ DataMQDesc mq_desc;
+ auto aidl_retval = audio_provider_->startSession(
+ audio_port_, AudioConfiguration(le_audio_config), latency_modes,
+ &mq_desc);
+
+ // AIDL call should fail on invalid codec
+ ASSERT_FALSE(aidl_retval.isOk());
+ EXPECT_TRUE(audio_provider_->endSession().isOk());
+ }
+ }
+}
+
/**
* openProvider LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH
*/
@@ -1877,7 +2036,7 @@
ASSERT_NE(audio_provider_, nullptr);
std::vector<CodecConfiguration::CodecSpecific> codec_specifics;
- for (auto codec_type : a2dp_codec_types) {
+ for (auto codec_type : ndk::enum_range<CodecType>()) {
switch (codec_type) {
case CodecType::SBC:
codec_specifics = GetSbcCodecSpecificSupportedList(false);
@@ -1898,6 +2057,8 @@
codec_specifics = GetOpusCodecSpecificSupportedList(false);
continue;
case CodecType::APTX_ADAPTIVE:
+ case CodecType::APTX_ADAPTIVE_LE:
+ case CodecType::APTX_ADAPTIVE_LEX:
case CodecType::LC3:
case CodecType::VENDOR:
case CodecType::UNKNOWN:
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
index faebbbf..3ed9e07 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
@@ -20,6 +20,8 @@
#include <aidl/android/hardware/bluetooth/audio/AacCapabilities.h>
#include <aidl/android/hardware/bluetooth/audio/AacObjectType.h>
+#include <aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeCapabilities.h>
+#include <aidl/android/hardware/bluetooth/audio/AptxAdaptiveLeConfiguration.h>
#include <aidl/android/hardware/bluetooth/audio/AptxCapabilities.h>
#include <aidl/android/hardware/bluetooth/audio/ChannelMode.h>
#include <aidl/android/hardware/bluetooth/audio/LdacCapabilities.h>
@@ -98,6 +100,55 @@
std::vector<LeAudioCodecCapabilitiesSetting> kDefaultOffloadLeAudioCapabilities;
+static const UnicastCapability kInvalidUnicastCapability = {
+ .codecType = CodecType::UNKNOWN};
+
+static const AptxAdaptiveLeCapabilities
+ kDefaultOffloadAptxAdaptiveLeCapability_48k = {
+ .samplingFrequencyHz = {48000},
+ .frameDurationUs = {10000},
+ .octetsPerFrame = {816}};
+
+static const AptxAdaptiveLeCapabilities
+ kDefaultOffloadAptxAdaptiveLeCapability_96k = {
+ .samplingFrequencyHz = {96000},
+ .frameDurationUs = {10000},
+ .octetsPerFrame = {816}};
+
+static const AptxAdaptiveLeCapabilities
+ kDefaultOffloadAptxAdaptiveLeXCapability_48k = {
+ .samplingFrequencyHz = {48000},
+ .frameDurationUs = {10000},
+ .octetsPerFrame = {816}};
+
+static const AptxAdaptiveLeCapabilities
+ kDefaultOffloadAptxAdaptiveLeXCapability_96k = {
+ .samplingFrequencyHz = {96000},
+ .frameDurationUs = {10000},
+ .octetsPerFrame = {816}};
+
+static const BroadcastCapability kInvalidBroadcastCapability = {
+ .codecType = CodecType::UNKNOWN};
+
+static AudioLocation stereoAudio = static_cast<AudioLocation>(
+ static_cast<uint8_t>(AudioLocation::FRONT_LEFT) |
+ static_cast<uint8_t>(AudioLocation::FRONT_RIGHT));
+
+static const std::vector<AptxAdaptiveLeCapabilities>
+ supportedAptxAdaptiveLeCapabilityList = {
+ kDefaultOffloadAptxAdaptiveLeCapability_48k,
+ kDefaultOffloadAptxAdaptiveLeCapability_96k,
+ kDefaultOffloadAptxAdaptiveLeXCapability_48k,
+ kDefaultOffloadAptxAdaptiveLeXCapability_96k};
+
+// Stores the supported setting of audio location, connected device, and the
+// channel count for each device
+std::vector<std::tuple<AudioLocation, uint8_t, uint8_t>>
+ supportedDeviceSetting = {
+ // Stereo, one connected device for both L and R
+ std::make_tuple(stereoAudio, 1, 2),
+};
+
template <class T>
bool BluetoothAudioCodecs::ContainedInVector(
const std::vector<T>& vector, const typename identity<T>::type& target) {
@@ -312,6 +363,8 @@
case CodecType::VENDOR:
case CodecType::LC3:
case CodecType::APTX_ADAPTIVE:
+ case CodecType::APTX_ADAPTIVE_LE:
+ case CodecType::APTX_ADAPTIVE_LEX:
break;
}
}
@@ -377,6 +430,8 @@
}
break;
case CodecType::APTX_ADAPTIVE:
+ case CodecType::APTX_ADAPTIVE_LE:
+ case CodecType::APTX_ADAPTIVE_LEX:
case CodecType::LC3:
case CodecType::UNKNOWN:
case CodecType::VENDOR:
@@ -403,8 +458,33 @@
kDefaultOffloadLeAudioCapabilities =
BluetoothLeAudioCodecsProvider::GetLeAudioCodecCapabilities(
le_audio_offload_setting);
- }
+ for (auto [audioLocation, deviceCnt, channelCount] :
+ supportedDeviceSetting) {
+ for (auto capability : supportedAptxAdaptiveLeCapabilityList) {
+ for (auto codec_type :
+ {CodecType::APTX_ADAPTIVE_LE, CodecType::APTX_ADAPTIVE_LEX}) {
+ if (session_type ==
+ SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
+ UnicastCapability aptx_adaptive_le_cap = {
+ .codecType = codec_type,
+ .supportedChannel = audioLocation,
+ .deviceCount = deviceCnt,
+ .channelCountPerDevice = channelCount,
+ .leAudioCodecCapabilities =
+ UnicastCapability::LeAudioCodecCapabilities(capability),
+ };
+
+ // Adds the capability for encode only
+ kDefaultOffloadLeAudioCapabilities.push_back(
+ {.unicastEncodeCapability = aptx_adaptive_le_cap,
+ .unicastDecodeCapability = kInvalidUnicastCapability,
+ .broadcastCapability = kInvalidBroadcastCapability});
+ }
+ }
+ }
+ }
+ }
return kDefaultOffloadLeAudioCapabilities;
}