• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 OHOS_CAMERA_DYNAMIC_LOADER_H
17 #define OHOS_CAMERA_DYNAMIC_LOADER_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace CameraStandard {
23 using namespace std;
24 
25 const std::string MEDIA_LIB_SO = "libcamera_dynamic_medialibrary.z.so";
26 const std::string PICTURE_SO = "libcamera_dynamic_picture.z.so";
27 
28 class Dynamiclib {
29 public:
30     explicit Dynamiclib(const std::string& libName);
31     ~Dynamiclib();
32     bool IsLoaded();
33     void* GetFunction(const std::string& functionName);
34 
35 private:
36     std::string libName_;
37     void* libHandle_ = nullptr;
38 };
39 
40 class CameraDynamicLoader {
41 public:
42     static std::shared_ptr<Dynamiclib> GetDynamiclib(const std::string& libName);
43     static void LoadDynamiclibAsync(const std::string& libName);
44     static void FreeDynamiclib(const std::string& libName);
45 
46 private:
47     explicit CameraDynamicLoader() = delete;
48     CameraDynamicLoader(const CameraDynamicLoader&) = delete;
49     CameraDynamicLoader& operator=(const CameraDynamicLoader&) = delete;
50 
51     static std::shared_ptr<Dynamiclib> GetDynamiclibNoLock(const std::string& libName);
52 };
53 
54 } // namespace CameraStandard
55 } // namespace OHOS
56 #endif // OHOS_CAMERA_DYNAMIC_LOADER_H