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