1 /* 2 * Copyright (c) 2023 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_SERVICE_H 17 #define CAMERA_HOST_SERVICE_H 18 19 #include <map> 20 #include "camera.h" 21 #include "hcs_dm_parser.h" 22 #include "v1_0/icamera_device.h" 23 #include "v1_0/icamera_host.h" 24 #include "v1_0/icamera_host_vdi.h" 25 26 namespace OHOS::Camera { 27 #define CONFIG_PATH_NAME HDF_CONFIG_DIR"/camera_host_config.hcb" 28 29 using namespace OHOS::HDI::Camera::V1_0; 30 using namespace OHOS::VDI::Camera::V1_0; 31 32 struct CameraIdInfo { 33 std::string totalCameraId; 34 ICameraHostVdi *cameraHostVdi; 35 std::string vendorCameraId; 36 }; 37 38 class CameraHostService : public ICameraHost { 39 public: 40 static OHOS::sptr<CameraHostService> GetInstance(); 41 int32_t SetCallback(const sptr<ICameraHostCallback> &callbackObj) override; 42 int32_t GetCameraIds(std::vector<std::string> &cameraIds) override; 43 int32_t GetCameraAbility(const std::string &cameraId, 44 std::vector<uint8_t> &cameraAbility) override; 45 int32_t OpenCamera(const std::string &cameraId, const sptr<ICameraDeviceCallback> &callbackObj, 46 sptr<ICameraDevice> &device) override; 47 int32_t SetFlashlight(const std::string &cameraId, bool isEnable) override; 48 49 private: 50 CameraHostService(std::vector<ICameraHostVdi*> cameraHostVdiList, 51 std::vector<struct HdfVdiObject *> cameraHostVdiLoaderList); 52 virtual ~CameraHostService(); 53 CameraHostService(const CameraHostService &other) = delete; 54 CameraHostService(CameraHostService &&other) = delete; 55 CameraHostService &operator=(const CameraHostService &other) = delete; 56 CameraHostService &operator=(CameraHostService &&other) = delete; 57 58 static int32_t GetVdiLibList(std::vector<std::string> &vdiLibList); 59 static void HdfCloseVdiLoaderList(std::vector<struct HdfVdiObject *> &cameraHostVdiLoaderList); 60 ICameraHostVdi* GetCameraHostVdi(const std::string &totalCameraId); 61 const std::string GetVendorCameraId(const std::string &totalCameraId); 62 int32_t UpdateCameraIdMapList(); 63 64 std::vector<ICameraHostVdi*> cameraHostVdiList_; 65 std::vector<CameraIdInfo> cameraIdInfoList_; 66 std::vector<struct HdfVdiObject *> cameraHostVdiLoaderList_; 67 static OHOS::sptr<CameraHostService> cameraHostService_; 68 }; 69 } // end namespace OHOS::Camera 70 #endif // CAMERA_HOST_SERVICE_H 71