blob: b7581ba0c3223e5337188570e51af06f467e66bb [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;
29using ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioPort;
30
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
44 Return<void> startSession(const sp<IBluetoothAudioPort>& hostIf,
45 const V2_0::AudioConfiguration& audioConfig,
46 startSession_cb _hidl_cb) override;
47 Return<void> startSession_2_1(const sp<IBluetoothAudioPort>& hostIf,
48 const V2_1::AudioConfiguration& audioConfig,
49 startSession_cb _hidl_cb) override;
50 Return<void> startSession_2_2(const sp<IBluetoothAudioPort>& hostIf,
51 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;
56
57 protected:
58 sp<BluetoothAudioDeathRecipient> death_recipient_;
59
60 V2_1::SessionType session_type_;
61 AudioConfiguration audio_config_;
62 sp<V2_0::IBluetoothAudioPort> stack_iface_;
63
64 virtual Return<void> onSessionReady(startSession_cb _hidl_cb) = 0;
65};
66
67class BluetoothAudioDeathRecipient : public hidl_death_recipient {
68 public:
69 BluetoothAudioDeathRecipient(const sp<BluetoothAudioProvider> provider)
70 : provider_(provider) {}
71
72 virtual void serviceDied(
73 uint64_t cookie,
74 const wp<::android::hidl::base::V1_0::IBase>& who) override;
75
76 private:
77 sp<BluetoothAudioProvider> provider_;
78};
79
80} // namespace implementation
81} // namespace V2_2
82} // namespace audio
83} // namespace bluetooth
84} // namespace hardware
85} // namespace android