• 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 WAKEUP_INTELL_VOICE_ENGINE_H
17 #define WAKEUP_INTELL_VOICE_ENGINE_H
18 
19 #include "intell_voice_info.h"
20 #include "i_intell_voice_engine.h"
21 #include "engine_callback_inner.h"
22 
23 namespace OHOS {
24 namespace IntellVoice {
25 using OHOS::IntellVoiceEngine::IIntellVoiceEngineEventCallback;
26 using OHOS::IntellVoiceEngine::IIntellVoiceEngine;
27 using OHOS::IntellVoiceEngine::EngineCallbackInner;
28 
29 struct WakeupIntelligentVoiceEngineDescriptor {
30     bool needReconfirm;
31     std::string wakeupPhrase;
32 };
33 
34 class WakeupIntellVoiceEngine {
35 public:
36     WakeupIntellVoiceEngine(const WakeupIntelligentVoiceEngineDescriptor &descriptor,
37         IntellVoiceEngine::IntellVoiceEngineType type = OHOS::IntellVoiceEngine::INTELL_VOICE_WAKEUP);
38     ~WakeupIntellVoiceEngine();
39 
40     int32_t SetSensibility(const int32_t &sensibility);
41     int32_t SetWakeupHapInfo(const WakeupHapInfo &info);
42     int32_t SetParameter(const std::string &key, const std::string &value);
43     std::string GetParameter(const std::string &key);
44     int32_t Release();
45     int32_t SetCallback(std::shared_ptr<IIntellVoiceEngineEventCallback> callback);
46     int32_t StartCapturer(int32_t channels);
47     int32_t Read(std::vector<uint8_t> &data);
48     int32_t StopCapturer();
49     int32_t GetWakeupPcm(std::vector<uint8_t> &data);
50     int32_t NotifyHeadsetWakeEvent();
51     int32_t NotifyHeadsetHostEvent(int32_t event);
52     int32_t result_ = INTELLIGENT_VOICE_SUCCESS;
53 
54 private:
55     sptr<IIntellVoiceEngine> engine_ = nullptr;
56     std::unique_ptr<WakeupIntelligentVoiceEngineDescriptor> descriptor_ = nullptr;
57     sptr<EngineCallbackInner> callback_ = nullptr;
58 };
59 }  // namespace IntellVoice
60 }  // namespace OHOS
61 
62 #endif
63