• 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_device.h
18  *
19  * @brief Declares APIs for camera device operations.
20  *
21  * @since 1.0
22  * @version 1.0
23  */
24 
25 #ifndef HDI_CAMERA_DEVICE_CLIENT_INF_H
26 #define HDI_CAMERA_DEVICE_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 "types.h"
34 #include "icamera_device_callback.h"
35 #include "istream_operator.h"
36 #include "istream_operator_callback.h"
37 
38 namespace OHOS::Camera {
39 enum {
40     CMD_CAMERA_DEVICE_GET_STREAM_OPERATOR = 0,
41     CMD_CAMERA_DEVICE_UPDATE_SETTINGS,
42     CMD_CAMERA_DEVICE_SET_RESULT_MODE,
43     CMD_CAMERA_DEVICE_GET_ENABLED_RESULTS,
44     CMD_CAMERA_DEVICE_ENABLE_RESULT,
45     CMD_CAMERA_DEVICE_DISABLE_RESULT,
46     CMD_CAMERA_DEVICE_CLOSE,
47 };
48 
49 class ICameraDevice : public IRemoteBroker {
50 public:
51     DECLARE_INTERFACE_DESCRIPTOR(u"HDI.Camera.V1_0.Device");
~ICameraDevice()52     virtual ~ICameraDevice() {}
53 
54     /**
55      * @brief Obtains the stream operation handle.
56      *
57      * @param callback Indicates a stream callback. For details, see {@link IStreamOperatorCallback}.
58      * {@link OnCaptureStarted} and {@link OnCaptureEnded} are used to report the start and end of capture,
59      * and {@link OnCaptureError} is used to report a capture error.
60      *
61      * @param streamOperator Indicates the stream operation handle.
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 GetStreamOperator(
69         const OHOS::sptr<IStreamOperatorCallback> &callback,
70         OHOS::sptr<IStreamOperator> &streamOperator) = 0;
71 
72     /**
73      * @brief Updates camera device control parameters.
74      *
75      * @param settings Indicates the camera parameters, including the sensor frame rate and 3A parameters. 3A stands for automatic focus (AF), automatic exposure (AE), and automatic white-balance (​AWB).
76      *
77      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
78      *
79      * @since 1.0
80      * @version 1.0
81      */
82     virtual CamRetCode UpdateSettings(const std::shared_ptr<CameraSetting> &settings) = 0;
83 
84     /**
85      * @brief Sets the metadata reporting mode.
86      *
87      * @param mode Indicates the metadata reporting mode to set, which can be frame-by-frame reporting or reporting upon device status change. For details, see {@link ResultCallbackMode}.
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 SetResultMode(const ResultCallbackMode &mode) = 0;
95 
96     /**
97      * @brief Obtains enabled metadata.
98      *
99      * Metadata to be reported is enabled by calling {@link EnableResult}.
100      *
101      * @param results Indicates all enabled metadata.
102      *
103      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
104      *
105      * @since 1.0
106      * @version 1.0
107      */
108     virtual CamRetCode GetEnabledResults(std::vector<MetaType> &results) = 0;
109 
110     /**
111      * @brief Enables metadata reporting.
112      *
113      * Only metadata that is enabled can be reported by using {@link OnResult}.
114      *
115      * @param results Indicates the metadata for which reporting is to be enabled.
116      *
117      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
118      *
119      * @since 1.0
120      * @version 1.0
121      */
122     virtual CamRetCode EnableResult(const std::vector<MetaType> &results) = 0;
123 
124     /**
125      * @brief Disables metadata reporting.
126      *
127      * After metadata reporting is disabled, the metadata is not reported by calling {@link OnResult}. To enable metadata reporting, you must call {@link EnableResult}.
128      *
129      * @param results Indicates the metadata for which reporting is to be disabled.
130      *
131      * @return Returns <b>NO_ERROR</b> if the operation is successful; returns an error code defined in {@link CamRetCode} otherwise.
132      *
133      * @since 1.0
134      * @version 1.0
135      */
136     virtual CamRetCode DisableResult(const std::vector<MetaType> &results) = 0;
137 
138     /**
139      * @brief Closes the camera device.
140      *
141      * @since 1.0
142      * @version 1.0
143      */
144     virtual void Close() = 0;
145 };
146 }
147 #endif // HDI_CAMERA_DEVICE_CLIENT_INF_H
148