blob: 02bf2b992a022011df44158343e8daa0f051851b [file] [log] [blame]
Cheney Ni47a83092018-11-17 01:42:19 +08001/*
2 * Copyright 2018 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.0/IBluetoothAudioProvider.h>
20
21namespace android {
22namespace hardware {
23namespace bluetooth {
24namespace audio {
25namespace V2_0 {
26namespace implementation {
27
28using ::android::sp;
29using ::android::hardware::bluetooth::audio::V2_0::AudioConfiguration;
30using ::android::hardware::bluetooth::audio::V2_0::SessionType;
31
32using BluetoothAudioStatus =
33 ::android::hardware::bluetooth::audio::V2_0::Status;
34
35class BluetoothAudioDeathRecipient;
36
37class BluetoothAudioProvider : public IBluetoothAudioProvider {
38 public:
39 BluetoothAudioProvider();
40 ~BluetoothAudioProvider() = default;
41
42 virtual bool isValid(const SessionType& sessionType) = 0;
43
44 Return<void> startSession(const sp<IBluetoothAudioPort>& hostIf,
45 const AudioConfiguration& audioConfig,
46 startSession_cb _hidl_cb) override;
47 Return<void> streamStarted(BluetoothAudioStatus status) override;
48 Return<void> streamSuspended(BluetoothAudioStatus status) override;
49 Return<void> endSession() override;
50
51 protected:
52 sp<BluetoothAudioDeathRecipient> death_recipient_;
53
54 SessionType session_type_;
55 AudioConfiguration audio_config_;
56 sp<IBluetoothAudioPort> stack_iface_;
57
58 virtual Return<void> onSessionReady(startSession_cb _hidl_cb) = 0;
59};
60
61class BluetoothAudioDeathRecipient : public hidl_death_recipient {
62 public:
63 BluetoothAudioDeathRecipient(const sp<BluetoothAudioProvider> provider)
64 : provider_(provider) {}
65
66 virtual void serviceDied(
67 uint64_t cookie,
68 const wp<::android::hidl::base::V1_0::IBase>& who) override;
69
70 private:
71 sp<BluetoothAudioProvider> provider_;
72};
73
74} // namespace implementation
75} // namespace V2_0
76} // namespace audio
77} // namespace bluetooth
78} // namespace hardware
79} // namespace android