• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "camera_hal_hicollie.h"
26 
27 namespace OHOS::Camera {
28 #ifdef CHIP_PROD_CAMERA_HOST_CONFIG
29 #define CONFIG_PATH_NAME HDF_CHIP_PROD_CONFIG_DIR"/camera_host_config.hcb"
30 #else
31 #define CONFIG_PATH_NAME HDF_CONFIG_DIR"/camera_host_config.hcb"
32 #endif
33 
34 using namespace OHOS::HDI::Camera::V1_0;
35 using namespace OHOS::VDI::Camera::V1_0;
36 
37 struct CameraIdInfo {
38     std::string currentCameraId;
39     ICameraHostVdi* cameraHostVdi;
40     std::string vendorCameraId;
41     bool isDeleted;
42 };
43 
44 class CameraHostService : public ICameraHost {
45 public:
46     static OHOS::sptr<CameraHostService> GetInstance();
47     int32_t SetCallback(const sptr<ICameraHostCallback> &callbackObj) override;
48     int32_t GetCameraIds(std::vector<std::string> &cameraIds) override;
49     int32_t GetCameraAbility(const std::string &cameraId,
50         std::vector<uint8_t> &cameraAbility) override;
51     int32_t OpenCamera(const std::string &cameraId, const sptr<ICameraDeviceCallback> &callbackObj,
52         sptr<ICameraDevice> &device) override;
53     int32_t SetFlashlight(const std::string &cameraId, bool isEnable) override;
54 
55 private:
56     CameraHostService(std::vector<ICameraHostVdi*> cameraHostVdiList,
57         std::vector<struct HdfVdiObject *> cameraHostVdiLoaderList);
58     virtual ~CameraHostService();
59     CameraHostService(const CameraHostService &other) = delete;
60     CameraHostService(CameraHostService &&other) = delete;
61     CameraHostService &operator=(const CameraHostService &other) = delete;
62     CameraHostService &operator=(CameraHostService &&other) = delete;
63 
64     static int32_t GetVdiLibList(std::vector<std::string> &vdiLibList);
65     static void HdfCloseVdiLoaderList(std::vector<struct HdfVdiObject *> &cameraHostVdiLoaderList);
66     ICameraHostVdi* GetCameraHostVdi(const std::string &currentCameraId);
67     const std::string GetVendorCameraId(const std::string &currentCameraId);
68     int32_t UpdateCameraIdMapList();
69 
70     std::vector<ICameraHostVdi*> cameraHostVdiList_;
71     std::vector<CameraIdInfo> cameraIdInfoList_;
72     std::vector<struct HdfVdiObject *> cameraHostVdiLoaderList_;
73     static OHOS::sptr<CameraHostService> cameraHostService_;
74 };
75 } // end namespace OHOS::Camera
76 #endif // CAMERA_HOST_SERVICE_H
77