• 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 types.h
18  *
19  * @brief Declares data types used by the Hardware Driver Interfaces (HDIs) of this module.
20  *
21  * @since 1.0
22  * @version 1.0
23  */
24 
25 #ifndef DISTRIBUTED_CAMERA_PROVIDER_TYPES_H
26 #define DISTRIBUTED_CAMERA_PROVIDER_TYPES_H
27 
28 #include <string>
29 #include <vector>
30 #include "buffer_handle.h"
31 
32 namespace OHOS {
33 namespace DistributedHardware {
34 /**
35  * @brief Enumerates distributed camera metadata updating types.
36  */
37 using DCSettingsType = enum _DCSettingsType : int32_t {
38     /**
39      * Set the whole package metadata.
40      */
41     UPDATE_METADATA = 0,
42     /**
43      * Enable metadata.
44      */
45     ENABLE_METADATA = 1,
46     /**
47      * Disable metadata.
48      */
49     DISABLE_METADATA = 2,
50     /**
51      * Metadata result.
52      */
53     METADATA_RESULT = 3,
54     /**
55      * Set flash light.
56      */
57     SET_FLASH_LIGHT = 4,
58     /**
59      * Set fps range.
60      */
61     FPS_RANGE = 5
62 };
63 
64 /**
65  * @brief Enumerates return values of the HDIs.
66  */
67 using DCamRetCode = enum _DCamRetCode : int32_t {
68     /**
69      * Successful call.
70      */
71     SUCCESS = 0,
72     /**
73      * The camera device is busy.
74      */
75     CAMERA_BUSY = 1,
76     /**
77      * Invalid parameters.
78      */
79     INVALID_ARGUMENT = 2,
80     /**
81      * Unsupported function.
82      */
83     METHOD_NOT_SUPPORTED = 3,
84     /**
85      * The camera device is offlined.
86      */
87     CAMERA_OFFLINE = 4,
88     /**
89      * The number of distributed camera devices enabled exceeds the limit.
90      */
91     EXCEED_MAX_NUMBER = 5,
92     /**
93      * The device is not initialized.
94      */
95     DEVICE_NOT_INIT = 6,
96     /**
97      * Failed call.
98      */
99     FAILED = -1,
100 };
101 
102  /**
103  * @brief Enumerates encoding types of stream data.
104  */
105 using DCEncodeType = enum _DCEncodeType : int32_t {
106     /**
107      * Unspecified
108      */
109     ENCODE_TYPE_NULL = 0,
110 
111     /**
112      * H.264
113      */
114     ENCODE_TYPE_H264 = 1,
115 
116     /**
117      * H.265
118      */
119     ENCODE_TYPE_H265 = 2,
120 
121     /**
122      * JPEG
123      */
124     ENCODE_TYPE_JPEG = 3,
125 };
126 
127 /**
128  * @brief Enumerates distributed camera inner stream types.
129  */
130 using DCStreamType = enum _DCStreamType : int32_t {
131     /**
132      * Continuous capture stream. For example preview streams, video streams.
133      */
134     CONTINUOUS_FRAME = 0,
135     /**
136      * Single capture stream. For example photographing streams.
137      */
138     SNAPSHOT_FRAME = 1
139 };
140 
141 /**
142  * @brief Distributed hardware device base info.
143  */
144 using DHBase = struct _DHBase {
145     /**
146      * The device id.
147     */
148     std::string deviceId_;
149     /**
150      * The distributed hardware id.
151      */
152     std::string dhId_;
153 
_DHBase_DHBase154     _DHBase() : deviceId_(""), dhId_("") {}
155 
_DHBase_DHBase156     _DHBase(const std::string &deviceId, const std::string &dhId) : deviceId_(deviceId), dhId_(dhId) {}
157 
158     bool operator ==(const _DHBase& others) const
159     {
160         return this->deviceId_ == others.deviceId_ && this->dhId_ == others.dhId_;
161     }
162 
163     bool operator < (const _DHBase& others) const
164     {
165         return (this->deviceId_ + this->dhId_) < (others.deviceId_ + others.dhId_);
166     }
167 };
168 
169 /**
170  * @brief The control settings of the distributed camera device.
171  */
172 using DCameraSettings = struct _DCameraSettings {
173     /**
174      * Settings type.
175      */
176     DCSettingsType type_;
177     /**
178      * Settings value. Serialized from bool, array, structure, etc.
179      */
180     std::string value_;
181 };
182 
183 /**
184  * @brief Defines the inner stream information of the distributed camera,
185  * which is used to pass configuration parameters during stream creation.
186  */
187 using DCStreamInfo = struct _DCStreamInfo {
188     /**
189      * Stream ID, which uniquely identifies a stream on a camera device.
190      */
191     int streamId_;
192     /**
193      * Image width.
194      */
195     int width_;
196     /**
197      * Image height.
198      */
199     int height_;
200     /**
201      * Image stride.
202      */
203     int stride_;
204     /**
205      * Image format.
206      */
207     int format_;
208     /**
209      * Image color space.
210      */
211     int dataspace_;
212     /**
213      * Encoding type.
214      */
215     DCEncodeType encodeType_;
216      /**
217      * Stream type.
218      */
219     DCStreamType type_;
220 };
221 
222 /**
223  * @brief Defines the information about a inner capture request of the distributed camera.
224  */
225 using DCCaptureInfo = struct _DCCaptureInfo {
226     /**
227      * IDs of captured streams.
228     */
229     std::vector<int> streamIds_;
230     /**
231      * Image width.
232      */
233     int width_;
234     /**
235      * Image height.
236      */
237     int height_;
238     /**
239      * Image stride.
240      */
241     int stride_;
242     /**
243      * Image format.
244      */
245     int format_;
246     /**
247      * Image color space.
248      */
249     int dataspace_;
250     /**
251      * Capture Info
252      */
253     bool isCapture_;
254     /**
255      * Encoding type.
256      */
257     DCEncodeType encodeType_;
258      /**
259      * Stream type.
260      */
261     DCStreamType type_;
262      /**
263      * Stream settings.
264      */
265     std::vector<std::shared_ptr<DCameraSettings>> captureSettings_;
266 };
267 
268 /**
269  * @brief Defines the inner buffer of the distributed camera,
270  * which is used to acquire buffer during procesing capture requests.
271  */
272 using DCameraBuffer = struct _DCameraBuffer {
273     /**
274      * Buffer index.
275      */
276     int32_t index_;
277     /**
278      * Buffer size.
279      */
280     uint32_t size_;
281     /**
282      * Buffer handle.
283      */
284     BufferHandle* bufferHandle_;
285 };
286 
287 /**
288  * @brief Notification event of the distributed camera.
289  */
290 using DCameraHDFEvent = struct _DCameraHDFEvent {
291     /**
292      * Event type.
293      */
294     int32_t type_;
295     /**
296      * Event result.
297      */
298     int32_t result_;
299     /**
300      * Extended content (optional).
301      */
302     std::string content_;
303 };
304 } // end namespace DistributedHardware
305 } // end namespace OHOS
306 
307 #endif // DISTRIBUTED_CAMERA_PROVIDER_TYPES_H