Grzegorz Kolodziejczyk | b5f2d23 | 2019-10-24 12:31:20 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 21 | namespace android { |
| 22 | namespace hardware { |
| 23 | namespace bluetooth { |
| 24 | namespace audio { |
| 25 | namespace V2_1 { |
| 26 | namespace implementation { |
| 27 | |
| 28 | using ::android::sp; |
| 29 | using ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioPort; |
| 30 | |
| 31 | using BluetoothAudioStatus = |
| 32 | ::android::hardware::bluetooth::audio::V2_0::Status; |
| 33 | |
| 34 | class BluetoothAudioDeathRecipient; |
| 35 | |
| 36 | class 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 | |
| 64 | class 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 |