1 /*
2  * Copyright (c) 2023-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 #ifndef OHOS_CAPTURE_SESSION_IMPL_H
17 #define OHOS_CAPTURE_SESSION_IMPL_H
18 
19 #include "input/camera_manager.h"
20 #include "kits/native/include/camera/camera.h"
21 #include "kits/native/include/camera/capture_session.h"
22 #include "session/capture_session.h"
23 #include "camera_input_impl.h"
24 #include "preview_output_impl.h"
25 #include "video_output_impl.h"
26 #include "photo_output_impl.h"
27 #include "metadata_output_impl.h"
28 
29 struct Camera_CaptureSession {
30 public:
31     explicit Camera_CaptureSession(OHOS::sptr<OHOS::CameraStandard::CaptureSession> &innerCaptureSession);
32     ~Camera_CaptureSession();
33 
34     Camera_ErrorCode RegisterCallback(CaptureSession_Callbacks* callback);
35 
36     Camera_ErrorCode UnregisterCallback(CaptureSession_Callbacks* callback);
37 
38     Camera_ErrorCode RegisterSmoothZoomInfoCallback(OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback);
39 
40     Camera_ErrorCode UnregisterSmoothZoomInfoCallback(OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback);
41 
42     Camera_ErrorCode SetSessionMode(Camera_SceneMode sceneMode);
43 
44     Camera_ErrorCode AddSecureOutput(Camera_PreviewOutput* previewOutput);
45 
46     Camera_ErrorCode BeginConfig();
47 
48     Camera_ErrorCode CommitConfig();
49 
50     Camera_ErrorCode AddInput(Camera_Input* cameraInput);
51 
52     Camera_ErrorCode RemoveInput(Camera_Input* cameraInput);
53 
54     Camera_ErrorCode AddPreviewOutput(Camera_PreviewOutput* previewOutput);
55 
56     Camera_ErrorCode RemovePreviewOutput(Camera_PreviewOutput* previewOutput);
57 
58     Camera_ErrorCode AddPhotoOutput(Camera_PhotoOutput* photoOutput);
59 
60     Camera_ErrorCode RemovePhotoOutput(Camera_PhotoOutput* photoOutput);
61 
62     Camera_ErrorCode AddVideoOutput(Camera_VideoOutput* videoOutput);
63 
64     Camera_ErrorCode RemoveVideoOutput(Camera_VideoOutput* videoOutput);
65 
66     Camera_ErrorCode AddMetaDataOutput(Camera_MetadataOutput* metadataOutput);
67 
68     Camera_ErrorCode RemoveMetaDataOutput(Camera_MetadataOutput* metadataOutput);
69 
70     Camera_ErrorCode IsVideoStabilizationModeSupported(Camera_VideoStabilizationMode mode, bool* isSupported);
71 
72     Camera_ErrorCode GetVideoStabilizationMode(Camera_VideoStabilizationMode* mode);
73 
74     Camera_ErrorCode SetVideoStabilizationMode(Camera_VideoStabilizationMode mode);
75 
76     Camera_ErrorCode GetZoomRatioRange(float* minZoom, float* maxZoom);
77 
78     Camera_ErrorCode GetZoomRatio(float* zoom);
79 
80     Camera_ErrorCode SetZoomRatio(float zoom);
81 
82     Camera_ErrorCode SetSmoothZoom(float targetZoom, Camera_SmoothZoomMode smoothZoomMode);
83 
84     Camera_ErrorCode IsFocusModeSupported(Camera_FocusMode focusMode, bool* isSupported);
85 
86     Camera_ErrorCode GetFocusMode(Camera_FocusMode* focusMode);
87 
88     Camera_ErrorCode SetFocusMode(Camera_FocusMode focusMode);
89 
90     Camera_ErrorCode SetQualityPrioritization(Camera_QualityPrioritization qualityPrioritization);
91 
92     Camera_ErrorCode SetFocusPoint(Camera_Point focusPoint);
93 
94     Camera_ErrorCode GetFocusPoint(Camera_Point* focusPoint);
95 
96     Camera_ErrorCode GetFocalLength(float* focalLength);
97 
98     Camera_ErrorCode HasFlash(bool* hasFlash);
99 
100     Camera_ErrorCode IsFlashModeSupported(Camera_FlashMode flashMode, bool* isSupported);
101 
102     Camera_ErrorCode GetFlashMode(Camera_FlashMode* flashMode);
103 
104     Camera_ErrorCode SetFlashMode(Camera_FlashMode flashMode);
105 
106     Camera_ErrorCode IsExposureModeSupported(Camera_ExposureMode exposureMode, bool* isSupported);
107 
108     Camera_ErrorCode GetExposureMode(Camera_ExposureMode* exposureMode);
109 
110     Camera_ErrorCode SetExposureMode(Camera_ExposureMode exposureMode);
111 
112     Camera_ErrorCode GetMeteringPoint(Camera_Point* point);
113 
114     Camera_ErrorCode SetMeteringPoint(Camera_Point point);
115 
116     Camera_ErrorCode GetExposureBiasRange(float* minExposureBias, float* maxExposureBias, float* step);
117 
118     Camera_ErrorCode SetExposureBias(float exposureBias);
119 
120     Camera_ErrorCode GetExposureBias(float* exposureBias);
121 
122     Camera_ErrorCode GetExposureValue(float* exposureValue);
123 
124     Camera_ErrorCode GetSupportedColorSpaces(OH_NativeBuffer_ColorSpace** colorSpace, uint32_t* size);
125 
126     Camera_ErrorCode GetActiveColorSpace(OH_NativeBuffer_ColorSpace* colorSpace);
127 
128     Camera_ErrorCode DeleteColorSpaces(OH_NativeBuffer_ColorSpace* colorSpace);
129 
130     Camera_ErrorCode SetActiveColorSpace(OH_NativeBuffer_ColorSpace colorSpace);
131 
132     Camera_ErrorCode Start();
133 
134     Camera_ErrorCode Stop();
135 
136     Camera_ErrorCode Release();
137 
138     Camera_ErrorCode CanAddInput(Camera_Input* cameraInput, bool* isSuccessful);
139 
140     Camera_ErrorCode CanAddPreviewOutput(Camera_PreviewOutput* previewOutput, bool* isSuccessful);
141 
142     Camera_ErrorCode CanAddPhotoOutput(Camera_PhotoOutput* photoOutput, bool* isSuccessful);
143 
144     Camera_ErrorCode CanAddVideoOutput(Camera_VideoOutput* cameraOutput, bool* isSuccessful);
145 
146     Camera_ErrorCode CanPreconfig(Camera_PreconfigType preconfigType, bool* canPreconfig);
147 
148     Camera_ErrorCode CanPreconfigWithRatio(Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio,
149         bool* canPreconfig);
150 
151     Camera_ErrorCode Preconfig(Camera_PreconfigType preconfigType);
152 
153     Camera_ErrorCode PreconfigWithRatio(Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio);
154 
155     Camera_ErrorCode RegisterAutoDeviceSwitchStatusCallback(
156         OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange);
157 
158     Camera_ErrorCode UnregisterAutoDeviceSwitchStatusCallback(
159         OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange);
160 
161     Camera_ErrorCode IsAutoDeviceSwitchSupported(bool* isSupported);
162 
163     Camera_ErrorCode EnableAutoDeviceSwitch(bool enabled);
164 
165 private:
166     OHOS::sptr<OHOS::CameraStandard::CaptureSession> innerCaptureSession_;
167 };
168 #endif // OHOS_CAPTURE_SESSION_IMPL_H