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
48extern "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 */
59typedef 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 */
67typedef 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 */
76typedef 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 */
87typedef 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 */
96typedef 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 */
122Camera_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 */
133Camera_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 */
145Camera_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 */
156Camera_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 */
167Camera_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 */
179Camera_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 */
189Camera_ErrorCode OH_VideoOutput_DeleteProfile(Camera_VideoProfile* profile);
190
191/**
192 * @brief Gets the video rotation angle.
193 *
194 * @param videoOutput the {@link Camera_VideoOutput} instance which used to get the video rotation angle.
195 * @param deviceDegree the current device rotation degree.
196 * @param imageRotation the {@link Camera_ImageRotation} result of video rotation angle.
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 */
202Camera_ErrorCode  OH_VideoOutput_GetVideoRotation(Camera_VideoOutput* videoOutput, int deviceDegree,
203    Camera_ImageRotation* imageRotation);
204
205/**
206 * @brief Get supported video output frame rate list.
207 *
208 * @param videoOutput the {@link Camera_VideoOutput} instance to deliver supported frame rate list.
209 * @param frameRateRange the supported {@link Camera_FrameRateRange} list to be filled if the method call succeeds.
210 * @param size the size of supported {@link Camera_FrameRateRange} list will be filled.
211 * @return {@link #CAMERA_OK} if the method call succeeds.
212 *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
213 *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
214 * @since 12
215 */
216Camera_ErrorCode OH_VideoOutput_GetSupportedFrameRates(Camera_VideoOutput* videoOutput,
217    Camera_FrameRateRange** frameRateRange, uint32_t* size);
218
219/**
220 * @brief Delete frame rate list.
221 *
222 * @param videoOutput the {@link Camera_VideoOutput} instance to deliver supported frame rate list.
223 * @param frameRateRange the {@link Camera_FrameRateRange} list to be deleted.
224 * @return {@link #CAMERA_OK} if the method call succeeds.
225 *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
226 * @since 12
227 */
228Camera_ErrorCode OH_VideoOutput_DeleteFrameRates(Camera_VideoOutput* videoOutput,
229    Camera_FrameRateRange* frameRateRange);
230
231/**
232 * @brief Set video output frame rate.
233 *
234 * @param videoOutput the {@link Camera_VideoOutput} instance to be set frame rate.
235 * @param minFps the minimum to be set.
236 * @param maxFps the maximum to be set.
237 * @return {@link #CAMERA_OK} if the method call succeeds.
238 *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
239 * @since 12
240 */
241Camera_ErrorCode OH_VideoOutput_SetFrameRate(Camera_VideoOutput* videoOutput,
242    int32_t minFps, int32_t maxFps);
243
244/**
245 * @brief Get active video output frame rate.
246 *
247 * @param videoOutput the {@link Camera_VideoOutput} instance to deliver the active frame rate.
248 * @param frameRateRange the active {@link Camera_FrameRateRange} to be filled if the method call succeeds.
249 * @return {@link #CAMERA_OK} if the method call succeeds.
250 *         {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect.
251 *         {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error.
252 * @since 12
253 */
254Camera_ErrorCode OH_VideoOutput_GetActiveFrameRate(Camera_VideoOutput* videoOutput,
255    Camera_FrameRateRange* frameRateRange);
256
257#ifdef __cplusplus
258}
259#endif
260
261#endif // NATIVE_INCLUDE_CAMERA_VIDEOOUTPUT_H
262/** @} */