• 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     uint8_t index;
43 };
44 
45 class CameraHostService : public ICameraHost {
46 public:
47     static OHOS::sptr<CameraHostService> GetInstance();
48     int32_t SetCallback(const sptr<ICameraHostCallback> &callbackObj) override;
49     int32_t GetCameraIds(std::vector<std::string> &cameraIds) override;
50     int32_t GetCameraAbility(const std::string &cameraId,
51         std::vector<uint8_t> &cameraAbility) override;
52     int32_t OpenCamera(const std::string &cameraId, const sptr<ICameraDeviceCallback> &callbackObj,
53         sptr<ICameraDevice> &device) override;
54     int32_t SetFlashlight(const std::string &cameraId, bool isEnable) override;
55 
56 private:
57     CameraHostService(std::vector<ICameraHostVdi*> cameraHostVdiList,
58         std::vector<struct HdfVdiObject *> cameraHostVdiLoaderList);
59     virtual ~CameraHostService();
60     CameraHostService(const CameraHostService &other) = delete;
61     CameraHostService(CameraHostService &&other) = delete;
62     CameraHostService &operator=(const CameraHostService &other) = delete;
63     CameraHostService &operator=(CameraHostService &&other) = delete;
64 
65     static int32_t GetVdiLibList(std::vector<std::string> &vdiLibList);
66     static void HdfCloseVdiLoaderList(std::vector<struct HdfVdiObject *> &cameraHostVdiLoaderList);
67     ICameraHostVdi* GetCameraHostVdi(const std::string &currentCameraId);
68     const std::string GetVendorCameraId(const std::string &currentCameraId);
69     int32_t UpdateCameraIdMapList();
70 
71     std::vector<ICameraHostVdi*> cameraHostVdiList_;
72     std::vector<CameraIdInfo> cameraIdInfoList_;
73     std::vector<struct HdfVdiObject *> cameraHostVdiLoaderList_;
74     static OHOS::sptr<CameraHostService> cameraHostService_;
75 };
76 } // end namespace OHOS::Camera
77 #endif // CAMERA_HOST_SERVICE_H
78