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 Check whether mirror mode is supported for videoOutput 193 * 194 * @param videoOutput the {@link Camera_VideoOutput} instance 195 * @param isSupported the result of whether mirror mode supported. 196 * @return {@link #CAMERA_OK} if the method call succeeds. 197 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 198 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 199 * @since 15 200 */ 201 Camera_ErrorCode OH_VideoOutput_IsMirrorSupported(Camera_VideoOutput* videoOutput, bool* isSupported); 202 203 /** 204 * @brief Enable or disable mirror mode for videoOutput 205 * 206 * @param videoOutput the {@link Camera_VideoOutput} instance 207 * @param mirrorMode enable mirror mode if mirrorMode is TRUE, otherwise disable 208 * @return {@link #CAMERA_OK} if the method call succeeds. 209 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 210 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 211 * @since 15 212 */ 213 Camera_ErrorCode OH_VideoOutput_EnableMirror(Camera_VideoOutput* videoOutput, bool mirrorMode); 214 215 /** 216 * @brief Gets the video rotation angle. 217 * 218 * @param videoOutput the {@link Camera_VideoOutput} instance which used to get the video rotation angle. 219 * @param deviceDegree the current device rotation degree. 220 * @param imageRotation the {@link Camera_ImageRotation} result of video rotation angle. 221 * @return {@link #CAMERA_OK} if the method call succeeds. 222 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 223 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 224 * @since 12 225 */ 226 Camera_ErrorCode OH_VideoOutput_GetVideoRotation(Camera_VideoOutput* videoOutput, int deviceDegree, 227 Camera_ImageRotation* imageRotation); 228 229 /** 230 * @brief Get supported video output frame rate list. 231 * 232 * @param videoOutput the {@link Camera_VideoOutput} instance to deliver supported frame rate list. 233 * @param frameRateRange the supported {@link Camera_FrameRateRange} list to be filled if the method call succeeds. 234 * @param size the size of supported {@link Camera_FrameRateRange} list will be filled. 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_GetSupportedFrameRates(Camera_VideoOutput* videoOutput, 241 Camera_FrameRateRange** frameRateRange, uint32_t* size); 242 243 /** 244 * @brief Delete frame rate list. 245 * 246 * @param videoOutput the {@link Camera_VideoOutput} instance to deliver supported frame rate list. 247 * @param frameRateRange the {@link Camera_FrameRateRange} list to be deleted. 248 * @return {@link #CAMERA_OK} if the method call succeeds. 249 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 250 * @since 12 251 */ 252 Camera_ErrorCode OH_VideoOutput_DeleteFrameRates(Camera_VideoOutput* videoOutput, 253 Camera_FrameRateRange* frameRateRange); 254 255 /** 256 * @brief Set video output frame rate. 257 * 258 * @param videoOutput the {@link Camera_VideoOutput} instance to be set frame rate. 259 * @param minFps the minimum to be set. 260 * @param maxFps the maximum to be set. 261 * @return {@link #CAMERA_OK} if the method call succeeds. 262 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 263 * @since 12 264 */ 265 Camera_ErrorCode OH_VideoOutput_SetFrameRate(Camera_VideoOutput* videoOutput, 266 int32_t minFps, int32_t maxFps); 267 268 /** 269 * @brief Get active video output frame rate. 270 * 271 * @param videoOutput the {@link Camera_VideoOutput} instance to deliver the active frame rate. 272 * @param frameRateRange the active {@link Camera_FrameRateRange} to be filled if the method call succeeds. 273 * @return {@link #CAMERA_OK} if the method call succeeds. 274 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 275 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 276 * @since 12 277 */ 278 Camera_ErrorCode OH_VideoOutput_GetActiveFrameRate(Camera_VideoOutput* videoOutput, 279 Camera_FrameRateRange* frameRateRange); 280 281 #ifdef __cplusplus 282 } 283 #endif 284 285 #endif // NATIVE_INCLUDE_CAMERA_VIDEOOUTPUT_H 286 /** @} */