• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 PLUGIN_MGR_H
17 #define PLUGIN_MGR_H
18 
19 #include <string>
20 #include <vector>
21 #include "nocopyable.h"
22 #include "singleton.h"
23 #include "plugin_errors.h"
24 #include "pointer_key_map.h"
25 
26 namespace OHOS {
27 namespace MultimediaPlugin {
28 class PlatformAdp;
29 class Plugin;
30 
31 class PluginMgr final : public NoCopyable {
32 public:
33     uint32_t Register(const std::vector<std::string> &canonicalPaths);
34     DECLARE_DELAYED_REF_SINGLETON(PluginMgr);
35 
36 private:
37     uint32_t TraverseFiles(const std::string &canonicalPath);
38     bool CheckPluginMetaFile(const std::string &candidateFile, std::string &libraryPath);
39     uint32_t RegisterPlugin(const std::string &metadataPath, std::string &&libraryPath);
40     uint32_t RegisterPlugin(const std::string &metadataJson);
41 
42     static PlatformAdp &platformAdp_;
43     using PluginMap = PointerKeyMap<const std::string, std::shared_ptr<Plugin>>;
44     PluginMap plugins_;
45 };
46 } // namespace MultimediaPlugin
47 } // namespace OHOS
48 
49 #endif // PLUGIN_MGR_H
50