blob: 90c158e5b5101ed13c0928f83d682451b92ab536 [file] [log] [blame]
Alice Kuo84e87672021-10-28 12:53:38 +08001/*
2 * Copyright 2021 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
17#pragma once
18
19#include <android/hardware/bluetooth/audio/2.2/IBluetoothAudioProvider.h>
20
21namespace android {
22namespace hardware {
23namespace bluetooth {
24namespace audio {
25namespace V2_2 {
26namespace implementation {
27
28using ::android::sp;
Jakub Pawlowski8d87eb72021-12-06 15:22:03 +010029using ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort;
Alice Kuo84e87672021-10-28 12:53:38 +080030
31using BluetoothAudioStatus =
32 ::android::hardware::bluetooth::audio::V2_0::Status;
33
34class BluetoothAudioDeathRecipient;
35
36class BluetoothAudioProvider : public IBluetoothAudioProvider {
37 public:
38 BluetoothAudioProvider();
39 ~BluetoothAudioProvider() = default;
40
41 virtual bool isValid(const V2_1::SessionType& sessionType) = 0;
42 virtual bool isValid(const V2_0::SessionType& sessionType) = 0;
43
Jakub Pawlowski8d87eb72021-12-06 15:22:03 +010044 Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf,
Alice Kuo84e87672021-10-28 12:53:38 +080045 const V2_0::AudioConfiguration& audioConfig,
46 startSession_cb _hidl_cb) override;
Jakub Pawlowski8d87eb72021-12-06 15:22:03 +010047 Return<void> startSession_2_1(const sp<V2_0::IBluetoothAudioPort>& hostIf,
Alice Kuo84e87672021-10-28 12:53:38 +080048 const V2_1::AudioConfiguration& audioConfig,
49 startSession_cb _hidl_cb) override;
Jakub Pawlowski8d87eb72021-12-06 15:22:03 +010050 Return<void> startSession_2_2(const sp<V2_2::IBluetoothAudioPort>& hostIf,
Alice Kuo84e87672021-10-28 12:53:38 +080051 const AudioConfiguration& audioConfig,
52 startSession_cb _hidl_cb) override;
53 Return<void> streamStarted(BluetoothAudioStatus status) override;
54 Return<void> streamSuspended(BluetoothAudioStatus status) override;
55 Return<void> endSession() override;
Alice Kuo3f9f41f2021-12-28 10:31:28 +080056 Return<void> updateAudioConfiguration(
57 const AudioConfiguration& audioConfig) override;
Alice Kuo84e87672021-10-28 12:53:38 +080058
Chen Chencc0cd5e2022-01-31 15:50:17 -080059 Return<void> setLowLatencyModeAllowed(bool allowed) override;
60
Alice Kuo84e87672021-10-28 12:53:38 +080061 protected:
62 sp<BluetoothAudioDeathRecipient> death_recipient_;
63
64 V2_1::SessionType session_type_;
65 AudioConfiguration audio_config_;
Jakub Pawlowski8d87eb72021-12-06 15:22:03 +010066 sp<V2_2::IBluetoothAudioPort> stack_iface_;
Alice Kuo84e87672021-10-28 12:53:38 +080067
68 virtual Return<void> onSessionReady(startSession_cb _hidl_cb) = 0;
69};
70
71class BluetoothAudioDeathRecipient : public hidl_death_recipient {
72 public:
73 BluetoothAudioDeathRecipient(const sp<BluetoothAudioProvider> provider)
74 : provider_(provider) {}
75
76 virtual void serviceDied(
77 uint64_t cookie,
78 const wp<::android::hidl::base::V1_0::IBase>& who) override;
79
80 private:
81 sp<BluetoothAudioProvider> provider_;
82};
83
84} // namespace implementation
85} // namespace V2_2
86} // namespace audio
87} // namespace bluetooth
88} // namespace hardware
89} // namespace android