1 /* 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 21 namespace android { 22 namespace hardware { 23 namespace bluetooth { 24 namespace audio { 25 namespace V2_0 { 26 namespace implementation { 27 28 using ::android::sp; 29 using ::android::hardware::bluetooth::audio::V2_0::AudioConfiguration; 30 using ::android::hardware::bluetooth::audio::V2_0::SessionType; 31 32 using BluetoothAudioStatus = 33 ::android::hardware::bluetooth::audio::V2_0::Status; 34 35 class BluetoothAudioDeathRecipient; 36 37 class 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 61 class BluetoothAudioDeathRecipient : public hidl_death_recipient { 62 public: BluetoothAudioDeathRecipient(const sp<BluetoothAudioProvider> provider)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 80