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, |
| 44 | const std::vector<LatencyMode>& latency_modes, |
| 45 | DataMQDesc* _aidl_return); |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 46 | ndk::ScopedAStatus endSession(); |
| 47 | ndk::ScopedAStatus streamStarted(BluetoothAudioStatus status); |
| 48 | ndk::ScopedAStatus streamSuspended(BluetoothAudioStatus status); |
| 49 | ndk::ScopedAStatus updateAudioConfiguration( |
| 50 | const AudioConfiguration& audio_config); |
Chen Chen | 7cdf832 | 2022-02-08 13:24:11 -0800 | [diff] [blame] | 51 | ndk::ScopedAStatus setLowLatencyModeAllowed(bool allowed); |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 52 | |
| 53 | virtual bool isValid(const SessionType& sessionType) = 0; |
| 54 | |
| 55 | protected: |
| 56 | virtual ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) = 0; |
| 57 | static void binderDiedCallbackAidl(void* cookie_ptr); |
| 58 | |
| 59 | ::ndk::ScopedAIBinder_DeathRecipient death_recipient_; |
| 60 | |
| 61 | std::shared_ptr<IBluetoothAudioPort> stack_iface_; |
| 62 | std::unique_ptr<AudioConfiguration> audio_config_ = nullptr; |
| 63 | SessionType session_type_; |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 64 | std::vector<LatencyMode> latency_modes_; |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | } // namespace audio |
| 68 | } // namespace bluetooth |
| 69 | } // namespace hardware |
| 70 | } // namespace android |
Cheney Ni | 6ecbc76 | 2022-03-03 00:12:48 +0800 | [diff] [blame^] | 71 | } // namespace aidl |