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 "plugin/interface/plugin_base.h"
20 #include "plugin/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() = default;
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() = default;
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 private:
46     RegisterFunc registerFunc_ {nullptr};
47     UnregisterFunc unregisterFunc_ {nullptr};
48 };
49 } // namespace Plugin
50 } // namespace Media
51 } // namespace OHOS
52 #endif // HISTREAMER_PLUGIN_LOADER_H
53