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 * @kit CameraKit 35 * @syscap SystemCapability.Multimedia.Camera.Core 36 * @since 11 37 * @version 1.0 38 */ 39 40 #ifndef NATIVE_INCLUDE_CAMERA_PREVIEWOUTPUT_H 41 #define NATIVE_INCLUDE_CAMERA_PREVIEWOUTPUT_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 Preview output object 53 * 54 * A pointer can be created using {@link Camera_PreviewOutput} method. 55 * 56 * @since 11 57 * @version 1.0 58 */ 59 typedef struct Camera_PreviewOutput Camera_PreviewOutput; 60 61 /** 62 * @brief Preview output frame start callback to be called in {@link PreviewOutput_Callbacks}. 63 * 64 * @param previewOutput the {@link Camera_PreviewOutput} which deliver the callback. 65 * @since 11 66 */ 67 typedef void (*OH_PreviewOutput_OnFrameStart)(Camera_PreviewOutput* previewOutput); 68 69 /** 70 * @brief Preview output frame end callback to be called in {@link PreviewOutput_Callbacks}. 71 * 72 * @param previewOutput the {@link Camera_PreviewOutput} which deliver the callback. 73 * @param frameCount the frame count which delivered by the callback. 74 * @since 11 75 */ 76 typedef void (*OH_PreviewOutput_OnFrameEnd)(Camera_PreviewOutput* previewOutput, int32_t frameCount); 77 78 /** 79 * @brief Preview output error callback to be called in {@link PreviewOutput_Callbacks}. 80 * 81 * @param previewOutput the {@link Camera_PreviewOutput} which deliver the callback. 82 * @param errorCode the {@link Camera_ErrorCode} of the preview output. 83 * 84 * @see CAMERA_SERVICE_FATAL_ERROR 85 * @since 11 86 */ 87 typedef void (*OH_PreviewOutput_OnError)(Camera_PreviewOutput* previewOutput, Camera_ErrorCode errorCode); 88 89 /** 90 * @brief A listener for preview output. 91 * 92 * @see OH_PreviewOutput_RegisterCallback 93 * @since 11 94 * @version 1.0 95 */ 96 typedef struct PreviewOutput_Callbacks { 97 /** 98 * Preview output frame start event. 99 */ 100 OH_PreviewOutput_OnFrameStart onFrameStart; 101 102 /** 103 * Preview output frame end event. 104 */ 105 OH_PreviewOutput_OnFrameEnd onFrameEnd; 106 107 /** 108 * Preview output error event. 109 */ 110 OH_PreviewOutput_OnError onError; 111 } PreviewOutput_Callbacks; 112 113 /** 114 * @brief Register preview output change event callback. 115 * 116 * @param previewOutput the {@link Camera_PreviewOutput} instance. 117 * @param callback the {@link PreviewOutput_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_PreviewOutput_RegisterCallback(Camera_PreviewOutput* previewOutput, 123 PreviewOutput_Callbacks* callback); 124 125 /** 126 * @brief Unregister preview output change event callback. 127 * 128 * @param previewOutput the {@link Camera_PreviewOutput} instance. 129 * @param callback the {@link PreviewOutput_Callbacks} to be unregistered. 130 * @return {@link #CAMERA_OK} if the method call succeeds. 131 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 132 * @since 11 133 */ 134 Camera_ErrorCode OH_PreviewOutput_UnregisterCallback(Camera_PreviewOutput* previewOutput, 135 PreviewOutput_Callbacks* callback); 136 137 /** 138 * @brief Start preview output. 139 * 140 * @param previewOutput the {@link Camera_PreviewOutput} instance to be started. 141 * @return {@link #CAMERA_OK} if the method call succeeds. 142 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 143 * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. 144 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 145 * @since 11 146 */ 147 Camera_ErrorCode OH_PreviewOutput_Start(Camera_PreviewOutput* previewOutput); 148 149 /** 150 * @brief Stop preview output. 151 * 152 * @param previewOutput the {@link Camera_PreviewOutput} instance to be stoped. 153 * @return {@link #CAMERA_OK} if the method call succeeds. 154 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 155 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 156 * @since 11 157 */ 158 Camera_ErrorCode OH_PreviewOutput_Stop(Camera_PreviewOutput* previewOutput); 159 160 /** 161 * @brief Release preview output. 162 * 163 * @param previewOutput the {@link Camera_PreviewOutput} instance to be released. 164 * @return {@link #CAMERA_OK} if the method call succeeds. 165 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 166 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 167 * @since 11 168 */ 169 Camera_ErrorCode OH_PreviewOutput_Release(Camera_PreviewOutput* previewOutput); 170 171 /** 172 * @brief Get active preview output profile. 173 * 174 * @param previewOutput the {@link Camera_PreviewOutput} instance to deliver active profile. 175 * @param profile the active {@link Camera_Profile} to be filled if the method call succeeds. 176 * @return {@link #CAMERA_OK} if the method call succeeds. 177 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 178 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 179 * @since 12 180 */ 181 Camera_ErrorCode OH_PreviewOutput_GetActiveProfile(Camera_PreviewOutput* previewOutput, Camera_Profile** profile); 182 183 /** 184 * @brief Delete preview profile instance. 185 * 186 * @param profile the {@link Camera_Profile} instance to deleted. 187 * @return {@link #CAMERA_OK} if the method call succeeds. 188 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 189 * @since 12 190 */ 191 Camera_ErrorCode OH_PreviewOutput_DeleteProfile(Camera_Profile* profile); 192 193 /** 194 * @brief Get supported preview output frame rate list. 195 * 196 * @param previewOutput the {@link Camera_PreviewOutput} instance to deliver supported frame rate list. 197 * @param frameRateRange the supported {@link Camera_FrameRateRange} list to be filled if the method call succeeds. 198 * @param size the size of supported {@link Camera_FrameRateRange} list will be filled. 199 * @return {@link #CAMERA_OK} if the method call succeeds. 200 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 201 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 202 * @since 12 203 */ 204 Camera_ErrorCode OH_PreviewOutput_GetSupportedFrameRates(Camera_PreviewOutput* previewOutput, 205 Camera_FrameRateRange** frameRateRange, uint32_t* size); 206 207 /** 208 * @brief Delete frame rate list. 209 * 210 * @param previewOutput the {@link Camera_PreviewOutput} instance to deliver supported frame rate list. 211 * @param frameRateRange the {@link Camera_FrameRateRange} list to be deleted. 212 * @return {@link #CAMERA_OK} if the method call succeeds. 213 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 214 * @since 12 215 */ 216 Camera_ErrorCode OH_PreviewOutput_DeleteFrameRates(Camera_PreviewOutput* previewOutput, 217 Camera_FrameRateRange* frameRateRange); 218 219 /** 220 * @brief Set preview output frame rate. 221 * 222 * @param previewOutput the {@link Camera_PreviewOutput} instance to be set frame rate. 223 * @param minFps the minimum to be set. 224 * @param maxFps the maximum to be set. 225 * @return {@link #CAMERA_OK} if the method call succeeds. 226 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 227 * @since 12 228 */ 229 Camera_ErrorCode OH_PreviewOutput_SetFrameRate(Camera_PreviewOutput* previewOutput, 230 int32_t minFps, int32_t maxFps); 231 232 /** 233 * @brief Get active preview output frame rate. 234 * 235 * @param previewOutput the {@link Camera_PreviewOutput} instance to deliver the active frame rate. 236 * @param frameRateRange the active {@link Camera_FrameRateRange} to be filled if the method call succeeds. 237 * @return {@link #CAMERA_OK} if the method call succeeds. 238 * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 239 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 240 * @since 12 241 */ 242 Camera_ErrorCode OH_PreviewOutput_GetActiveFrameRate(Camera_PreviewOutput* previewOutput, 243 Camera_FrameRateRange* frameRateRange); 244 245 #ifdef __cplusplus 246 } 247 #endif 248 249 #endif // NATIVE_INCLUDE_CAMERA_PREVIEWOUTPUT_H 250 /** @} */