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 "capture_session_impl.h"
17 #include "camera_log.h"
18 #include "camera_util.h"
19 #include "capture_scene_const.h"
20
21 using namespace std;
22 using namespace OHOS;
23 using namespace OHOS::CameraStandard;
24
25 const std::unordered_map<Camera_SceneMode, SceneMode> g_ndkToFwMode_ = {
26 {Camera_SceneMode::NORMAL_PHOTO, SceneMode::CAPTURE},
27 {Camera_SceneMode::NORMAL_VIDEO, SceneMode::VIDEO},
28 {Camera_SceneMode::SECURE_PHOTO, SceneMode::SECURE},
29 };
30 const std::unordered_map<Camera_PreconfigType, PreconfigType> g_ndkToFwPreconfig = {
31 {Camera_PreconfigType::PRECONFIG_720P, PreconfigType::PRECONFIG_720P},
32 {Camera_PreconfigType::PRECONFIG_1080P, PreconfigType::PRECONFIG_1080P},
33 {Camera_PreconfigType::PRECONFIG_4K, PreconfigType::PRECONFIG_4K},
34 {Camera_PreconfigType::PRECONFIG_HIGH_QUALITY, PreconfigType::PRECONFIG_HIGH_QUALITY}
35 };
36 const std::unordered_map<Camera_PreconfigRatio, ProfileSizeRatio> g_ndkToFwPreconfigRatio = {
37 {Camera_PreconfigRatio::PRECONFIG_RATIO_1_1, ProfileSizeRatio::RATIO_1_1},
38 {Camera_PreconfigRatio::PRECONFIG_RATIO_4_3, ProfileSizeRatio::RATIO_4_3},
39 {Camera_PreconfigRatio::PRECONFIG_RATIO_16_9, ProfileSizeRatio::RATIO_16_9}
40 };
41 const std::unordered_map<ColorSpace, OH_NativeBuffer_ColorSpace> g_fwToNdkColorSpace_ = {
42 {ColorSpace::COLOR_SPACE_UNKNOWN, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_NONE},
43 {ColorSpace::DISPLAY_P3, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_FULL},
44 {ColorSpace::SRGB, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_SRGB_FULL},
45 {ColorSpace::BT709, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT709_FULL},
46 {ColorSpace::BT2020_HLG, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT2020_HLG_FULL},
47 {ColorSpace::BT2020_PQ, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT2020_PQ_FULL},
48 {ColorSpace::P3_HLG, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_HLG_FULL},
49 {ColorSpace::P3_PQ, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_PQ_FULL},
50 {ColorSpace::DISPLAY_P3_LIMIT, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_LIMIT},
51 {ColorSpace::SRGB_LIMIT, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_SRGB_LIMIT},
52 {ColorSpace::BT709_LIMIT, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT709_LIMIT},
53 {ColorSpace::BT2020_HLG_LIMIT, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT2020_HLG_LIMIT},
54 {ColorSpace::BT2020_PQ_LIMIT, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT2020_PQ_LIMIT},
55 {ColorSpace::P3_HLG_LIMIT, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_HLG_LIMIT},
56 {ColorSpace::P3_PQ_LIMIT, OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_PQ_LIMIT}
57 };
58 const std::unordered_map<OH_NativeBuffer_ColorSpace, ColorSpace> g_ndkToFwColorSpace_ = {
59 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_NONE, ColorSpace::COLOR_SPACE_UNKNOWN},
60 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_FULL, ColorSpace::DISPLAY_P3},
61 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_SRGB_FULL, ColorSpace::SRGB},
62 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT709_FULL, ColorSpace::BT709},
63 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT2020_HLG_FULL, ColorSpace::BT2020_HLG},
64 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT2020_PQ_FULL, ColorSpace::BT2020_PQ},
65 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_HLG_FULL, ColorSpace::P3_HLG},
66 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_PQ_FULL, ColorSpace::P3_PQ},
67 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_LIMIT, ColorSpace::DISPLAY_P3_LIMIT},
68 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_SRGB_LIMIT, ColorSpace::SRGB_LIMIT},
69 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT709_LIMIT, ColorSpace::BT709_LIMIT},
70 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT2020_HLG_LIMIT, ColorSpace::BT2020_HLG_LIMIT},
71 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_BT2020_PQ_LIMIT, ColorSpace::BT2020_PQ_LIMIT},
72 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_HLG_LIMIT, ColorSpace::P3_HLG_LIMIT},
73 {OH_NativeBuffer_ColorSpace::OH_COLORSPACE_P3_PQ_LIMIT, ColorSpace::P3_PQ_LIMIT}
74 };
75
76 class InnerCaptureSessionCallback : public SessionCallback, public FocusCallback {
77 public:
InnerCaptureSessionCallback(Camera_CaptureSession * captureSession,CaptureSession_Callbacks * callback)78 InnerCaptureSessionCallback(Camera_CaptureSession* captureSession, CaptureSession_Callbacks* callback)
79 : captureSession_(captureSession), callback_(*callback) {}
80 ~InnerCaptureSessionCallback() = default;
81
OnFocusState(FocusState state)82 void OnFocusState(FocusState state) override
83 {
84 MEDIA_DEBUG_LOG("OnFrameStarted is called!");
85 if (captureSession_ != nullptr && callback_.onFocusStateChange != nullptr) {
86 callback_.onFocusStateChange(captureSession_, static_cast<Camera_FocusState>(state));
87 }
88 }
89
OnError(const int32_t errorCode)90 void OnError(const int32_t errorCode) override
91 {
92 MEDIA_DEBUG_LOG("OnError is called!, errorCode: %{public}d", errorCode);
93 if (captureSession_ != nullptr && callback_.onError != nullptr) {
94 callback_.onError(captureSession_, FrameworkToNdkCameraError(errorCode));
95 }
96 }
97
98 private:
99 Camera_CaptureSession* captureSession_;
100 CaptureSession_Callbacks callback_;
101 };
102
103 class InnerCaptureSessionSmoothZoomInfoCallback : public SmoothZoomCallback {
104 public:
InnerCaptureSessionSmoothZoomInfoCallback(Camera_CaptureSession * captureSession,OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)105 InnerCaptureSessionSmoothZoomInfoCallback(Camera_CaptureSession* captureSession,
106 OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)
107 : captureSession_(captureSession), smoothZoomInfoCallback_(smoothZoomInfoCallback) {};
108 ~InnerCaptureSessionSmoothZoomInfoCallback() = default;
109
OnSmoothZoom(int32_t duration)110 void OnSmoothZoom(int32_t duration) override
111 {
112 MEDIA_DEBUG_LOG("OnSmoothZoom is called!");
113 if (captureSession_ != nullptr && smoothZoomInfoCallback_ != nullptr) {
114 Camera_SmoothZoomInfo info;
115 info.duration = duration;
116 smoothZoomInfoCallback_(captureSession_, &info);
117 }
118 }
119
120 private:
121 Camera_CaptureSession* captureSession_;
122 OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback_ = nullptr;
123 };
124
125 class InnerCaptureSessionAutoDeviceSwitchStatusCallback : public AutoDeviceSwitchCallback {
126 public:
InnerCaptureSessionAutoDeviceSwitchStatusCallback(Camera_CaptureSession * captureSession,OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusCallback)127 InnerCaptureSessionAutoDeviceSwitchStatusCallback(Camera_CaptureSession* captureSession,
128 OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusCallback)
129 : captureSession_(captureSession), autoDeviceSwitchStatusCallback_(autoDeviceSwitchStatusCallback) {};
130 ~InnerCaptureSessionAutoDeviceSwitchStatusCallback() = default;
131
OnAutoDeviceSwitchStatusChange(bool isDeviceSwitched,bool isDeviceCapabilityChanged) const132 void OnAutoDeviceSwitchStatusChange(bool isDeviceSwitched, bool isDeviceCapabilityChanged) const override
133 {
134 MEDIA_DEBUG_LOG("OnAutoDeviceSwitchStatusChange is called!");
135 if (captureSession_ != nullptr && autoDeviceSwitchStatusCallback_ != nullptr) {
136 Camera_AutoDeviceSwitchStatusInfo info;
137 info.isDeviceSwitched = isDeviceSwitched;
138 info.isDeviceCapabilityChanged = isDeviceCapabilityChanged;
139 autoDeviceSwitchStatusCallback_(captureSession_, &info);
140 }
141 }
142
143 private:
144 Camera_CaptureSession* captureSession_;
145 OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusCallback_ = nullptr;
146 };
147
Camera_CaptureSession(sptr<CaptureSession> & innerCaptureSession)148 Camera_CaptureSession::Camera_CaptureSession(sptr<CaptureSession> &innerCaptureSession)
149 : innerCaptureSession_(innerCaptureSession)
150 {
151 MEDIA_DEBUG_LOG("Camera_CaptureSession Constructor is called");
152 }
153
~Camera_CaptureSession()154 Camera_CaptureSession::~Camera_CaptureSession()
155 {
156 MEDIA_DEBUG_LOG("~Camera_CaptureSession is called");
157 if (innerCaptureSession_) {
158 innerCaptureSession_ = nullptr;
159 }
160 }
161
RegisterCallback(CaptureSession_Callbacks * callback)162 Camera_ErrorCode Camera_CaptureSession::RegisterCallback(CaptureSession_Callbacks* callback)
163 {
164 shared_ptr<InnerCaptureSessionCallback> innerCallback =
165 make_shared<InnerCaptureSessionCallback>(this, callback);
166 CHECK_AND_RETURN_RET_LOG(innerCallback != nullptr, CAMERA_SERVICE_FATAL_ERROR,
167 "create innerCallback failed!");
168 if (callback->onError != nullptr) {
169 innerCaptureSession_->SetCallback(innerCallback);
170 }
171 if (callback->onFocusStateChange != nullptr) {
172 innerCaptureSession_->SetFocusCallback(innerCallback);
173 }
174 return CAMERA_OK;
175 }
176
UnregisterCallback(CaptureSession_Callbacks * callback)177 Camera_ErrorCode Camera_CaptureSession::UnregisterCallback(CaptureSession_Callbacks* callback)
178 {
179 if (callback->onError != nullptr) {
180 innerCaptureSession_->SetCallback(nullptr);
181 }
182 if (callback->onFocusStateChange != nullptr) {
183 innerCaptureSession_->SetFocusCallback(nullptr);
184 }
185 return CAMERA_OK;
186 }
187
RegisterSmoothZoomInfoCallback(OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)188 Camera_ErrorCode Camera_CaptureSession::RegisterSmoothZoomInfoCallback(
189 OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)
190 {
191 shared_ptr<InnerCaptureSessionSmoothZoomInfoCallback> innerSmoothZoomInfoCallback =
192 make_shared<InnerCaptureSessionSmoothZoomInfoCallback>(this, smoothZoomInfoCallback);
193 CHECK_AND_RETURN_RET_LOG(innerSmoothZoomInfoCallback != nullptr, CAMERA_SERVICE_FATAL_ERROR,
194 "create innerCallback failed!");
195 innerCaptureSession_->SetSmoothZoomCallback(innerSmoothZoomInfoCallback);
196 return CAMERA_OK;
197 }
198
UnregisterSmoothZoomInfoCallback(OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)199 Camera_ErrorCode Camera_CaptureSession::UnregisterSmoothZoomInfoCallback(
200 OH_CaptureSession_OnSmoothZoomInfo smoothZoomInfoCallback)
201 {
202 innerCaptureSession_->SetSmoothZoomCallback(nullptr);
203 return CAMERA_OK;
204 }
205
SetSessionMode(Camera_SceneMode sceneMode)206 Camera_ErrorCode Camera_CaptureSession::SetSessionMode(Camera_SceneMode sceneMode)
207 {
208 CHECK_AND_RETURN_RET_LOG(!innerCaptureSession_->IsSessionConfiged() && !innerCaptureSession_->IsSessionCommited(),
209 CAMERA_OPERATION_NOT_ALLOWED, "Camera_Manager::SetSessionMode can not set sceneMode after BeginConfig!");
210 auto itr = g_ndkToFwMode_.find(static_cast<Camera_SceneMode>(sceneMode));
211 CHECK_AND_RETURN_RET_LOG(itr != g_ndkToFwMode_.end(), CAMERA_INVALID_ARGUMENT,
212 "Camera_CaptureSession::SetSessionMode sceneMode not found!");
213 SceneMode innerSceneMode = static_cast<SceneMode>(itr->second);
214 switch (innerSceneMode) {
215 case SceneMode::CAPTURE:
216 innerCaptureSession_ = CameraManager::GetInstance()->CreateCaptureSession(SceneMode::CAPTURE);
217 break;
218 case SceneMode::VIDEO:
219 innerCaptureSession_ = CameraManager::GetInstance()->CreateCaptureSession(SceneMode::VIDEO);
220 break;
221 case SceneMode::SECURE:
222 innerCaptureSession_ = CameraManager::GetInstance()->CreateCaptureSession(SceneMode::SECURE);
223 break;
224 default:
225 MEDIA_ERR_LOG("Camera_CaptureSession::SetSessionMode sceneMode = %{public}d not supported", sceneMode);
226 return CAMERA_INVALID_ARGUMENT;
227 }
228 return CAMERA_OK;
229 }
230
AddSecureOutput(Camera_PreviewOutput * previewOutput)231 Camera_ErrorCode Camera_CaptureSession::AddSecureOutput(Camera_PreviewOutput* previewOutput)
232 {
233 MEDIA_DEBUG_LOG("Camera_CaptureSession::AddSecureOutput is called");
234 sptr<CaptureOutput> innerPreviewOutput = previewOutput->GetInnerPreviewOutput();
235 int32_t ret = innerCaptureSession_->AddSecureOutput(innerPreviewOutput);
236 return FrameworkToNdkCameraError(ServiceToCameraError(ret));
237 }
238
BeginConfig()239 Camera_ErrorCode Camera_CaptureSession::BeginConfig()
240 {
241 int32_t ret = innerCaptureSession_->BeginConfig();
242 return FrameworkToNdkCameraError(ret);
243 }
244
CommitConfig()245 Camera_ErrorCode Camera_CaptureSession::CommitConfig()
246 {
247 int32_t ret = innerCaptureSession_->CommitConfig();
248 return FrameworkToNdkCameraError(ret);
249 }
250
AddInput(Camera_Input * cameraInput)251 Camera_ErrorCode Camera_CaptureSession::AddInput(Camera_Input* cameraInput)
252 {
253 sptr<CaptureInput> innerCameraInput = cameraInput->GetInnerCameraInput();
254 int32_t ret = innerCaptureSession_->AddInput(innerCameraInput);
255 return FrameworkToNdkCameraError(ret);
256 }
257
RemoveInput(Camera_Input * cameraInput)258 Camera_ErrorCode Camera_CaptureSession::RemoveInput(Camera_Input* cameraInput)
259 {
260 sptr<CaptureInput> innerCameraInput = cameraInput->GetInnerCameraInput();
261 int32_t ret = innerCaptureSession_->RemoveInput(innerCameraInput);
262 return FrameworkToNdkCameraError(ret);
263 }
264
AddPreviewOutput(Camera_PreviewOutput * previewOutput)265 Camera_ErrorCode Camera_CaptureSession::AddPreviewOutput(Camera_PreviewOutput* previewOutput)
266 {
267 sptr<CaptureOutput> innerPreviewOutput = previewOutput->GetInnerPreviewOutput();
268 int32_t ret = innerCaptureSession_->AddOutput(innerPreviewOutput);
269 return FrameworkToNdkCameraError(ret);
270 }
271
RemovePreviewOutput(Camera_PreviewOutput * previewOutput)272 Camera_ErrorCode Camera_CaptureSession::RemovePreviewOutput(Camera_PreviewOutput* previewOutput)
273 {
274 sptr<CaptureOutput> innerPreviewOutput = previewOutput->GetInnerPreviewOutput();
275 int32_t ret = innerCaptureSession_->RemoveOutput(innerPreviewOutput);
276 return FrameworkToNdkCameraError(ret);
277 }
278
AddPhotoOutput(Camera_PhotoOutput * photoOutput)279 Camera_ErrorCode Camera_CaptureSession::AddPhotoOutput(Camera_PhotoOutput* photoOutput)
280 {
281 MEDIA_DEBUG_LOG("Camera_CaptureSession::AddPhotoOutput is called");
282 sptr<CaptureOutput> innerPhotoOutput = photoOutput->GetInnerPhotoOutput();
283 int32_t ret = innerCaptureSession_->AddOutput(innerPhotoOutput);
284 return FrameworkToNdkCameraError(ret);
285 }
286
RemovePhotoOutput(Camera_PhotoOutput * photoOutput)287 Camera_ErrorCode Camera_CaptureSession::RemovePhotoOutput(Camera_PhotoOutput* photoOutput)
288 {
289 MEDIA_DEBUG_LOG("Camera_CaptureSession::RemovePhotoOutput is called");
290 sptr<CaptureOutput> innerPhotoOutput = photoOutput->GetInnerPhotoOutput();
291 int32_t ret = innerCaptureSession_->RemoveOutput(innerPhotoOutput);
292 return FrameworkToNdkCameraError(ret);
293 }
294
AddMetaDataOutput(Camera_MetadataOutput * metadataOutput)295 Camera_ErrorCode Camera_CaptureSession::AddMetaDataOutput(Camera_MetadataOutput* metadataOutput)
296 {
297 MEDIA_DEBUG_LOG("Camera_CaptureSession::AddMetaDataOutput is called");
298 sptr<CaptureOutput> innerMetaDataOutput = metadataOutput->GetInnerMetadataOutput();
299 int32_t ret = innerCaptureSession_->AddOutput(innerMetaDataOutput);
300 return FrameworkToNdkCameraError(ret);
301 }
302
RemoveMetaDataOutput(Camera_MetadataOutput * metadataOutput)303 Camera_ErrorCode Camera_CaptureSession::RemoveMetaDataOutput(Camera_MetadataOutput* metadataOutput)
304 {
305 MEDIA_DEBUG_LOG("Camera_CaptureSession::RemoveMetaDataOutput is called");
306 sptr<CaptureOutput> innerMetaDataOutput = metadataOutput->GetInnerMetadataOutput();
307 int32_t ret = innerCaptureSession_->AddOutput(innerMetaDataOutput);
308 return FrameworkToNdkCameraError(ret);
309 }
310
IsVideoStabilizationModeSupported(Camera_VideoStabilizationMode mode,bool * isSupported)311 Camera_ErrorCode Camera_CaptureSession::IsVideoStabilizationModeSupported(Camera_VideoStabilizationMode mode,
312 bool* isSupported)
313 {
314 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsVideoStabilizationModeSupported is called");
315 VideoStabilizationMode innerVideoStabilizationMode = static_cast<VideoStabilizationMode>(mode);
316 int32_t ret = innerCaptureSession_->IsVideoStabilizationModeSupported(innerVideoStabilizationMode, *isSupported);
317 return FrameworkToNdkCameraError(ret);
318 }
319
GetVideoStabilizationMode(Camera_VideoStabilizationMode * mode)320 Camera_ErrorCode Camera_CaptureSession::GetVideoStabilizationMode(Camera_VideoStabilizationMode* mode)
321 {
322 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetVideoStabilizationMode is called");
323
324 *mode = static_cast<Camera_VideoStabilizationMode>(innerCaptureSession_->GetActiveVideoStabilizationMode());
325 return CAMERA_OK;
326 }
327
SetVideoStabilizationMode(Camera_VideoStabilizationMode mode)328 Camera_ErrorCode Camera_CaptureSession::SetVideoStabilizationMode(Camera_VideoStabilizationMode mode)
329 {
330 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetVideoStabilizationMode is called");
331
332 VideoStabilizationMode innerVideoStabilizationMode = static_cast<VideoStabilizationMode>(mode);
333 int32_t ret = innerCaptureSession_->SetVideoStabilizationMode(innerVideoStabilizationMode);
334 return FrameworkToNdkCameraError(ret);
335 }
336
GetZoomRatioRange(float * minZoom,float * maxZoom)337 Camera_ErrorCode Camera_CaptureSession::GetZoomRatioRange(float* minZoom, float* maxZoom)
338 {
339 std::vector<float> vecZoomRatioList = innerCaptureSession_->GetZoomRatioRange();
340 if (vecZoomRatioList.empty()) {
341 MEDIA_ERR_LOG("Camera_CaptureSession::GetZoomRatioRange vecZoomRatioList size is null ");
342 } else {
343 *minZoom = vecZoomRatioList[0];
344 *maxZoom = vecZoomRatioList[1];
345 }
346 return CAMERA_OK;
347 }
348
GetZoomRatio(float * zoom)349 Camera_ErrorCode Camera_CaptureSession::GetZoomRatio(float* zoom)
350 {
351 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetZoomRatio is called");
352 *zoom = innerCaptureSession_->GetZoomRatio();
353
354 return CAMERA_OK;
355 }
356
SetZoomRatio(float zoom)357 Camera_ErrorCode Camera_CaptureSession::SetZoomRatio(float zoom)
358 {
359 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetZoomRatio is called");
360
361 innerCaptureSession_->LockForControl();
362 int32_t ret = innerCaptureSession_->SetZoomRatio(zoom);
363 innerCaptureSession_->UnlockForControl();
364
365 if (ret != CameraErrorCode::SUCCESS) {
366 return CAMERA_SERVICE_FATAL_ERROR;
367 }
368 return FrameworkToNdkCameraError(ret);
369 }
370
IsFocusModeSupported(Camera_FocusMode focusMode,bool * isSupported)371 Camera_ErrorCode Camera_CaptureSession::IsFocusModeSupported(Camera_FocusMode focusMode, bool* isSupported)
372 {
373 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsFocusModeSupported is called");
374 FocusMode innerFocusMode = static_cast<FocusMode>(focusMode);
375 int32_t ret = innerCaptureSession_->IsFocusModeSupported(innerFocusMode, *isSupported);
376 if (ret != CameraErrorCode::SUCCESS) {
377 return CAMERA_SERVICE_FATAL_ERROR;
378 }
379 return FrameworkToNdkCameraError(ret);
380 }
381
GetFocusMode(Camera_FocusMode * focusMode)382 Camera_ErrorCode Camera_CaptureSession::GetFocusMode(Camera_FocusMode* focusMode)
383 {
384 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetFocusMode is called");
385
386 *focusMode = static_cast<Camera_FocusMode>(innerCaptureSession_->GetFocusMode());
387 return CAMERA_OK;
388 }
389
SetFocusMode(Camera_FocusMode focusMode)390 Camera_ErrorCode Camera_CaptureSession::SetFocusMode(Camera_FocusMode focusMode)
391 {
392 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetFocusMode is called");
393
394 FocusMode innerFocusMode = static_cast<FocusMode>(focusMode);
395 innerCaptureSession_->LockForControl();
396 int32_t ret = innerCaptureSession_->SetFocusMode(innerFocusMode);
397 innerCaptureSession_->UnlockForControl();
398
399 if (ret != CameraErrorCode::SUCCESS) {
400 return CAMERA_SERVICE_FATAL_ERROR;
401 }
402 return FrameworkToNdkCameraError(ret);
403 }
404
SetFocusPoint(Camera_Point focusPoint)405 Camera_ErrorCode Camera_CaptureSession::SetFocusPoint(Camera_Point focusPoint)
406 {
407 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetFocusPoint is called");
408
409 Point innerFocusPoint;
410 innerFocusPoint.x = focusPoint.x;
411 innerFocusPoint.y = focusPoint.y;
412
413 innerCaptureSession_->LockForControl();
414 int32_t ret = innerCaptureSession_->SetFocusPoint(innerFocusPoint);
415 innerCaptureSession_->UnlockForControl();
416
417 if (ret != CameraErrorCode::SUCCESS) {
418 return CAMERA_SERVICE_FATAL_ERROR;
419 }
420 return FrameworkToNdkCameraError(ret);
421 }
422
GetFocusPoint(Camera_Point * focusPoint)423 Camera_ErrorCode Camera_CaptureSession::GetFocusPoint(Camera_Point* focusPoint)
424 {
425 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetFocusPoint is called");
426 Point innerFocusPoint = innerCaptureSession_->GetFocusPoint();
427 (*focusPoint).x = innerFocusPoint.x;
428 (*focusPoint).y = innerFocusPoint.y;
429
430 return CAMERA_OK;
431 }
432
HasFlash(bool * hasFlash)433 Camera_ErrorCode Camera_CaptureSession::HasFlash(bool* hasFlash)
434 {
435 MEDIA_DEBUG_LOG("Camera_CaptureSession::HasFlash is called");
436
437 *hasFlash = innerCaptureSession_->HasFlash();
438
439 return CAMERA_OK;
440 }
441
IsFlashModeSupported(Camera_FlashMode flashMode,bool * isSupported)442 Camera_ErrorCode Camera_CaptureSession::IsFlashModeSupported(Camera_FlashMode flashMode, bool* isSupported)
443 {
444 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsFlashModeSupported is called");
445 FlashMode innerFlashMode = static_cast<FlashMode>(flashMode);
446
447 *isSupported = innerCaptureSession_->IsFlashModeSupported(innerFlashMode);
448
449 return CAMERA_OK;
450 }
451
GetFlashMode(Camera_FlashMode * flashMode)452 Camera_ErrorCode Camera_CaptureSession::GetFlashMode(Camera_FlashMode* flashMode)
453 {
454 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetFlashMode is called");
455 *flashMode = static_cast<Camera_FlashMode>(innerCaptureSession_->GetFlashMode());
456
457 return CAMERA_OK;
458 }
459
SetFlashMode(Camera_FlashMode flashMode)460 Camera_ErrorCode Camera_CaptureSession::SetFlashMode(Camera_FlashMode flashMode)
461 {
462 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetFlashMode is called");
463
464 FlashMode innerFlashMode = static_cast<FlashMode>(flashMode);
465 innerCaptureSession_->LockForControl();
466 int32_t ret = innerCaptureSession_->SetFlashMode(innerFlashMode);
467 innerCaptureSession_->UnlockForControl();
468
469 if (ret != CameraErrorCode::SUCCESS) {
470 return CAMERA_SERVICE_FATAL_ERROR;
471 }
472 return FrameworkToNdkCameraError(ret);
473 }
474
IsExposureModeSupported(Camera_ExposureMode exposureMode,bool * isSupported)475 Camera_ErrorCode Camera_CaptureSession::IsExposureModeSupported(Camera_ExposureMode exposureMode, bool* isSupported)
476 {
477 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsExposureModeSupported is called");
478 ExposureMode innerExposureMode = static_cast<ExposureMode>(exposureMode);
479 int32_t ret = innerCaptureSession_->IsExposureModeSupported(innerExposureMode, *isSupported);
480 if (ret != CameraErrorCode::SUCCESS) {
481 return CAMERA_SERVICE_FATAL_ERROR;
482 }
483 return FrameworkToNdkCameraError(ret);
484 }
485
GetExposureMode(Camera_ExposureMode * exposureMode)486 Camera_ErrorCode Camera_CaptureSession::GetExposureMode(Camera_ExposureMode* exposureMode)
487 {
488 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetExposureMode is called");
489
490 *exposureMode = static_cast<Camera_ExposureMode>(innerCaptureSession_->GetExposureMode());
491 return CAMERA_OK;
492 }
493
SetExposureMode(Camera_ExposureMode exposureMode)494 Camera_ErrorCode Camera_CaptureSession::SetExposureMode(Camera_ExposureMode exposureMode)
495 {
496 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetExposureMode is called");
497
498 ExposureMode innerExposureMode = static_cast<ExposureMode>(exposureMode);
499 innerCaptureSession_->LockForControl();
500 int32_t ret = innerCaptureSession_->SetExposureMode(innerExposureMode);
501 innerCaptureSession_->UnlockForControl();
502
503 if (ret != CameraErrorCode::SUCCESS) {
504 return CAMERA_SERVICE_FATAL_ERROR;
505 }
506 return FrameworkToNdkCameraError(ret);
507 }
508
GetMeteringPoint(Camera_Point * point)509 Camera_ErrorCode Camera_CaptureSession::GetMeteringPoint(Camera_Point* point)
510 {
511 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetMeteringPoint is called");
512
513 Point innerFocusPoint = innerCaptureSession_->GetMeteringPoint();
514 (*point).x = innerFocusPoint.x;
515 (*point).y = innerFocusPoint.y;
516 return CAMERA_OK;
517 }
518
SetMeteringPoint(Camera_Point point)519 Camera_ErrorCode Camera_CaptureSession::SetMeteringPoint(Camera_Point point)
520 {
521 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetMeteringPoint is called");
522 Point innerExposurePoint;
523 innerExposurePoint.x = point.x;
524 innerExposurePoint.y = point.y;
525
526 innerCaptureSession_->LockForControl();
527 int32_t ret = innerCaptureSession_->SetMeteringPoint(innerExposurePoint);
528 innerCaptureSession_->UnlockForControl();
529
530 if (ret != CameraErrorCode::SUCCESS) {
531 return CAMERA_SERVICE_FATAL_ERROR;
532 }
533 return FrameworkToNdkCameraError(ret);
534 }
535
GetExposureBiasRange(float * minExposureBias,float * maxExposureBias,float * step)536 Camera_ErrorCode Camera_CaptureSession::GetExposureBiasRange(float* minExposureBias,
537 float* maxExposureBias, float* step)
538 {
539 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetExposureBiasRange is called");
540
541 std::vector<float> vecExposureBiasList = innerCaptureSession_->GetExposureBiasRange();
542 constexpr int32_t ARGS_TWO = 2;
543 if (!vecExposureBiasList.empty() && vecExposureBiasList.size() >= ARGS_TWO) {
544 *minExposureBias = vecExposureBiasList[0];
545 *maxExposureBias = vecExposureBiasList[1];
546 } else {
547 MEDIA_ERR_LOG("Camera_CaptureSession::GetExposureBiasRange vecZoomRatioList illegal.");
548 }
549 return CAMERA_OK;
550 }
551
SetExposureBias(float exposureBias)552 Camera_ErrorCode Camera_CaptureSession::SetExposureBias(float exposureBias)
553 {
554 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetExposureBias is called");
555
556 innerCaptureSession_->LockForControl();
557 int32_t ret = innerCaptureSession_->SetExposureBias(exposureBias);
558 innerCaptureSession_->UnlockForControl();
559
560 if (ret != CameraErrorCode::SUCCESS) {
561 return CAMERA_SERVICE_FATAL_ERROR;
562 }
563 return FrameworkToNdkCameraError(ret);
564 }
565
GetExposureBias(float * exposureBias)566 Camera_ErrorCode Camera_CaptureSession::GetExposureBias(float* exposureBias)
567 {
568 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetExposureBias is called");
569
570 *exposureBias = innerCaptureSession_->GetExposureValue();
571
572 return CAMERA_OK;
573 }
574
AddVideoOutput(Camera_VideoOutput * videoOutput)575 Camera_ErrorCode Camera_CaptureSession::AddVideoOutput(Camera_VideoOutput* videoOutput)
576 {
577 sptr<CaptureOutput> innerVideoOutput = videoOutput->GetInnerVideoOutput();
578 int32_t ret = innerCaptureSession_->AddOutput(innerVideoOutput);
579 return FrameworkToNdkCameraError(ret);
580 }
581
RemoveVideoOutput(Camera_VideoOutput * videoOutput)582 Camera_ErrorCode Camera_CaptureSession::RemoveVideoOutput(Camera_VideoOutput* videoOutput)
583 {
584 sptr<CaptureOutput> innerVideoOutput = videoOutput->GetInnerVideoOutput();
585 int32_t ret = innerCaptureSession_->RemoveOutput(innerVideoOutput);
586 return FrameworkToNdkCameraError(ret);
587 }
588
Start()589 Camera_ErrorCode Camera_CaptureSession::Start()
590 {
591 int32_t ret = innerCaptureSession_->Start();
592 return FrameworkToNdkCameraError(ret);
593 }
594
Stop()595 Camera_ErrorCode Camera_CaptureSession::Stop()
596 {
597 int32_t ret = innerCaptureSession_->Stop();
598 return FrameworkToNdkCameraError(ret);
599 }
600
Release()601 Camera_ErrorCode Camera_CaptureSession::Release()
602 {
603 int32_t ret = innerCaptureSession_->Release();
604 return FrameworkToNdkCameraError(ret);
605 }
606
CanAddInput(Camera_Input * cameraInput,bool * isSuccessful)607 Camera_ErrorCode Camera_CaptureSession::CanAddInput(Camera_Input* cameraInput, bool* isSuccessful)
608 {
609 sptr<CaptureInput> innerCameraInput = cameraInput->GetInnerCameraInput();
610 *isSuccessful = innerCaptureSession_->CanAddInput(innerCameraInput);
611 return CAMERA_OK;
612 }
613
CanAddPreviewOutput(Camera_PreviewOutput * previewOutput,bool * isSuccessful)614 Camera_ErrorCode Camera_CaptureSession::CanAddPreviewOutput(Camera_PreviewOutput* previewOutput, bool* isSuccessful)
615 {
616 sptr<CaptureOutput> innerPreviewOutput = previewOutput->GetInnerPreviewOutput();
617 *isSuccessful = innerCaptureSession_->CanAddOutput(innerPreviewOutput);
618 return CAMERA_OK;
619 }
620
CanAddPhotoOutput(Camera_PhotoOutput * photoOutput,bool * isSuccessful)621 Camera_ErrorCode Camera_CaptureSession::CanAddPhotoOutput(Camera_PhotoOutput* photoOutput, bool* isSuccessful)
622 {
623 sptr<CaptureOutput> innerPhotoOutput = photoOutput->GetInnerPhotoOutput();
624 *isSuccessful = innerCaptureSession_->CanAddOutput(innerPhotoOutput);
625 return CAMERA_OK;
626 }
627
CanAddVideoOutput(Camera_VideoOutput * videoOutput,bool * isSuccessful)628 Camera_ErrorCode Camera_CaptureSession::CanAddVideoOutput(Camera_VideoOutput* videoOutput, bool* isSuccessful)
629 {
630 sptr<CaptureOutput> innerVideoOutput = videoOutput->GetInnerVideoOutput();
631 *isSuccessful = innerCaptureSession_->CanAddOutput(innerVideoOutput);
632 return CAMERA_OK;
633 }
634
CanPreconfig(Camera_PreconfigType preconfigType,bool * canPreconfig)635 Camera_ErrorCode Camera_CaptureSession::CanPreconfig(Camera_PreconfigType preconfigType, bool* canPreconfig)
636 {
637 auto itr = g_ndkToFwPreconfig.find(preconfigType);
638 if (itr == g_ndkToFwPreconfig.end()) {
639 MEDIA_ERR_LOG("Camera_CaptureSession::CanPreconfig preconfigType: [%{public}d] is invalid!", preconfigType);
640 *canPreconfig = false;
641 return CAMERA_INVALID_ARGUMENT;
642 }
643
644 *canPreconfig = innerCaptureSession_->CanPreconfig(itr->second, ProfileSizeRatio::UNSPECIFIED);
645 return CAMERA_OK;
646 }
647
CanPreconfigWithRatio(Camera_PreconfigType preconfigType,Camera_PreconfigRatio preconfigRatio,bool * canPreconfig)648 Camera_ErrorCode Camera_CaptureSession::CanPreconfigWithRatio(Camera_PreconfigType preconfigType,
649 Camera_PreconfigRatio preconfigRatio, bool* canPreconfig)
650 {
651 auto type = g_ndkToFwPreconfig.find(preconfigType);
652 auto ratio = g_ndkToFwPreconfigRatio.find(preconfigRatio);
653 if (type == g_ndkToFwPreconfig.end() || ratio == g_ndkToFwPreconfigRatio.end()) {
654 MEDIA_ERR_LOG("Camera_CaptureSession::CanPreconfigWithRatio preconfigType: [%{public}d] "
655 "or preconfigRatio: [%{public}d] is invalid!", preconfigType, preconfigRatio);
656 *canPreconfig = false;
657 return CAMERA_INVALID_ARGUMENT;
658 }
659
660 *canPreconfig = innerCaptureSession_->CanPreconfig(type->second, ratio->second);
661 return CAMERA_OK;
662 }
663
Preconfig(Camera_PreconfigType preconfigType)664 Camera_ErrorCode Camera_CaptureSession::Preconfig(Camera_PreconfigType preconfigType)
665 {
666 auto itr = g_ndkToFwPreconfig.find(preconfigType);
667 CHECK_AND_RETURN_RET_LOG(itr != g_ndkToFwPreconfig.end(), CAMERA_INVALID_ARGUMENT,
668 "Camera_CaptureSession::Preconfig preconfigType: [%{public}d] is invalid!", preconfigType);
669
670 int32_t ret = innerCaptureSession_->Preconfig(itr->second, ProfileSizeRatio::UNSPECIFIED);
671 return FrameworkToNdkCameraError(ret);
672 }
673
PreconfigWithRatio(Camera_PreconfigType preconfigType,Camera_PreconfigRatio preconfigRatio)674 Camera_ErrorCode Camera_CaptureSession::PreconfigWithRatio(Camera_PreconfigType preconfigType,
675 Camera_PreconfigRatio preconfigRatio)
676 {
677 auto type = g_ndkToFwPreconfig.find(preconfigType);
678 auto ratio = g_ndkToFwPreconfigRatio.find(preconfigRatio);
679 CHECK_AND_RETURN_RET_LOG(type != g_ndkToFwPreconfig.end(), CAMERA_INVALID_ARGUMENT,
680 "Camera_CaptureSession::PreconfigWithRatio preconfigType: [%{public}d] is invalid!", preconfigType);
681 CHECK_AND_RETURN_RET_LOG(ratio != g_ndkToFwPreconfigRatio.end(), CAMERA_INVALID_ARGUMENT,
682 "Camera_CaptureSession::PreconfigWithRatio preconfigRatio: [%{public}d] is invalid!", preconfigRatio);
683
684 int32_t ret = innerCaptureSession_->Preconfig(type->second, ratio->second);
685 return FrameworkToNdkCameraError(ret);
686 }
687
GetExposureValue(float * exposureValue)688 Camera_ErrorCode Camera_CaptureSession::GetExposureValue(float* exposureValue)
689 {
690 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetExposureValue is called");
691
692 int32_t ret = innerCaptureSession_->GetExposureValue(*exposureValue);
693 return FrameworkToNdkCameraError(ret);
694 }
695
GetFocalLength(float * focalLength)696 Camera_ErrorCode Camera_CaptureSession::GetFocalLength(float* focalLength)
697 {
698 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetFocalLength is called");
699
700 int32_t ret = innerCaptureSession_->GetFocalLength(*focalLength);
701 return FrameworkToNdkCameraError(ret);
702 }
703
SetSmoothZoom(float targetZoom,Camera_SmoothZoomMode smoothZoomMode)704 Camera_ErrorCode Camera_CaptureSession::SetSmoothZoom(float targetZoom, Camera_SmoothZoomMode smoothZoomMode)
705 {
706 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetSmoothZoom is called");
707
708 int32_t ret = innerCaptureSession_->SetSmoothZoom(targetZoom, static_cast<uint32_t>(smoothZoomMode));
709 return FrameworkToNdkCameraError(ret);
710 }
711
GetSupportedColorSpaces(OH_NativeBuffer_ColorSpace ** colorSpace,uint32_t * size)712 Camera_ErrorCode Camera_CaptureSession::GetSupportedColorSpaces(OH_NativeBuffer_ColorSpace** colorSpace,
713 uint32_t* size)
714 {
715 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetSupportedColorSpaces is called");
716
717 auto colorSpaces = innerCaptureSession_->GetSupportedColorSpaces();
718 if (colorSpaces.empty()) {
719 MEDIA_ERR_LOG("Supported ColorSpace is empty!");
720 *size = 0;
721 return CAMERA_OK;
722 }
723
724 std::vector<OH_NativeBuffer_ColorSpace> cameraColorSpace;
725 for (size_t i = 0; i < colorSpaces.size(); ++i) {
726 auto itr = g_fwToNdkColorSpace_.find(colorSpaces[i]);
727 if (itr != g_fwToNdkColorSpace_.end()) {
728 cameraColorSpace.push_back(itr->second);
729 }
730 }
731
732 if (cameraColorSpace.size() == 0) {
733 MEDIA_ERR_LOG("Supported ColorSpace is empty!");
734 *size = 0;
735 return CAMERA_OK;
736 }
737
738 OH_NativeBuffer_ColorSpace* newColorSpace = new OH_NativeBuffer_ColorSpace[cameraColorSpace.size()];
739 CHECK_AND_RETURN_RET_LOG(newColorSpace != nullptr, CAMERA_SERVICE_FATAL_ERROR,
740 "Failed to allocate memory for color space!");
741 for (size_t index = 0; index < cameraColorSpace.size(); index++) {
742 newColorSpace[index] = cameraColorSpace[index];
743 }
744
745 *size = cameraColorSpace.size();
746 *colorSpace = newColorSpace;
747 return CAMERA_OK;
748 }
749
DeleteColorSpaces(OH_NativeBuffer_ColorSpace * colorSpace)750 Camera_ErrorCode Camera_CaptureSession::DeleteColorSpaces(OH_NativeBuffer_ColorSpace* colorSpace)
751 {
752 if (colorSpace != nullptr) {
753 delete[] colorSpace;
754 colorSpace = nullptr;
755 }
756
757 return CAMERA_OK;
758 }
759
GetActiveColorSpace(OH_NativeBuffer_ColorSpace * colorSpace)760 Camera_ErrorCode Camera_CaptureSession::GetActiveColorSpace(OH_NativeBuffer_ColorSpace* colorSpace)
761 {
762 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetActiveColorSpace is called");
763
764 ColorSpace innerColorSpace;
765 int32_t ret = innerCaptureSession_->GetActiveColorSpace(innerColorSpace);
766 if (ret != SUCCESS) {
767 return FrameworkToNdkCameraError(ret);
768 }
769 auto itr = g_fwToNdkColorSpace_.find(innerColorSpace);
770 if (itr != g_fwToNdkColorSpace_.end()) {
771 *colorSpace = itr->second;
772 } else {
773 MEDIA_ERR_LOG("colorSpace[%{public}d] is invalid", innerColorSpace);
774 return CAMERA_SERVICE_FATAL_ERROR;
775 }
776 return CAMERA_OK;
777 }
778
SetActiveColorSpace(OH_NativeBuffer_ColorSpace colorSpace)779 Camera_ErrorCode Camera_CaptureSession::SetActiveColorSpace(OH_NativeBuffer_ColorSpace colorSpace)
780 {
781 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetActiveColorSpace is called");
782
783 auto itr = g_ndkToFwColorSpace_.find(colorSpace);
784 if (itr == g_ndkToFwColorSpace_.end()) {
785 MEDIA_ERR_LOG("colorSpace[%{public}d] is invalid", colorSpace);
786 return CAMERA_INVALID_ARGUMENT;
787 }
788 int32_t ret = innerCaptureSession_->SetColorSpace(itr->second);
789 return FrameworkToNdkCameraError(ret);
790 }
791
RegisterAutoDeviceSwitchStatusCallback(OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)792 Camera_ErrorCode Camera_CaptureSession::RegisterAutoDeviceSwitchStatusCallback(
793 OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)
794 {
795 shared_ptr<InnerCaptureSessionAutoDeviceSwitchStatusCallback> innerDeviceSwitchStatusCallback =
796 make_shared<InnerCaptureSessionAutoDeviceSwitchStatusCallback>(this, autoDeviceSwitchStatusChange);
797 CHECK_AND_RETURN_RET_LOG(innerDeviceSwitchStatusCallback != nullptr, CAMERA_SERVICE_FATAL_ERROR,
798 "create innerCallback failed!");
799 innerCaptureSession_->SetAutoDeviceSwitchCallback(innerDeviceSwitchStatusCallback);
800 return CAMERA_OK;
801 }
802
UnregisterAutoDeviceSwitchStatusCallback(OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)803 Camera_ErrorCode Camera_CaptureSession::UnregisterAutoDeviceSwitchStatusCallback(
804 OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)
805 {
806 innerCaptureSession_->SetAutoDeviceSwitchCallback(nullptr);
807 return CAMERA_OK;
808 }
809
IsAutoDeviceSwitchSupported(bool * isSupported)810 Camera_ErrorCode Camera_CaptureSession::IsAutoDeviceSwitchSupported(bool* isSupported)
811 {
812 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsAutoDeviceSwitchSupported is called");
813 *isSupported = innerCaptureSession_->IsAutoDeviceSwitchSupported();
814 return CAMERA_OK;
815 }
816
EnableAutoDeviceSwitch(bool enabled)817 Camera_ErrorCode Camera_CaptureSession::EnableAutoDeviceSwitch(bool enabled)
818 {
819 MEDIA_DEBUG_LOG("Camera_CaptureSession::EnableAutoDeviceSwitch is called");
820 int32_t ret = innerCaptureSession_->EnableAutoDeviceSwitch(enabled);
821 return FrameworkToNdkCameraError(ret);
822 }