1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef HEADSET_MANAGER_HOST_H 16 #define HEADSET_MANAGER_HOST_H 17 #include "v1_0/iintell_voice_engine_manager.h" 18 #include "v1_1/iintell_voice_engine_manager.h" 19 #include "intell_voice_death_recipient.h" 20 #include "i_adapter_host_manager.h" 21 22 namespace OHOS { 23 namespace IntellVoiceEngine { 24 using OHOS::HDI::IntelligentVoice::Engine::V1_0::IIntellVoiceEngineAdapter; 25 using OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineAdapterDescriptor; 26 27 class HeadsetHostManager { 28 public: 29 HeadsetHostManager() = default; 30 ~HeadsetHostManager(); GetInstance()31 static HeadsetHostManager &GetInstance() 32 { 33 static HeadsetHostManager headsetHostMgr; 34 return headsetHostMgr; 35 } 36 37 bool Init(); 38 bool RegisterEngineHDIDeathRecipient(); 39 void DeregisterEngineHDIDeathRecipient(); 40 std::shared_ptr<IAdapterHostManager> CreateEngineAdapter(const IntellVoiceEngineAdapterDescriptor &desc); 41 void ReleaseEngineAdapter(const IntellVoiceEngineAdapterDescriptor &desc); GetHeadsetHostProxy1_0()42 const sptr<OHOS::HDI::IntelligentVoice::Engine::V1_0::IIntellVoiceEngineManager> &GetHeadsetHostProxy1_0() const 43 { 44 return headsetHostProxy1_0_; 45 } 46 47 private: 48 static void OnEngineHDIDiedCallback(); 49 50 sptr<OHOS::HDI::IntelligentVoice::Engine::V1_0::IIntellVoiceEngineManager> headsetHostProxy1_0_ = nullptr; 51 sptr<OHOS::IntellVoiceUtils::IntellVoiceDeathRecipient> engineHdiDeathRecipient_ = nullptr; 52 }; 53 } 54 } 55 #endif 56