bluetooth: LE Audio multi-codec extensibility - broadcast

Bug: 308428217
Bug: 307258939
Test: m android.hardware.bluetooth.audio-update-api
Change-Id: I50c07be7bd947f095824f3cf4630c0d640921f9a
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
index 788e38f..f155634 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
@@ -48,6 +48,8 @@
   android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioDataPathConfigurationPair getLeAudioAseDatapathConfiguration(in android.hardware.bluetooth.audio.AudioContext context, in android.hardware.bluetooth.audio.LeAudioConfiguration.StreamMap[] streamMap);
   void onSinkAseMetadataChanged(in android.hardware.bluetooth.audio.IBluetoothAudioProvider.AseState state, int cigId, int cisId, in @nullable android.hardware.bluetooth.audio.MetadataLtv[] metadata);
   void onSourceAseMetadataChanged(in android.hardware.bluetooth.audio.IBluetoothAudioProvider.AseState state, int cigId, int cisId, in @nullable android.hardware.bluetooth.audio.MetadataLtv[] metadata);
+  android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioBroadcastConfigurationSetting getLeAudioBroadcastConfiguration(in @nullable List<android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioDeviceCapabilities> remoteSinkAudioCapabilities, in android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioBroadcastConfigurationRequirement requirement);
+  android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioDataPathConfiguration getLeAudioBroadcastDatapathConfiguration(in android.hardware.bluetooth.audio.AudioContext context, in android.hardware.bluetooth.audio.LeAudioBroadcastConfiguration.BroadcastStreamMap[] streamMap);
   @VintfStability
   parcelable LeAudioDeviceCapabilities {
     android.hardware.bluetooth.audio.CodecId codecId;
@@ -121,7 +123,7 @@
     android.hardware.bluetooth.audio.AudioContext contextType;
     @nullable android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioAseQosConfigurationRequirement.AseQosDirectionRequirement sinkAseQosRequirement;
     @nullable android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioAseQosConfigurationRequirement.AseQosDirectionRequirement sourceAseQosRequirement;
-    @nullable android.hardware.bluetooth.audio.ConfigurationFlags[] flags;
+    @nullable android.hardware.bluetooth.audio.ConfigurationFlags flags;
     @VintfStability
     parcelable AseQosDirectionRequirement {
       android.hardware.bluetooth.audio.IBluetoothAudioProvider.Framing framing;
@@ -150,4 +152,42 @@
     STREAMING = 0x01,
     DISABLING = 0x02,
   }
+  @Backing(type="byte") @VintfStability
+  enum BroadcastQuality {
+    STANDARD,
+    HIGH,
+  }
+  @VintfStability
+  parcelable LeAudioBroadcastSubgroupConfigurationRequirement {
+    android.hardware.bluetooth.audio.AudioContext context;
+    android.hardware.bluetooth.audio.IBluetoothAudioProvider.BroadcastQuality quality;
+    int bisNumPerSubgroup;
+  }
+  @VintfStability
+  parcelable LeAudioBroadcastConfigurationRequirement {
+    List<android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioBroadcastSubgroupConfigurationRequirement> subgroupConfigurationRequirements;
+  }
+  @VintfStability
+  parcelable LeAudioSubgroupBisConfiguration {
+    int numBis;
+    android.hardware.bluetooth.audio.LeAudioBisConfiguration bisConfiguration;
+  }
+  @VintfStability
+  parcelable LeAudioBroadcastSubgroupConfiguration {
+    List<android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioSubgroupBisConfiguration> bisConfigurations;
+    @nullable byte[] vendorCodecConfiguration;
+  }
+  @VintfStability
+  parcelable LeAudioBroadcastConfigurationSetting {
+    int sduIntervalUs;
+    int numBis;
+    int maxSduOctets;
+    int maxTransportLatencyMs;
+    int retransmitionNum;
+    android.hardware.bluetooth.audio.Phy[] phy;
+    android.hardware.bluetooth.audio.IBluetoothAudioProvider.Packing packing;
+    android.hardware.bluetooth.audio.IBluetoothAudioProvider.Framing framing;
+    @nullable android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioDataPathConfiguration dataPathConfiguration;
+    List<android.hardware.bluetooth.audio.IBluetoothAudioProvider.LeAudioBroadcastSubgroupConfiguration> subgroupsConfigurations;
+  }
 }
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBisConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBisConfiguration.aidl
new file mode 100644
index 0000000..b09d34f
--- /dev/null
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBisConfiguration.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2023 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 <name>-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 LeAudioBisConfiguration {
+  android.hardware.bluetooth.audio.CodecId codecId;
+  android.hardware.bluetooth.audio.CodecSpecificConfigurationLtv[] codecConfiguration;
+  byte[] vendorCodecConfiguration;
+  @nullable android.hardware.bluetooth.audio.MetadataLtv[] metadata;
+}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
index 2945710..efd3b02 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
@@ -42,5 +42,7 @@
     int audioChannelAllocation;
     android.hardware.bluetooth.audio.LeAudioCodecConfiguration leAudioCodecConfig;
     char pcmStreamId;
+    @nullable android.hardware.bluetooth.audio.LeAudioBisConfiguration bisConfiguration;
+    @nullable android.hardware.bluetooth.audio.ConfigurationFlags flags;
   }
 }
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
index f565018..2e16f4e 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
@@ -26,10 +26,13 @@
 import android.hardware.bluetooth.audio.CodecId;
 import android.hardware.bluetooth.audio.CodecParameters;
 import android.hardware.bluetooth.audio.CodecSpecificCapabilitiesLtv;
+import android.hardware.bluetooth.audio.CodecSpecificConfigurationLtv;
 import android.hardware.bluetooth.audio.ConfigurationFlags;
 import android.hardware.bluetooth.audio.IBluetoothAudioPort;
 import android.hardware.bluetooth.audio.LatencyMode;
 import android.hardware.bluetooth.audio.LeAudioAseConfiguration;
+import android.hardware.bluetooth.audio.LeAudioBisConfiguration;
+import android.hardware.bluetooth.audio.LeAudioBroadcastConfiguration.BroadcastStreamMap;
 import android.hardware.bluetooth.audio.LeAudioConfiguration.StreamMap;
 import android.hardware.bluetooth.audio.MetadataLtv;
 import android.hardware.bluetooth.audio.Phy;
@@ -477,7 +480,7 @@
         /**
          * Additional configuration flags requirements
          */
-        @nullable ConfigurationFlags[] flags;
+        @nullable ConfigurationFlags flags;
     }
 
     /**
@@ -548,4 +551,158 @@
             in AseState state, int cigId, int cisId, in @nullable MetadataLtv[] metadata);
     void onSourceAseMetadataChanged(
             in AseState state, int cigId, int cisId, in @nullable MetadataLtv[] metadata);
+
+    /**
+     * Broadcast quality index
+     */
+    @VintfStability
+    @Backing(type="byte")
+    enum BroadcastQuality {
+        STANDARD,
+        HIGH,
+    }
+
+    /**
+     * It is used in LeAudioBroadcastConfigurationRequirement
+     */
+    @VintfStability
+    parcelable LeAudioBroadcastSubgroupConfigurationRequirement {
+        /**
+         * Streaming Audio Context for the given subgroup.
+         * This can serve as a hint for selecting the proper configuration by
+         * the offloader.
+         */
+        AudioContext context;
+        /**
+         * Streaming Broadcast Audio Quality
+         */
+        BroadcastQuality quality;
+        /**
+         * Number of BISes for the given subgroup
+         */
+        int bisNumPerSubgroup;
+    }
+
+    /**
+     * It is used in getLeAudioBroadcastConfiguration method
+     * If any group id is provided, the Provider should check Pacs capabilities
+     * of the group(s) and provide Broadcast configuration supported by the
+     * group.
+     */
+    @VintfStability
+    parcelable LeAudioBroadcastConfigurationRequirement {
+        List<LeAudioBroadcastSubgroupConfigurationRequirement> subgroupConfigurationRequirements;
+    }
+
+    /**
+     * Subgroup BIS configuration
+     *
+     */
+    @VintfStability
+    parcelable LeAudioSubgroupBisConfiguration {
+        /**
+         * The number of BISes with the given configuration
+         */
+        int numBis;
+        /**
+         * LE Audio BIS configuration for the `numBis` number of BISes
+         */
+        LeAudioBisConfiguration bisConfiguration;
+    }
+
+    /**
+     * Subgroup configuration with a list of BIS configurations
+     *
+     */
+    @VintfStability
+    parcelable LeAudioBroadcastSubgroupConfiguration {
+        List<LeAudioSubgroupBisConfiguration> bisConfigurations;
+
+        /**
+         * Vendor specific codec configuration for all the BISes inside this
+         * subgroup. Only the vendor specific part is needed, since the BT stack
+         * can derive the common subgroup configuration by intersecting the LTV
+         * formatted configuration of every BIS inside the subgroup.
+         * This will not be parsed by the BT stack but will be set as the codec
+         * specific configuration for the ongoing audio stream at the subgroup
+         * level of the audio announcement,The remote device will receive this
+         * information when being configured for receiveing a brodcast audio
+         * stream.
+         */
+        @nullable byte[] vendorCodecConfiguration;
+    }
+
+    /**
+     * LeAudioBroadcastConfigurationSetting is a result of
+     * getLeAudioBroadcastConfiguration. It is used in HCI_LE_Create_BIG command
+     * and for creating the Broadcast Announcements.
+     *
+     */
+    @VintfStability
+    parcelable LeAudioBroadcastConfigurationSetting {
+        /**
+         * SDU Interval (in microseconds) used in LE Create BIG command
+         */
+        int sduIntervalUs;
+        /**
+         * Total number of BISes in the BIG
+         */
+        int numBis;
+        /**
+         *  Maximum size of an SDU in octets
+         */
+        int maxSduOctets;
+        /**
+         * Maximum transport latency (in milliseconds)
+         */
+        int maxTransportLatencyMs;
+        /**
+         * The number of times every PDU should be retransmitted
+         */
+        int retransmitionNum;
+        /**
+         * A list of PHYs used for transmission of PDUs of BISes in the BIG.
+         */
+        Phy[] phy;
+        /**
+         * The preferred method of arranging subevents of multiple BISes
+         */
+        Packing packing;
+        /**
+         * format for sending BIS Data PDUs
+         */
+        Framing framing;
+
+        /**
+         * Data path configuration
+         * If not provided, getLeAudioBroadcastDatapathConfiguration() will be
+         * called during the configuration, increasing the stream establishment
+         * time (not recommended).
+         */
+        @nullable LeAudioDataPathConfiguration dataPathConfiguration;
+
+        /**
+         * A list of subgroup configurations in the broadcast.
+         */
+        List<LeAudioBroadcastSubgroupConfiguration> subgroupsConfigurations;
+    }
+
+    /**
+     * Get Broadcast configuration. Output of this function will be used
+     * in HCI_LE_Create_BIG  (0x0068) command and also to create BIG INFO
+     *
+     */
+    LeAudioBroadcastConfigurationSetting getLeAudioBroadcastConfiguration(
+            in @nullable List<LeAudioDeviceCapabilities> remoteSinkAudioCapabilities,
+            in LeAudioBroadcastConfigurationRequirement requirement);
+
+    /**
+     * Used to get a data path configuration which dynamically depends on BIS
+     * handles in BroadcastStreamMap. This is used if non-dynamic data path was
+     * not provided in LeAudioBroadcastConfigurationSetting. Calling this during
+     * the broadcast audio stream establishment might slightly delay the stream
+     * start.
+     */
+    LeAudioDataPathConfiguration getLeAudioBroadcastDatapathConfiguration(
+            in AudioContext context, in BroadcastStreamMap[] streamMap);
 }
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBisConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBisConfiguration.aidl
new file mode 100644
index 0000000..4d6cfde
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBisConfiguration.aidl
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2023 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;
+
+import android.hardware.bluetooth.audio.CodecId;
+import android.hardware.bluetooth.audio.CodecSpecificConfigurationLtv;
+import android.hardware.bluetooth.audio.MetadataLtv;
+
+/**
+ * LE Audio BIS configuration. This will be part of the streaming broadcast
+ * audio announcement advertised by the BT stack during the broadcast audio
+ * stream to inform the remote devices about the broadcast audio configuration.
+ * It will also be passed back to the vendor module as part of the currently
+ * active LeAudioBroadcastConfiguration for the encoder setup.
+ * As defined in Bluetooth Basic Audio Profile Specification, v.1.0.1,
+ * Sec. 3.7.2.2, Table 3.15, Level 3.
+ */
+@VintfStability
+parcelable LeAudioBisConfiguration {
+    /**
+     * Codec ID
+     */
+    CodecId codecId;
+
+    /**
+     * Codec configuration for BIS or group of BISes represented in the LTV
+     * types defined by Bluetooht SIG. Regardless of vendor specific
+     * configuration being used or not, this shall contain Bluetooth LTV types
+     * describing the common stream parameters, at least
+     * CodecSpecificConfigurationLtv.SamplingFrequency and
+     * CodecSpecificConfigurationLtv.AudioChannelAllocation.
+     * This will also be used to verify the requirements on the known LTV types.
+     */
+    CodecSpecificConfigurationLtv[] codecConfiguration;
+
+    /**
+     * Vendor specific codec configuration.
+     * This will not be parsed by the BT stack but will be set as the codec
+     * specific configuration for the ongoing audio stream, encoded by the
+     * vendor module. The remote device will receive this information when being
+     * configured for receiveing a brodcast audio stream. If this is populated,
+     * only the `vendorCodecConfiguration` will be used when configuring the
+     * remote device, otherwise `codecConfiguration` will be used.
+     */
+    byte[] vendorCodecConfiguration;
+
+    /**
+     * Metadata for the particular BIS or group of BISes. This is optional.
+     */
+    @nullable MetadataLtv[] metadata;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
index 16503fb..da90373 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioBroadcastConfiguration.aidl
@@ -17,6 +17,8 @@
 package android.hardware.bluetooth.audio;
 
 import android.hardware.bluetooth.audio.CodecType;
+import android.hardware.bluetooth.audio.ConfigurationFlags;
+import android.hardware.bluetooth.audio.LeAudioBisConfiguration;
 import android.hardware.bluetooth.audio.LeAudioCodecConfiguration;
 
 @VintfStability
@@ -39,6 +41,15 @@
          * Pcm stream id to identify the source for given streamHandle.
          */
         char pcmStreamId;
+        /*
+         * LE Audio BIS configuration
+         */
+        @nullable LeAudioBisConfiguration bisConfiguration;
+        /*
+         * Additional flags, used to request configurations with special
+         * features
+         */
+        @nullable ConfigurationFlags flags;
     }
     CodecType codecType;
     BroadcastStreamMap[] streamMap;