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 I_ENGINE_H 16 #define I_ENGINE_H 17 18 #include <functional> 19 #include <memory> 20 #include "v1_0/intell_voice_engine_types.h" 21 22 namespace OHOS { 23 namespace IntelligentVoice { 24 namespace Engine { 25 using OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineCallBackEvent; 26 using OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineAdapterInfo; 27 using OHOS::HDI::IntelligentVoice::Engine::V1_0::StartInfo; 28 using OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineAdapterDescriptor; 29 using OHOS::HDI::IntelligentVoice::Engine::V1_0::ContentType; 30 31 using IntellVoiceStatus = int32_t; 32 33 using getParameterCb = std::function<void(const std::string &retStr)>; 34 using getFileDataCb = std::function<void(std::shared_ptr<uint8_t> data, uint32_t size)>; 35 36 class IEngineCallback { 37 public: 38 IEngineCallback() = default; 39 virtual ~IEngineCallback() = default; 40 virtual void OnIntellVoiceEvent(const IntellVoiceEngineCallBackEvent &event) = 0; 41 }; 42 43 class IEngine { 44 public: IEngine()45 IEngine() {}; ~IEngine()46 virtual ~IEngine() {}; 47 virtual IntellVoiceStatus SetListener(std::shared_ptr<IEngineCallback> listener) = 0; 48 virtual IntellVoiceStatus Init(const IntellVoiceEngineAdapterInfo &adapterInfo) = 0; 49 virtual IntellVoiceStatus Release() = 0; 50 virtual IntellVoiceStatus SetParameter(const std::string &keyValueList) = 0; 51 virtual IntellVoiceStatus GetParameter(const std::string &keyList, getParameterCb cb) = 0; 52 virtual IntellVoiceStatus Write(const uint8_t *buffer, uint32_t size) = 0; 53 virtual IntellVoiceStatus Start(const StartInfo &info) = 0; 54 virtual IntellVoiceStatus Stop() = 0; 55 virtual IntellVoiceStatus Cancel() = 0; 56 virtual IntellVoiceStatus ReadFileData(ContentType type, getFileDataCb cb) = 0; 57 }; 58 59 class IEngineManager { 60 public: 61 virtual int32_t CreateAdapter(const IntellVoiceEngineAdapterDescriptor &descriptor, 62 std::unique_ptr<IEngine> &engine) = 0; 63 virtual int32_t ReleaseAdapter(const IntellVoiceEngineAdapterDescriptor &descriptor) = 0; 64 }; 65 } 66 } 67 } 68 #endif