1 /* 2 * Copyright (C) 2021 HiHope Open Source Organization . 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_PLUGIN_H_ 17 #define OMX_PLUGIN_H_ 18 19 #include <mutex> 20 #include <vector> 21 #include "IOMXComponentMgr.h" 22 23 namespace OHOS { 24 namespace Media { 25 namespace OMX { 26 using namespace std; 27 28 struct OMXCore { 29 typedef OMX_ERRORTYPE (*InitFunc)(); 30 typedef OMX_ERRORTYPE (*DeinitFunc)(); 31 typedef OMX_ERRORTYPE (*ComponentNameEnumFunc)( 32 OMX_STRING, OMX_U32, OMX_U32); 33 34 typedef OMX_ERRORTYPE (*GetHandleFunc)( 35 OMX_HANDLETYPE *, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE *); 36 37 typedef OMX_ERRORTYPE (*FreeHandleFunc)(OMX_HANDLETYPE *); 38 39 typedef OMX_ERRORTYPE (*GetRolesOfComponentFunc)( 40 OMX_STRING, OMX_U32 *, OMX_U8 **); 41 42 void *mLibHandle; 43 44 InitFunc mInit; 45 DeinitFunc mDeinit; 46 ComponentNameEnumFunc mComponentNameEnum; 47 GetHandleFunc mGetHandle; 48 FreeHandleFunc mFreeHandle; 49 GetRolesOfComponentFunc mGetRolesOfComponentHandle; 50 51 OMX_U32 mNumComponents; 52 }; 53 54 struct OMXComponent { 55 OMX_COMPONENTTYPE *mComponent; 56 OMXCore *mCore; 57 }; 58 59 struct OMXPlugin : public IOMXComponentMgr { 60 OMXPlugin(); 61 virtual ~OMXPlugin() override; 62 63 virtual OMX_ERRORTYPE CreateComponentInstance( 64 const OMX_STRING name, 65 const OMX_CALLBACKTYPE *callbacks, 66 OMX_PTR appData, 67 OMX_COMPONENTTYPE **component) override; 68 69 virtual OMX_ERRORTYPE DeleteComponentInstance( 70 OMX_COMPONENTTYPE *component) override; 71 72 virtual OMX_ERRORTYPE EnumerateComponentsByIndex( 73 OMX_U32 index, 74 OMX_STRING name, 75 size_t size) override; 76 77 virtual OMX_ERRORTYPE GetRolesForComponent( 78 const OMX_STRING name, 79 vector<string> *roles) override; 80 private: 81 82 mutex mMutex; 83 vector<OMXCore*> mCores; 84 vector<OMXComponent> mComponents; 85 86 OMX_ERRORTYPE AddCore(const char* coreName); 87 88 OMXPlugin(const OMXPlugin &); 89 OMXPlugin &operator=(const OMXPlugin &); 90 }; 91 } // OMX 92 } // Media 93 } // OHOS 94 95 #endif // OMX_PLUGIN_H_ 96