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 #include "kits/native/include/camera/capture_session.h"
17 #include "impl/capture_session_impl.h"
18 #include "camera_log.h"
19 #include "hilog/log.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
OH_CaptureSession_RegisterCallback(Camera_CaptureSession* session, CaptureSession_Callbacks* callback)25 Camera_ErrorCode OH_CaptureSession_RegisterCallback(Camera_CaptureSession* session, CaptureSession_Callbacks* callback)
26 {
27     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
28     CHECK_AND_RETURN_RET_LOG(callback != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, callback is null!");
29     CHECK_AND_RETURN_RET_LOG(callback->onFocusStateChange != nullptr || callback->onError != nullptr,
30         CAMERA_INVALID_ARGUMENT, "Invaild argument, callback onFocusStateChange and onError are null!");
31 
32     session->RegisterCallback(callback);
33     return CAMERA_OK;
34 }
35 
OH_CaptureSession_UnregisterCallback(Camera_CaptureSession* session, CaptureSession_Callbacks* callback)36 Camera_ErrorCode OH_CaptureSession_UnregisterCallback(Camera_CaptureSession* session,
37     CaptureSession_Callbacks* callback)
38 {
39     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
40     CHECK_AND_RETURN_RET_LOG(callback != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, callback is null!");
41     CHECK_AND_RETURN_RET_LOG(callback->onFocusStateChange != nullptr || callback->onError != nullptr,
42         CAMERA_INVALID_ARGUMENT, "Invaild argument, callback onFocusStateChange and onError are null!");
43 
44     session->UnregisterCallback(callback);
45     return CAMERA_OK;
46 }
47 
OH_CaptureSession_RegisterSmoothZoomInfoCallback(Camera_CaptureSession* session, OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)48 Camera_ErrorCode OH_CaptureSession_RegisterSmoothZoomInfoCallback(Camera_CaptureSession* session,
49     OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)
50 {
51     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
52     CHECK_AND_RETURN_RET_LOG(smoothZoomInfoCallback != nullptr, CAMERA_INVALID_ARGUMENT,
53         "Invaild argument, callback is null!");
54     session->RegisterSmoothZoomInfoCallback(smoothZoomInfoCallback);
55     return CAMERA_OK;
56 }
57 
OH_CaptureSession_UnregisterSmoothZoomInfoCallback(Camera_CaptureSession* session, OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)58 Camera_ErrorCode OH_CaptureSession_UnregisterSmoothZoomInfoCallback(Camera_CaptureSession* session,
59     OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)
60 {
61     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
62     CHECK_AND_RETURN_RET_LOG(smoothZoomInfoCallback != nullptr, CAMERA_INVALID_ARGUMENT,
63         "Invaild argument, callback is null!");
64     session->UnregisterSmoothZoomInfoCallback(smoothZoomInfoCallback);
65     return CAMERA_OK;
66 }
67 
OH_CaptureSession_SetSessionMode(Camera_CaptureSession* session, Camera_SceneMode sceneMode)68 Camera_ErrorCode OH_CaptureSession_SetSessionMode(Camera_CaptureSession* session, Camera_SceneMode sceneMode)
69 {
70     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
71 
72     return session->SetSessionMode(sceneMode);
73 }
74 
OH_CaptureSession_AddSecureOutput(Camera_CaptureSession* session, Camera_PreviewOutput* previewOutput)75 Camera_ErrorCode OH_CaptureSession_AddSecureOutput(Camera_CaptureSession* session, Camera_PreviewOutput* previewOutput)
76 {
77     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invalid argument, session is null!");
78     CHECK_AND_RETURN_RET_LOG(previewOutput != nullptr,
79         CAMERA_INVALID_ARGUMENT, "Invalid argument, previewOutput is null!");
80     return session->AddSecureOutput(previewOutput);
81 }
82 
OH_CaptureSession_BeginConfig(Camera_CaptureSession* session)83 Camera_ErrorCode OH_CaptureSession_BeginConfig(Camera_CaptureSession* session)
84 {
85     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
86 
87     return session->BeginConfig();
88 }
89 
OH_CaptureSession_CommitConfig(Camera_CaptureSession* session)90 Camera_ErrorCode OH_CaptureSession_CommitConfig(Camera_CaptureSession* session)
91 {
92     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
93 
94     return session->CommitConfig();
95 }
96 
OH_CaptureSession_AddInput(Camera_CaptureSession* session, Camera_Input* cameraInput)97 Camera_ErrorCode OH_CaptureSession_AddInput(Camera_CaptureSession* session, Camera_Input* cameraInput)
98 {
99     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
100     CHECK_AND_RETURN_RET_LOG(cameraInput != nullptr, CAMERA_INVALID_ARGUMENT,
101         "Invaild argument, cameraInput is null!");
102 
103     return session->AddInput(cameraInput);
104 }
105 
OH_CaptureSession_RemoveInput(Camera_CaptureSession* session, Camera_Input* cameraInput)106 Camera_ErrorCode OH_CaptureSession_RemoveInput(Camera_CaptureSession* session, Camera_Input* cameraInput)
107 {
108     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
109     CHECK_AND_RETURN_RET_LOG(cameraInput != nullptr, CAMERA_INVALID_ARGUMENT,
110         "Invaild argument, cameraInput is null!");
111 
112     return session->RemoveInput(cameraInput);
113 }
114 
OH_CaptureSession_AddPreviewOutput(Camera_CaptureSession* session, Camera_PreviewOutput* previewOutput)115 Camera_ErrorCode OH_CaptureSession_AddPreviewOutput(Camera_CaptureSession* session,
116     Camera_PreviewOutput* previewOutput)
117 {
118     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
119     CHECK_AND_RETURN_RET_LOG(previewOutput != nullptr, CAMERA_INVALID_ARGUMENT,
120         "Invaild argument, previewOutput is null!");
121 
122     return session->AddPreviewOutput(previewOutput);
123 }
124 
OH_CaptureSession_RemovePreviewOutput(Camera_CaptureSession* session, Camera_PreviewOutput* previewOutput)125 Camera_ErrorCode OH_CaptureSession_RemovePreviewOutput(Camera_CaptureSession* session,
126     Camera_PreviewOutput* previewOutput)
127 {
128     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
129     CHECK_AND_RETURN_RET_LOG(previewOutput != nullptr, CAMERA_INVALID_ARGUMENT,
130         "Invaild argument, previewOutput is null!");
131 
132     return session->RemovePreviewOutput(previewOutput);
133 }
134 
OH_CaptureSession_AddPhotoOutput(Camera_CaptureSession* session, Camera_PhotoOutput* photoOutput)135 Camera_ErrorCode OH_CaptureSession_AddPhotoOutput(Camera_CaptureSession* session, Camera_PhotoOutput* photoOutput)
136 {
137     MEDIA_DEBUG_LOG("OH_CaptureSession_AddPhotoOutput is called");
138     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
139     CHECK_AND_RETURN_RET_LOG(photoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
140         "Invaild argument, photoOutput is null!");
141 
142     return session->AddPhotoOutput(photoOutput);
143 }
144 
OH_CaptureSession_RemovePhotoOutput(Camera_CaptureSession* session, Camera_PhotoOutput* photoOutput)145 Camera_ErrorCode OH_CaptureSession_RemovePhotoOutput(Camera_CaptureSession* session, Camera_PhotoOutput* photoOutput)
146 {
147     MEDIA_DEBUG_LOG("OH_CaptureSession_RemovePhotoOutput is called");
148     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
149     CHECK_AND_RETURN_RET_LOG(photoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
150         "Invaild argument, photoOutput is null!");
151 
152     return session->RemovePhotoOutput(photoOutput);
153 }
154 
OH_CaptureSession_AddMetadataOutput(Camera_CaptureSession* session, Camera_MetadataOutput* metadataOutput)155 Camera_ErrorCode OH_CaptureSession_AddMetadataOutput(Camera_CaptureSession* session,
156     Camera_MetadataOutput* metadataOutput)
157 {
158     MEDIA_DEBUG_LOG("OH_CaptureSession_AddMetadataOutput is called");
159     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
160     CHECK_AND_RETURN_RET_LOG(metadataOutput != nullptr, CAMERA_INVALID_ARGUMENT,
161         "Invaild argument, metadataOutput is null!");
162 
163     return session->AddMetaDataOutput(metadataOutput);
164 }
165 
OH_CaptureSession_RemoveMetadataOutput(Camera_CaptureSession* session, Camera_MetadataOutput* metadataOutput)166 Camera_ErrorCode OH_CaptureSession_RemoveMetadataOutput(Camera_CaptureSession* session,
167     Camera_MetadataOutput* metadataOutput)
168 {
169     MEDIA_DEBUG_LOG("OH_CaptureSession_RemoveMetadataOutput is called");
170     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
171     CHECK_AND_RETURN_RET_LOG(metadataOutput != nullptr, CAMERA_INVALID_ARGUMENT,
172         "Invaild argument, metadataOutput is null!");
173 
174     return session->RemoveMetaDataOutput(metadataOutput);
175 }
176 
OH_CaptureSession_IsVideoStabilizationModeSupported(Camera_CaptureSession* session, Camera_VideoStabilizationMode mode, bool* isSupported)177 Camera_ErrorCode OH_CaptureSession_IsVideoStabilizationModeSupported(Camera_CaptureSession* session,
178     Camera_VideoStabilizationMode mode, bool* isSupported)
179 {
180     MEDIA_DEBUG_LOG("OH_CaptureSession_IsVideoStabilizationModeSupported is called");
181     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
182     CHECK_AND_RETURN_RET_LOG(isSupported != nullptr, CAMERA_INVALID_ARGUMENT,
183         "Invaild argument, isSupported is null!");
184     CHECK_AND_RETURN_RET_LOG(mode == STABILIZATION_MODE_OFF ||
185         mode == STABILIZATION_MODE_LOW ||
186         mode == STABILIZATION_MODE_MIDDLE ||
187         mode == STABILIZATION_MODE_HIGH ||
188         mode == STABILIZATION_MODE_AUTO,
189         CAMERA_INVALID_ARGUMENT, "Invaild argument, mode is invaid!");
190 
191     return session->IsVideoStabilizationModeSupported(mode, isSupported);
192 }
193 
OH_CaptureSession_GetVideoStabilizationMode(Camera_CaptureSession* session, Camera_VideoStabilizationMode* mode)194 Camera_ErrorCode OH_CaptureSession_GetVideoStabilizationMode(Camera_CaptureSession* session,
195     Camera_VideoStabilizationMode* mode)
196 {
197     MEDIA_DEBUG_LOG("OH_CaptureSession_GetVideoStabilizationMode is called");
198     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
199     CHECK_AND_RETURN_RET_LOG(mode != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, mode is null!");
200 
201     return session->GetVideoStabilizationMode(mode);
202 }
203 
OH_CaptureSession_SetVideoStabilizationMode(Camera_CaptureSession* session, Camera_VideoStabilizationMode mode)204 Camera_ErrorCode OH_CaptureSession_SetVideoStabilizationMode(Camera_CaptureSession* session,
205     Camera_VideoStabilizationMode mode)
206 {
207     MEDIA_DEBUG_LOG("OH_CaptureSession_SetVideoStabilizationMode is called");
208     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
209     CHECK_AND_RETURN_RET_LOG(mode == STABILIZATION_MODE_OFF ||
210         mode == STABILIZATION_MODE_LOW ||
211         mode == STABILIZATION_MODE_MIDDLE ||
212         mode == STABILIZATION_MODE_HIGH ||
213         mode == STABILIZATION_MODE_AUTO,
214         CAMERA_INVALID_ARGUMENT, "Invaild argument, mode is invaid!");
215 
216     return session->SetVideoStabilizationMode(mode);
217 }
218 
OH_CaptureSession_GetZoomRatioRange(Camera_CaptureSession* session, float* minZoom, float* maxZoom)219 Camera_ErrorCode OH_CaptureSession_GetZoomRatioRange(Camera_CaptureSession* session, float* minZoom, float* maxZoom)
220 {
221     MEDIA_DEBUG_LOG("OH_CaptureSession_GetZoomRatioRange is called");
222     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
223     CHECK_AND_RETURN_RET_LOG(minZoom != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, minZoom is null!");
224     CHECK_AND_RETURN_RET_LOG(maxZoom != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, maxZoom is null!");
225 
226     return session->GetZoomRatioRange(minZoom, maxZoom);
227 }
228 
OH_CaptureSession_GetZoomRatio(Camera_CaptureSession* session, float* zoom)229 Camera_ErrorCode OH_CaptureSession_GetZoomRatio(Camera_CaptureSession* session, float* zoom)
230 {
231     MEDIA_DEBUG_LOG("OH_CaptureSession_GetZoomRatio is called");
232     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
233     CHECK_AND_RETURN_RET_LOG(zoom != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, zoom is null!");
234 
235     return session->GetZoomRatio(zoom);
236 }
237 
OH_CaptureSession_SetZoomRatio(Camera_CaptureSession* session, float zoom)238 Camera_ErrorCode OH_CaptureSession_SetZoomRatio(Camera_CaptureSession* session, float zoom)
239 {
240     MEDIA_DEBUG_LOG("OH_CaptureSession_SetZoomRatio is called");
241     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
242 
243     return session->SetZoomRatio(zoom);
244 }
245 
OH_CaptureSession_IsFocusModeSupported(Camera_CaptureSession* session, Camera_FocusMode focusMode, bool* isSupported)246 Camera_ErrorCode OH_CaptureSession_IsFocusModeSupported(Camera_CaptureSession* session,
247     Camera_FocusMode focusMode, bool* isSupported)
248 {
249     MEDIA_DEBUG_LOG("OH_CaptureSession_IsFocusModeSupported is called");
250     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
251     CHECK_AND_RETURN_RET_LOG(focusMode == FOCUS_MODE_MANUAL ||
252         focusMode == FOCUS_MODE_CONTINUOUS_AUTO ||
253         focusMode == FOCUS_MODE_AUTO ||
254         focusMode == FOCUS_MODE_LOCKED,
255         CAMERA_INVALID_ARGUMENT, "Invaild argument,focusMode is invaild!");
256     CHECK_AND_RETURN_RET_LOG(isSupported != nullptr, CAMERA_INVALID_ARGUMENT,
257         "Invaild argument, isSupported is null!");
258 
259     return session->IsFocusModeSupported(focusMode, isSupported);
260 }
261 
OH_CaptureSession_GetFocusMode(Camera_CaptureSession* session, Camera_FocusMode* focusMode)262 Camera_ErrorCode OH_CaptureSession_GetFocusMode(Camera_CaptureSession* session, Camera_FocusMode* focusMode)
263 {
264     MEDIA_DEBUG_LOG("OH_CaptureSession_GetFocusMode is called");
265     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
266     CHECK_AND_RETURN_RET_LOG(focusMode != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, focusMode is null!");
267 
268     return session->GetFocusMode(focusMode);
269 }
270 
OH_CaptureSession_SetFocusMode(Camera_CaptureSession* session, Camera_FocusMode focusMode)271 Camera_ErrorCode OH_CaptureSession_SetFocusMode(Camera_CaptureSession* session, Camera_FocusMode focusMode)
272 {
273     MEDIA_DEBUG_LOG("OH_CaptureSession_SetFocusMode is called");
274     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
275     CHECK_AND_RETURN_RET_LOG(focusMode == FOCUS_MODE_MANUAL ||
276         focusMode == FOCUS_MODE_CONTINUOUS_AUTO ||
277         focusMode == FOCUS_MODE_AUTO ||
278         focusMode == FOCUS_MODE_LOCKED,
279         CAMERA_INVALID_ARGUMENT, "Invaild argument,focusMode is invaild!");
280 
281     return session->SetFocusMode(focusMode);
282 }
283 
OH_CaptureSession_SetFocusPoint(Camera_CaptureSession* session, Camera_Point focusPoint)284 Camera_ErrorCode OH_CaptureSession_SetFocusPoint(Camera_CaptureSession* session, Camera_Point focusPoint)
285 {
286     MEDIA_DEBUG_LOG("OH_CaptureSession_SetFocusPoint is called");
287     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
288 
289     return session->SetFocusPoint(focusPoint);
290 }
291 
OH_CaptureSession_GetFocusPoint(Camera_CaptureSession* session, Camera_Point* focusPoint)292 Camera_ErrorCode OH_CaptureSession_GetFocusPoint(Camera_CaptureSession* session, Camera_Point* focusPoint)
293 {
294     MEDIA_DEBUG_LOG("OH_CaptureSession_GetFocusPoint is called");
295     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
296     CHECK_AND_RETURN_RET_LOG(focusPoint != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, focusPoint is null!");
297 
298     return session->GetFocusPoint(focusPoint);
299 }
300 
OH_CaptureSession_AddVideoOutput(Camera_CaptureSession* session, Camera_VideoOutput* videoOutput)301 Camera_ErrorCode OH_CaptureSession_AddVideoOutput(Camera_CaptureSession* session, Camera_VideoOutput* videoOutput)
302 {
303     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
304     CHECK_AND_RETURN_RET_LOG(videoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
305         "Invaild argument, videoOutput is null!");
306 
307     return session->AddVideoOutput(videoOutput);
308 }
309 
OH_CaptureSession_RemoveVideoOutput(Camera_CaptureSession* session, Camera_VideoOutput* videoOutput)310 Camera_ErrorCode OH_CaptureSession_RemoveVideoOutput(Camera_CaptureSession* session, Camera_VideoOutput* videoOutput)
311 {
312     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
313     CHECK_AND_RETURN_RET_LOG(videoOutput != nullptr, CAMERA_INVALID_ARGUMENT,
314         "Invaild argument, videoOutput is null!");
315 
316     return session->RemoveVideoOutput(videoOutput);
317 }
318 
OH_CaptureSession_Start(Camera_CaptureSession* session)319 Camera_ErrorCode OH_CaptureSession_Start(Camera_CaptureSession* session)
320 {
321     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
322 
323     return session->Start();
324 }
325 
OH_CaptureSession_Stop(Camera_CaptureSession* session)326 Camera_ErrorCode OH_CaptureSession_Stop(Camera_CaptureSession* session)
327 {
328     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
329 
330     return session->Stop();
331 }
332 
OH_CaptureSession_Release(Camera_CaptureSession* session)333 Camera_ErrorCode OH_CaptureSession_Release(Camera_CaptureSession* session)
334 {
335     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
336 
337     Camera_ErrorCode retCode = session->Release();
338     if (session != nullptr) {
339         delete session;
340     }
341     return retCode;
342 }
343 
OH_CaptureSession_HasFlash(Camera_CaptureSession* session, bool* hasFlash)344 Camera_ErrorCode OH_CaptureSession_HasFlash(Camera_CaptureSession* session, bool* hasFlash)
345 {
346     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
347     CHECK_AND_RETURN_RET_LOG(hasFlash != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, hasFlash is null!");
348 
349     return session->HasFlash(hasFlash);
350 }
351 
OH_CaptureSession_IsFlashModeSupported(Camera_CaptureSession* session, Camera_FlashMode flashMode, bool* isSupported)352 Camera_ErrorCode OH_CaptureSession_IsFlashModeSupported(Camera_CaptureSession* session,
353     Camera_FlashMode flashMode, bool* isSupported)
354 {
355     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
356     CHECK_AND_RETURN_RET_LOG(isSupported != nullptr, CAMERA_INVALID_ARGUMENT,
357         "Invaild argument, isSupported is null!");
358 
359     return session->IsFlashModeSupported(flashMode, isSupported);
360 }
361 
OH_CaptureSession_GetFlashMode(Camera_CaptureSession* session, Camera_FlashMode* flashMode)362 Camera_ErrorCode OH_CaptureSession_GetFlashMode(Camera_CaptureSession* session, Camera_FlashMode* flashMode)
363 {
364     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
365     CHECK_AND_RETURN_RET_LOG(flashMode != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, flashMode is null!");
366 
367     return session->GetFlashMode(flashMode);
368 }
369 
OH_CaptureSession_SetFlashMode(Camera_CaptureSession* session, Camera_FlashMode flashMode)370 Camera_ErrorCode OH_CaptureSession_SetFlashMode(Camera_CaptureSession* session, Camera_FlashMode flashMode)
371 {
372     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
373     CHECK_AND_RETURN_RET_LOG(flashMode == FLASH_MODE_CLOSE ||
374         flashMode == FLASH_MODE_OPEN ||
375         flashMode == FLASH_MODE_AUTO ||
376         flashMode == FLASH_MODE_ALWAYS_OPEN,
377         CAMERA_INVALID_ARGUMENT, "Invaild argument,flashMode is invaild!");
378     return session->SetFlashMode(flashMode);
379 }
380 
OH_CaptureSession_IsExposureModeSupported(Camera_CaptureSession* session, Camera_ExposureMode exposureMode, bool* isSupported)381 Camera_ErrorCode OH_CaptureSession_IsExposureModeSupported(Camera_CaptureSession* session,
382     Camera_ExposureMode exposureMode, bool* isSupported)
383 {
384     MEDIA_DEBUG_LOG("OH_CaptureSession_IsExposureModeSupported is called");
385     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
386     CHECK_AND_RETURN_RET_LOG(isSupported != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, isSupported is null!");
387     CHECK_AND_RETURN_RET_LOG(exposureMode == EXPOSURE_MODE_LOCKED ||
388         exposureMode == EXPOSURE_MODE_AUTO ||
389         exposureMode == EXPOSURE_MODE_CONTINUOUS_AUTO,
390         CAMERA_INVALID_ARGUMENT, "Invaild argument,exposureMode is invaild!");
391     return session->IsExposureModeSupported(exposureMode, isSupported);
392 }
393 
OH_CaptureSession_GetExposureMode(Camera_CaptureSession* session, Camera_ExposureMode* exposureMode)394 Camera_ErrorCode OH_CaptureSession_GetExposureMode(Camera_CaptureSession* session, Camera_ExposureMode* exposureMode)
395 {
396     MEDIA_DEBUG_LOG("OH_CaptureSession_GetExposureMode is called");
397     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
398     CHECK_AND_RETURN_RET_LOG(exposureMode != nullptr, CAMERA_INVALID_ARGUMENT,
399         "Invaild argument, exposureMode is null!");
400     return session->GetExposureMode(exposureMode);
401 }
402 
OH_CaptureSession_SetExposureMode(Camera_CaptureSession* session, Camera_ExposureMode exposureMode)403 Camera_ErrorCode OH_CaptureSession_SetExposureMode(Camera_CaptureSession* session, Camera_ExposureMode exposureMode)
404 {
405     MEDIA_DEBUG_LOG("OH_CaptureSession_SetExposureMode is called");
406     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
407     CHECK_AND_RETURN_RET_LOG(exposureMode == EXPOSURE_MODE_LOCKED ||
408         exposureMode == EXPOSURE_MODE_AUTO ||
409         exposureMode == EXPOSURE_MODE_CONTINUOUS_AUTO,
410         CAMERA_INVALID_ARGUMENT, "Invaild argument,exposureMode is invaild!");
411 
412     return session->SetExposureMode(exposureMode);
413 }
414 
OH_CaptureSession_GetMeteringPoint(Camera_CaptureSession* session, Camera_Point* point)415 Camera_ErrorCode OH_CaptureSession_GetMeteringPoint(Camera_CaptureSession* session, Camera_Point* point)
416 {
417     MEDIA_DEBUG_LOG("OH_CaptureSession_GetMeteringPoint is called");
418     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
419     CHECK_AND_RETURN_RET_LOG(point != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, point is null!");
420     return session->GetMeteringPoint(point);
421 }
422 
OH_CaptureSession_SetMeteringPoint(Camera_CaptureSession* session, Camera_Point point)423 Camera_ErrorCode OH_CaptureSession_SetMeteringPoint(Camera_CaptureSession* session, Camera_Point point)
424 {
425     MEDIA_DEBUG_LOG("OH_CaptureSession_SetMeteringPoint is called");
426     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
427     CHECK_AND_RETURN_RET_LOG(point.x >= 0 && point.y >= 0,
428         CAMERA_INVALID_ARGUMENT, "Invaild argument, point is invaild!");
429 
430     return session->SetMeteringPoint(point);
431 }
432 
OH_CaptureSession_GetExposureBiasRange(Camera_CaptureSession* session, float* minExposureBias, float* maxExposureBias, float* step)433 Camera_ErrorCode OH_CaptureSession_GetExposureBiasRange(Camera_CaptureSession* session,
434     float* minExposureBias, float* maxExposureBias, float* step)
435 {
436     MEDIA_DEBUG_LOG("OH_CaptureSession_GetExposureBiasRange is called");
437     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
438     CHECK_AND_RETURN_RET_LOG(minExposureBias != nullptr, CAMERA_INVALID_ARGUMENT,
439         "Invaild argument, minExposureBias is null!");
440     CHECK_AND_RETURN_RET_LOG(maxExposureBias != nullptr, CAMERA_INVALID_ARGUMENT,
441         "Invaild argument, maxExposureBias is null!");
442     CHECK_AND_RETURN_RET_LOG(step != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, step is null!");
443     return session->GetExposureBiasRange(minExposureBias, maxExposureBias, step);
444 }
445 
OH_CaptureSession_SetExposureBias(Camera_CaptureSession* session, float exposureBias)446 Camera_ErrorCode OH_CaptureSession_SetExposureBias(Camera_CaptureSession* session, float exposureBias)
447 {
448     MEDIA_DEBUG_LOG("OH_CaptureSession_SetExposureBias is called");
449     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
450     return session->SetExposureBias(exposureBias);
451 }
OH_CaptureSession_GetExposureBias(Camera_CaptureSession* session, float* exposureBias)452 Camera_ErrorCode OH_CaptureSession_GetExposureBias(Camera_CaptureSession* session, float* exposureBias)
453 {
454     MEDIA_DEBUG_LOG("OH_CaptureSession_GetExposureBias is called");
455     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
456     CHECK_AND_RETURN_RET_LOG(exposureBias != nullptr, CAMERA_INVALID_ARGUMENT,
457         "Invaild argument, exposureBias is null!");
458     return session->GetExposureBias(exposureBias);
459 }
460 
OH_CaptureSession_CanAddInput(Camera_CaptureSession* session, Camera_Input* cameraInput, bool* isSuccessful)461 Camera_ErrorCode OH_CaptureSession_CanAddInput(Camera_CaptureSession* session,
462     Camera_Input* cameraInput, bool* isSuccessful)
463 {
464     MEDIA_DEBUG_LOG("OH_CaptureSession_CanAddInput is called");
465     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
466         "Invaild argument, session is null!");
467     CHECK_AND_RETURN_RET_LOG(cameraInput != nullptr, CAMERA_INVALID_ARGUMENT,
468         "Invaild argument, cameraInput is null!");
469     CHECK_AND_RETURN_RET_LOG(isSuccessful != nullptr, CAMERA_INVALID_ARGUMENT,
470         "Invaild argument, isSuccessful is null!");
471 
472     return session->CanAddInput(cameraInput, isSuccessful);
473 }
474 
OH_CaptureSession_CanAddPreviewOutput(Camera_CaptureSession* session, Camera_PreviewOutput* cameraOutput, bool* isSuccessful)475 Camera_ErrorCode OH_CaptureSession_CanAddPreviewOutput(Camera_CaptureSession* session,
476     Camera_PreviewOutput* cameraOutput, bool* isSuccessful)
477 {
478     MEDIA_DEBUG_LOG("OH_CaptureSession_CanAddPreviewOutput is called");
479     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
480         "Invaild argument, session is null!");
481     CHECK_AND_RETURN_RET_LOG(cameraOutput != nullptr, CAMERA_INVALID_ARGUMENT,
482         "Invaild argument, cameraOutput is null!");
483     CHECK_AND_RETURN_RET_LOG(isSuccessful != nullptr, CAMERA_INVALID_ARGUMENT,
484         "Invaild argument, isSuccessful is null!");
485 
486     return session->CanAddPreviewOutput(cameraOutput, isSuccessful);
487 }
488 
OH_CaptureSession_CanAddPhotoOutput(Camera_CaptureSession* session, Camera_PhotoOutput* cameraOutput, bool* isSuccessful)489 Camera_ErrorCode OH_CaptureSession_CanAddPhotoOutput(Camera_CaptureSession* session,
490     Camera_PhotoOutput* cameraOutput, bool* isSuccessful)
491 {
492     MEDIA_DEBUG_LOG("OH_CaptureSession_CanAddPhotoOutput is called");
493     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
494         "Invaild argument, session is null!");
495     CHECK_AND_RETURN_RET_LOG(cameraOutput != nullptr, CAMERA_INVALID_ARGUMENT,
496         "Invaild argument, cameraOutput is null!");
497     CHECK_AND_RETURN_RET_LOG(isSuccessful != nullptr, CAMERA_INVALID_ARGUMENT,
498         "Invaild argument, isSuccessful is null!");
499 
500     return session->CanAddPhotoOutput(cameraOutput, isSuccessful);
501 }
502 
OH_CaptureSession_CanAddVideoOutput(Camera_CaptureSession* session, Camera_VideoOutput* cameraOutput, bool* isSuccessful)503 Camera_ErrorCode OH_CaptureSession_CanAddVideoOutput(Camera_CaptureSession* session,
504     Camera_VideoOutput* cameraOutput, bool* isSuccessful)
505 {
506     MEDIA_DEBUG_LOG("OH_CaptureSession_CanAddVideoOutput is called");
507     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
508         "Invaild argument, session is null!");
509     CHECK_AND_RETURN_RET_LOG(cameraOutput != nullptr, CAMERA_INVALID_ARGUMENT,
510         "Invaild argument, cameraOutput is null!");
511     CHECK_AND_RETURN_RET_LOG(isSuccessful != nullptr, CAMERA_INVALID_ARGUMENT,
512         "Invaild argument, isSuccessful is null!");
513 
514     return session->CanAddVideoOutput(cameraOutput, isSuccessful);
515 }
516 
OH_CaptureSession_CanPreconfig(Camera_CaptureSession* session, Camera_PreconfigType preconfigType, bool* canPreconfig)517 Camera_ErrorCode OH_CaptureSession_CanPreconfig(Camera_CaptureSession* session,
518     Camera_PreconfigType preconfigType, bool* canPreconfig)
519 {
520     MEDIA_DEBUG_LOG("OH_CaptureSession_CanPreconfig is called.");
521     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
522         "Invaild argument, session is null!");
523     CHECK_AND_RETURN_RET_LOG(canPreconfig != nullptr, CAMERA_INVALID_ARGUMENT,
524         "Invaild argument, canPreconfig is null!");
525 
526     return session->CanPreconfig(preconfigType, canPreconfig);
527 }
528 
OH_CaptureSession_CanPreconfigWithRatio(Camera_CaptureSession* session, Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio, bool* canPreconfig)529 Camera_ErrorCode OH_CaptureSession_CanPreconfigWithRatio(Camera_CaptureSession* session,
530     Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio, bool* canPreconfig)
531 {
532     MEDIA_DEBUG_LOG("OH_CaptureSession_CanPreconfigWithRatio is called.");
533     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
534         "Invaild argument, session is null!");
535     CHECK_AND_RETURN_RET_LOG(canPreconfig != nullptr, CAMERA_INVALID_ARGUMENT,
536         "Invaild argument, canPreconfig is null!");
537 
538     return session->CanPreconfigWithRatio(preconfigType, preconfigRatio, canPreconfig);
539 }
540 
OH_CaptureSession_Preconfig(Camera_CaptureSession* session, Camera_PreconfigType preconfigType)541 Camera_ErrorCode OH_CaptureSession_Preconfig(Camera_CaptureSession* session, Camera_PreconfigType preconfigType)
542 {
543     MEDIA_DEBUG_LOG("OH_CaptureSession_Preconfig is called.");
544     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
545         "Invaild argument, session is null!");
546 
547     return session->Preconfig(preconfigType);
548 }
549 
OH_CaptureSession_PreconfigWithRatio(Camera_CaptureSession* session, Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio)550 Camera_ErrorCode OH_CaptureSession_PreconfigWithRatio(Camera_CaptureSession* session,
551     Camera_PreconfigType preconfigType, Camera_PreconfigRatio preconfigRatio)
552 {
553     MEDIA_DEBUG_LOG("OH_CaptureSession_PreconfigWithRatio is called.");
554     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
555         "Invaild argument, session is null!");
556 
557     return session->PreconfigWithRatio(preconfigType, preconfigRatio);
558 }
559 
560 /**
561  * @since 12
562  * @version 1.0
563  */
OH_CaptureSession_GetExposureValue(Camera_CaptureSession* session, float* exposureValue)564 Camera_ErrorCode OH_CaptureSession_GetExposureValue(Camera_CaptureSession* session, float* exposureValue)
565 {
566     MEDIA_DEBUG_LOG("OH_CaptureSession_GetExposureValue is called");
567     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
568         "Invaild argument, session is null!");
569     CHECK_AND_RETURN_RET_LOG(exposureValue != nullptr, CAMERA_INVALID_ARGUMENT,
570         "Invaild argument, exposureValue is null!");
571 
572     return session->GetExposureValue(exposureValue);
573 }
574 
575 /**
576  * @since 12
577  * @version 1.0
578  */
OH_CaptureSession_GetFocalLength(Camera_CaptureSession* session, float* focalLength)579 Camera_ErrorCode OH_CaptureSession_GetFocalLength(Camera_CaptureSession* session, float* focalLength)
580 {
581     MEDIA_DEBUG_LOG("OH_CaptureSession_GetFocalLength is called");
582     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
583         "Invaild argument, session is null!");
584     CHECK_AND_RETURN_RET_LOG(focalLength != nullptr, CAMERA_INVALID_ARGUMENT,
585         "Invaild argument, focalLength is null!");
586 
587     return session->GetFocalLength(focalLength);
588 }
589 
590 /**
591  * @since 12
592  * @version 1.0
593  */
OH_CaptureSession_SetSmoothZoom(Camera_CaptureSession *session, float targetZoom, Camera_SmoothZoomMode smoothZoomMode)594 Camera_ErrorCode OH_CaptureSession_SetSmoothZoom(Camera_CaptureSession *session, float targetZoom,
595     Camera_SmoothZoomMode smoothZoomMode)
596 {
597     MEDIA_DEBUG_LOG("OH_CaptureSession_SetSmoothZoom is called");
598     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
599         "Invaild argument, session is null!");
600 
601     return session->SetSmoothZoom(targetZoom, smoothZoomMode);
602 }
603 
604 /**
605  * @since 12
606  * @version 1.0
607  */
OH_CaptureSession_GetSupportedColorSpaces(Camera_CaptureSession* session, OH_NativeBuffer_ColorSpace** colorSpace, uint32_t* size)608 Camera_ErrorCode OH_CaptureSession_GetSupportedColorSpaces(Camera_CaptureSession* session,
609     OH_NativeBuffer_ColorSpace** colorSpace, uint32_t* size)
610 {
611     MEDIA_DEBUG_LOG("OH_CaptureSession_GetSupportedColorSpaces is called");
612     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
613         "Invaild argument, session is null!");
614     CHECK_AND_RETURN_RET_LOG(colorSpace != nullptr, CAMERA_INVALID_ARGUMENT,
615         "Invaild argument, colorSpace is null!");
616     CHECK_AND_RETURN_RET_LOG(size != nullptr, CAMERA_INVALID_ARGUMENT,
617         "Invaild argument, size is null!");
618 
619     return session->GetSupportedColorSpaces(colorSpace, size);
620 }
621 
622 /**
623  * @since 12
624  * @version 1.0
625  */
OH_CaptureSession_DeleteColorSpaces(Camera_CaptureSession* session, OH_NativeBuffer_ColorSpace* colorSpace)626 Camera_ErrorCode OH_CaptureSession_DeleteColorSpaces(Camera_CaptureSession* session,
627     OH_NativeBuffer_ColorSpace* colorSpace)
628 {
629     MEDIA_DEBUG_LOG("OH_CaptureSession_DeleteSupportedColorSpaces is called");
630     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
631         "Invaild argument, session is null!");
632     CHECK_AND_RETURN_RET_LOG(colorSpace != nullptr, CAMERA_INVALID_ARGUMENT,
633         "Invaild argument, colorSpace is null!");
634 
635     return session->DeleteColorSpaces(colorSpace);
636 }
637 
638 /**
639  * @since 12
640  * @version 1.0
641  */
OH_CaptureSession_GetActiveColorSpace(Camera_CaptureSession* session, OH_NativeBuffer_ColorSpace* colorSpace)642 Camera_ErrorCode OH_CaptureSession_GetActiveColorSpace(Camera_CaptureSession* session,
643     OH_NativeBuffer_ColorSpace* colorSpace)
644 {
645     MEDIA_DEBUG_LOG("OH_CaptureSession_GetActiveColorSpace is called");
646     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
647         "Invaild argument, session is null!");
648     CHECK_AND_RETURN_RET_LOG(colorSpace != nullptr, CAMERA_INVALID_ARGUMENT,
649         "Invaild argument, colorSpace is null!");
650 
651     return session->GetActiveColorSpace(colorSpace);
652 }
653 
654 /**
655  * @since 12
656  * @version 1.0
657  */
OH_CaptureSession_SetActiveColorSpace(Camera_CaptureSession* session, OH_NativeBuffer_ColorSpace colorSpace)658 Camera_ErrorCode OH_CaptureSession_SetActiveColorSpace(Camera_CaptureSession* session,
659     OH_NativeBuffer_ColorSpace colorSpace)
660 {
661     MEDIA_DEBUG_LOG("OH_CaptureSession_SetActiveColorSpace is called");
662     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
663         "Invaild argument, session is null!");
664 
665     return session->SetActiveColorSpace(colorSpace);
666 }
667 
668 /**
669  * @since 13
670  * @version 1.0
671  */
OH_CaptureSession_RegisterAutoDeviceSwitchStatusCallback(Camera_CaptureSession* session, OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)672 Camera_ErrorCode OH_CaptureSession_RegisterAutoDeviceSwitchStatusCallback(Camera_CaptureSession* session,
673     OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)
674 {
675     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
676     CHECK_AND_RETURN_RET_LOG(autoDeviceSwitchStatusChange != nullptr, CAMERA_INVALID_ARGUMENT,
677         "Invaild argument, callback is null!");
678     session->RegisterAutoDeviceSwitchStatusCallback(autoDeviceSwitchStatusChange);
679     return CAMERA_OK;
680 }
681 
682 /**
683  * @since 13
684  * @version 1.0
685  */
OH_CaptureSession_UnregisterAutoDeviceSwitchStatusCallback(Camera_CaptureSession* session, OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)686 Camera_ErrorCode OH_CaptureSession_UnregisterAutoDeviceSwitchStatusCallback(Camera_CaptureSession* session,
687     OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)
688 {
689     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT, "Invaild argument, session is null!");
690     CHECK_AND_RETURN_RET_LOG(autoDeviceSwitchStatusChange != nullptr, CAMERA_INVALID_ARGUMENT,
691         "Invaild argument, callback is null!");
692     session->UnregisterAutoDeviceSwitchStatusCallback(autoDeviceSwitchStatusChange);
693     return CAMERA_OK;
694 }
695 
696 /**
697  * @since 13
698  * @version 1.0
699  */
OH_CaptureSession_IsAutoDeviceSwitchSupported(Camera_CaptureSession* session, bool* isSupported)700 Camera_ErrorCode OH_CaptureSession_IsAutoDeviceSwitchSupported(Camera_CaptureSession* session, bool* isSupported)
701 {
702     MEDIA_DEBUG_LOG("OH_CaptureSession_IsAutoDeviceSwitchSupported is called");
703     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
704         "Invaild argument, session is null!");
705     return session->IsAutoDeviceSwitchSupported(isSupported);
706 }
707 
708 /**
709  * @since 13
710  * @version 1.0
711  */
OH_CaptureSession_EnableAutoDeviceSwitch(Camera_CaptureSession* session, bool enabled)712 Camera_ErrorCode OH_CaptureSession_EnableAutoDeviceSwitch(Camera_CaptureSession* session, bool enabled)
713 {
714     MEDIA_DEBUG_LOG("OH_CaptureSession_EnableAutoDeviceSwitch is called");
715     CHECK_AND_RETURN_RET_LOG(session != nullptr, CAMERA_INVALID_ARGUMENT,
716         "Invaild argument, session is null!");
717     return session->EnableAutoDeviceSwitch(enabled);
718 }
719 #ifdef __cplusplus
720 }
721 #endif