blob: 5064869ca357c52bedb977afc630c525fd7dea28 [file] [log] [blame]
Josh Wu6ab53e72021-12-29 23:53:33 -08001/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <aidl/android/hardware/bluetooth/audio/BnBluetoothAudioProvider.h>
Chen Chenc92270e2022-02-14 18:29:52 -080019#include <aidl/android/hardware/bluetooth/audio/LatencyMode.h>
Josh Wu6ab53e72021-12-29 23:53:33 -080020#include <aidl/android/hardware/bluetooth/audio/SessionType.h>
21#include <fmq/AidlMessageQueue.h>
22
23using ::aidl::android::hardware::common::fmq::MQDescriptor;
24using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
25using ::android::AidlMessageQueue;
26
27using MqDataType = int8_t;
28using MqDataMode = SynchronizedReadWrite;
29using DataMQ = AidlMessageQueue<MqDataType, MqDataMode>;
30using DataMQDesc = MQDescriptor<MqDataType, MqDataMode>;
31
32namespace aidl {
33namespace android {
34namespace hardware {
35namespace bluetooth {
36namespace audio {
37
38class BluetoothAudioProvider : public BnBluetoothAudioProvider {
39 public:
40 BluetoothAudioProvider();
Josh Wu6ab53e72021-12-29 23:53:33 -080041 ndk::ScopedAStatus startSession(
42 const std::shared_ptr<IBluetoothAudioPort>& host_if,
Chen Chenc92270e2022-02-14 18:29:52 -080043 const AudioConfiguration& audio_config,
Bao Do6aeb5d72023-12-11 10:53:18 +000044 const std::vector<LatencyMode>& latency_modes, DataMQDesc* _aidl_return);
Josh Wu6ab53e72021-12-29 23:53:33 -080045 ndk::ScopedAStatus endSession();
46 ndk::ScopedAStatus streamStarted(BluetoothAudioStatus status);
47 ndk::ScopedAStatus streamSuspended(BluetoothAudioStatus status);
48 ndk::ScopedAStatus updateAudioConfiguration(
49 const AudioConfiguration& audio_config);
Chen Chen7cdf8322022-02-08 13:24:11 -080050 ndk::ScopedAStatus setLowLatencyModeAllowed(bool allowed);
Jakub Tyszkowskiccceb2f2023-11-10 09:55:22 +000051 ndk::ScopedAStatus setCodecPriority(
52 const ::aidl::android::hardware::bluetooth::audio::CodecId& in_codecId,
53 int32_t in_priority) override;
54 ndk::ScopedAStatus getLeAudioAseConfiguration(
55 const std::optional<std::vector<std::optional<
56 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
57 LeAudioDeviceCapabilities>>>& in_remoteSinkAudioCapabilities,
58 const std::optional<std::vector<std::optional<
59 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
60 LeAudioDeviceCapabilities>>>& in_remoteSourceAudioCapabilities,
61 const std::vector<
62 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
63 LeAudioConfigurationRequirement>& in_requirements,
64 std::vector<::aidl::android::hardware::bluetooth::audio::
65 IBluetoothAudioProvider::LeAudioAseConfigurationSetting>*
66 _aidl_return) override;
67 ndk::ScopedAStatus getLeAudioAseQosConfiguration(
68 const ::aidl::android::hardware::bluetooth::audio::
69 IBluetoothAudioProvider::LeAudioAseQosConfigurationRequirement&
70 in_qosRequirement,
71 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
72 LeAudioAseQosConfigurationPair* _aidl_return) override;
73 ndk::ScopedAStatus getLeAudioAseDatapathConfiguration(
74 const ::aidl::android::hardware::bluetooth::audio::AudioContext&
75 in_context,
76 const std::vector<::aidl::android::hardware::bluetooth::audio::
77 LeAudioConfiguration::StreamMap>& in_streamMap,
78 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
79 LeAudioDataPathConfigurationPair* _aidl_return) override;
80 ndk::ScopedAStatus onSinkAseMetadataChanged(
81 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
82 AseState in_state,
83 int32_t cigId, int32_t cisId,
84 const std::optional<std::vector<std::optional<
85 ::aidl::android::hardware::bluetooth::audio::MetadataLtv>>>&
86 in_metadata) override;
87 ndk::ScopedAStatus onSourceAseMetadataChanged(
88 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
89 AseState in_state,
90 int32_t cigId, int32_t cisId,
91 const std::optional<std::vector<std::optional<
92 ::aidl::android::hardware::bluetooth::audio::MetadataLtv>>>&
93 in_metadata) override;
94 ndk::ScopedAStatus getLeAudioBroadcastConfiguration(
95 const std::optional<std::vector<std::optional<
96 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
97 LeAudioDeviceCapabilities>>>& in_remoteSinkAudioCapabilities,
98 const ::aidl::android::hardware::bluetooth::audio::
99 IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement&
100 in_requirement,
101 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
102 LeAudioBroadcastConfigurationSetting* _aidl_return) override;
103 ndk::ScopedAStatus getLeAudioBroadcastDatapathConfiguration(
104 const ::aidl::android::hardware::bluetooth::audio::AudioContext&
105 in_context,
106 const std::vector<::aidl::android::hardware::bluetooth::audio::
107 LeAudioBroadcastConfiguration::BroadcastStreamMap>&
108 in_streamMap,
109 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
110 LeAudioDataPathConfiguration* _aidl_return) override;
Josh Wu6ab53e72021-12-29 23:53:33 -0800111
Antoine SOULIER33c4e5a2023-09-28 21:59:19 +0000112 ndk::ScopedAStatus parseA2dpConfiguration(
113 const CodecId& codec_id, const std::vector<uint8_t>& configuration,
114 CodecParameters* codec_parameters, A2dpStatus* _aidl_return);
115 ndk::ScopedAStatus getA2dpConfiguration(
116 const std::vector<A2dpRemoteCapabilities>& remote_a2dp_capabilities,
117 const A2dpConfigurationHint& hint,
118 std::optional<audio::A2dpConfiguration>* _aidl_return);
119
Josh Wu6ab53e72021-12-29 23:53:33 -0800120 virtual bool isValid(const SessionType& sessionType) = 0;
121
122 protected:
123 virtual ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) = 0;
Josh Wu6ab53e72021-12-29 23:53:33 -0800124
125 ::ndk::ScopedAIBinder_DeathRecipient death_recipient_;
126
127 std::shared_ptr<IBluetoothAudioPort> stack_iface_;
128 std::unique_ptr<AudioConfiguration> audio_config_ = nullptr;
129 SessionType session_type_;
Chen Chenc92270e2022-02-14 18:29:52 -0800130 std::vector<LatencyMode> latency_modes_;
Josh Wu6ab53e72021-12-29 23:53:33 -0800131};
Josh Wu6ab53e72021-12-29 23:53:33 -0800132} // namespace audio
133} // namespace bluetooth
134} // namespace hardware
135} // namespace android
Cheney Ni6ecbc762022-03-03 00:12:48 +0800136} // namespace aidl