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 INTELL_VOICE_TRIGGER_MODEL_H 16 #define INTELL_VOICE_TRIGGER_MODEL_H 17 18 #include <cstdint> 19 #include <memory> 20 #include <vector> 21 22 namespace OHOS { 23 namespace IntellVoiceTrigger { 24 class TriggerModel { 25 public: 26 enum TriggerModelType { 27 UNKNOWN_TYPE = -1, 28 GENERIC_TYPE = 1, 29 VOICE_WAKEUP_TYPE = 1, 30 PROXIMAL_WAKEUP_TYPE = 2, 31 }; 32 33 enum TriggerModelVersion { 34 MODLE_VERSION_1 = 1, 35 MODLE_VERSION_2 = 2, 36 }; 37 38 TriggerModel(int32_t uuid, int32_t version, TriggerModelType type); 39 virtual ~TriggerModel(); 40 41 bool SetData(const uint8_t *data, uint32_t size); 42 bool SetData(std::vector<uint8_t> &data); 43 void Print(); 44 GetUuid()45 int32_t GetUuid() const 46 { 47 return uuid_; 48 } 49 GetType()50 int32_t GetType() const 51 { 52 return type_; 53 } 54 GetVendorUuid()55 int32_t GetVendorUuid() const 56 { 57 return vendorUuid_; 58 } 59 GetVersion()60 int32_t GetVersion() const 61 { 62 return version_; 63 } 64 GetData()65 std::vector<uint8_t> GetData() const 66 { 67 return data_; 68 } 69 70 protected: 71 int32_t uuid_ = -1; 72 int32_t vendorUuid_ = -1; 73 int32_t version_ = -1; 74 TriggerModelType type_ = UNKNOWN_TYPE; 75 76 private: 77 std::vector<uint8_t> data_; 78 }; 79 80 class GenericTriggerModel : public TriggerModel { 81 public: GenericTriggerModel(int32_t uuid,int32_t version,TriggerModel::TriggerModelType type)82 GenericTriggerModel(int32_t uuid, int32_t version, TriggerModel::TriggerModelType type) 83 : TriggerModel(uuid, version, type) 84 {} ~GenericTriggerModel()85 ~GenericTriggerModel() override 86 {} 87 }; 88 } // namespace IntellVoiceTrigger 89 } // namespace OHOS 90 91 #endif