Add Opus to BT Audio HAL and update version to V2
This CL adds Opus as a supported A2DP codec to the BT Audio HAL and
updates HAL compatibility matrix.
Bug: 226441860
Test: A2DP sink device using bds-dev
Change-Id: I21249e3e7e76412af7ed62a3fc9ec133434cf963
diff --git a/bluetooth/audio/aidl/vts/Android.bp b/bluetooth/audio/aidl/vts/Android.bp
index feb952e..3aed1b3 100644
--- a/bluetooth/audio/aidl/vts/Android.bp
+++ b/bluetooth/audio/aidl/vts/Android.bp
@@ -17,7 +17,7 @@
srcs: ["VtsHalBluetoothAudioTargetTest.cpp"],
shared_libs: [
"android.hardware.audio.common-V1-ndk",
- "android.hardware.bluetooth.audio-V1-ndk",
+ "android.hardware.bluetooth.audio-V2-ndk",
"android.hardware.common-V2-ndk",
"android.hardware.common.fmq-V1-ndk",
"libbase",
diff --git a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
index b599365..ebd728d 100644
--- a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
+++ b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
@@ -57,6 +57,8 @@
LeAudioCodecCapabilitiesSetting;
using aidl::android::hardware::bluetooth::audio::LeAudioCodecConfiguration;
using aidl::android::hardware::bluetooth::audio::LeAudioConfiguration;
+using aidl::android::hardware::bluetooth::audio::OpusCapabilities;
+using aidl::android::hardware::bluetooth::audio::OpusConfiguration;
using aidl::android::hardware::bluetooth::audio::PcmConfiguration;
using aidl::android::hardware::bluetooth::audio::PresentationPosition;
using aidl::android::hardware::bluetooth::audio::SbcAllocMethod;
@@ -121,9 +123,9 @@
dst.set<CodecConfiguration::CodecSpecific::aptxConfig>(
src.get<CodecConfiguration::CodecSpecific::aptxConfig>());
break;
- case CodecConfiguration::CodecSpecific::lc3Config:
- dst.set<CodecConfiguration::CodecSpecific::lc3Config>(
- src.get<CodecConfiguration::CodecSpecific::lc3Config>());
+ case CodecConfiguration::CodecSpecific::opusConfig:
+ dst.set<CodecConfiguration::CodecSpecific::opusConfig>(
+ src.get<CodecConfiguration::CodecSpecific::opusConfig>());
break;
case CodecConfiguration::CodecSpecific::aptxAdaptiveConfig:
dst.set<CodecConfiguration::CodecSpecific::aptxAdaptiveConfig>(
@@ -230,11 +232,12 @@
ASSERT_EQ(codec_capabilities.capabilities.getTag(),
CodecCapabilities::Capabilities::ldacCapabilities);
break;
- case CodecType::LC3:
+ case CodecType::OPUS:
ASSERT_EQ(codec_capabilities.capabilities.getTag(),
- CodecCapabilities::Capabilities::lc3Capabilities);
+ CodecCapabilities::Capabilities::opusCapabilities);
break;
case CodecType::APTX_ADAPTIVE:
+ case CodecType::LC3:
case CodecType::VENDOR:
case CodecType::UNKNOWN:
break;
@@ -484,39 +487,40 @@
}
std::vector<CodecConfiguration::CodecSpecific>
- GetLc3CodecSpecificSupportedList(bool supported) {
- std::vector<CodecConfiguration::CodecSpecific> lc3_codec_specifics;
+ GetOpusCodecSpecificSupportedList(bool supported) {
+ std::vector<CodecConfiguration::CodecSpecific> opus_codec_specifics;
if (!supported) {
- Lc3Configuration lc3_config{.samplingFrequencyHz = 0,
- .frameDurationUs = 0};
- lc3_codec_specifics.push_back(
- CodecConfiguration::CodecSpecific(lc3_config));
- return lc3_codec_specifics;
+ OpusConfiguration opus_config{.samplingFrequencyHz = 0,
+ .frameDurationUs = 0};
+ opus_codec_specifics.push_back(
+ CodecConfiguration::CodecSpecific(opus_config));
+ return opus_codec_specifics;
}
- GetA2dpOffloadCapabilityHelper(CodecType::LC3);
+ GetA2dpOffloadCapabilityHelper(CodecType::OPUS);
if (temp_codec_capabilities_ == nullptr ||
- temp_codec_capabilities_->codecType != CodecType::LC3) {
- return lc3_codec_specifics;
+ temp_codec_capabilities_->codecType != CodecType::OPUS) {
+ return opus_codec_specifics;
}
// parse the capability
- auto& lc3_capability =
+ auto& opus_capability =
temp_codec_capabilities_->capabilities
- .get<CodecCapabilities::Capabilities::lc3Capabilities>();
+ .get<CodecCapabilities::Capabilities::opusCapabilities>();
// combine those parameters into one list of
// CodecConfiguration::CodecSpecific
- for (int32_t samplingFrequencyHz : lc3_capability.samplingFrequencyHz) {
- for (int32_t frameDurationUs : lc3_capability.frameDurationUs) {
- for (auto channel_mode : lc3_capability.channelMode) {
- Lc3Configuration lc3_data{.samplingFrequencyHz = samplingFrequencyHz,
- .channelMode = channel_mode,
- .frameDurationUs = frameDurationUs};
- lc3_codec_specifics.push_back(
- CodecConfiguration::CodecSpecific(lc3_data));
+ for (int32_t samplingFrequencyHz : opus_capability->samplingFrequencyHz) {
+ for (int32_t frameDurationUs : opus_capability->frameDurationUs) {
+ for (auto channel_mode : opus_capability->channelMode) {
+ OpusConfiguration opus_data{
+ .samplingFrequencyHz = samplingFrequencyHz,
+ .channelMode = channel_mode,
+ .frameDurationUs = frameDurationUs};
+ opus_codec_specifics.push_back(
+ CodecConfiguration::CodecSpecific(opus_data));
}
}
}
- return lc3_codec_specifics;
+ return opus_codec_specifics;
}
bool IsPcmConfigSupported(const PcmConfiguration& pcm_config) {
@@ -762,23 +766,23 @@
/**
* Test whether each provider of type
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
- * LDAC hardware encoding config
+ * Opus hardware encoding config
*/
TEST_P(BluetoothAudioProviderA2dpEncodingHardwareAidl,
- StartAndEndA2dpLc3EncodingHardwareSession) {
+ StartAndEndA2dpOpusEncodingHardwareSession) {
if (!IsOffloadSupported()) {
return;
}
CodecConfiguration codec_config = {
- .codecType = CodecType::LC3,
+ .codecType = CodecType::OPUS,
.encodedAudioBitrate = 990000,
.peerMtu = 1005,
.isScmstEnabled = false,
};
- auto lc3_codec_specifics = GetLc3CodecSpecificSupportedList(true);
+ auto opus_codec_specifics = GetOpusCodecSpecificSupportedList(true);
- for (auto& codec_specific : lc3_codec_specifics) {
+ for (auto& codec_specific : opus_codec_specifics) {
copy_codec_specific(codec_config.config, codec_specific);
DataMQDesc mq_desc;
auto aidl_retval = audio_provider_->startSession(
@@ -855,10 +859,11 @@
case CodecType::APTX_HD:
codec_specifics = GetAptxCodecSpecificSupportedList(true, false);
break;
- case CodecType::LC3:
- codec_specifics = GetLc3CodecSpecificSupportedList(false);
+ case CodecType::OPUS:
+ codec_specifics = GetOpusCodecSpecificSupportedList(false);
continue;
case CodecType::APTX_ADAPTIVE:
+ case CodecType::LC3:
case CodecType::VENDOR:
case CodecType::UNKNOWN:
codec_specifics.clear();
@@ -1788,23 +1793,23 @@
/**
* Test whether each provider of type
* SessionType::A2DP_HARDWARE_DECODING_DATAPATH can be started and stopped with
- * LDAC hardware encoding config
+ * Opus hardware encoding config
*/
TEST_P(BluetoothAudioProviderA2dpDecodingHardwareAidl,
- StartAndEndA2dpLc3DecodingHardwareSession) {
+ StartAndEndA2dpOpusDecodingHardwareSession) {
if (!IsOffloadSupported()) {
return;
}
CodecConfiguration codec_config = {
- .codecType = CodecType::LC3,
+ .codecType = CodecType::OPUS,
.encodedAudioBitrate = 990000,
.peerMtu = 1005,
.isScmstEnabled = false,
};
- auto lc3_codec_specifics = GetLc3CodecSpecificSupportedList(true);
+ auto opus_codec_specifics = GetOpusCodecSpecificSupportedList(true);
- for (auto& codec_specific : lc3_codec_specifics) {
+ for (auto& codec_specific : opus_codec_specifics) {
copy_codec_specific(codec_config.config, codec_specific);
DataMQDesc mq_desc;
auto aidl_retval = audio_provider_->startSession(
@@ -1881,10 +1886,11 @@
case CodecType::APTX_HD:
codec_specifics = GetAptxCodecSpecificSupportedList(true, false);
break;
- case CodecType::LC3:
- codec_specifics = GetLc3CodecSpecificSupportedList(false);
+ case CodecType::OPUS:
+ codec_specifics = GetOpusCodecSpecificSupportedList(false);
continue;
case CodecType::APTX_ADAPTIVE:
+ case CodecType::LC3:
case CodecType::VENDOR:
case CodecType::UNKNOWN:
codec_specifics.clear();