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 899b8ca6db..e548cd326a 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 @@ parcelable AacCapabilities { 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 6adef6df16..29ab8ce3d0 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 @@ parcelable AacConfiguration { 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 0000000000..c9d3cde671 --- /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 -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 0000000000..76df4edba1 --- /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 -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 d1723e6dab..3e204f9412 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 @@ enum CodecType { 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 bb3d7e4b1e..031ee679ac 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 @@ package android.hardware.bluetooth.audio; 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 679655c8dd..2d9ebae9f4 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 @@ parcelable LeAudioConfiguration { 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 2781893973..2c04b0f3bb 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 067690ede2..811d32a7ea 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 130fef971c..894a2f3148 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 @@ parcelable UnicastCapability { 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 c4153e9ffd..d7d67de00e 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 @@ parcelable AacCapabilities { 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 30338e76d0..34998cd10c 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 @@ parcelable AacConfiguration { 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 0000000000..b3fe71c760 --- /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 0000000000..060d5d5119 --- /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 34991558de..1d8acdf983 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 @@ enum CodecType { 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 421eeb27f2..7ce6ff3fa9 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 @@ union LeAudioCodecConfiguration { } 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 f22f309f74..7302aea255 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 @@ parcelable LeAudioConfiguration { 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 f8a924aeb4..07688a7a67 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 @@ package android.hardware.bluetooth.audio; 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 @@ parcelable UnicastCapability { 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 6a913f7b1e..858fa38825 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::SinkMetadata; 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 int32_t a2dp_sample_rates[] = {0, 44100, 48000, 88200, 96000}; 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 latency_modes = {LatencyMode::FREE}; // Helpers @@ -238,6 +236,8 @@ class BluetoothAudioProviderFactoryAidl 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 @@ class BluetoothAudioProviderFactoryAidl variable_bit_rate_enableds.push_back(true); } + std::vector 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 @@ class BluetoothAudioProviderFactoryAidl 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 @@ TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, ASSERT_NE(audio_provider_, nullptr); std::vector codec_specifics; - for (auto codec_type : a2dp_codec_types) { + for (auto codec_type : ndk::enum_range()) { switch (codec_type) { case CodecType::SBC: codec_specifics = GetSbcCodecSpecificSupportedList(false); @@ -866,6 +875,8 @@ TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl, 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 @@ class BluetoothAudioProviderLeAudioOutputHardwareAidl return le_audio_codec_configs; } + static constexpr int32_t apx_adaptive_le_config_codec_modes[] = {0, 1, 2, 3}; + + std::vector + GetUnicastAptxAdaptiveLeSupportedList(bool decoding, bool supported, + bool is_le_extended) { + std::vector 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 aptx_adaptive_le_capabilities; + for (auto& capability : temp_provider_capabilities_) { + if (capability.getTag() != AudioCapabilities::leAudioCapabilities) { + continue; + } + auto& le_audio_capability = + capability.get(); + 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(); + + 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 @@ TEST_P(BluetoothAudioProviderLeAudioOutputHardwareAidl, } } +static std::vector 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( + 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( + 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 @@ TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, ASSERT_NE(audio_provider_, nullptr); std::vector codec_specifics; - for (auto codec_type : a2dp_codec_types) { + for (auto codec_type : ndk::enum_range()) { switch (codec_type) { case CodecType::SBC: codec_specifics = GetSbcCodecSpecificSupportedList(false); @@ -1898,6 +2057,8 @@ TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl, 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 faebbbf32b..3ed9e070c5 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp @@ -20,6 +20,8 @@ #include #include +#include +#include #include #include #include @@ -98,6 +100,55 @@ const std::vector kDefaultOffloadA2dpCodecCapabilities = { std::vector 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( + static_cast(AudioLocation::FRONT_LEFT) | + static_cast(AudioLocation::FRONT_RIGHT)); + +static const std::vector + 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> + supportedDeviceSetting = { + // Stereo, one connected device for both L and R + std::make_tuple(stereoAudio, 1, 2), +}; + template bool BluetoothAudioCodecs::ContainedInVector( const std::vector& vector, const typename identity::type& target) { @@ -312,6 +363,8 @@ BluetoothAudioCodecs::GetA2dpOffloadCodecCapabilities( 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 @@ bool BluetoothAudioCodecs::IsOffloadCodecConfigurationValid( } 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 @@ BluetoothAudioCodecs::GetLeAudioOffloadCodecCapabilities( 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; }