xref: /aosp_15_r20/hardware/interfaces/bluetooth/audio/2.0/IBluetoothAudioPort.hal (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker/*
2*4d7e907cSAndroid Build Coastguard Worker * Copyright 2018 The Android Open Source Project
3*4d7e907cSAndroid Build Coastguard Worker *
4*4d7e907cSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*4d7e907cSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*4d7e907cSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*4d7e907cSAndroid Build Coastguard Worker *
8*4d7e907cSAndroid Build Coastguard Worker *      http://www.apache.org/licenses/LICENSE-2.0
9*4d7e907cSAndroid Build Coastguard Worker *
10*4d7e907cSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*4d7e907cSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*4d7e907cSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*4d7e907cSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*4d7e907cSAndroid Build Coastguard Worker * limitations under the License.
15*4d7e907cSAndroid Build Coastguard Worker */
16*4d7e907cSAndroid Build Coastguard Worker
17*4d7e907cSAndroid Build Coastguard Workerpackage [email protected];
18*4d7e907cSAndroid Build Coastguard Worker
19*4d7e907cSAndroid Build Coastguard Workerimport [email protected]::SourceMetadata;
20*4d7e907cSAndroid Build Coastguard Worker
21*4d7e907cSAndroid Build Coastguard Worker/**
22*4d7e907cSAndroid Build Coastguard Worker * HAL interface from the Audio HAL to the Bluetooth stack
23*4d7e907cSAndroid Build Coastguard Worker *
24*4d7e907cSAndroid Build Coastguard Worker * The Audio HAL calls methods in this interface to start, suspend, and stop
25*4d7e907cSAndroid Build Coastguard Worker * an audio stream. These calls return immediately and the results, if any,
26*4d7e907cSAndroid Build Coastguard Worker * are sent over the IBluetoothAudioProvider interface.
27*4d7e907cSAndroid Build Coastguard Worker *
28*4d7e907cSAndroid Build Coastguard Worker * Moreover, the Audio HAL can also get the presentation position of the stream
29*4d7e907cSAndroid Build Coastguard Worker * and provide stream metadata.
30*4d7e907cSAndroid Build Coastguard Worker *
31*4d7e907cSAndroid Build Coastguard Worker * Note: For HIDL APIs with a "generates" statement, the callback parameter used
32*4d7e907cSAndroid Build Coastguard Worker * for return value must be invoked synchronously before the API call returns.
33*4d7e907cSAndroid Build Coastguard Worker */
34*4d7e907cSAndroid Build Coastguard Workerinterface IBluetoothAudioPort {
35*4d7e907cSAndroid Build Coastguard Worker    /**
36*4d7e907cSAndroid Build Coastguard Worker     * This indicates that the caller of this method has opened the data path
37*4d7e907cSAndroid Build Coastguard Worker     * and wants to start an audio stream. The caller must wait for a
38*4d7e907cSAndroid Build Coastguard Worker     * IBluetoothAudioProvider.streamStarted(Status) call.
39*4d7e907cSAndroid Build Coastguard Worker     */
40*4d7e907cSAndroid Build Coastguard Worker    startStream();
41*4d7e907cSAndroid Build Coastguard Worker
42*4d7e907cSAndroid Build Coastguard Worker    /**
43*4d7e907cSAndroid Build Coastguard Worker     * This indicates that the caller of this method wants to suspend the audio
44*4d7e907cSAndroid Build Coastguard Worker     * stream. The caller must wait for the Bluetooth process to call
45*4d7e907cSAndroid Build Coastguard Worker     * IBluetoothAudioProvider.streamSuspended(Status). The caller still keeps
46*4d7e907cSAndroid Build Coastguard Worker     * the data path open.
47*4d7e907cSAndroid Build Coastguard Worker     */
48*4d7e907cSAndroid Build Coastguard Worker    suspendStream();
49*4d7e907cSAndroid Build Coastguard Worker
50*4d7e907cSAndroid Build Coastguard Worker    /**
51*4d7e907cSAndroid Build Coastguard Worker     * This indicates that the caller of this method wants to stop the audio
52*4d7e907cSAndroid Build Coastguard Worker     * stream. The data path will be closed after this call. There is no
53*4d7e907cSAndroid Build Coastguard Worker     * callback from the IBluetoothAudioProvider interface even though the
54*4d7e907cSAndroid Build Coastguard Worker     * teardown is asynchronous.
55*4d7e907cSAndroid Build Coastguard Worker     */
56*4d7e907cSAndroid Build Coastguard Worker    stopStream();
57*4d7e907cSAndroid Build Coastguard Worker
58*4d7e907cSAndroid Build Coastguard Worker    /**
59*4d7e907cSAndroid Build Coastguard Worker     * Get the audio presentation position.
60*4d7e907cSAndroid Build Coastguard Worker     *
61*4d7e907cSAndroid Build Coastguard Worker     * @return status the command status
62*4d7e907cSAndroid Build Coastguard Worker     * @return remoteDeviceAudioDelayNanos the audio delay from when the remote
63*4d7e907cSAndroid Build Coastguard Worker     *    device (e.g. headset) receives audio data to when the device plays the
64*4d7e907cSAndroid Build Coastguard Worker     *    sound. If the delay is unknown, the value is set to zero.
65*4d7e907cSAndroid Build Coastguard Worker     * @return transmittedOctets the number of audio data octets that were sent
66*4d7e907cSAndroid Build Coastguard Worker     *    to a remote device. This excludes octets that have been written to the
67*4d7e907cSAndroid Build Coastguard Worker     *    data path but have not been sent to the remote device. The count is
68*4d7e907cSAndroid Build Coastguard Worker     *    not reset until stopStream() is called. If the software data path is
69*4d7e907cSAndroid Build Coastguard Worker     *    unused (e.g. A2DP Hardware Offload), the value is set to 0.
70*4d7e907cSAndroid Build Coastguard Worker     * @return transmittedOctetsTimeStamp the value of CLOCK_MONOTONIC
71*4d7e907cSAndroid Build Coastguard Worker     *    corresponding to transmittedOctets. If the software data path is
72*4d7e907cSAndroid Build Coastguard Worker     *    unused (e.g., for A2DP Hardware Offload), the value is set to zero.
73*4d7e907cSAndroid Build Coastguard Worker     */
74*4d7e907cSAndroid Build Coastguard Worker    getPresentationPosition() generates (Status status,
75*4d7e907cSAndroid Build Coastguard Worker        uint64_t remoteDeviceAudioDelayNanos, uint64_t transmittedOctets,
76*4d7e907cSAndroid Build Coastguard Worker        TimeSpec transmittedOctetsTimeStamp);
77*4d7e907cSAndroid Build Coastguard Worker
78*4d7e907cSAndroid Build Coastguard Worker    /**
79*4d7e907cSAndroid Build Coastguard Worker     * Called when the metadata of the stream's source has been changed.
80*4d7e907cSAndroid Build Coastguard Worker     *
81*4d7e907cSAndroid Build Coastguard Worker     * @param sourceMetadata Description of the audio that is played by the
82*4d7e907cSAndroid Build Coastguard Worker     *    clients.
83*4d7e907cSAndroid Build Coastguard Worker     */
84*4d7e907cSAndroid Build Coastguard Worker    updateMetadata(SourceMetadata sourceMetadata);
85*4d7e907cSAndroid Build Coastguard Worker};
86