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 ENGINE_BASE_H 16 #define ENGINE_BASE_H 17 #include <vector> 18 #include "intell_voice_engine_stub.h" 19 20 namespace OHOS { 21 namespace IntellVoiceEngine { 22 class EngineBase : public IntellVoiceEngineStub { 23 public: 24 ~EngineBase() = default; 25 virtual bool Init(const std::string ¶m = "", bool reEnroll = false) = 0; WriteAudio(const uint8_t * buffer,uint32_t size)26 int32_t WriteAudio(const uint8_t *buffer, uint32_t size) override 27 { 28 return 0; 29 } OnDetected(int32_t uuid)30 virtual void OnDetected(int32_t uuid) {}; ResetAdapter()31 virtual bool ResetAdapter() 32 { 33 return true; 34 } ReleaseAdapter()35 virtual void ReleaseAdapter() 36 { 37 } 38 int32_t StartCapturer(int32_t channels) override; 39 int32_t Read(std::vector<uint8_t> &data) override; 40 int32_t StopCapturer() override; 41 int32_t GetWakeupPcm(std::vector<uint8_t> &data) override; 42 int32_t Evaluate(const std::string &word, EvaluationResult &result) override; 43 int32_t NotifyHeadsetWakeEvent() override; 44 int32_t NotifyHeadsetHostEvent(HeadsetHostEventType event) override; 45 protected: 46 EngineBase() = default; 47 }; 48 } 49 } 50 #endif 51