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 if (innerCaptureSession_ == nullptr) {
308 return CAMERA_INVALID_ARGUMENT;
309 }
310 int32_t ret = innerCaptureSession_->AddOutput(innerMetaDataOutput);
311 return FrameworkToNdkCameraError(ret);
312 }
313
IsVideoStabilizationModeSupported(Camera_VideoStabilizationMode mode,bool * isSupported)314 Camera_ErrorCode Camera_CaptureSession::IsVideoStabilizationModeSupported(Camera_VideoStabilizationMode mode,
315 bool* isSupported)
316 {
317 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsVideoStabilizationModeSupported is called");
318 VideoStabilizationMode innerVideoStabilizationMode = static_cast<VideoStabilizationMode>(mode);
319 int32_t ret = innerCaptureSession_->IsVideoStabilizationModeSupported(innerVideoStabilizationMode, *isSupported);
320 return FrameworkToNdkCameraError(ret);
321 }
322
GetVideoStabilizationMode(Camera_VideoStabilizationMode * mode)323 Camera_ErrorCode Camera_CaptureSession::GetVideoStabilizationMode(Camera_VideoStabilizationMode* mode)
324 {
325 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetVideoStabilizationMode is called");
326
327 *mode = static_cast<Camera_VideoStabilizationMode>(innerCaptureSession_->GetActiveVideoStabilizationMode());
328 return CAMERA_OK;
329 }
330
SetVideoStabilizationMode(Camera_VideoStabilizationMode mode)331 Camera_ErrorCode Camera_CaptureSession::SetVideoStabilizationMode(Camera_VideoStabilizationMode mode)
332 {
333 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetVideoStabilizationMode is called");
334
335 VideoStabilizationMode innerVideoStabilizationMode = static_cast<VideoStabilizationMode>(mode);
336 int32_t ret = innerCaptureSession_->SetVideoStabilizationMode(innerVideoStabilizationMode);
337 return FrameworkToNdkCameraError(ret);
338 }
339
GetZoomRatioRange(float * minZoom,float * maxZoom)340 Camera_ErrorCode Camera_CaptureSession::GetZoomRatioRange(float* minZoom, float* maxZoom)
341 {
342 std::vector<float> vecZoomRatioList = innerCaptureSession_->GetZoomRatioRange();
343 if (vecZoomRatioList.empty()) {
344 MEDIA_ERR_LOG("Camera_CaptureSession::GetZoomRatioRange vecZoomRatioList size is null ");
345 } else {
346 *minZoom = vecZoomRatioList[0];
347 *maxZoom = vecZoomRatioList[1];
348 }
349 return CAMERA_OK;
350 }
351
GetZoomRatio(float * zoom)352 Camera_ErrorCode Camera_CaptureSession::GetZoomRatio(float* zoom)
353 {
354 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetZoomRatio is called");
355 *zoom = innerCaptureSession_->GetZoomRatio();
356
357 return CAMERA_OK;
358 }
359
SetZoomRatio(float zoom)360 Camera_ErrorCode Camera_CaptureSession::SetZoomRatio(float zoom)
361 {
362 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetZoomRatio is called");
363
364 innerCaptureSession_->LockForControl();
365 int32_t ret = innerCaptureSession_->SetZoomRatio(zoom);
366 innerCaptureSession_->UnlockForControl();
367
368 if (ret != CameraErrorCode::SUCCESS) {
369 return CAMERA_SERVICE_FATAL_ERROR;
370 }
371 return FrameworkToNdkCameraError(ret);
372 }
373
IsFocusModeSupported(Camera_FocusMode focusMode,bool * isSupported)374 Camera_ErrorCode Camera_CaptureSession::IsFocusModeSupported(Camera_FocusMode focusMode, bool* isSupported)
375 {
376 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsFocusModeSupported is called");
377 FocusMode innerFocusMode = static_cast<FocusMode>(focusMode);
378 int32_t ret = innerCaptureSession_->IsFocusModeSupported(innerFocusMode, *isSupported);
379 if (ret != CameraErrorCode::SUCCESS) {
380 return CAMERA_SERVICE_FATAL_ERROR;
381 }
382 return FrameworkToNdkCameraError(ret);
383 }
384
GetFocusMode(Camera_FocusMode * focusMode)385 Camera_ErrorCode Camera_CaptureSession::GetFocusMode(Camera_FocusMode* focusMode)
386 {
387 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetFocusMode is called");
388
389 *focusMode = static_cast<Camera_FocusMode>(innerCaptureSession_->GetFocusMode());
390 return CAMERA_OK;
391 }
392
SetFocusMode(Camera_FocusMode focusMode)393 Camera_ErrorCode Camera_CaptureSession::SetFocusMode(Camera_FocusMode focusMode)
394 {
395 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetFocusMode is called");
396
397 FocusMode innerFocusMode = static_cast<FocusMode>(focusMode);
398 innerCaptureSession_->LockForControl();
399 int32_t ret = innerCaptureSession_->SetFocusMode(innerFocusMode);
400 innerCaptureSession_->UnlockForControl();
401
402 if (ret != CameraErrorCode::SUCCESS) {
403 return CAMERA_SERVICE_FATAL_ERROR;
404 }
405 return FrameworkToNdkCameraError(ret);
406 }
407
SetFocusPoint(Camera_Point focusPoint)408 Camera_ErrorCode Camera_CaptureSession::SetFocusPoint(Camera_Point focusPoint)
409 {
410 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetFocusPoint is called");
411
412 Point innerFocusPoint;
413 innerFocusPoint.x = focusPoint.x;
414 innerFocusPoint.y = focusPoint.y;
415
416 innerCaptureSession_->LockForControl();
417 int32_t ret = innerCaptureSession_->SetFocusPoint(innerFocusPoint);
418 innerCaptureSession_->UnlockForControl();
419
420 if (ret != CameraErrorCode::SUCCESS) {
421 return CAMERA_SERVICE_FATAL_ERROR;
422 }
423 return FrameworkToNdkCameraError(ret);
424 }
425
GetFocusPoint(Camera_Point * focusPoint)426 Camera_ErrorCode Camera_CaptureSession::GetFocusPoint(Camera_Point* focusPoint)
427 {
428 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetFocusPoint is called");
429 Point innerFocusPoint = innerCaptureSession_->GetFocusPoint();
430 (*focusPoint).x = innerFocusPoint.x;
431 (*focusPoint).y = innerFocusPoint.y;
432
433 return CAMERA_OK;
434 }
435
HasFlash(bool * hasFlash)436 Camera_ErrorCode Camera_CaptureSession::HasFlash(bool* hasFlash)
437 {
438 MEDIA_DEBUG_LOG("Camera_CaptureSession::HasFlash is called");
439
440 *hasFlash = innerCaptureSession_->HasFlash();
441
442 return CAMERA_OK;
443 }
444
IsFlashModeSupported(Camera_FlashMode flashMode,bool * isSupported)445 Camera_ErrorCode Camera_CaptureSession::IsFlashModeSupported(Camera_FlashMode flashMode, bool* isSupported)
446 {
447 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsFlashModeSupported is called");
448 FlashMode innerFlashMode = static_cast<FlashMode>(flashMode);
449
450 *isSupported = innerCaptureSession_->IsFlashModeSupported(innerFlashMode);
451
452 return CAMERA_OK;
453 }
454
GetFlashMode(Camera_FlashMode * flashMode)455 Camera_ErrorCode Camera_CaptureSession::GetFlashMode(Camera_FlashMode* flashMode)
456 {
457 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetFlashMode is called");
458 *flashMode = static_cast<Camera_FlashMode>(innerCaptureSession_->GetFlashMode());
459
460 return CAMERA_OK;
461 }
462
SetFlashMode(Camera_FlashMode flashMode)463 Camera_ErrorCode Camera_CaptureSession::SetFlashMode(Camera_FlashMode flashMode)
464 {
465 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetFlashMode is called");
466
467 FlashMode innerFlashMode = static_cast<FlashMode>(flashMode);
468 innerCaptureSession_->LockForControl();
469 int32_t ret = innerCaptureSession_->SetFlashMode(innerFlashMode);
470 innerCaptureSession_->UnlockForControl();
471
472 if (ret != CameraErrorCode::SUCCESS) {
473 return CAMERA_SERVICE_FATAL_ERROR;
474 }
475 return FrameworkToNdkCameraError(ret);
476 }
477
IsExposureModeSupported(Camera_ExposureMode exposureMode,bool * isSupported)478 Camera_ErrorCode Camera_CaptureSession::IsExposureModeSupported(Camera_ExposureMode exposureMode, bool* isSupported)
479 {
480 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsExposureModeSupported is called");
481 ExposureMode innerExposureMode = static_cast<ExposureMode>(exposureMode);
482 int32_t ret = innerCaptureSession_->IsExposureModeSupported(innerExposureMode, *isSupported);
483 if (ret != CameraErrorCode::SUCCESS) {
484 return CAMERA_SERVICE_FATAL_ERROR;
485 }
486 return FrameworkToNdkCameraError(ret);
487 }
488
GetExposureMode(Camera_ExposureMode * exposureMode)489 Camera_ErrorCode Camera_CaptureSession::GetExposureMode(Camera_ExposureMode* exposureMode)
490 {
491 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetExposureMode is called");
492
493 *exposureMode = static_cast<Camera_ExposureMode>(innerCaptureSession_->GetExposureMode());
494 return CAMERA_OK;
495 }
496
SetExposureMode(Camera_ExposureMode exposureMode)497 Camera_ErrorCode Camera_CaptureSession::SetExposureMode(Camera_ExposureMode exposureMode)
498 {
499 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetExposureMode is called");
500
501 ExposureMode innerExposureMode = static_cast<ExposureMode>(exposureMode);
502 innerCaptureSession_->LockForControl();
503 int32_t ret = innerCaptureSession_->SetExposureMode(innerExposureMode);
504 innerCaptureSession_->UnlockForControl();
505
506 if (ret != CameraErrorCode::SUCCESS) {
507 return CAMERA_SERVICE_FATAL_ERROR;
508 }
509 return FrameworkToNdkCameraError(ret);
510 }
511
GetMeteringPoint(Camera_Point * point)512 Camera_ErrorCode Camera_CaptureSession::GetMeteringPoint(Camera_Point* point)
513 {
514 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetMeteringPoint is called");
515
516 Point innerFocusPoint = innerCaptureSession_->GetMeteringPoint();
517 (*point).x = innerFocusPoint.x;
518 (*point).y = innerFocusPoint.y;
519 return CAMERA_OK;
520 }
521
SetMeteringPoint(Camera_Point point)522 Camera_ErrorCode Camera_CaptureSession::SetMeteringPoint(Camera_Point point)
523 {
524 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetMeteringPoint is called");
525 Point innerExposurePoint;
526 innerExposurePoint.x = point.x;
527 innerExposurePoint.y = point.y;
528
529 innerCaptureSession_->LockForControl();
530 int32_t ret = innerCaptureSession_->SetMeteringPoint(innerExposurePoint);
531 innerCaptureSession_->UnlockForControl();
532
533 if (ret != CameraErrorCode::SUCCESS) {
534 return CAMERA_SERVICE_FATAL_ERROR;
535 }
536 return FrameworkToNdkCameraError(ret);
537 }
538
GetExposureBiasRange(float * minExposureBias,float * maxExposureBias,float * step)539 Camera_ErrorCode Camera_CaptureSession::GetExposureBiasRange(float* minExposureBias,
540 float* maxExposureBias, float* step)
541 {
542 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetExposureBiasRange is called");
543
544 std::vector<float> vecExposureBiasList = innerCaptureSession_->GetExposureBiasRange();
545 constexpr int32_t ARGS_TWO = 2;
546 if (!vecExposureBiasList.empty() && vecExposureBiasList.size() >= ARGS_TWO) {
547 *minExposureBias = vecExposureBiasList[0];
548 *maxExposureBias = vecExposureBiasList[1];
549 } else {
550 MEDIA_ERR_LOG("Camera_CaptureSession::GetExposureBiasRange vecZoomRatioList illegal.");
551 }
552 return CAMERA_OK;
553 }
554
SetExposureBias(float exposureBias)555 Camera_ErrorCode Camera_CaptureSession::SetExposureBias(float exposureBias)
556 {
557 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetExposureBias is called");
558
559 innerCaptureSession_->LockForControl();
560 int32_t ret = innerCaptureSession_->SetExposureBias(exposureBias);
561 innerCaptureSession_->UnlockForControl();
562
563 if (ret != CameraErrorCode::SUCCESS) {
564 return CAMERA_SERVICE_FATAL_ERROR;
565 }
566 return FrameworkToNdkCameraError(ret);
567 }
568
GetExposureBias(float * exposureBias)569 Camera_ErrorCode Camera_CaptureSession::GetExposureBias(float* exposureBias)
570 {
571 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetExposureBias is called");
572
573 *exposureBias = innerCaptureSession_->GetExposureValue();
574
575 return CAMERA_OK;
576 }
577
AddVideoOutput(Camera_VideoOutput * videoOutput)578 Camera_ErrorCode Camera_CaptureSession::AddVideoOutput(Camera_VideoOutput* videoOutput)
579 {
580 sptr<CaptureOutput> innerVideoOutput = videoOutput->GetInnerVideoOutput();
581 int32_t ret = innerCaptureSession_->AddOutput(innerVideoOutput);
582 return FrameworkToNdkCameraError(ret);
583 }
584
RemoveVideoOutput(Camera_VideoOutput * videoOutput)585 Camera_ErrorCode Camera_CaptureSession::RemoveVideoOutput(Camera_VideoOutput* videoOutput)
586 {
587 sptr<CaptureOutput> innerVideoOutput = videoOutput->GetInnerVideoOutput();
588 int32_t ret = innerCaptureSession_->RemoveOutput(innerVideoOutput);
589 return FrameworkToNdkCameraError(ret);
590 }
591
Start()592 Camera_ErrorCode Camera_CaptureSession::Start()
593 {
594 int32_t ret = innerCaptureSession_->Start();
595 return FrameworkToNdkCameraError(ret);
596 }
597
Stop()598 Camera_ErrorCode Camera_CaptureSession::Stop()
599 {
600 int32_t ret = innerCaptureSession_->Stop();
601 return FrameworkToNdkCameraError(ret);
602 }
603
Release()604 Camera_ErrorCode Camera_CaptureSession::Release()
605 {
606 int32_t ret = innerCaptureSession_->Release();
607 return FrameworkToNdkCameraError(ret);
608 }
609
CanAddInput(Camera_Input * cameraInput,bool * isSuccessful)610 Camera_ErrorCode Camera_CaptureSession::CanAddInput(Camera_Input* cameraInput, bool* isSuccessful)
611 {
612 sptr<CaptureInput> innerCameraInput = cameraInput->GetInnerCameraInput();
613 *isSuccessful = innerCaptureSession_->CanAddInput(innerCameraInput);
614 return CAMERA_OK;
615 }
616
CanAddPreviewOutput(Camera_PreviewOutput * previewOutput,bool * isSuccessful)617 Camera_ErrorCode Camera_CaptureSession::CanAddPreviewOutput(Camera_PreviewOutput* previewOutput, bool* isSuccessful)
618 {
619 sptr<CaptureOutput> innerPreviewOutput = previewOutput->GetInnerPreviewOutput();
620 *isSuccessful = innerCaptureSession_->CanAddOutput(innerPreviewOutput);
621 return CAMERA_OK;
622 }
623
CanAddPhotoOutput(Camera_PhotoOutput * photoOutput,bool * isSuccessful)624 Camera_ErrorCode Camera_CaptureSession::CanAddPhotoOutput(Camera_PhotoOutput* photoOutput, bool* isSuccessful)
625 {
626 sptr<CaptureOutput> innerPhotoOutput = photoOutput->GetInnerPhotoOutput();
627 *isSuccessful = innerCaptureSession_->CanAddOutput(innerPhotoOutput);
628 return CAMERA_OK;
629 }
630
CanAddVideoOutput(Camera_VideoOutput * videoOutput,bool * isSuccessful)631 Camera_ErrorCode Camera_CaptureSession::CanAddVideoOutput(Camera_VideoOutput* videoOutput, bool* isSuccessful)
632 {
633 sptr<CaptureOutput> innerVideoOutput = videoOutput->GetInnerVideoOutput();
634 *isSuccessful = innerCaptureSession_->CanAddOutput(innerVideoOutput);
635 return CAMERA_OK;
636 }
637
CanPreconfig(Camera_PreconfigType preconfigType,bool * canPreconfig)638 Camera_ErrorCode Camera_CaptureSession::CanPreconfig(Camera_PreconfigType preconfigType, bool* canPreconfig)
639 {
640 auto itr = g_ndkToFwPreconfig.find(preconfigType);
641 if (itr == g_ndkToFwPreconfig.end()) {
642 MEDIA_ERR_LOG("Camera_CaptureSession::CanPreconfig preconfigType: [%{public}d] is invalid!", preconfigType);
643 *canPreconfig = false;
644 return CAMERA_INVALID_ARGUMENT;
645 }
646
647 *canPreconfig = innerCaptureSession_->CanPreconfig(itr->second, ProfileSizeRatio::UNSPECIFIED);
648 return CAMERA_OK;
649 }
650
CanPreconfigWithRatio(Camera_PreconfigType preconfigType,Camera_PreconfigRatio preconfigRatio,bool * canPreconfig)651 Camera_ErrorCode Camera_CaptureSession::CanPreconfigWithRatio(Camera_PreconfigType preconfigType,
652 Camera_PreconfigRatio preconfigRatio, bool* canPreconfig)
653 {
654 auto type = g_ndkToFwPreconfig.find(preconfigType);
655 auto ratio = g_ndkToFwPreconfigRatio.find(preconfigRatio);
656 if (type == g_ndkToFwPreconfig.end() || ratio == g_ndkToFwPreconfigRatio.end()) {
657 MEDIA_ERR_LOG("Camera_CaptureSession::CanPreconfigWithRatio preconfigType: [%{public}d] "
658 "or preconfigRatio: [%{public}d] is invalid!", preconfigType, preconfigRatio);
659 *canPreconfig = false;
660 return CAMERA_INVALID_ARGUMENT;
661 }
662
663 *canPreconfig = innerCaptureSession_->CanPreconfig(type->second, ratio->second);
664 return CAMERA_OK;
665 }
666
Preconfig(Camera_PreconfigType preconfigType)667 Camera_ErrorCode Camera_CaptureSession::Preconfig(Camera_PreconfigType preconfigType)
668 {
669 auto itr = g_ndkToFwPreconfig.find(preconfigType);
670 CHECK_AND_RETURN_RET_LOG(itr != g_ndkToFwPreconfig.end(), CAMERA_INVALID_ARGUMENT,
671 "Camera_CaptureSession::Preconfig preconfigType: [%{public}d] is invalid!", preconfigType);
672
673 int32_t ret = innerCaptureSession_->Preconfig(itr->second, ProfileSizeRatio::UNSPECIFIED);
674 return FrameworkToNdkCameraError(ret);
675 }
676
PreconfigWithRatio(Camera_PreconfigType preconfigType,Camera_PreconfigRatio preconfigRatio)677 Camera_ErrorCode Camera_CaptureSession::PreconfigWithRatio(Camera_PreconfigType preconfigType,
678 Camera_PreconfigRatio preconfigRatio)
679 {
680 auto type = g_ndkToFwPreconfig.find(preconfigType);
681 auto ratio = g_ndkToFwPreconfigRatio.find(preconfigRatio);
682 CHECK_AND_RETURN_RET_LOG(type != g_ndkToFwPreconfig.end(), CAMERA_INVALID_ARGUMENT,
683 "Camera_CaptureSession::PreconfigWithRatio preconfigType: [%{public}d] is invalid!", preconfigType);
684 CHECK_AND_RETURN_RET_LOG(ratio != g_ndkToFwPreconfigRatio.end(), CAMERA_INVALID_ARGUMENT,
685 "Camera_CaptureSession::PreconfigWithRatio preconfigRatio: [%{public}d] is invalid!", preconfigRatio);
686
687 int32_t ret = innerCaptureSession_->Preconfig(type->second, ratio->second);
688 return FrameworkToNdkCameraError(ret);
689 }
690
GetExposureValue(float * exposureValue)691 Camera_ErrorCode Camera_CaptureSession::GetExposureValue(float* exposureValue)
692 {
693 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetExposureValue is called");
694
695 int32_t ret = innerCaptureSession_->GetExposureValue(*exposureValue);
696 return FrameworkToNdkCameraError(ret);
697 }
698
GetFocalLength(float * focalLength)699 Camera_ErrorCode Camera_CaptureSession::GetFocalLength(float* focalLength)
700 {
701 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetFocalLength is called");
702
703 int32_t ret = innerCaptureSession_->GetFocalLength(*focalLength);
704 return FrameworkToNdkCameraError(ret);
705 }
706
SetSmoothZoom(float targetZoom,Camera_SmoothZoomMode smoothZoomMode)707 Camera_ErrorCode Camera_CaptureSession::SetSmoothZoom(float targetZoom, Camera_SmoothZoomMode smoothZoomMode)
708 {
709 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetSmoothZoom is called");
710
711 int32_t ret = innerCaptureSession_->SetSmoothZoom(targetZoom, static_cast<uint32_t>(smoothZoomMode));
712 return FrameworkToNdkCameraError(ret);
713 }
714
GetSupportedColorSpaces(OH_NativeBuffer_ColorSpace ** colorSpace,uint32_t * size)715 Camera_ErrorCode Camera_CaptureSession::GetSupportedColorSpaces(OH_NativeBuffer_ColorSpace** colorSpace,
716 uint32_t* size)
717 {
718 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetSupportedColorSpaces is called");
719
720 auto colorSpaces = innerCaptureSession_->GetSupportedColorSpaces();
721 if (colorSpaces.empty()) {
722 MEDIA_ERR_LOG("Supported ColorSpace is empty!");
723 *size = 0;
724 return CAMERA_OK;
725 }
726
727 std::vector<OH_NativeBuffer_ColorSpace> cameraColorSpace;
728 for (size_t i = 0; i < colorSpaces.size(); ++i) {
729 auto itr = g_fwToNdkColorSpace_.find(colorSpaces[i]);
730 if (itr != g_fwToNdkColorSpace_.end()) {
731 cameraColorSpace.push_back(itr->second);
732 }
733 }
734
735 if (cameraColorSpace.size() == 0) {
736 MEDIA_ERR_LOG("Supported ColorSpace is empty!");
737 *size = 0;
738 return CAMERA_OK;
739 }
740
741 OH_NativeBuffer_ColorSpace* newColorSpace = new OH_NativeBuffer_ColorSpace[cameraColorSpace.size()];
742 CHECK_AND_RETURN_RET_LOG(newColorSpace != nullptr, CAMERA_SERVICE_FATAL_ERROR,
743 "Failed to allocate memory for color space!");
744 for (size_t index = 0; index < cameraColorSpace.size(); index++) {
745 newColorSpace[index] = cameraColorSpace[index];
746 }
747
748 *size = cameraColorSpace.size();
749 *colorSpace = newColorSpace;
750 return CAMERA_OK;
751 }
752
DeleteColorSpaces(OH_NativeBuffer_ColorSpace * colorSpace)753 Camera_ErrorCode Camera_CaptureSession::DeleteColorSpaces(OH_NativeBuffer_ColorSpace* colorSpace)
754 {
755 if (colorSpace != nullptr) {
756 delete[] colorSpace;
757 colorSpace = nullptr;
758 }
759
760 return CAMERA_OK;
761 }
762
GetActiveColorSpace(OH_NativeBuffer_ColorSpace * colorSpace)763 Camera_ErrorCode Camera_CaptureSession::GetActiveColorSpace(OH_NativeBuffer_ColorSpace* colorSpace)
764 {
765 MEDIA_DEBUG_LOG("Camera_CaptureSession::GetActiveColorSpace is called");
766
767 ColorSpace innerColorSpace;
768 int32_t ret = innerCaptureSession_->GetActiveColorSpace(innerColorSpace);
769 if (ret != SUCCESS) {
770 return FrameworkToNdkCameraError(ret);
771 }
772 auto itr = g_fwToNdkColorSpace_.find(innerColorSpace);
773 if (itr != g_fwToNdkColorSpace_.end()) {
774 *colorSpace = itr->second;
775 } else {
776 MEDIA_ERR_LOG("colorSpace[%{public}d] is invalid", innerColorSpace);
777 return CAMERA_SERVICE_FATAL_ERROR;
778 }
779 return CAMERA_OK;
780 }
781
SetActiveColorSpace(OH_NativeBuffer_ColorSpace colorSpace)782 Camera_ErrorCode Camera_CaptureSession::SetActiveColorSpace(OH_NativeBuffer_ColorSpace colorSpace)
783 {
784 MEDIA_DEBUG_LOG("Camera_CaptureSession::SetActiveColorSpace is called");
785
786 auto itr = g_ndkToFwColorSpace_.find(colorSpace);
787 if (itr == g_ndkToFwColorSpace_.end()) {
788 MEDIA_ERR_LOG("colorSpace[%{public}d] is invalid", colorSpace);
789 return CAMERA_INVALID_ARGUMENT;
790 }
791 int32_t ret = innerCaptureSession_->SetColorSpace(itr->second);
792 return FrameworkToNdkCameraError(ret);
793 }
794
RegisterAutoDeviceSwitchStatusCallback(OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)795 Camera_ErrorCode Camera_CaptureSession::RegisterAutoDeviceSwitchStatusCallback(
796 OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)
797 {
798 shared_ptr<InnerCaptureSessionAutoDeviceSwitchStatusCallback> innerDeviceSwitchStatusCallback =
799 make_shared<InnerCaptureSessionAutoDeviceSwitchStatusCallback>(this, autoDeviceSwitchStatusChange);
800 CHECK_AND_RETURN_RET_LOG(innerDeviceSwitchStatusCallback != nullptr, CAMERA_SERVICE_FATAL_ERROR,
801 "create innerCallback failed!");
802 innerCaptureSession_->SetAutoDeviceSwitchCallback(innerDeviceSwitchStatusCallback);
803 return CAMERA_OK;
804 }
805
UnregisterAutoDeviceSwitchStatusCallback(OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)806 Camera_ErrorCode Camera_CaptureSession::UnregisterAutoDeviceSwitchStatusCallback(
807 OH_CaptureSession_OnAutoDeviceSwitchStatusChange autoDeviceSwitchStatusChange)
808 {
809 innerCaptureSession_->SetAutoDeviceSwitchCallback(nullptr);
810 return CAMERA_OK;
811 }
812
IsAutoDeviceSwitchSupported(bool * isSupported)813 Camera_ErrorCode Camera_CaptureSession::IsAutoDeviceSwitchSupported(bool* isSupported)
814 {
815 MEDIA_DEBUG_LOG("Camera_CaptureSession::IsAutoDeviceSwitchSupported is called");
816 *isSupported = innerCaptureSession_->IsAutoDeviceSwitchSupported();
817 return CAMERA_OK;
818 }
819
EnableAutoDeviceSwitch(bool enabled)820 Camera_ErrorCode Camera_CaptureSession::EnableAutoDeviceSwitch(bool enabled)
821 {
822 MEDIA_DEBUG_LOG("Camera_CaptureSession::EnableAutoDeviceSwitch is called");
823 int32_t ret = innerCaptureSession_->EnableAutoDeviceSwitch(enabled);
824 return FrameworkToNdkCameraError(ret);
825 }
826
SetQualityPrioritization(Camera_QualityPrioritization qualityPrioritization)827 Camera_ErrorCode Camera_CaptureSession::SetQualityPrioritization(Camera_QualityPrioritization qualityPrioritization)
828 {
829 MEDIA_INFO_LOG("Camera_CaptureSession::SetQualityPrioritization is called");
830 QualityPrioritization innerQualityPrioritization = static_cast<QualityPrioritization>(qualityPrioritization);
831 innerCaptureSession_->LockForControl();
832 int32_t ret = innerCaptureSession_->SetQualityPrioritization(innerQualityPrioritization);
833 innerCaptureSession_->UnlockForControl();
834 return FrameworkToNdkCameraError(ret);
835 }
836