• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 CAMERA_UTILS_H
17 #define CAMERA_UTILS_H
18 
19 #include <cstdint>
20 #include <memory>
21 #include <refbase.h>
22 #include <string>
23 #include "camera_device.h"
24 #include "camera_output_capability.h"
25 #include "cj_common_ffi.h"
26 #include "input/camera_manager.h"
27 
28 namespace OHOS {
29 namespace CameraStandard {
30 
31 struct CJCameraDevice {
32     char *cameraId;
33     int32_t cameraPosition;
34     int32_t cameraType;
35     int32_t connectionType;
36     uint32_t cameraOrientation;
37 };
38 
39 struct CArrCJCameraDevice {
40     CJCameraDevice *head;
41     int64_t size;
42 };
43 
44 struct CJProfile {
45     int32_t format;
46     uint32_t width;
47     uint32_t height;
48 };
49 
50 struct CArrCJProfile {
51     CJProfile *head;
52     int64_t size;
53 };
54 
55 struct CJFrameRateRange {
56     int32_t min;
57     int32_t max;
58 };
59 
60 struct CJVideoProfile {
61     int32_t format;
62     uint32_t width;
63     uint32_t height;
64     CJFrameRateRange frameRateRange;
65 };
66 
67 struct CArrCJVideoProfile {
68     CJVideoProfile *head;
69     int64_t size;
70 };
71 
72 struct CJCameraOutputCapability {
73     CArrCJProfile previewProfiles;
74     CArrCJProfile photoProfiles;
75     CArrCJVideoProfile videoProfiles;
76     CArrI32 supportedMetadataObjectTypes;
77 };
78 
79 struct FrameRateRange {
80     int32_t min;
81     int32_t max;
82 };
83 
84 struct CArrFrameRateRange {
85     FrameRateRange *head;
86     int64_t size;
87 };
88 
89 struct CArrDouble {
90     double *head;
91     int64_t size;
92 };
93 
94 struct CArrFloat32 {
95     float *head;
96     int64_t size;
97 };
98 
99 struct RetDataCArrDouble {
100     int32_t code;
101     CArrDouble data;
102 };
103 
104 struct CJLocation {
105     double latitude = -1;
106     double longitude = -1;
107     double altitude = -1;
108 };
109 
110 struct CJCameraStatusInfo {
111     CJCameraDevice camera;
112     int32_t status;
113 };
114 
115 struct CJPhotoCaptureSetting {
116     int32_t quality;
117     int32_t rotation;
118     CJLocation location;
119     bool mirror;
120 };
121 
122 struct CJFoldStatusInfo {
123     CArrCJCameraDevice supportedCameras;
124     int32_t foldStatus;
125 };
126 
127 struct CJTorchStatusInfo {
128     bool isTorchAvailable;
129     bool isTorchActive;
130     float torchLevel;
131 };
132 
133 struct CJErrorCallback {
134     int32_t errorType;
135     int32_t errorMsg;
136 };
137 
138 struct CJCaptureStartInfo {
139     int32_t captureID;
140     uint32_t exposureTime;
141 };
142 
143 struct CJFrameShutterInfo {
144     int32_t captureID;
145     uint64_t timestamp;
146 };
147 
148 struct CJCaptureEndInfo {
149     int32_t captureID;
150     int32_t frameCount;
151 };
152 
153 struct CJRect {
154     double topLeftX;
155     double topLeftY;
156     double width;
157     double height;
158 };
159 
160 struct CJMetadataObject {
161     int32_t type;
162     int32_t timestamp;
163     CJRect boundingBox;
164 };
165 
166 struct CArrCJMetadataObject {
167     CJMetadataObject *head;
168     int64_t size;
169 };
170 
171 enum OutputType { METADATA_OUTPUT = 0, PHOTO_OUTPUT, PREVIEW_OUTPUT, VIDEO_OUTPUT };
172 
173 CJMetadataObject MetadataObjectToCJMetadataObject(MetadataObject metaObject);
174 
175 CArrCJMetadataObject MetadataObjectsToCArrCJMetadataObject(std::vector<sptr<MetadataObject>> metaObjects);
176 
177 CJErrorCallback ErrorCallBackToCJErrorCallBack(const int32_t errorType, const int32_t errorMsg);
178 
179 CJTorchStatusInfo TorchStatusInfoToCJTorchStatusInfo(const TorchStatusInfo &torchStatusInfo);
180 
181 CArrCJCameraDevice CameraDeviceVetorToCArrCJCameraDevice(const std::vector<sptr<CameraDevice>> cameras);
182 
183 CJCameraDevice CameraDeviceToCJCameraDevice(CameraDevice &cameraDevice);
184 
185 CJFoldStatusInfo FoldStatusInfoToCJFoldStatusInfo(const FoldStatusInfo &foldStatusInfo);
186 
187 CJCameraStatusInfo CameraStatusInfoToCJCameraStatusInfo(const CameraStatusInfo &cameraStatusInfo);
188 
189 CJCameraOutputCapability CameraOutputCapabilityToCJCameraOutputCapability(
190     sptr<CameraOutputCapability> cameraOutputCapability, int32_t *errCode);
191 
192 char *MallocCString(const std::string &origin);
193 } // namespace CameraStandard
194 } // namespace OHOS
195 
196 #endif