Allow OPUS codec on LE Audio.
Bug: 377204617
Test: atest VtsHalBluetoothAudioTargetTest
Change-Id: I847f23395f984d3c344ec06a8f7f9e4b967b74ed
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecSpecificCapabilitiesLtv.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecSpecificCapabilitiesLtv.aidl
index 60c276b..93c3d8c 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecSpecificCapabilitiesLtv.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecSpecificCapabilitiesLtv.aidl
@@ -59,8 +59,10 @@
int bitmask;
const int US7500 = 0x01;
const int US10000 = 0x02;
+ const int US20000 = 0x04;
const int US7500PREFERRED = 0x10;
const int US10000PREFERRED = 0x20;
+ const int US20000PREFERRED = 0x40;
}
parcelable SupportedAudioChannelCounts {
int bitmask;
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecSpecificConfigurationLtv.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecSpecificConfigurationLtv.aidl
index 943d396..be79b0d 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecSpecificConfigurationLtv.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecSpecificConfigurationLtv.aidl
@@ -59,6 +59,7 @@
enum FrameDuration {
US7500 = 0x00,
US10000 = 0x01,
+ US20000 = 0x02,
}
parcelable AudioChannelAllocation {
int bitmask;
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 031ee67..0613f6c 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
@@ -37,6 +37,7 @@
android.hardware.bluetooth.audio.Lc3Configuration lc3Config;
android.hardware.bluetooth.audio.LeAudioCodecConfiguration.VendorConfiguration vendorConfig;
android.hardware.bluetooth.audio.AptxAdaptiveLeConfiguration aptxAdaptiveLeConfig;
+ android.hardware.bluetooth.audio.OpusConfiguration opusConfig;
@VintfStability
parcelable VendorConfiguration {
ParcelableHolder extension;
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 894a2f3..481e2ac 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
@@ -48,5 +48,6 @@
android.hardware.bluetooth.audio.Lc3Capabilities lc3Capabilities;
android.hardware.bluetooth.audio.UnicastCapability.VendorCapabilities vendorCapabillities;
android.hardware.bluetooth.audio.AptxAdaptiveLeCapabilities aptxAdaptiveLeCapabilities;
+ android.hardware.bluetooth.audio.OpusCapabilities opusCapabilities;
}
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecSpecificCapabilitiesLtv.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecSpecificCapabilitiesLtv.aidl
index fa302e3..94f0544 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecSpecificCapabilitiesLtv.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecSpecificCapabilitiesLtv.aidl
@@ -50,9 +50,11 @@
parcelable SupportedFrameDurations {
const int US7500 = 0x01;
const int US10000 = 0x02;
+ const int US20000 = 0x04;
/* Bits 2-3 are RFU */
const int US7500PREFERRED = 0x10;
const int US10000PREFERRED = 0x20;
+ const int US20000PREFERRED = 0x40;
/* 8 bit wide bit mask */
int bitmask;
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecSpecificConfigurationLtv.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecSpecificConfigurationLtv.aidl
index c099ebe..5e32e5e 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecSpecificConfigurationLtv.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecSpecificConfigurationLtv.aidl
@@ -43,6 +43,7 @@
enum FrameDuration {
US7500 = 0x00,
US10000 = 0x01,
+ US20000 = 0x02,
}
parcelable AudioChannelAllocation {
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
index 7ce6ff3..20e6c0c 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
@@ -16,8 +16,9 @@
package android.hardware.bluetooth.audio;
-import android.hardware.bluetooth.audio.Lc3Configuration;
import android.hardware.bluetooth.audio.AptxAdaptiveLeConfiguration;
+import android.hardware.bluetooth.audio.Lc3Configuration;
+import android.hardware.bluetooth.audio.OpusConfiguration;
@VintfStability
union LeAudioCodecConfiguration {
@@ -28,4 +29,5 @@
Lc3Configuration lc3Config;
VendorConfiguration vendorConfig;
AptxAdaptiveLeConfiguration aptxAdaptiveLeConfig;
+ OpusConfiguration opusConfig;
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl
index 07688a7..8583221 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastCapability.aidl
@@ -16,10 +16,11 @@
package android.hardware.bluetooth.audio;
+import android.hardware.bluetooth.audio.AptxAdaptiveLeCapabilities;
import android.hardware.bluetooth.audio.AudioLocation;
import android.hardware.bluetooth.audio.CodecType;
import android.hardware.bluetooth.audio.Lc3Capabilities;
-import android.hardware.bluetooth.audio.AptxAdaptiveLeCapabilities;
+import android.hardware.bluetooth.audio.OpusCapabilities;
/**
* Used to specify the le audio unicast codec capabilities for hardware offload.
@@ -35,6 +36,7 @@
Lc3Capabilities lc3Capabilities;
VendorCapabilities vendorCapabillities;
AptxAdaptiveLeCapabilities aptxAdaptiveLeCapabilities;
+ OpusCapabilities opusCapabilities;
}
CodecType codecType;
AudioLocation supportedChannel;
diff --git a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
index 61c29d3..a10e0a6 100644
--- a/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/LeAudioOffloadAudioProvider.cpp
@@ -82,6 +82,8 @@
CodecSpecificCapabilitiesLtv::SupportedFrameDurations::US7500},
{CodecSpecificConfigurationLtv::FrameDuration::US10000,
CodecSpecificCapabilitiesLtv::SupportedFrameDurations::US10000},
+ {CodecSpecificConfigurationLtv::FrameDuration::US20000,
+ CodecSpecificCapabilitiesLtv::SupportedFrameDurations::US20000},
};
std::map<int32_t, CodecSpecificConfigurationLtv::SamplingFrequency>
@@ -768,7 +770,7 @@
// A setting must match both source and sink.
// First filter all setting matched with sink capability
if (in_remoteSinkAudioCapabilities.has_value()) {
- for (auto& setting : ase_configuration_settings)
+ for (auto& setting : ase_configuration_settings) {
for (auto& capability : in_remoteSinkAudioCapabilities.value()) {
if (!capability.has_value()) continue;
auto filtered_ase_configuration_setting =
@@ -779,6 +781,7 @@
filtered_ase_configuration_setting.value());
}
}
+ }
} else {
sink_matched_ase_configuration_settings = ase_configuration_settings;
}
@@ -809,7 +812,6 @@
// Matching priority list:
// Preferred context - exact match with allocation
// Any context - exact match with allocation
-
auto matched_setting_with_context = matchWithRequirement(
matched_ase_configuration_settings, requirement, true);
if (matched_setting_with_context.has_value()) {
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.cpp b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.cpp
index 37812fa..8475d39 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothLeAudioAseConfigurationSettingProvider.cpp
@@ -92,6 +92,7 @@
/* Frame Durations */
constexpr uint8_t kLeAudioCodecFrameDur7500us = 0x00;
constexpr uint8_t kLeAudioCodecFrameDur10000us = 0x01;
+constexpr uint8_t kLeAudioCodecFrameDur20000us = 0x02;
/* Audio Allocations */
constexpr uint32_t kLeAudioLocationNotAllowed = 0x00000000;
@@ -171,7 +172,9 @@
{kLeAudioCodecFrameDur7500us,
CodecSpecificConfigurationLtv::FrameDuration::US7500},
{kLeAudioCodecFrameDur10000us,
- CodecSpecificConfigurationLtv::FrameDuration::US10000}};
+ CodecSpecificConfigurationLtv::FrameDuration::US10000},
+ {kLeAudioCodecFrameDur20000us,
+ CodecSpecificConfigurationLtv::FrameDuration::US20000}};
/* Helper map for matching various audio channel allocation notations */
std::map<uint32_t, uint32_t> audio_channel_allocation_map = {
@@ -487,6 +490,9 @@
case CodecSpecificConfigurationLtv::FrameDuration::US10000:
qos.sduIntervalUs = 10000;
break;
+ case CodecSpecificConfigurationLtv::FrameDuration::US20000:
+ qos.sduIntervalUs = 20000;
+ break;
}
qos.sduIntervalUs *= frameBlockValue;
}
diff --git a/bluetooth/audio/utils/le_audio_configuration_set/audio_set_configurations.json b/bluetooth/audio/utils/le_audio_configuration_set/audio_set_configurations.json
index fbfa3f9..88e9ce4 100644
--- a/bluetooth/audio/utils/le_audio_configuration_set/audio_set_configurations.json
+++ b/bluetooth/audio/utils/le_audio_configuration_set/audio_set_configurations.json
@@ -18,6 +18,7 @@
" Example values which can be used as 'codec_configuration.compound_value'",
" Codec Coding formats:",
" LC3 = 6",
+ " OPUS = 225",
" Sampling Frequencies: ",
" 8000Hz = 1",
" 11025Hz = 2",
@@ -34,7 +35,8 @@
" 384000Hz = 13",
" Frame Durations:",
" 7500us = 0",
- " 10000us = 1"
+ " 10000us = 1",
+ " 20000us = 2"
],
"configurations": [
{