Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 1 | /* |
| 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 Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 19 | #include <aidl/android/hardware/bluetooth/audio/LatencyMode.h> |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 20 | #include <aidl/android/hardware/bluetooth/audio/SessionType.h> |
| 21 | #include <fmq/AidlMessageQueue.h> |
| 22 | |
| 23 | using ::aidl::android::hardware::common::fmq::MQDescriptor; |
| 24 | using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite; |
| 25 | using ::android::AidlMessageQueue; |
| 26 | |
| 27 | using MqDataType = int8_t; |
| 28 | using MqDataMode = SynchronizedReadWrite; |
| 29 | using DataMQ = AidlMessageQueue<MqDataType, MqDataMode>; |
| 30 | using DataMQDesc = MQDescriptor<MqDataType, MqDataMode>; |
| 31 | |
| 32 | namespace aidl { |
| 33 | namespace android { |
| 34 | namespace hardware { |
| 35 | namespace bluetooth { |
| 36 | namespace audio { |
| 37 | |
| 38 | class BluetoothAudioProvider : public BnBluetoothAudioProvider { |
| 39 | public: |
| 40 | BluetoothAudioProvider(); |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 41 | ndk::ScopedAStatus startSession( |
| 42 | const std::shared_ptr<IBluetoothAudioPort>& host_if, |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 43 | const AudioConfiguration& audio_config, |
Bao Do | 6aeb5d7 | 2023-12-11 10:53:18 +0000 | [diff] [blame] | 44 | const std::vector<LatencyMode>& latency_modes, DataMQDesc* _aidl_return); |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 45 | 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 Chen | 7cdf832 | 2022-02-08 13:24:11 -0800 | [diff] [blame] | 50 | ndk::ScopedAStatus setLowLatencyModeAllowed(bool allowed); |
Jakub Tyszkowski | ccceb2f | 2023-11-10 09:55:22 +0000 | [diff] [blame] | 51 | 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 Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 111 | |
Antoine SOULIER | 33c4e5a | 2023-09-28 21:59:19 +0000 | [diff] [blame] | 112 | 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 Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 120 | virtual bool isValid(const SessionType& sessionType) = 0; |
| 121 | |
| 122 | protected: |
| 123 | virtual ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) = 0; |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 124 | |
| 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 Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 130 | std::vector<LatencyMode> latency_modes_; |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 131 | }; |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 132 | } // namespace audio |
| 133 | } // namespace bluetooth |
| 134 | } // namespace hardware |
| 135 | } // namespace android |
Cheney Ni | 6ecbc76 | 2022-03-03 00:12:48 +0800 | [diff] [blame] | 136 | } // namespace aidl |