1 /* 2 * Copyright (c) 2021 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 #ifndef HOS_CAMERA_TYPES_C_IF_H 17 #define HOS_CAMERA_TYPES_C_IF_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 enum CameraStatusCIF { 24 UNAVAILABLE = 0, 25 AVAILABLE = 1, 26 }; 27 28 enum FlashlightStatusCIF { 29 FLASHLIGHT_OFF = 0, 30 FLASHLIGHT_ON = 1, 31 FLASHLIGHT_UNAVAILABLE = 2, 32 }; 33 34 enum RetCodeCIF { 35 NO_ERROR = 0, 36 CAMERA_BUSY = 1, 37 INSUFFICIENT_RESOURCES = 2, 38 INVALID_ARGUMENT = 3, 39 METHOD_NOT_SUPPORTED = 4, 40 CAMERA_CLOSED = 5, 41 DEVICE_ERROR = 6, 42 }; 43 44 typedef int MetaTypeCIF; 45 46 enum ErrorTypeCIF { 47 FATAL_ERROR, 48 }; 49 50 enum OperationModeCIF { 51 NORMAL = 0, 52 }; 53 54 enum StreamIntentCIF { 55 /** 56 * 用来送显的流类型 57 */ 58 PREVIEW = 0, 59 /** 60 * 送给VideoEncoder的流类型 61 */ 62 VIDEO = 1, 63 /** 64 * 进行拍照的流配型 65 */ 66 STILL_CAPTURE = 2, 67 /** 68 * 用来进行拍照回显的流类型 69 */ 70 POST_VIEW = 3, 71 /** 72 * 用来做图像分析的流类型 73 */ 74 ANALYZE = 4, 75 /** 76 * 普通自定义类型 77 */ 78 CUSTOM = 5, 79 }; 80 81 enum StreamSupportTypeCIF { 82 /** 83 * 流的组合和参数支持,并且基于当前流的配置可以动态切换 84 */ 85 DYNAMIC_SUPPORTED, 86 /** 87 * 流的组合和参数支持,但是需要服务重新配置所有流 88 */ 89 RE_CONFIGURED_REQUIRED, 90 /** 91 * 流的组合或者参数不支持 92 */ 93 NOT_SUPPORTED, 94 }; 95 96 typedef struct StreamAttributeCIF { 97 /** 98 * 流的标志Id号,设备级别唯一 99 */ 100 int streamId; 101 /** 102 * 请求的图像长度 103 */ 104 int width; 105 /** 106 * 请求的图像高度 107 */ 108 int height; 109 /** 110 * HAL覆盖的图像格式 111 */ 112 int overrideFormat; 113 /** 114 * HAL覆盖的图像颜色空间 115 */ 116 int overrideDataspace; 117 /** 118 * HAL需要的usage(需要等Graphic提供正式的BuferQueue定义) 119 */ 120 int producerUsage; 121 /** 122 * HAL需要的buffer个数 123 */ 124 int producerBufferCount; 125 /** 126 * 通过batch模式在一次Capture中能下发的捕获帧数 127 */ 128 int maxBatchCaptureCount; 129 /** 130 * 可以最大的并发拍照请求次数 131 */ 132 int maxCaptureCount; 133 } StreamAttributeCIF; 134 135 typedef struct CaptureInfoCIF { 136 /** 137 * 拍照的流Id 138 */ 139 int* streamIds; 140 int count; 141 /** 142 * 拍照的流参数 143 */ 144 // CameraMetadata* captureSetting; 145 /** 146 * 使能shutter回调 147 */ 148 int enableShutterCallback; 149 } CaptureInfoCIF; 150 151 struct CaptureEndedInfoCIF { 152 /** 153 * 流Id 154 */ 155 int streamId; 156 157 /** 158 * 捕获结束时正常抓取的帧数 159 */ 160 int frameCount; 161 }; 162 163 enum StreamErrorCIF { 164 /** 165 * 流未知错误 166 */ 167 UNKNOWN_ERROR = 0, 168 /** 169 * 丢包 170 */ 171 BUFFER_LOST = 1, 172 }; 173 174 typedef struct CaptureErrorInfoCIF { 175 /** 176 * 流Id 177 */ 178 int streamId; 179 180 /** 181 * 错误类型 182 */ 183 StreamErrorCIF error; 184 } CaptureErrorInfoCIF; 185 186 enum ResultCallbackModeCIF { 187 /** 188 * 每帧上报Result 189 */ 190 PER_FRAME, 191 /** 192 * 设备状态变化时才上报Result 193 */ 194 ON_CHANGED 195 }; 196 197 typedef struct GraphicBufferCIF { 198 int fd; 199 int width; 200 int stride; 201 int height; 202 int size; 203 int format; 204 int64_t usage; 205 void* virAddr; 206 uint64_t phyAddr; 207 int fence; 208 int streamId; 209 } GraphicBufferCIF; 210 211 typedef struct BufferProducerCIF { 212 int (*RequestBuffer)(GraphicBufferCIF* buffer); 213 int (*CancelBuffer)(GraphicBufferCIF* buffer); 214 int (*FlushBuffer)(GraphicBufferCIF* buffer); 215 int (*GetQueueSize)(int streamId); 216 unsigned int (*SetQueueSize)(int streamId, int size); 217 void (*DetachBufferProducer)(int streamId); 218 } BufferProducerCIF; 219 220 typedef struct StreamInfoCIF { 221 int streamId; 222 int width; 223 int height; 224 int format; 225 int dataspace; 226 int intent; // StreamIntentCIF 227 int tunneledMode; 228 BufferProducerCIF producer; 229 int minFrameDuration; 230 } StreamInfoCIF; 231 232 #ifdef __cplusplus 233 } 234 #endif 235 236 #endif 237