/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef CAMERA_HOST_CONFIG_MANAGER_H #define CAMERA_HOST_CONFIG_MANAGER_H #include #include #include #include "utils.h" #include "camera.h" namespace OHOS::Camera { class HcsDeal; class CameraHostConfig { public: static CameraHostConfig *GetInstance(); RetCode ReadConfigFile(); RetCode GetCameraIds(std::vector &cameraIds); RetCode GetPhysicCameraIds(const std::string &lCameraId, std::vector &pCameraIds); RetCode GetCameraAbility(const std::string &cameraId, std::shared_ptr &ability); RetCode AddCameraId(const std::string &logicalCameraId, const std::vector &physicalCameraIds, const std::shared_ptr ability); std::string SubtractCameraId(const std::vector &physicalCameraIds); std::string ReturnEnableLogicalCameraId(); std::string GenerateNewLogicalCameraId(); std::string ReturnPhysicalCameraIdToString(const CameraId &physicalCameraId); std::string ReturnLogicalCameraIdToString(const std::string &physicalCameraId); void AddUsbCameraId(std::string cameraId); bool SearchUsbCameraId(std::string cameraId); public: virtual ~CameraHostConfig(); CameraHostConfig(const CameraHostConfig &other) = delete; CameraHostConfig(CameraHostConfig &&other) = delete; CameraHostConfig& operator=(const CameraHostConfig &other) = delete; CameraHostConfig& operator=(CameraHostConfig &&other) = delete; public: // key: config cameraId; value: DeviceManager cameraId enum static std::map enumCameraIdMap_; private: CameraHostConfig(); class AutoRelease { public: AutoRelease() {} ~AutoRelease() { if (CameraHostConfig::instance_ != nullptr) { delete CameraHostConfig::instance_; CameraHostConfig::instance_ = nullptr; } } }; static CameraHostConfig *instance_; static AutoRelease autoRelease_; private: // key: cameraId, value: CameraAbility using CameraAbilityMap = std::map>; CameraAbilityMap cameraAbilityMap_; // key: logicCameraId, value: physicsCameraIds using CameraIdMap = std::map>; CameraIdMap cameraIdMap_; std::vector usbCameraIdVector_; }; } // end namespace OHOS::Camera #endif // CAMERA_HOST_CONFIG_MANAGER_H