• 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 CAMERA_HOST_CONFIG_MANAGER_H
17 #define CAMERA_HOST_CONFIG_MANAGER_H
18 
19 #include <vector>
20 #include <map>
21 #include <list>
22 #include "utils.h"
23 
24 namespace OHOS::Camera {
25 class HcsDeal;
26 class CameraHostConfig {
27 public:
28     static CameraHostConfig *GetInstance();
29     RetCode ReadConfigFile();
30     RetCode GetCameraIds(std::vector<std::string> &cameraIds);
31     RetCode GetPhysicCameraIds(const std::string &lCameraId, std::vector<std::string> &pCameraIds);
32     RetCode GetCameraAbility(const std::string &cameraId, std::shared_ptr<CameraAbility> &ability);
33     RetCode AddCameraId(const std::string &logicalCameraId,
34         const std::vector<std::string> &physicalCameraIds, const std::shared_ptr<CameraAbility> ability);
35     std::string SubtractCameraId(const std::vector<std::string> &physicalCameraIds);
36     std::string ReturnEnableLogicalCameraId();
37     std::string ReturnPhysicalCameraIdToString(const CameraId &physicalCameraId);
38     std::string ReturnLogicalCameraIdToString(const std::string &physicalCameraId);
39 
40 public:
41     virtual ~CameraHostConfig();
42     CameraHostConfig(const CameraHostConfig &other) = delete;
43     CameraHostConfig(CameraHostConfig &&other) = delete;
44     CameraHostConfig& operator=(const CameraHostConfig &other) = delete;
45     CameraHostConfig& operator=(CameraHostConfig &&other) = delete;
46 
47 public:
48     // key: config cameraId; value: DeviceManager cameraId enum
49     static std::map<std::string, CameraId> enumCameraIdMap_;
50 
51 private:
52     CameraHostConfig();
53     class AutoRelease {
54     public:
AutoRelease()55         AutoRelease() {};
~AutoRelease()56         ~AutoRelease()
57         {
58             if (CameraHostConfig::instance_ != nullptr) {
59                 delete CameraHostConfig::instance_;
60                 CameraHostConfig::instance_ = nullptr;
61             }
62         };
63     };
64     static CameraHostConfig *instance_;
65     static AutoRelease autoRelease_;
66 
67 private:
68     // key: cameraId, value: CameraAbility
69     using CameraAbilityMap = std::map<std::string, std::shared_ptr<CameraAbility>>;
70     CameraAbilityMap cameraAbilityMap_;
71     // key: logicCameraId, value: physicsCameraIds
72     using CameraIdMap = std::map<std::string, std::vector<std::string>>;
73     CameraIdMap cameraIdMap_;
74 };
75 } // end namespace OHOS::Camera
76 #endif // CAMERA_HOST_CONFIG_MANAGER_H
77