• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef I_TRIGGER_H
17 #define I_TRIGGER_H
18 #include <memory>
19 #include <vector>
20 #include "v1_0/intell_voice_trigger_types.h"
21 
22 namespace OHOS {
23 namespace IntelligentVoice {
24 namespace Trigger {
25 using OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerAdapterDsecriptor;
26 using OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerProperties;
27 using OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerModel;
28 using OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceTriggerModelType;
29 using OHOS::HDI::IntelligentVoice::Trigger::V1_0::IntellVoiceRecognitionEvent;
30 
31 struct TriggerModel {
TriggerModelTriggerModel32     TriggerModel(IntellVoiceTriggerModelType typeIn, uint32_t uidIn, std::vector<uint8_t> dataIn) : type(typeIn),
33         uid(uidIn)
34     {
35         data.swap(dataIn);
36     }
37     IntellVoiceTriggerModelType type;
38     uint32_t uid;
39     std::vector<uint8_t> data;
40 };
41 
42 class ITriggerCallback {
43 public:
44     virtual ~ITriggerCallback() = default;
45     virtual void OnRecognitionHdiEvent(const IntellVoiceRecognitionEvent &event, int32_t cookie) = 0;
46 };
47 
48 class ITrigger {
49 public:
~ITrigger()50     virtual ~ITrigger() {};
51     virtual int32_t GetProperties(IntellVoiceTriggerProperties &properties) = 0;
52     virtual int32_t LoadIntellVoiceTriggerModel(const TriggerModel &model,
53         const std::shared_ptr<ITriggerCallback> &callback, int32_t cookie, int32_t &handle) = 0;
54     virtual int32_t UnloadIntellVoiceTriggerModel(int32_t handle) = 0;
55     virtual int32_t Start(int32_t handle) = 0;
56     virtual int32_t Stop(int32_t handle) = 0;
57 };
58 
59 class ITriggerManager {
60 public:
61     virtual int32_t LoadAdapter(const IntellVoiceTriggerAdapterDsecriptor &descriptor,
62         std::unique_ptr<ITrigger> &adapter) = 0;
63     virtual int32_t UnloadAdapter(const IntellVoiceTriggerAdapterDsecriptor &descriptor) = 0;
64 };
65 }
66 }
67 }
68 #endif
69