1 /* 2 * Copyright (c) 2021-2021 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 HISTREAMER_PLUGIN_LOADER_H 17 #define HISTREAMER_PLUGIN_LOADER_H 18 19 #include "interface/plugin_base.h" 20 #include "interface/plugin_definition.h" 21 22 namespace OHOS { 23 namespace Media { 24 namespace Plugin { 25 class PluginLoader { 26 public: 27 PluginLoader(const PluginLoader &) = delete; 28 29 PluginLoader operator=(const PluginLoader &) = delete; 30 31 ~PluginLoader(); 32 33 static std::shared_ptr<PluginLoader> Create(const std::string &name, const std::string &path); 34 35 RegisterFunc FetchRegisterFunction(); 36 37 UnregisterFunc FetchUnregisterFunction(); 38 39 private: 40 PluginLoader(void* handler, std::string name); // NOLINT: void* 41 42 static void* LoadPluginFile(const std::string &path); 43 44 static std::shared_ptr<PluginLoader> CheckSymbol(void* handler, const std::string &name); // NOLINT: void* 45 46 void UnLoadPluginFile(); 47 48 private: 49 const void *handler_; 50 const std::string name_; 51 RegisterFunc registerFunc_ {nullptr}; 52 UnregisterFunc unregisterFunc_ {nullptr}; 53 }; 54 } // namespace Plugin 55 } // namespace Media 56 } // namespace OHOS 57 #endif // HISTREAMER_PLUGIN_LOADER_H 58