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 * @syscap SystemCapability.Multimedia.Camera.Core 35 * @since 11 36 * @version 1.0 37 */ 38 39 #ifndef NATIVE_INCLUDE_CAMERA_VIDEOOUTPUT_H 40 #define NATIVE_INCLUDE_CAMERA_VIDEOOUTPUT_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 Video output object 52 * 53 * A pointer can be created using {@link Camera_VideoOutput} method. 54 * 55 * @since 11 56 * @version 1.0 57 */ 58 typedef struct Camera_VideoOutput Camera_VideoOutput; 59 60 /** 61 * @brief Video output frame start callback to be called in {@link VideoOutput_Callbacks}. 62 * 63 * @param videoOutput the {@link Camera_VideoOutput} which deliver the callback. 64 * @since 11 65 */ 66 typedef void (*OH_VideoOutput_OnFrameStart)(Camera_VideoOutput* videoOutput); 67 68 /** 69 * @brief Video output frame end callback to be called in {@link VideoOutput_Callbacks}. 70 * 71 * @param videoOutput the {@link Camera_VideoOutput} which deliver the callback. 72 * @param frameCount the frame count which delivered by the callback. 73 * @since 11 74 */ 75 typedef void (*OH_VideoOutput_OnFrameEnd)(Camera_VideoOutput* videoOutput, int32_t frameCount); 76 77 /** 78 * @brief Video output error callback to be called in {@link VideoOutput_Callbacks}. 79 * 80 * @param videoOutput the {@link Camera_VideoOutput} which deliver the callback. 81 * @param errorCode the {@link Camera_ErrorCode} of the video output. 82 * 83 * @see CAMERA_SERVICE_FATAL_ERROR 84 * @since 11 85 */ 86 typedef void (*OH_VideoOutput_OnError)(Camera_VideoOutput* videoOutput, Camera_ErrorCode errorCode); 87 88 /** 89 * @brief A listener for video output. 90 * 91 * @see OH_VideoOutput_RegisterCallback 92 * @since 11 93 * @version 1.0 94 */ 95 typedef struct VideoOutput_Callbacks { 96 /** 97 * Video output frame start event. 98 */ 99 OH_VideoOutput_OnFrameStart onFrameStart; 100 101 /** 102 * Video output frame end event. 103 */ 104 OH_VideoOutput_OnFrameEnd onFrameEnd; 105 106 /** 107 * Video output error event. 108 */ 109 OH_VideoOutput_OnError onError; 110 } VideoOutput_Callbacks; 111 112 /** 113 * @brief Register video output change event callback. 114 * 115 * @param videoOutput the {@link Camera_VideoOutput} instance. 116 * @param callback the {@link VideoOutput_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_VideoOutput_RegisterCallback(Camera_VideoOutput* videoOutput, VideoOutput_Callbacks* callback); 122 123 /** 124 * @brief Unregister video output change event callback. 125 * 126 * @param videoOutput the {@link Camera_VideoOutput} instance. 127 * @param callback the {@link VideoOutput_Callbacks} to be unregistered. 128 * @return {@link #CAMERA_OK} if the method call succeeds. 129 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 130 * @since 11 131 */ 132 Camera_ErrorCode OH_VideoOutput_UnregisterCallback(Camera_VideoOutput* videoOutput, VideoOutput_Callbacks* callback); 133 134 /** 135 * @brief Start video output. 136 * 137 * @param videoOutput the {@link Camera_VideoOutput} instance to be started. 138 * @return {@link #CAMERA_OK} if the method call succeeds. 139 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 140 * {@link #CAMERA_SESSION_NOT_CONFIG} if the capture session not config. 141 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 142 * @since 11 143 */ 144 Camera_ErrorCode OH_VideoOutput_Start(Camera_VideoOutput* videoOutput); 145 146 /** 147 * @brief Stop video output. 148 * 149 * @param videoOutput the {@link Camera_VideoOutput} instance to be stoped. 150 * @return {@link #CAMERA_OK} if the method call succeeds. 151 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 152 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 153 * @since 11 154 */ 155 Camera_ErrorCode OH_VideoOutput_Stop(Camera_VideoOutput* videoOutput); 156 157 /** 158 * @brief Release video output. 159 * 160 * @param videoOutput the {@link Camera_VideoOutput} instance to be released. 161 * @return {@link #CAMERA_OK} if the method call succeeds. 162 * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. 163 * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. 164 * @since 11 165 */ 166 Camera_ErrorCode OH_VideoOutput_Release(Camera_VideoOutput* videoOutput); 167 168 #ifdef __cplusplus 169 } 170 #endif 171 172 #endif // NATIVE_INCLUDE_CAMERA_VIDEOOUTPUT_H 173 /** @} */