blob: a2e611f01e475c0a3cd14d8ad0fb61d272da6164 [file] [log] [blame]
Grzegorz Kolodziejczykb5f2d232019-10-24 12:31:20 +02001/*
2 * Copyright 2020 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.1/IBluetoothAudioProvider.h>
20
21namespace android {
22namespace hardware {
23namespace bluetooth {
24namespace audio {
25namespace V2_1 {
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 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 AudioConfiguration& audioConfig,
49 startSession_cb _hidl_cb) override;
50 Return<void> streamStarted(BluetoothAudioStatus status) override;
51 Return<void> streamSuspended(BluetoothAudioStatus status) override;
52 Return<void> endSession() override;
53
54 protected:
55 sp<BluetoothAudioDeathRecipient> death_recipient_;
56
57 SessionType session_type_;
58 AudioConfiguration audio_config_;
59 sp<V2_0::IBluetoothAudioPort> stack_iface_;
60
61 virtual Return<void> onSessionReady(startSession_cb _hidl_cb) = 0;
62};
63
64class BluetoothAudioDeathRecipient : public hidl_death_recipient {
65 public:
66 BluetoothAudioDeathRecipient(const sp<BluetoothAudioProvider> provider)
67 : provider_(provider) {}
68
69 virtual void serviceDied(
70 uint64_t cookie,
71 const wp<::android::hidl::base::V1_0::IBase>& who) override;
72
73 private:
74 sp<BluetoothAudioProvider> provider_;
75};
76
77} // namespace implementation
78} // namespace V2_1
79} // namespace audio
80} // namespace bluetooth
81} // namespace hardware
82} // namespace android