• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 preview_output.h
30  *
31  * @brief Declare the preview output concepts.
32  *
33  * @library libohcamera.so
34  * @syscap SystemCapability.Multimedia.Camera.Core
35  * @since 11
36  * @version 1.0
37  */
38 
39 #ifndef NATIVE_INCLUDE_CAMERA_PREVIEWOUTPUT_H
40 #define NATIVE_INCLUDE_CAMERA_PREVIEWOUTPUT_H
41 
42 #include <stdint.h>
43 #include <stdio.h>
44 #include "camera.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /**
51  * @brief Preview output object
52  *
53  * A pointer can be created using {@link Camera_PreviewOutput} method.
54  *
55  * @since 11
56  * @version 1.0
57  */
58 typedef struct Camera_PreviewOutput Camera_PreviewOutput;
59 
60 /**
61  * @brief Preview output frame start callback to be called in {@link PreviewOutput_Callbacks}.
62  *
63  * @param previewOutput the {@link Camera_PreviewOutput} which deliver the callback.
64  * @since 11
65  */
66 typedef void (*OH_PreviewOutput_OnFrameStart)(Camera_PreviewOutput* previewOutput);
67 
68 /**
69  * @brief Preview output frame end callback to be called in {@link PreviewOutput_Callbacks}.
70  *
71  * @param previewOutput the {@link Camera_PreviewOutput} which deliver the callback.
72  * @param frameCount the frame count which delivered by the callback.
73  * @since 11
74  */
75 typedef void (*OH_PreviewOutput_OnFrameEnd)(Camera_PreviewOutput* previewOutput, int32_t frameCount);
76 
77 /**
78  * @brief Preview output error callback to be called in {@link PreviewOutput_Callbacks}.
79  *
80  * @param previewOutput the {@link Camera_PreviewOutput} which deliver the callback.
81  * @param errorCode the {@link Camera_ErrorCode} of the preview output.
82  *
83  * @see CAMERA_SERVICE_FATAL_ERROR
84  * @since 11
85  */
86 typedef void (*OH_PreviewOutput_OnError)(Camera_PreviewOutput* previewOutput, Camera_ErrorCode errorCode);
87 
88 /**
89  * @brief A listener for preview output.
90  *
91  * @see OH_PreviewOutput_RegisterCallback
92  * @since 11
93  * @version 1.0
94  */
95 typedef struct PreviewOutput_Callbacks {
96     /**
97      * Preview output frame start event.
98      */
99     OH_PreviewOutput_OnFrameStart onFrameStart;
100 
101     /**
102      * Preview output frame end event.
103      */
104     OH_PreviewOutput_OnFrameEnd onFrameEnd;
105 
106     /**
107      * Preview output error event.
108      */
109     OH_PreviewOutput_OnError onError;
110 } PreviewOutput_Callbacks;
111 
112 /**
113  * @brief Register preview output change event callback.
114  *
115  * @param previewOutput the {@link Camera_PreviewOutput} instance.
116  * @param callback the {@link PreviewOutput_Callbacks} to be registered.
117  * @return {@link #CAMERA_OK} if the method call succeeds.
118  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
119  * @since 11
120  */
121 Camera_ErrorCode OH_PreviewOutput_RegisterCallback(Camera_PreviewOutput* previewOutput,
122     PreviewOutput_Callbacks* callback);
123 
124 /**
125  * @brief Unregister preview output change event callback.
126  *
127  * @param previewOutput the {@link Camera_PreviewOutput} instance.
128  * @param callback the {@link PreviewOutput_Callbacks} to be unregistered.
129  * @return {@link #CAMERA_OK} if the method call succeeds.
130  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
131  * @since 11
132  */
133 Camera_ErrorCode OH_PreviewOutput_UnregisterCallback(Camera_PreviewOutput* previewOutput,
134     PreviewOutput_Callbacks* callback);
135 
136 /**
137  * @brief Start preview output.
138  *
139  * @param previewOutput the {@link Camera_PreviewOutput} instance to be started.
140  * @return {@link #CAMERA_OK} if the method call succeeds.
141  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
142  *         {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config.
143  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
144  * @since 11
145  */
146 Camera_ErrorCode OH_PreviewOutput_Start(Camera_PreviewOutput* previewOutput);
147 
148 /**
149  * @brief Stop preview output.
150  *
151  * @param previewOutput the {@link Camera_PreviewOutput} instance to be stoped.
152  * @return {@link #CAMERA_OK} if the method call succeeds.
153  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
154  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
155  * @since 11
156  */
157 Camera_ErrorCode OH_PreviewOutput_Stop(Camera_PreviewOutput* previewOutput);
158 
159 /**
160  * @brief Release preview output.
161  *
162  * @param previewOutput the {@link Camera_PreviewOutput} instance to be released.
163  * @return {@link #CAMERA_OK} if the method call succeeds.
164  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
165  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
166  * @since 11
167  */
168 Camera_ErrorCode OH_PreviewOutput_Release(Camera_PreviewOutput* previewOutput);
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 #endif // NATIVE_INCLUDE_CAMERA_PREVIEWOUTPUT_H
175 /** @} */