blob: dbfff7d26cb745e546cbb9854ec002620d751902 [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,
44 const std::vector<LatencyMode>& latency_modes,
45 DataMQDesc* _aidl_return);
Josh Wu6ab53e72021-12-29 23:53:33 -080046 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 Chen7cdf8322022-02-08 13:24:11 -080051 ndk::ScopedAStatus setLowLatencyModeAllowed(bool allowed);
Josh Wu6ab53e72021-12-29 23:53:33 -080052
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 Chenc92270e2022-02-14 18:29:52 -080064 std::vector<LatencyMode> latency_modes_;
Josh Wu08255b42022-03-28 02:59:45 -070065 bool is_binder_died = false;
Josh Wu6ab53e72021-12-29 23:53:33 -080066};
67
68} // namespace audio
69} // namespace bluetooth
70} // namespace hardware
71} // namespace android
Cheney Ni6ecbc762022-03-03 00:12:48 +080072} // namespace aidl