blob: 393aaba7b6c1605170c884d0eec4973dcfec6063 [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>
19#include <aidl/android/hardware/bluetooth/audio/SessionType.h>
20#include <fmq/AidlMessageQueue.h>
21
22using ::aidl::android::hardware::common::fmq::MQDescriptor;
23using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
24using ::android::AidlMessageQueue;
25
26using MqDataType = int8_t;
27using MqDataMode = SynchronizedReadWrite;
28using DataMQ = AidlMessageQueue<MqDataType, MqDataMode>;
29using DataMQDesc = MQDescriptor<MqDataType, MqDataMode>;
30
31namespace aidl {
32namespace android {
33namespace hardware {
34namespace bluetooth {
35namespace audio {
36
37class BluetoothAudioProvider : public BnBluetoothAudioProvider {
38 public:
39 BluetoothAudioProvider();
40
41 ndk::ScopedAStatus startSession(
42 const std::shared_ptr<IBluetoothAudioPort>& host_if,
43 const AudioConfiguration& audio_config, DataMQDesc* _aidl_return);
44 ndk::ScopedAStatus endSession();
45 ndk::ScopedAStatus streamStarted(BluetoothAudioStatus status);
46 ndk::ScopedAStatus streamSuspended(BluetoothAudioStatus status);
47 ndk::ScopedAStatus updateAudioConfiguration(
48 const AudioConfiguration& audio_config);
Chen Chen7cdf8322022-02-08 13:24:11 -080049 ndk::ScopedAStatus setLowLatencyModeAllowed(bool allowed);
Josh Wu6ab53e72021-12-29 23:53:33 -080050
51 virtual bool isValid(const SessionType& sessionType) = 0;
52
53 protected:
54 virtual ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) = 0;
55 static void binderDiedCallbackAidl(void* cookie_ptr);
56
57 ::ndk::ScopedAIBinder_DeathRecipient death_recipient_;
58
59 std::shared_ptr<IBluetoothAudioPort> stack_iface_;
60 std::unique_ptr<AudioConfiguration> audio_config_ = nullptr;
61 SessionType session_type_;
62};
63
64} // namespace audio
65} // namespace bluetooth
66} // namespace hardware
67} // namespace android
68} // namespace aidl