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 #include "engine_factory.h"
17 #include "enroll_engine.h"
18 #include "wakeup_engine_obj.h"
19 #include "update_engine.h"
20 #include "high_power_wakeup_engine.h"
21 #include "intell_voice_log.h"
22 #include "intell_voice_generic_factory.h"
23
24 using namespace OHOS::IntellVoiceUtils;
25 #define LOG_TAG "EngineFactory"
26
27 namespace OHOS {
28 namespace IntellVoiceEngine {
CreateEngineInst(IntellVoiceEngineType type,const std::string & param,bool reEnroll)29 sptr<EngineBase> EngineFactory::CreateEngineInst(IntellVoiceEngineType type, const std::string ¶m, bool reEnroll)
30 {
31 sptr<EngineBase> engine = nullptr;
32 switch (type) {
33 case INTELL_VOICE_ENROLL:
34 engine = SptrFactory<EngineBase, EnrollEngine>::CreateInstance(param);
35 break;
36 case INTELL_VOICE_WAKEUP:
37 #ifdef ONLY_SECOND_STAGE
38 engine = SptrFactory<EngineBase, HighPowerWakeupEngine>::CreateInstance(param);
39 #else
40 engine = SptrFactory<EngineBase, WakeupEngineObj>::CreateInstance(param);
41 #endif
42 break;
43 case INTELL_VOICE_UPDATE:
44 engine = SptrFactory<EngineBase, UpdateEngine>::CreateInstance(param, reEnroll);
45 break;
46 default:
47 INTELL_VOICE_LOG_INFO("create engine enter, type:%{public}d", type);
48 break;
49 }
50
51 return engine;
52 }
53 }
54 }
55