1 /* 2 * Copyright (c) 2022-2023 Shenzhen Kaihong DID 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 OMX_CODEC_CORE_H 17 #define OMX_CODEC_CORE_H 18 #include <OMX_Component.h> 19 #include <functional> 20 #include <string> 21 #include <vector> 22 #include <errno.h> 23 namespace OHOS { 24 namespace Codec { 25 namespace Omx { 26 class CodecOMXCore { 27 public: 28 typedef OMX_ERRORTYPE (*InitFunc)(); 29 typedef OMX_ERRORTYPE (*DeinitFunc)(); 30 typedef OMX_ERRORTYPE (*ComponentNameEnumFunc)(OMX_STRING, OMX_U32, OMX_U32); 31 typedef OMX_ERRORTYPE (*GetHandleFunc)(OMX_HANDLETYPE *, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE *); 32 typedef OMX_ERRORTYPE (*FreeHandleFunc)(OMX_HANDLETYPE); 33 typedef OMX_ERRORTYPE (*GetRolesOfComponentFunc)(OMX_STRING, OMX_U32 *, OMX_U8 **); 34 35 public: 36 CodecOMXCore() = default; 37 ~CodecOMXCore(); 38 int32_t Init(const std::string &libName); 39 void DeInit(); 40 int32_t GetHandle(OMX_HANDLETYPE &handle, std::string &compName, OMX_PTR appData, 41 const OMX_CALLBACKTYPE &callbacks); 42 int32_t FreeHandle(OMX_HANDLETYPE handle); 43 int32_t ComponentNameEnum(std::string &name, uint32_t index); 44 int32_t GetRolesOfComponent(std::string &name, std::vector<std::string> &roles); 45 46 private: 47 void *libHandle_ = nullptr; 48 InitFunc init_ = nullptr; 49 DeinitFunc deInit_ = nullptr; 50 ComponentNameEnumFunc componentNameEnum_ = nullptr; 51 GetHandleFunc getHandle_ = nullptr; 52 FreeHandleFunc freeHandle_ = nullptr; 53 GetRolesOfComponentFunc getRoles_ = nullptr; 54 }; 55 } // namespace Omx 56 } // namespace Codec 57 } // namespace OHOS 58 #endif