blob: 2c21440ab2d5aed981f355d55ea9fc6cc41bb5c5 [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(
Jakub Tyszkowski48563082024-01-04 16:02:38 +000074 const std::optional<::aidl::android::hardware::bluetooth::audio::
75 IBluetoothAudioProvider::StreamConfig>&
76 in_sinkConfig,
77 const std::optional<::aidl::android::hardware::bluetooth::audio::
78 IBluetoothAudioProvider::StreamConfig>&
79 in_sourceConfig,
Jakub Tyszkowskiccceb2f2023-11-10 09:55:22 +000080 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
81 LeAudioDataPathConfigurationPair* _aidl_return) override;
82 ndk::ScopedAStatus onSinkAseMetadataChanged(
83 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
84 AseState in_state,
85 int32_t cigId, int32_t cisId,
86 const std::optional<std::vector<std::optional<
87 ::aidl::android::hardware::bluetooth::audio::MetadataLtv>>>&
88 in_metadata) override;
89 ndk::ScopedAStatus onSourceAseMetadataChanged(
90 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
91 AseState in_state,
92 int32_t cigId, int32_t cisId,
93 const std::optional<std::vector<std::optional<
94 ::aidl::android::hardware::bluetooth::audio::MetadataLtv>>>&
95 in_metadata) override;
96 ndk::ScopedAStatus getLeAudioBroadcastConfiguration(
97 const std::optional<std::vector<std::optional<
98 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
99 LeAudioDeviceCapabilities>>>& in_remoteSinkAudioCapabilities,
100 const ::aidl::android::hardware::bluetooth::audio::
101 IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement&
102 in_requirement,
103 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
104 LeAudioBroadcastConfigurationSetting* _aidl_return) override;
105 ndk::ScopedAStatus getLeAudioBroadcastDatapathConfiguration(
106 const ::aidl::android::hardware::bluetooth::audio::AudioContext&
107 in_context,
108 const std::vector<::aidl::android::hardware::bluetooth::audio::
109 LeAudioBroadcastConfiguration::BroadcastStreamMap>&
110 in_streamMap,
111 ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
112 LeAudioDataPathConfiguration* _aidl_return) override;
Josh Wu6ab53e72021-12-29 23:53:33 -0800113
Antoine SOULIER33c4e5a2023-09-28 21:59:19 +0000114 ndk::ScopedAStatus parseA2dpConfiguration(
115 const CodecId& codec_id, const std::vector<uint8_t>& configuration,
116 CodecParameters* codec_parameters, A2dpStatus* _aidl_return);
117 ndk::ScopedAStatus getA2dpConfiguration(
118 const std::vector<A2dpRemoteCapabilities>& remote_a2dp_capabilities,
119 const A2dpConfigurationHint& hint,
120 std::optional<audio::A2dpConfiguration>* _aidl_return);
121
Josh Wu6ab53e72021-12-29 23:53:33 -0800122 virtual bool isValid(const SessionType& sessionType) = 0;
123
124 protected:
125 virtual ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) = 0;
Josh Wu6ab53e72021-12-29 23:53:33 -0800126
127 ::ndk::ScopedAIBinder_DeathRecipient death_recipient_;
128
129 std::shared_ptr<IBluetoothAudioPort> stack_iface_;
130 std::unique_ptr<AudioConfiguration> audio_config_ = nullptr;
131 SessionType session_type_;
Chen Chenc92270e2022-02-14 18:29:52 -0800132 std::vector<LatencyMode> latency_modes_;
Josh Wu6ab53e72021-12-29 23:53:33 -0800133};
Josh Wu6ab53e72021-12-29 23:53:33 -0800134} // namespace audio
135} // namespace bluetooth
136} // namespace hardware
137} // namespace android
Cheney Ni6ecbc762022-03-03 00:12:48 +0800138} // namespace aidl