1 /* 2 * Copyright (c) 2021 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 /** 17 * @file icamera_host.h 18 * 19 * @brief Management class of the camera service that provides Hardware Driver Interfaces (HDIs) for the upper layer. 20 * 21 * @since 1.0 22 * @version 1.0 23 */ 24 25 #ifndef HDI_CAMERA_HOST_CLIENT_INF_H 26 #define HDI_CAMERA_HOST_CLIENT_INF_H 27 28 #include <list> 29 #include <map> 30 #include <vector> 31 #include "icamera_device_callback.h" 32 #include "types.h" 33 #include "icamera_interface.h" 34 35 namespace OHOS::Camera { 36 class ICameraDevice; 37 class ICameraHostCallback; 38 class ICameraDeviceCallback; 39 class ICameraHost : public ICameraInterface { 40 public: 41 DECLARE_INTERFACE_DESCRIPTOR(u"HDI.Camera.V1_0.Host"); ~ICameraHost()42 virtual ~ICameraHost() {} 43 /** 44 * @brief Obtains an <b>ICameraHost</b> instance. 45 * 46 * This function provides the entry to the camera service. You must use this function to obtain an <b>ICameraHost</b> instance before performing other operations. 47 * 48 * @param serviceName Indicates the name of the <b>ICameraHost</b> instance to obtain. Currently, the name is fixed at <b>camera_service</b>. 49 * 50 * @return Returns the <b>ICameraHost</b> instance if the operation is successful; returns <b>nullptr</b> otherwise. 51 * 52 * @since 1.0 53 * @version 1.0 54 */ 55 static sptr<ICameraHost> Get(const char *serviceName); 56 57 /** 58 * @brief Sets callbacks. For details about the callbacks, see {@link ICameraHostCallback}. 59 * 60 * @param callback Indicates the callbacks to set. 61 * 62 * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise. 63 * 64 * @since 1.0 65 * @version 1.0 66 */ 67 virtual CamRetCode SetCallback(const OHOS::sptr<ICameraHostCallback> &callback) = 0; 68 69 /** 70 * @brief Obtains the IDs of available camera devices. 71 * 72 * @param cameraIds Indicates the IDs of available camera devices. 73 * 74 * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise. 75 * 76 * @since 1.0 77 * @version 1.0 78 */ 79 virtual CamRetCode GetCameraIds(std::vector<std::string> &cameraIds) = 0; 80 81 /** 82 * @brief Obtains the abilities of a camera device. 83 * 84 * @param cameraId Indicates the ID of the camera device, which can be obtained by calling {@link GetCameraIds}. 85 * 86 * @param ability Returns the abilities of the camera device. 87 * 88 * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise. 89 * 90 * @since 1.0 91 * @version 1.0 92 */ 93 virtual CamRetCode GetCameraAbility(const std::string &cameraId, 94 std::shared_ptr<CameraAbility> &ability) = 0; 95 96 /** 97 * @brief Opens a camera device. 98 * 99 * By calling this function, you can obtain the <b>ICameraDevice</b> instance and operate the specific camera device mapping to the instance. 100 * 101 * @param cameraId Indicates the ID of the camera device, which can be obtained by calling {@link GetCameraIds}. 102 * @param callback Indicates the callback related to the camera. For details, see {@link ICameraDeviceCallback}. 103 * @param device Indicates the <b>ICameraDevice</b> instance corresponding to the ID of the camera device. 104 * 105 * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise. 106 * 107 * @since 1.0 108 * @version 1.0 109 */ 110 virtual CamRetCode OpenCamera(const std::string &cameraId, 111 const OHOS::sptr<ICameraDeviceCallback> &callback, 112 OHOS::sptr<ICameraDevice> &device) = 0; 113 114 /** 115 * @brief Turns on or off the flash. 116 * 117 * This function can be used only by the caller who has opened the camera device specified by <b>cameraId</b>. 118 * 119 * @param cameraId Indicates the ID of the camera whose flash is to be turned on or off. 120 * @param isEnable Specifies whether to turn on or off the flash. The value <b>true</b> means to turn on the flash, and <b>false</b> means the opposite. 121 * 122 * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise. 123 * 124 * @since 1.0 125 * @version 1.0 126 */ 127 virtual CamRetCode SetFlashlight(const std::string &cameraId, bool &isEnable) = 0; 128 }; 129 } 130 #endif // HDI_CAMERA_HOST_CLIENT_INF_H