diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp index 3ed9e070c5..b4cba49502 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp @@ -20,8 +20,6 @@ #include #include -#include -#include #include #include #include @@ -100,55 +98,6 @@ 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) { @@ -458,32 +407,6 @@ 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; } diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp index 0a804bbb41..26da5fbe81 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.cpp @@ -256,6 +256,15 @@ UnicastCapability BluetoothLeAudioCodecsProvider::GetUnicastCapability( strategy_configuration_iter->second.getConnectedDevice(), strategy_configuration_iter->second.getChannelCount(), ComposeLc3Capability(codec_configuration_iter->second)); + } else if (codec_type == CodecType::APTX_ADAPTIVE_LE || + codec_type == CodecType::APTX_ADAPTIVE_LEX) { + return ComposeUnicastCapability( + codec_type, + GetAudioLocation( + strategy_configuration_iter->second.getAudioLocation()), + strategy_configuration_iter->second.getConnectedDevice(), + strategy_configuration_iter->second.getChannelCount(), + ComposeAptxAdaptiveLeCapability(codec_configuration_iter->second)); } return {.codecType = CodecType::UNKNOWN}; } @@ -330,6 +339,14 @@ Lc3Capabilities BluetoothLeAudioCodecsProvider::ComposeLc3Capability( .octetsPerFrame = {codec_configuration.getOctetsPerCodecFrame()}}; } +AptxAdaptiveLeCapabilities +BluetoothLeAudioCodecsProvider::ComposeAptxAdaptiveLeCapability( + const setting::CodecConfiguration& codec_configuration) { + return {.samplingFrequencyHz = {codec_configuration.getSamplingFrequency()}, + .frameDurationUs = {codec_configuration.getFrameDurationUs()}, + .octetsPerFrame = {codec_configuration.getOctetsPerCodecFrame()}}; +} + AudioLocation BluetoothLeAudioCodecsProvider::GetAudioLocation( const setting::AudioLocation& audio_location) { switch (audio_location) { @@ -347,6 +364,10 @@ CodecType BluetoothLeAudioCodecsProvider::GetCodecType( switch (codec_type) { case setting::CodecType::LC3: return CodecType::LC3; + case setting::CodecType::APTX_ADAPTIVE_LE: + return CodecType::APTX_ADAPTIVE_LE; + case setting::CodecType::APTX_ADAPTIVE_LEX: + return CodecType::APTX_ADAPTIVE_LEX; default: return CodecType::UNKNOWN; } diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h index 06e4595a4f..654e70cccf 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h +++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioCodecsProvider.h @@ -84,6 +84,9 @@ class BluetoothLeAudioCodecsProvider { static inline Lc3Capabilities ComposeLc3Capability( const setting::CodecConfiguration& codec_configuration); + static inline AptxAdaptiveLeCapabilities ComposeAptxAdaptiveLeCapability( + const setting::CodecConfiguration& codec_configuration); + static inline AudioLocation GetAudioLocation( const setting::AudioLocation& audio_location); static inline CodecType GetCodecType(const setting::CodecType& codec_type); diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml index c8d1af097d..eaace78791 100644 --- a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml +++ b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xml @@ -31,6 +31,10 @@ + + + + @@ -51,10 +55,18 @@ + + + + + + + + diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd index 8c2d6a11eb..03c8ade8a7 100644 --- a/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd +++ b/bluetooth/audio/utils/le_audio_codec_capabilities/le_audio_codec_capabilities.xsd @@ -70,6 +70,8 @@ + + diff --git a/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt b/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt index 3cef4172fe..a882174ba0 100644 --- a/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt +++ b/bluetooth/audio/utils/le_audio_codec_capabilities/schema/current.txt @@ -32,6 +32,8 @@ package aidl.android.hardware.bluetooth.audio.setting { public enum CodecType { method public String getRawName(); + enum_constant public static final aidl.android.hardware.bluetooth.audio.setting.CodecType APTX_ADAPTIVE_LE; + enum_constant public static final aidl.android.hardware.bluetooth.audio.setting.CodecType APTX_ADAPTIVE_LEX; enum_constant public static final aidl.android.hardware.bluetooth.audio.setting.CodecType LC3; }