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 16094332d3Sopenharmony_ci#ifndef I_TRIGGER_H 17094332d3Sopenharmony_ci#define I_TRIGGER_H 18094332d3Sopenharmony_ci#include <memory> 19094332d3Sopenharmony_ci#include <vector> 20094332d3Sopenharmony_ci#include "v1_2/intell_voice_trigger_types.h" 21094332d3Sopenharmony_ci 22094332d3Sopenharmony_cinamespace OHOS { 23094332d3Sopenharmony_cinamespace IntelligentVoice { 24094332d3Sopenharmony_cinamespace Trigger { 25094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerAdapterDsecriptor; 26094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerProperties; 27094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerModel; 28094332d3Sopenharmony_ciusing OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceRecognitionEvent; 29094332d3Sopenharmony_ci 30094332d3Sopenharmony_cistruct TriggerModel { 31094332d3Sopenharmony_ci TriggerModel(OHOS::HDI::IntelligentVoice::Trigger::V1_2::IntellVoiceTriggerModelType typeIn, uint32_t uidIn, 32094332d3Sopenharmony_ci std::vector<uint8_t> dataIn) : type(typeIn), uid(uidIn) 33094332d3Sopenharmony_ci { 34094332d3Sopenharmony_ci data.swap(dataIn); 35094332d3Sopenharmony_ci } 36094332d3Sopenharmony_ci OHOS::HDI::IntelligentVoice::Trigger::V1_2::IntellVoiceTriggerModelType type; 37094332d3Sopenharmony_ci uint32_t uid; 38094332d3Sopenharmony_ci std::vector<uint8_t> data; 39094332d3Sopenharmony_ci}; 40094332d3Sopenharmony_ci 41094332d3Sopenharmony_ciclass ITriggerCallback { 42094332d3Sopenharmony_cipublic: 43094332d3Sopenharmony_ci virtual ~ITriggerCallback() = default; 44094332d3Sopenharmony_ci virtual void OnRecognitionHdiEvent(const IntellVoiceRecognitionEvent &event, int32_t cookie) = 0; 45094332d3Sopenharmony_ci}; 46094332d3Sopenharmony_ci 47094332d3Sopenharmony_ciclass ITrigger { 48094332d3Sopenharmony_cipublic: 49094332d3Sopenharmony_ci virtual ~ITrigger() {}; 50094332d3Sopenharmony_ci virtual int32_t GetProperties(IntellVoiceTriggerProperties &properties) = 0; 51094332d3Sopenharmony_ci virtual int32_t LoadIntellVoiceTriggerModel(const TriggerModel &model, 52094332d3Sopenharmony_ci const std::shared_ptr<ITriggerCallback> &callback, int32_t cookie, int32_t &handle) = 0; 53094332d3Sopenharmony_ci virtual int32_t UnloadIntellVoiceTriggerModel(int32_t handle) = 0; 54094332d3Sopenharmony_ci virtual int32_t Start(int32_t handle) = 0; 55094332d3Sopenharmony_ci virtual int32_t Stop(int32_t handle) = 0; 56094332d3Sopenharmony_ci virtual int32_t SetParams(const std::string &key, const std::string &value) = 0; 57094332d3Sopenharmony_ci virtual std::string GetParams(const std::string &key) = 0; 58094332d3Sopenharmony_ci}; 59094332d3Sopenharmony_ci 60094332d3Sopenharmony_ciclass ITriggerManager { 61094332d3Sopenharmony_cipublic: 62094332d3Sopenharmony_ci virtual int32_t LoadAdapter(const IntellVoiceTriggerAdapterDsecriptor &descriptor, 63094332d3Sopenharmony_ci std::unique_ptr<ITrigger> &adapter) = 0; 64094332d3Sopenharmony_ci virtual int32_t UnloadAdapter(const IntellVoiceTriggerAdapterDsecriptor &descriptor) = 0; 65094332d3Sopenharmony_ci}; 66094332d3Sopenharmony_ci} 67094332d3Sopenharmony_ci} 68094332d3Sopenharmony_ci} 69094332d3Sopenharmony_ci#endif 70