1/* 2 * Copyright (c) 2022 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 OHOS_HDI_CAMERA_V1_0_TYPES_H 17#define OHOS_HDI_CAMERA_V1_0_TYPES_H 18 19#include <cstdbool> 20#include <cstdint> 21#include <vector> 22#include "buffer_producer_sequenceable.h" 23 24#ifndef HDI_BUFF_MAX_SIZE 25#define HDI_BUFF_MAX_SIZE (1024 * 200) 26#endif 27 28#ifndef HDI_CHECK_VALUE_RETURN 29#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \ 30 if ((lv) compare (rv)) { \ 31 return ret; \ 32 } \ 33} while (false) 34#endif 35 36#ifndef HDI_CHECK_VALUE_RET_GOTO 37#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \ 38 if ((lv) compare (rv)) { \ 39 ret = value; \ 40 goto table; \ 41 } \ 42} while (false) 43#endif 44 45namespace OHOS { 46class MessageParcel; 47} 48 49namespace OHOS { 50namespace HDI { 51namespace Camera { 52namespace V1_0 { 53 54using namespace OHOS; 55 56enum CamRetCode : int32_t { 57 NO_ERROR = 0, 58 CAMERA_BUSY = -1, 59 INSUFFICIENT_RESOURCES = -2, 60 INVALID_ARGUMENT = -3, 61 METHOD_NOT_SUPPORTED = -4, 62 CAMERA_CLOSED = -5, 63 DEVICE_ERROR = -6, 64 NO_PERMISSION = -7, 65}; 66 67enum ResultCallbackMode : int32_t { 68 PER_FRAME = 0, 69 ON_CHANGED = 1, 70}; 71 72enum OperationMode : int32_t { 73 NORMAL = 0, 74}; 75 76enum StreamIntent : int32_t { 77 PREVIEW = 0, 78 VIDEO = 1, 79 STILL_CAPTURE = 2, 80 POST_VIEW = 3, 81 ANALYZE = 4, 82 CUSTOM = 5, 83}; 84 85enum EncodeType : int32_t { 86 ENCODE_TYPE_NULL = 0, 87 ENCODE_TYPE_H264 = 1, 88 ENCODE_TYPE_H265 = 2, 89 ENCODE_TYPE_JPEG = 3, 90}; 91 92enum StreamSupportType : int32_t { 93 DYNAMIC_SUPPORTED = 0, 94 RE_CONFIGURED_REQUIRED = 1, 95 NOT_SUPPORTED = 2, 96}; 97 98enum CameraStatus : int32_t { 99 UN_AVAILABLE = 0, 100 AVAILABLE = 1, 101}; 102 103enum FlashlightStatus : int32_t { 104 FLASHLIGHT_OFF = 0, 105 FLASHLIGHT_ON = 1, 106 FLASHLIGHT_UNAVAILABLE = 2, 107}; 108 109enum CameraEvent : int32_t { 110 CAMERA_EVENT_DEVICE_ADD = 0, 111 CAMERA_EVENT_DEVICE_RMV = 1, 112}; 113 114enum ErrorType : int32_t { 115 FATAL_ERROR = 0, 116 REQUEST_TIMEOUT = 1, 117 DRIVER_ERROR = 2, 118 DEVICE_PREEMPT = 3, 119 DEVICE_DISCONNECT = 4, 120 DCAMERA_ERROR_BEGIN = 1024, 121 DCAMERA_ERROR_DEVICE_IN_USE, 122 DCAMERA_ERROR_NO_PERMISSION, 123}; 124 125enum StreamError : int32_t { 126 UNKNOWN_ERROR = 0, 127 BUFFER_LOST = 1, 128}; 129 130struct StreamInfo { 131 int32_t streamId_; 132 int32_t width_; 133 int32_t height_; 134 int32_t format_; 135 int32_t dataspace_; 136 OHOS::HDI::Camera::V1_0::StreamIntent intent_; 137 bool tunneledMode_; 138 sptr<OHOS::HDI::Camera::V1_0::BufferProducerSequenceable> bufferQueue_; 139 int32_t minFrameDuration_; 140 OHOS::HDI::Camera::V1_0::EncodeType encodeType_; 141}; 142 143struct StreamAttribute { 144 int32_t streamId_; 145 int32_t width_; 146 int32_t height_; 147 int32_t overrideFormat_; 148 int32_t overrideDataspace_; 149 int32_t producerUsage_; 150 int32_t producerBufferCount_; 151 int32_t maxBatchCaptureCount_; 152 int32_t maxCaptureCount_; 153} __attribute__ ((aligned(8))); 154 155struct CaptureInfo { 156 std::vector<int32_t> streamIds_; 157 std::vector<uint8_t> captureSetting_; 158 bool enableShutterCallback_; 159}; 160 161struct CaptureEndedInfo { 162 int32_t streamId_; 163 int32_t frameCount_; 164} __attribute__ ((aligned(8))); 165 166struct CaptureErrorInfo { 167 int32_t streamId_; 168 OHOS::HDI::Camera::V1_0::StreamError error_; 169} __attribute__ ((aligned(8))); 170 171bool StreamInfoBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Camera::V1_0::StreamInfo& dataBlock); 172 173bool StreamInfoBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Camera::V1_0::StreamInfo& dataBlock); 174 175bool StreamAttributeBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Camera::V1_0::StreamAttribute& dataBlock); 176 177bool StreamAttributeBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Camera::V1_0::StreamAttribute& dataBlock); 178 179bool CaptureInfoBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Camera::V1_0::CaptureInfo& dataBlock); 180 181bool CaptureInfoBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Camera::V1_0::CaptureInfo& dataBlock); 182 183bool CaptureEndedInfoBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Camera::V1_0::CaptureEndedInfo& dataBlock); 184 185bool CaptureEndedInfoBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Camera::V1_0::CaptureEndedInfo& dataBlock); 186 187bool CaptureErrorInfoBlockMarshalling(OHOS::MessageParcel &data, const OHOS::HDI::Camera::V1_0::CaptureErrorInfo& dataBlock); 188 189bool CaptureErrorInfoBlockUnmarshalling(OHOS::MessageParcel &data, OHOS::HDI::Camera::V1_0::CaptureErrorInfo& dataBlock); 190 191} // V1_0 192} // Camera 193} // HDI 194} // OHOS 195 196#endif // OHOS_HDI_CAMERA_V1_0_TYPES_H 197 198