Move APTX_ADAPTIVE_LE and APTX_ADAPTVIE_LEX to configurable

We should bring the capabilities from the configure file that the device
could have its own capabilties.

Bug: 302173270
Test: atest VtsHalBluetoothAudioTargetTest
Change-Id: I2cb5194acbe64d7d64cca9b245b26ca5fbac35d4
This commit is contained in:
Alice Kuo 2023-10-04 04:02:24 +08:00
parent 4e3c5aca14
commit f850de6732
6 changed files with 40 additions and 77 deletions

View file

@ -20,8 +20,6 @@
#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>
@ -100,55 +98,6 @@ const std::vector<CodecCapabilities> kDefaultOffloadA2dpCodecCapabilities = {
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) {
@ -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;
}

View file

@ -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;
}

View file

@ -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);

View file

@ -31,6 +31,10 @@
<scenario encode="OneChanMono_16_2" decode="invalid"/>
<scenario encode="TwoChanStereo_16_2" decode="invalid"/>
<scenario encode="OneChanStereo_16_2" decode="invalid"/>
<scenario encode="APEX_ADAPTIVE_LE_TwoChanStereo_48" decode="invalid"/>
<scenario encode="APEX_ADAPTIVE_LE_TwoChanStereo_96" decode="invalid"/>
<scenario encode="APEX_ADAPTIVE_LEX_TwoChanStereo_48" decode="invalid"/>
<scenario encode="APEX_ADAPTIVE_LEX_TwoChanStereo_96" decode="invalid"/>
<!-- encode and decode -->
<scenario encode="OneChanStereo_16_1" decode="OneChanStereo_16_1"/>
<scenario encode="OneChanStereo_16_1" decode="OneChanMono_16_1"/>
@ -51,10 +55,18 @@
<configuration name="TwoChanStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
<configuration name="OneChanStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="STEREO_ONE_CIS_PER_DEVICE"/>
<configuration name="BcastStereo_16_2" codecConfiguration="LC3_16k_2" strategyConfiguration="BROADCAST_STEREO"/>
<configuration name="APEX_ADAPTIVE_LE_TwoChanStereo_48" codecConfiguration="APTX_ADAPTIVE_LE_48k" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
<configuration name="APEX_ADAPTIVE_LE_TwoChanStereo_96" codecConfiguration="APTX_ADAPTIVE_LE_96k" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
<configuration name="APEX_ADAPTIVE_LEX_TwoChanStereo_48" codecConfiguration="APTX_ADAPTIVE_LEX_48k" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
<configuration name="APEX_ADAPTIVE_LEX_TwoChanStereo_96" codecConfiguration="APTX_ADAPTIVE_LEX_96k" strategyConfiguration="STEREO_TWO_CISES_PER_DEVICE"/>
</configurationList>
<codecConfigurationList>
<codecConfiguration name="LC3_16k_1" codec="LC3" samplingFrequency="16000" frameDurationUs="7500" octetsPerCodecFrame="30"/>
<codecConfiguration name="LC3_16k_2" codec="LC3" samplingFrequency="16000" frameDurationUs="10000" octetsPerCodecFrame="40"/>
<codecConfiguration name="APTX_ADAPTIVE_LE_48k" codec="APTX_ADAPTIVE_LE" samplingFrequency="48000" frameDurationUs="10000" octetsPerCodecFrame="816"/>
<codecConfiguration name="APTX_ADAPTIVE_LE_96k" codec="APTX_ADAPTIVE_LE" samplingFrequency="96000" frameDurationUs="10000" octetsPerCodecFrame="816"/>
<codecConfiguration name="APTX_ADAPTIVE_LEX_48k" codec="APTX_ADAPTIVE_LEX" samplingFrequency="48000" frameDurationUs="10000" octetsPerCodecFrame="816"/>
<codecConfiguration name="APTX_ADAPTIVE_LEX_96k" codec="APTX_ADAPTIVE_LEX" samplingFrequency="96000" frameDurationUs="10000" octetsPerCodecFrame="816"/>
</codecConfigurationList>
<strategyConfigurationList>
<strategyConfiguration name="STEREO_ONE_CIS_PER_DEVICE" audioLocation="STEREO" connectedDevice="2" channelCount="1"/>

View file

@ -70,6 +70,8 @@
<xs:simpleType name="codecType">
<xs:restriction base="xs:string">
<xs:enumeration value="LC3"/>
<xs:enumeration value="APTX_ADAPTIVE_LE"/>
<xs:enumeration value="APTX_ADAPTIVE_LEX"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View file

@ -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;
}