• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <iservmgr_hdi.h>
32 #include <hdf_log.h>
33 #include "icamera_device_callback.h"
34 #include "types.h"
35 
36 namespace OHOS::Camera {
37 class ICameraDevice;
38 class ICameraHostCallback;
39 class ICameraDeviceCallback;
40 class ICameraHost : public IRemoteBroker {
41 public:
42     DECLARE_INTERFACE_DESCRIPTOR(u"HDI.Camera.V1_0.Host");
~ICameraHost()43     virtual ~ICameraHost() {}
44     /**
45      * @brief Obtains an <b>ICameraHost</b> instance.
46      *
47      * 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.
48      *
49      * @param serviceName Indicates the name of the <b>ICameraHost</b> instance to obtain. Currently, the name is fixed at <b>camera_service</b>.
50      *
51      * @return Returns the <b>ICameraHost</b> instance if the operation is successful; returns <b>nullptr</b> otherwise.
52      *
53      * @since 1.0
54      * @version 1.0
55      */
56     static sptr<ICameraHost> Get(const char *serviceName);
57 
58     /**
59      * @brief Sets callbacks. For details about the callbacks, see {@link ICameraHostCallback}.
60      *
61      * @param callback Indicates the callbacks to set.
62      *
63      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
64      *
65      * @since 1.0
66      * @version 1.0
67      */
68     virtual CamRetCode SetCallback(const OHOS::sptr<ICameraHostCallback> &callback) = 0;
69 
70     /**
71      * @brief Obtains the IDs of available camera devices.
72      *
73      * @param cameraIds Indicates the IDs of available camera devices.
74      *
75      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
76      *
77      * @since 1.0
78      * @version 1.0
79      */
80     virtual CamRetCode GetCameraIds(std::vector<std::string> &cameraIds) = 0;
81 
82     /**
83      * @brief Obtains the abilities of a camera device.
84      *
85      * @param cameraId Indicates the ID of the camera device, which can be obtained by calling {@link GetCameraIds}.
86      *
87      * @param ability Returns the abilities of the camera device.
88      *
89      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
90      *
91      * @since 1.0
92      * @version 1.0
93      */
94     virtual CamRetCode GetCameraAbility(const std::string &cameraId,
95         std::shared_ptr<CameraAbility> &ability) = 0;
96 
97     /**
98      * @brief Opens a camera device.
99      *
100      * By calling this function, you can obtain the <b>ICameraDevice</b> instance and operate the specific camera device mapping to the instance.
101      *
102      * @param cameraId Indicates the ID of the camera device, which can be obtained by calling {@link GetCameraIds}.
103      * @param callback Indicates the callback related to the camera. For details, see {@link ICameraDeviceCallback}.
104      * @param device Indicates the <b>ICameraDevice</b> instance corresponding to the ID of the camera device.
105      *
106      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
107      *
108      * @since 1.0
109      * @version 1.0
110      */
111     virtual CamRetCode OpenCamera(const std::string &cameraId,
112         const OHOS::sptr<ICameraDeviceCallback> &callback,
113         OHOS::sptr<ICameraDevice> &device) = 0;
114 
115     /**
116      * @brief Turns on or off the flash.
117      *
118      * This function can be used only by the caller who has opened the camera device specified by <b>cameraId</b>.
119      *
120      * @param cameraId Indicates the ID of the camera whose flash is to be turned on or off.
121      * @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.
122      *
123      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
124      *
125      * @since 1.0
126      * @version 1.0
127      */
128     virtual CamRetCode SetFlashlight(const std::string &cameraId, bool &isEnable) = 0;
129 };
130 }
131 #endif // HDI_CAMERA_HOST_CLIENT_INF_H