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 /**
17  * @addtogroup OH_Camera
18  * @{
19  *
20  * @brief Provide the definition of the C interface for the camera module.
21  *
22  * @syscap SystemCapability.Multimedia.Camera.Core
23  *
24  * @since 11
25  * @version 1.0
26  */
27 
28 /**
29  * @file photo_output.h
30  *
31  * @brief Declare the photo output concepts.
32  *
33  * @library libohcamera.so
34  * @kit CameraKit
35  * @syscap SystemCapability.Multimedia.Camera.Core
36  * @since 11
37  * @version 1.0
38  */
39 
40 #ifndef NATIVE_INCLUDE_CAMERA_PHOTOOUTPUT_H
41 #define NATIVE_INCLUDE_CAMERA_PHOTOOUTPUT_H
42 
43 #include <stdint.h>
44 #include <stdio.h>
45 #include "camera.h"
46 #include "photo_native.h"
47 #include "media_asset_base_capi.h"
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /**
54  * @brief Photo output object
55  *
56  * A pointer can be created using {@link Camera_PhotoOutput} method.
57  *
58  * @since 11
59  * @version 1.0
60  */
61 typedef struct Camera_PhotoOutput Camera_PhotoOutput;
62 
63 /**
64  * @brief Photo output frame start callback to be called in {@link PhotoOutput_Callbacks}.
65  *
66  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
67  * @since 11
68  */
69 typedef void (*OH_PhotoOutput_OnFrameStart)(Camera_PhotoOutput* photoOutput);
70 
71 /**
72  * @brief Photo output frame shutter callback to be called in {@link PhotoOutput_Callbacks}.
73  *
74  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
75  * @param info the {@link Camera_FrameShutterInfo} which delivered by the callback.
76  * @since 11
77  */
78 typedef void (*OH_PhotoOutput_OnFrameShutter)(Camera_PhotoOutput* photoOutput, Camera_FrameShutterInfo* info);
79 
80 /**
81  * @brief Photo output frame end callback to be called in {@link PhotoOutput_Callbacks}.
82  *
83  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
84  * @param frameCount the frame count which delivered by the callback.
85  * @since 11
86  */
87 typedef void (*OH_PhotoOutput_OnFrameEnd)(Camera_PhotoOutput* photoOutput, int32_t frameCount);
88 
89 /**
90  * @brief Photo output error callback to be called in {@link PhotoOutput_Callbacks}.
91  *
92  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
93  * @param errorCode the {@link Camera_ErrorCode} of the photo output.
94  *
95  * @see CAMERA_SERVICE_FATAL_ERROR
96  * @since 11
97  */
98 typedef void (*OH_PhotoOutput_OnError)(Camera_PhotoOutput* photoOutput, Camera_ErrorCode errorCode);
99 
100 /**
101  * @brief Photo output capture end callback.
102  *
103  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
104  * @param frameCount the frameCount which is delivered by the callback.
105  * @since 12
106  */
107 typedef void (*OH_PhotoOutput_CaptureEnd) (Camera_PhotoOutput* photoOutput, int32_t frameCount);
108 
109 /**
110  * @brief Photo output capture start with infomation callback.
111  *
112  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
113  * @param Info the {@link Camera_CaptureStartInfo} which is delivered by the callback..
114  * @since 12
115  */
116 typedef void (*OH_PhotoOutput_CaptureStartWithInfo) (Camera_PhotoOutput* photoOutput, Camera_CaptureStartInfo* Info);
117 
118 /**
119  * @brief Photo output eframe shutter end callback.
120  *
121  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
122  * @param Info the {@link Camera_CaptureStartInfo} which is delivered by the callback.
123  * @since 12
124  */
125 typedef void (*OH_PhotoOutput_OnFrameShutterEnd) (Camera_PhotoOutput* photoOutput, Camera_FrameShutterInfo* Info);
126 
127 /**
128  * @brief Photo output capture ready callback.
129  *
130  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
131  * @since 12
132  */
133 typedef void (*OH_PhotoOutput_CaptureReady) (Camera_PhotoOutput* photoOutput);
134 
135 /**
136  * @brief Photo output estimated capture duration callback.
137  *
138  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
139  * @param duration the duration which is delivered by the callback.
140  * @since 12
141  */
142 typedef void (*OH_PhotoOutput_EstimatedCaptureDuration) (Camera_PhotoOutput* photoOutput, int64_t duration);
143 
144 /**
145  * @brief Photo output available high-resolution images callback.
146  *
147  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
148  * @param photo the {@link OH_PhotoNative} which delivered by the callback.
149  * @since 12
150  */
151 typedef void (*OH_PhotoOutput_PhotoAvailable)(Camera_PhotoOutput* photoOutput, OH_PhotoNative* photo);
152 
153 /**
154  * @brief Photo output photo asset available callback.
155  *
156  * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback.
157  * @param photoAsset the {@link OH_MediaAsset} which delivered by the callback.
158  * @since 12
159  */
160 typedef void (*OH_PhotoOutput_PhotoAssetAvailable)(Camera_PhotoOutput* photoOutput, OH_MediaAsset* photoAsset);
161 
162 /**
163  * @brief A listener for photo output.
164  *
165  * @see OH_PhotoOutput_RegisterCallback
166  * @since 11
167  * @version 1.0
168  */
169 typedef struct PhotoOutput_Callbacks {
170     /**
171      * Photo output frame start event.
172      */
173     OH_PhotoOutput_OnFrameStart onFrameStart;
174 
175     /**
176      * Photo output frame shutter event.
177      */
178     OH_PhotoOutput_OnFrameShutter onFrameShutter;
179 
180     /**
181      * Photo output frame end event.
182      */
183     OH_PhotoOutput_OnFrameEnd onFrameEnd;
184 
185     /**
186      * Photo output error event.
187      */
188     OH_PhotoOutput_OnError onError;
189 } PhotoOutput_Callbacks;
190 
191 /**
192  * @brief Register photo output change event callback.
193  *
194  * @param photoOutput the {@link Camera_PhotoOutput} instance.
195  * @param callback the {@link PhotoOutput_Callbacks} to be registered.
196  * @return {@link #CAMERA_OK} if the method call succeeds.
197  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
198  * @since 11
199  */
200 Camera_ErrorCode OH_PhotoOutput_RegisterCallback(Camera_PhotoOutput* photoOutput, PhotoOutput_Callbacks* callback);
201 
202 /**
203  * @brief Unregister photo output change event callback.
204  *
205  * @param photoOutput the {@link Camera_PhotoOutput} instance.
206  * @param callback the {@link PhotoOutput_Callbacks} to be unregistered.
207  * @return {@link #CAMERA_OK} if the method call succeeds.
208  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
209  * @since 11
210  */
211 Camera_ErrorCode OH_PhotoOutput_UnregisterCallback(Camera_PhotoOutput* photoOutput, PhotoOutput_Callbacks* callback);
212 
213 /**
214  * @brief Register capture start event callback.
215  *
216  * @param photoOutput the {@link Camera_PhotoOutput} instance.
217  * @param callback the {@link OH_PhotoOutput_CaptureStartWithInfo} to be registered.
218  * @return {@link #CAMERA_OK} if the method call succeeds.
219  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
220  * @since 12
221  */
222 Camera_ErrorCode OH_PhotoOutput_RegisterCaptureStartWithInfoCallback(Camera_PhotoOutput* photoOutput,
223     OH_PhotoOutput_CaptureStartWithInfo callback);
224 
225 /**
226  * @brief Unregister capture start event callback.
227  *
228  * @param photoOutput the {@link Camera_PhotoOutput} instance.
229  * @param callback the {@link OH_PhotoOutput_CaptureStartWithInfo} to be unregistered.
230  * @return {@link #CAMERA_OK} if the method call succeeds.
231  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
232  * @since 12
233  */
234 Camera_ErrorCode OH_PhotoOutput_UnregisterCaptureStartWithInfoCallback(Camera_PhotoOutput* photoOutput,
235     OH_PhotoOutput_CaptureStartWithInfo callback);
236 
237 /**
238  * @brief Register capture end event callback.
239  *
240  * @param photoOutput the {@link Camera_PhotoOutput} instance.
241  * @param callback the {@link OH_PhotoOutput_CaptureEnd} to be registered.
242  * @return {@link #CAMERA_OK} if the method call succeeds.
243  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
244  * @since 12
245  */
246 Camera_ErrorCode OH_PhotoOutput_RegisterCaptureEndCallback(Camera_PhotoOutput* photoOutput,
247     OH_PhotoOutput_CaptureEnd callback);
248 
249 /**
250  * @brief Unregister capture end event callback.
251  *
252  * @param photoOutput the {@link Camera_PhotoOutput} instance.
253  * @param callback the {@link OH_PhotoOutput_CaptureEnd} to be unregistered.
254  * @return {@link #CAMERA_OK} if the method call succeeds.
255  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
256  * @since 12
257  */
258 Camera_ErrorCode OH_PhotoOutput_UnregisterCaptureEndCallback(Camera_PhotoOutput* photoOutput,
259     OH_PhotoOutput_CaptureEnd callback);
260 
261 /**
262  * @brief Register frame shutter end event callback.
263  *
264  * @param photoOutput the {@link Camera_PhotoOutput} instance.
265  * @param callback the {@link OH_PhotoOutput_OnFrameShutterEnd} to be registered.
266  * @return {@link #CAMERA_OK} if the method call succeeds.
267  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
268  * @since 12
269  */
270 Camera_ErrorCode OH_PhotoOutput_RegisterFrameShutterEndCallback(Camera_PhotoOutput* photoOutput,
271     OH_PhotoOutput_OnFrameShutterEnd callback);
272 
273 /**
274  * @brief Unregister frame shutter end event callback.
275  *
276  * @param photoOutput the {@link Camera_PhotoOutput} instance.
277  * @param callback the {@link OH_PhotoOutput_OnFrameShutterEnd} to be unregistered.
278  * @return {@link #CAMERA_OK} if the method call succeeds.
279  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
280  * @since 12
281  */
282 Camera_ErrorCode OH_PhotoOutput_UnregisterFrameShutterEndCallback(Camera_PhotoOutput* photoOutput,
283     OH_PhotoOutput_OnFrameShutterEnd callback);
284 
285 /**
286  * @brief Register capture ready event callback. After receiving the callback, can proceed to the next capture.
287  *
288  * @param photoOutput the {@link Camera_PhotoOutput} instance.
289  * @param callback the {@link OH_PhotoOutput_CaptureReady} to be registered.
290  * @return {@link #CAMERA_OK} if the method call succeeds.
291  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
292  * @since 12
293  */
294 Camera_ErrorCode OH_PhotoOutput_RegisterCaptureReadyCallback(Camera_PhotoOutput* photoOutput,
295     OH_PhotoOutput_CaptureReady callback);
296 
297 /**
298  * @brief Unregister capture ready event callback.
299  *
300  * @param photoOutput the {@link Camera_PhotoOutput} instance.
301  * @param callback the {@link OH_PhotoOutput_CaptureReady} to be unregistered.
302  * @return {@link #CAMERA_OK} if the method call succeeds.
303  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
304  * @since 12
305  */
306 Camera_ErrorCode OH_PhotoOutput_UnregisterCaptureReadyCallback(Camera_PhotoOutput* photoOutput,
307     OH_PhotoOutput_CaptureReady callback);
308 
309 /**
310  * @brief Register estimated capture duration event callback.
311  *
312  * @param photoOutput the {@link Camera_PhotoOutput} instance.
313  * @param callback the {@link OH_PhotoOutput_EstimatedCaptureDuration} to be registered.
314  * @return {@link #CAMERA_OK} if the method call succeeds.
315  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
316  * @since 12
317  */
318 Camera_ErrorCode OH_PhotoOutput_RegisterEstimatedCaptureDurationCallback(Camera_PhotoOutput* photoOutput,
319     OH_PhotoOutput_EstimatedCaptureDuration callback);
320 
321 /**
322  * @brief Unregister estimated capture duration event callback.
323  *
324  * @param photoOutput the {@link Camera_PhotoOutput} instance.
325  * @param callback the {@link OH_PhotoOutput_EstimatedCaptureDuration} to be unregistered.
326  * @return {@link #CAMERA_OK} if the method call succeeds.
327  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
328  * @since 12
329  */
330 Camera_ErrorCode OH_PhotoOutput_UnregisterEstimatedCaptureDurationCallback(Camera_PhotoOutput* photoOutput,
331     OH_PhotoOutput_EstimatedCaptureDuration callback);
332 
333 /**
334  * @brief Register photo output photo available callback.
335  *
336  * @param photoOutput the {@link Camera_PhotoOutput} instance.
337  * @param callback the {@link OH_PhotoOutput_PhotoAvailable} to be registered.
338  * @return {@link #CAMERA_OK} if the method call succeeds.
339  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
340  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
341  * @since 12
342  */
343 Camera_ErrorCode OH_PhotoOutput_RegisterPhotoAvailableCallback(Camera_PhotoOutput* photoOutput,
344     OH_PhotoOutput_PhotoAvailable callback);
345 
346 /**
347  * @brief Unregister photo output photo available callback.
348  *
349  * @param photoOutput the {@link Camera_PhotoOutput} instance.
350  * @param callback the {@link PhotoOutput_Callbacks} to be unregistered.
351  * @return {@link #CAMERA_OK} if the method call succeeds.
352  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
353  * @since 12
354  */
355 Camera_ErrorCode OH_PhotoOutput_UnregisterPhotoAvailableCallback(Camera_PhotoOutput* photoOutput,
356     OH_PhotoOutput_PhotoAvailable callback);
357 
358 /**
359  * @brief Register photo output photo asset available callback.
360  *
361  * @param photoOutput the {@link Camera_PhotoOutput} instance.
362  * @param callback the {@link OH_PhotoOutput_PhotoAssetAvailable} to be registered.
363  * @return {@link #CAMERA_OK} if the method call succeeds.
364  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
365  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
366  * @since 12
367  */
368 Camera_ErrorCode OH_PhotoOutput_RegisterPhotoAssetAvailableCallback(Camera_PhotoOutput* photoOutput,
369     OH_PhotoOutput_PhotoAssetAvailable callback);
370 
371 /**
372  * @brief Unregister photo output photo asset available callback.
373  *
374  * @param photoOutput the {@link Camera_PhotoOutput} instance.
375  * @param callback the {@link OH_PhotoOutput_PhotoAssetAvailable} to be unregistered.
376  * @return {@link #CAMERA_OK} if the method call succeeds.
377  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
378  * @since 12
379  */
380 Camera_ErrorCode OH_PhotoOutput_UnregisterPhotoAssetAvailableCallback(Camera_PhotoOutput* photoOutput,
381     OH_PhotoOutput_PhotoAssetAvailable callback);
382 
383 /**
384  * @brief Capture photo.
385  *
386  * @param photoOutput the {@link Camera_PhotoOutput} instance which used to capture photo.
387  * @return {@link #CAMERA_OK} if the method call succeeds.
388  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
389  *         {@link #CAMERA_SESSION_NOT_RUNNING} if the capture session not running.
390  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
391  * @since 11
392  */
393 Camera_ErrorCode OH_PhotoOutput_Capture(Camera_PhotoOutput* photoOutput);
394 
395 /**
396  * @brief Capture photo with capture setting.
397  *
398  * @param photoOutput the {@link Camera_PhotoOutput} instance which used to capture photo.
399  * @param setting the {@link Camera_PhotoCaptureSetting} to used to capture photo.
400  * @return {@link #CAMERA_OK} if the method call succeeds.
401  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
402  *         {@link #CAMERA_SESSION_NOT_RUNNING} if the capture session not running.
403  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
404  * @since 11
405  */
406 Camera_ErrorCode OH_PhotoOutput_Capture_WithCaptureSetting(Camera_PhotoOutput* photoOutput,
407     Camera_PhotoCaptureSetting setting);
408 
409 /**
410  * @brief Release photo output.
411  *
412  * @param photoOutput the {@link Camera_PhotoOutput} instance to released.
413  * @return {@link #CAMERA_OK} if the method call succeeds.
414  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
415  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
416  * @since 11
417  */
418 Camera_ErrorCode OH_PhotoOutput_Release(Camera_PhotoOutput* photoOutput);
419 
420 /**
421  * @brief Check whether to support mirror photo.
422  *
423  * @param photoOutput the {@link Camera_PhotoOutput} instance which used to check whether mirror supported.
424  * @param isSupported the result of whether mirror supported.
425  * @return {@link #CAMERA_OK} if the method call succeeds.
426  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
427  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
428  * @since 11
429  */
430 Camera_ErrorCode OH_PhotoOutput_IsMirrorSupported(Camera_PhotoOutput* photoOutput, bool* isSupported);
431 
432 /**
433  * @brief Enable mirror photo or not.
434  *
435  * @param photoOutput the {@link Camera_PhotoOutput} instance which used to enable mirror photo or not.
436  * @param enabled the flag of enable mirror photo or not.
437  * @return {@link #CAMERA_OK} if the method call succeeds.
438  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
439  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
440  * @since 13
441   */
442 Camera_ErrorCode OH_PhotoOutput_EnableMirror(Camera_PhotoOutput* photoOutput, bool enabled);
443 
444 /**
445  * @brief Get active photo output profile.
446  *
447  * @param photoOutput the {@link Camera_PhotoOutput} instance to deliver active profile.
448  * @param profile the active {@link Camera_Profile} to be filled if the method call succeeds.
449  * @return {@link #CAMERA_OK} if the method call succeeds.
450  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
451  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
452  * @since 12
453  */
454 Camera_ErrorCode OH_PhotoOutput_GetActiveProfile(Camera_PhotoOutput* photoOutput, Camera_Profile** profile);
455 
456 /**
457  * @brief Delete photo profile instance.
458  *
459  * @param profile the {@link Camera_Profile} instance to deleted.
460  * @return {@link #CAMERA_OK} if the method call succeeds.
461  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
462  * @since 12
463  */
464 Camera_ErrorCode OH_PhotoOutput_DeleteProfile(Camera_Profile* profile);
465 
466 /**
467  * @brief Check whether to support moving photo.
468  *
469  * @param photoOutput the {@link Camera_PhotoOutput} instance which used to check whether moving photo supported.
470  * @param isSupported the result of whether moving photo supported.
471  * @return {@link #CAMERA_OK} if the method call succeeds.
472  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
473  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
474  * @since 12
475  */
476 Camera_ErrorCode OH_PhotoOutput_IsMovingPhotoSupported(Camera_PhotoOutput* photoOutput, bool* isSupported);
477 
478 /**
479  * @brief Enable moving photo or not.
480  *
481  * @param photoOutput the {@link Camera_PhotoOutput} instance which used to enable moving photo or not.
482  * @param enabled the flag of enable moving photo or not.
483  * @return {@link #CAMERA_OK} if the method call succeeds.
484  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
485  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
486  * @permission ohos.permission.MICROPHONE
487  * @since 12
488  */
489 Camera_ErrorCode OH_PhotoOutput_EnableMovingPhoto(Camera_PhotoOutput* photoOutput, bool enabled);
490 
491 #ifdef __cplusplus
492 }
493 #endif
494 
495 #endif // NATIVE_INCLUDE_CAMERA_PHOTOOUTPUT_H
496 /** @} */