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