1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci#ifndef I_ENGINE_H 16094332d3Sopenharmony_ci#define I_ENGINE_H 17094332d3Sopenharmony_ci 18094332d3Sopenharmony_ci#include <functional> 19094332d3Sopenharmony_ci#include <memory> 20094332d3Sopenharmony_ci#include "v1_0/intell_voice_engine_types.h" 21094332d3Sopenharmony_ci#include "v1_1/intell_voice_engine_types.h" 22094332d3Sopenharmony_ci#include "v1_2/intell_voice_engine_types.h" 23094332d3Sopenharmony_ci 24094332d3Sopenharmony_cinamespace OHOS { 25094332d3Sopenharmony_cinamespace IntelligentVoice { 26094332d3Sopenharmony_cinamespace Engine { 27094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineCallBackEvent; 28094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineAdapterInfo; 29094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Engine::V1_0::StartInfo; 30094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Engine::V1_0::IntellVoiceEngineAdapterDescriptor; 31094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Engine::V1_0::ContentType; 32094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Engine::V1_1::IntellVoiceDataOprType; 33094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Engine::V1_2::UploadHdiFile; 34094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Engine::V1_2::EvaluationResultInfo; 35094332d3Sopenharmony_ciusing IntellVoiceStatus = int32_t; 36094332d3Sopenharmony_ci 37094332d3Sopenharmony_ciusing getParameterCb = std::function<void(const std::string &retStr)>; 38094332d3Sopenharmony_ciusing getFileDataCb = std::function<void(std::shared_ptr<uint8_t> data, uint32_t size)>; 39094332d3Sopenharmony_ci 40094332d3Sopenharmony_ciclass IEngineCallback { 41094332d3Sopenharmony_cipublic: 42094332d3Sopenharmony_ci IEngineCallback() = default; 43094332d3Sopenharmony_ci virtual ~IEngineCallback() = default; 44094332d3Sopenharmony_ci virtual void OnIntellVoiceEvent(const IntellVoiceEngineCallBackEvent &event) = 0; 45094332d3Sopenharmony_ci}; 46094332d3Sopenharmony_ci 47094332d3Sopenharmony_cistruct OprDataInfo { 48094332d3Sopenharmony_ci std::shared_ptr<char> data = nullptr; 49094332d3Sopenharmony_ci uint32_t size = 0; 50094332d3Sopenharmony_ci}; 51094332d3Sopenharmony_ci 52094332d3Sopenharmony_ciclass IDataOprListener { 53094332d3Sopenharmony_cipublic: 54094332d3Sopenharmony_ci IDataOprListener() = default; 55094332d3Sopenharmony_ci virtual ~IDataOprListener() = default; 56094332d3Sopenharmony_ci virtual int32_t OnDataOprEvent(IntellVoiceDataOprType type, const OprDataInfo &inData, OprDataInfo &outData) = 0; 57094332d3Sopenharmony_ci}; 58094332d3Sopenharmony_ci 59094332d3Sopenharmony_ciclass IEngine { 60094332d3Sopenharmony_cipublic: 61094332d3Sopenharmony_ci IEngine() {}; 62094332d3Sopenharmony_ci virtual ~IEngine() {}; 63094332d3Sopenharmony_ci virtual IntellVoiceStatus SetListener(std::shared_ptr<IEngineCallback> listener) = 0; 64094332d3Sopenharmony_ci virtual IntellVoiceStatus Init(const IntellVoiceEngineAdapterInfo &adapterInfo) = 0; 65094332d3Sopenharmony_ci virtual IntellVoiceStatus Release() = 0; 66094332d3Sopenharmony_ci virtual IntellVoiceStatus SetParameter(const std::string &keyValueList) = 0; 67094332d3Sopenharmony_ci virtual IntellVoiceStatus GetParameter(const std::string &keyList, getParameterCb cb) = 0; 68094332d3Sopenharmony_ci virtual IntellVoiceStatus Write(const uint8_t *buffer, uint32_t size) = 0; 69094332d3Sopenharmony_ci virtual IntellVoiceStatus Start(const StartInfo &info) = 0; 70094332d3Sopenharmony_ci virtual IntellVoiceStatus Stop() = 0; 71094332d3Sopenharmony_ci virtual IntellVoiceStatus Cancel() = 0; 72094332d3Sopenharmony_ci virtual IntellVoiceStatus ReadFileData(ContentType type, getFileDataCb cb) = 0; 73094332d3Sopenharmony_ci virtual IntellVoiceStatus GetWakeupPcm(std::vector<uint8_t> &data) = 0; 74094332d3Sopenharmony_ci virtual IntellVoiceStatus Evaluate(const std::string &word, EvaluationResultInfo &info) = 0; 75094332d3Sopenharmony_ci}; 76094332d3Sopenharmony_ci 77094332d3Sopenharmony_ciclass IEngineManager { 78094332d3Sopenharmony_cipublic: 79094332d3Sopenharmony_ci virtual int32_t CreateAdapter(const IntellVoiceEngineAdapterDescriptor &descriptor, 80094332d3Sopenharmony_ci std::unique_ptr<IEngine> &engine) = 0; 81094332d3Sopenharmony_ci virtual int32_t ReleaseAdapter(const IntellVoiceEngineAdapterDescriptor &descriptor) = 0; 82094332d3Sopenharmony_ci virtual int32_t SetDataOprListener(std::shared_ptr<IDataOprListener> listener) = 0; 83094332d3Sopenharmony_ci virtual int32_t GetUploadFiles(int32_t maxNum, std::vector<UploadHdiFile> &files) = 0; 84094332d3Sopenharmony_ci virtual int32_t GetCloneFilesList(std::vector<std::string> &cloneFiles) = 0; 85094332d3Sopenharmony_ci virtual int32_t GetCloneFile(const std::string &filePath, std::shared_ptr<uint8_t> &buffer, uint32_t &size) = 0; 86094332d3Sopenharmony_ci virtual int32_t SendCloneFile(const std::string &filePath, const uint8_t *buffer, uint32_t size) = 0; 87094332d3Sopenharmony_ci virtual int32_t ClearUserWakeupData(const std::string &wakeupPhrase) = 0; 88094332d3Sopenharmony_ci}; 89094332d3Sopenharmony_ci} 90094332d3Sopenharmony_ci} 91094332d3Sopenharmony_ci} 92094332d3Sopenharmony_ci#endif 93