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 video_output.h
30  *
31  * @brief Declare the video 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_VIDEOOUTPUT_H
41 #define NATIVE_INCLUDE_CAMERA_VIDEOOUTPUT_H
42 
43 #include <stdint.h>
44 #include <stdio.h>
45 #include "camera.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /**
52  * @brief Video output object
53  *
54  * A pointer can be created using {@link Camera_VideoOutput} method.
55  *
56  * @since 11
57  * @version 1.0
58  */
59 typedef struct Camera_VideoOutput Camera_VideoOutput;
60 
61 /**
62  * @brief Video output frame start callback to be called in {@link VideoOutput_Callbacks}.
63  *
64  * @param videoOutput the {@link Camera_VideoOutput} which deliver the callback.
65  * @since 11
66  */
67 typedef void (*OH_VideoOutput_OnFrameStart)(Camera_VideoOutput* videoOutput);
68 
69 /**
70  * @brief Video output frame end callback to be called in {@link VideoOutput_Callbacks}.
71  *
72  * @param videoOutput the {@link Camera_VideoOutput} which deliver the callback.
73  * @param frameCount the frame count which delivered by the callback.
74  * @since 11
75  */
76 typedef void (*OH_VideoOutput_OnFrameEnd)(Camera_VideoOutput* videoOutput, int32_t frameCount);
77 
78 /**
79  * @brief Video output error callback to be called in {@link VideoOutput_Callbacks}.
80  *
81  * @param videoOutput the {@link Camera_VideoOutput} which deliver the callback.
82  * @param errorCode the {@link Camera_ErrorCode} of the video output.
83  *
84  * @see CAMERA_SERVICE_FATAL_ERROR
85  * @since 11
86  */
87 typedef void (*OH_VideoOutput_OnError)(Camera_VideoOutput* videoOutput, Camera_ErrorCode errorCode);
88 
89 /**
90  * @brief A listener for video output.
91  *
92  * @see OH_VideoOutput_RegisterCallback
93  * @since 11
94  * @version 1.0
95  */
96 typedef struct VideoOutput_Callbacks {
97     /**
98      * Video output frame start event.
99      */
100     OH_VideoOutput_OnFrameStart onFrameStart;
101 
102     /**
103      * Video output frame end event.
104      */
105     OH_VideoOutput_OnFrameEnd onFrameEnd;
106 
107     /**
108      * Video output error event.
109      */
110     OH_VideoOutput_OnError onError;
111 } VideoOutput_Callbacks;
112 
113 /**
114  * @brief Register video output change event callback.
115  *
116  * @param videoOutput the {@link Camera_VideoOutput} instance.
117  * @param callback the {@link VideoOutput_Callbacks} to be registered.
118  * @return {@link #CAMERA_OK} if the method call succeeds.
119  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
120  * @since 11
121  */
122 Camera_ErrorCode OH_VideoOutput_RegisterCallback(Camera_VideoOutput* videoOutput, VideoOutput_Callbacks* callback);
123 
124 /**
125  * @brief Unregister video output change event callback.
126  *
127  * @param videoOutput the {@link Camera_VideoOutput} instance.
128  * @param callback the {@link VideoOutput_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_VideoOutput_UnregisterCallback(Camera_VideoOutput* videoOutput, VideoOutput_Callbacks* callback);
134 
135 /**
136  * @brief Start video output.
137  *
138  * @param videoOutput the {@link Camera_VideoOutput} instance to be started.
139  * @return {@link #CAMERA_OK} if the method call succeeds.
140  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
141  *         {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config.
142  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
143  * @since 11
144  */
145 Camera_ErrorCode OH_VideoOutput_Start(Camera_VideoOutput* videoOutput);
146 
147 /**
148  * @brief Stop video output.
149  *
150  * @param videoOutput the {@link Camera_VideoOutput} instance to be stoped.
151  * @return {@link #CAMERA_OK} if the method call succeeds.
152  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
153  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
154  * @since 11
155  */
156 Camera_ErrorCode OH_VideoOutput_Stop(Camera_VideoOutput* videoOutput);
157 
158 /**
159  * @brief Release video output.
160  *
161  * @param videoOutput the {@link Camera_VideoOutput} instance to be released.
162  * @return {@link #CAMERA_OK} if the method call succeeds.
163  *         {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
164  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
165  * @since 11
166  */
167 Camera_ErrorCode OH_VideoOutput_Release(Camera_VideoOutput* videoOutput);
168 
169 /**
170  * @brief Get active video output profile.
171  *
172  * @param videoOutput the {@link Camera_VideoOutput} instance to deliver active video profile.
173  * @param profile the active {@link Camera_VideoProfile} to be filled if the method call succeeds.
174  * @return {@link #CAMERA_OK} if the method call succeeds.
175  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
176  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
177  * @since 12
178  */
179 Camera_ErrorCode OH_VideoOutput_GetActiveProfile(Camera_VideoOutput* videoOutput, Camera_VideoProfile** profile);
180 
181 /**
182  * @brief Delete video profile instance.
183  *
184  * @param profile the {@link Camera_VideoProfile} instance to deleted.
185  * @return {@link #CAMERA_OK} if the method call succeeds.
186  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
187  * @since 12
188  */
189 Camera_ErrorCode OH_VideoOutput_DeleteProfile(Camera_VideoProfile* profile);
190 
191 /**
192  * @brief Get supported video output frame rate list.
193  *
194  * @param videoOutput the {@link Camera_VideoOutput} instance to deliver supported frame rate list.
195  * @param frameRateRange the supported {@link Camera_FrameRateRange} list to be filled if the method call succeeds.
196  * @param size the size of supported {@link Camera_FrameRateRange} list will be filled.
197  * @return {@link #CAMERA_OK} if the method call succeeds.
198  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
199  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
200  * @since 12
201  */
202 Camera_ErrorCode OH_VideoOutput_GetSupportedFrameRates(Camera_VideoOutput* videoOutput,
203     Camera_FrameRateRange** frameRateRange, uint32_t* size);
204 
205 /**
206  * @brief Delete frame rate list.
207  *
208  * @param videoOutput the {@link Camera_VideoOutput} instance to deliver supported frame rate list.
209  * @param frameRateRange the {@link Camera_FrameRateRange} list to be deleted.
210  * @return {@link #CAMERA_OK} if the method call succeeds.
211  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
212  * @since 12
213  */
214 Camera_ErrorCode OH_VideoOutput_DeleteFrameRates(Camera_VideoOutput* videoOutput,
215     Camera_FrameRateRange* frameRateRange);
216 
217 /**
218  * @brief Set video output frame rate.
219  *
220  * @param videoOutput the {@link Camera_VideoOutput} instance to be set frame rate.
221  * @param minFps the minimum to be set.
222  * @param maxFps the maximum to be set.
223  * @return {@link #CAMERA_OK} if the method call succeeds.
224  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
225  * @since 12
226  */
227 Camera_ErrorCode OH_VideoOutput_SetFrameRate(Camera_VideoOutput* videoOutput,
228     int32_t minFps, int32_t maxFps);
229 
230 /**
231  * @brief Get active video output frame rate.
232  *
233  * @param videoOutput the {@link Camera_VideoOutput} instance to deliver the active frame rate.
234  * @param frameRateRange the active {@link Camera_FrameRateRange} to be filled if the method call succeeds.
235  * @return {@link #CAMERA_OK} if the method call succeeds.
236  *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
237  *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
238  * @since 12
239  */
240 Camera_ErrorCode OH_VideoOutput_GetActiveFrameRate(Camera_VideoOutput* videoOutput,
241     Camera_FrameRateRange* frameRateRange);
242 
243 #ifdef __cplusplus
244 }
245 #endif
246 
247 #endif // NATIVE_INCLUDE_CAMERA_VIDEOOUTPUT_H
248 /** @} */