1 /*
2 * Copyright (c) 2021-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef OHOS_CAMERA_CAPTURE_SESSION_H
17 #define OHOS_CAMERA_CAPTURE_SESSION_H
18
19 #include <atomic>
20 #include <cstdint>
21 #include <iostream>
22 #include <map>
23 #include <memory>
24 #include <mutex>
25 #include <set>
26 #include <sstream>
27 #include <string>
28 #include <unordered_map>
29 #include <vector>
30
31 #include "camera_error_code.h"
32 #include "camera_photo_proxy.h"
33 #include "capture_scene_const.h"
34 #include "color_space_info_parse.h"
35 #include "control_center_effect_status_callback_stub.h"
36 #include "features/moon_capture_boost_feature.h"
37 #include "capture_session_callback_stub.h"
38 #include "camera_service_callback_stub.h"
39 #include "icamera_util.h"
40 #include "icapture_session.h"
41 #include "icapture_session_callback.h"
42 #include "input/camera_death_recipient.h"
43 #include "input/capture_input.h"
44 #include "output/camera_output_capability.h"
45 #include "output/capture_output.h"
46 #include "refbase.h"
47 #include "effect_suggestion_info_parse.h"
48 #include "capture_scene_const.h"
49 #include "ability/camera_ability.h"
50 #include "ability/camera_ability_parse_util.h"
51 #include "fold_service_callback_stub.h"
52 #include "pressure_status_callback_stub.h"
53 #include "camera_common_struct.h"
54
55 namespace OHOS {
56 namespace CameraStandard {
57
58 using Point = CameraPoint;
59
60 enum FocusState {
61 FOCUS_STATE_SCAN = 0,
62 FOCUS_STATE_FOCUSED,
63 FOCUS_STATE_UNFOCUSED
64 };
65
66 enum ExposureState {
67 EXPOSURE_STATE_SCAN = 0,
68 EXPOSURE_STATE_CONVERGED
69 };
70
71 enum FilterType {
72 NONE = 0,
73 CLASSIC = 1,
74 DAWN = 2,
75 PURE = 3,
76 GREY = 4,
77 NATURAL = 5,
78 MORI = 6,
79 FAIR = 7,
80 PINK = 8,
81 };
82
83 enum PreconfigType : int32_t {
84 PRECONFIG_720P = 0,
85 PRECONFIG_1080P = 1,
86 PRECONFIG_4K = 2,
87 PRECONFIG_HIGH_QUALITY = 3
88 };
89
90 enum UsageType {
91 BOKEH = 0
92 };
93
94 enum FocusTrackingMode : int32_t {
95 FOCUS_TRACKING_MODE_AUTO = 0,
96 FOCUS_TRACKING_MODE_LOCKED,
97 };
98
99 struct PreconfigProfiles {
100 public:
PreconfigProfilesPreconfigProfiles101 explicit PreconfigProfiles(ColorSpace colorSpace) : colorSpace(colorSpace) {}
102 Profile previewProfile;
103 Profile photoProfile;
104 VideoProfile videoProfile;
105 ColorSpace colorSpace;
106
ToStringPreconfigProfiles107 std::string ToString()
108 {
109 std::ostringstream oss;
110 oss << "colorSpace:[" << to_string(colorSpace);
111 oss << "]\n";
112
113 oss << "previewProfile:[";
114 oss << " format:" << to_string(previewProfile.format_);
115 oss << " size:" << to_string(previewProfile.size_.width) << "x" << to_string(previewProfile.size_.height);
116 oss << " fps:" << to_string(previewProfile.fps_.minFps) << "," << to_string(previewProfile.fps_.maxFps) << ","
117 << to_string(previewProfile.fps_.fixedFps);
118 oss << "]\n";
119
120 oss << "photoProfile:[";
121 oss << " format:" << to_string(photoProfile.format_);
122 oss << " size:" << to_string(photoProfile.size_.width) << "x" << to_string(photoProfile.size_.height);
123 oss << " dynamic:" << to_string(photoProfile.sizeFollowSensorMax_) << "," << to_string(photoProfile.sizeRatio_);
124 oss << "]\n";
125
126 oss << "videoProfile:[";
127 oss << " format:" << to_string(videoProfile.format_);
128 oss << " size:" << to_string(videoProfile.size_.width) << "x" << to_string(videoProfile.size_.height);
129 oss << " frameRates:";
130 for (auto& fps : videoProfile.framerates_) {
131 oss << to_string(fps) << " ";
132 }
133 oss << "]\n";
134 return oss.str();
135 }
136 };
137
138 enum EffectSuggestionType {
139 EFFECT_SUGGESTION_NONE = 0,
140 EFFECT_SUGGESTION_PORTRAIT,
141 EFFECT_SUGGESTION_FOOD,
142 EFFECT_SUGGESTION_SKY,
143 EFFECT_SUGGESTION_SUNRISE_SUNSET,
144 EFFECT_SUGGESTION_STAGE
145 };
146
147 typedef enum {
148 AWB_MODE_AUTO = 0,
149 AWB_MODE_CLOUDY_DAYLIGHT,
150 AWB_MODE_INCANDESCENT,
151 AWB_MODE_FLUORESCENT,
152 AWB_MODE_DAYLIGHT,
153 AWB_MODE_OFF,
154 AWB_MODE_LOCKED,
155 AWB_MODE_WARM_FLUORESCENT,
156 AWB_MODE_TWILIGHT,
157 AWB_MODE_SHADE,
158 } WhiteBalanceMode;
159
160 enum LightPaintingType {
161 CAR = 0,
162 STAR,
163 WATER,
164 LIGHT
165 };
166
167 enum class FwkTripodStatus {
168 INVALID = 0,
169 ACTIVE,
170 ENTER,
171 EXITING
172 };
173
174 typedef struct {
175 float zoomRatio;
176 int32_t equivalentFocalLength;
177 } ZoomPointInfo;
178
179 template<class T>
180 struct RefBaseCompare {
181 public:
operatorRefBaseCompare182 bool operator()(const wptr<T>& firstPtr, const wptr<T>& secondPtr) const
183 {
184 return firstPtr.GetRefPtr() < secondPtr.GetRefPtr();
185 }
186 };
187
188 class SessionCallback {
189 public:
190 SessionCallback() = default;
191 virtual ~SessionCallback() = default;
192 /**
193 * @brief Called when error occured during capture session callback.
194 *
195 * @param errorCode Indicates a {@link ErrorCode} which will give information for capture session callback error.
196 */
197 virtual void OnError(int32_t errorCode) = 0;
198 };
199
200 class PressureCallback {
201 public:
202 PressureCallback() = default;
203 virtual ~PressureCallback() = default;
204 /**
205 * @brief Called when pressure status changed during capture session callback.
206 *
207 * @param status Indicates the pressure status.
208 */
209 virtual void OnPressureStatusChanged(PressureStatus status) = 0;
210 };
211
212 class ControlCenterEffectCallback {
213 public:
214 ControlCenterEffectCallback() = default;
215 virtual ~ControlCenterEffectCallback() = default;
216 /**
217 * @brief Called when control center effect status changed during capture session callback.
218 *
219 * @param status Indicates the control center effect status.
220 */
221 virtual void OnControlCenterEffectStatusChanged(ControlCenterStatusInfo status) = 0;
222 };
223
224 class ExposureCallback {
225 public:
226 enum ExposureState {
227 SCAN = 0,
228 CONVERGED,
229 };
230 ExposureCallback() = default;
231 virtual ~ExposureCallback() = default;
232 virtual void OnExposureState(ExposureState state) = 0;
233 };
234
235 class FocusCallback {
236 public:
237 enum FocusState {
238 SCAN = 0,
239 FOCUSED,
240 UNFOCUSED
241 };
242 FocusCallback() = default;
243 virtual ~FocusCallback() = default;
244 virtual void OnFocusState(FocusState state) = 0;
245 FocusState currentState;
246 };
247
248 class MacroStatusCallback {
249 public:
250 enum MacroStatus { IDLE = 0, ACTIVE, UNKNOWN };
251 MacroStatusCallback() = default;
252 virtual ~MacroStatusCallback() = default;
253 virtual void OnMacroStatusChanged(MacroStatus status) = 0;
254 MacroStatus currentStatus = UNKNOWN;
255 };
256
257 class MoonCaptureBoostStatusCallback {
258 public:
259 enum MoonCaptureBoostStatus { IDLE = 0, ACTIVE, UNKNOWN };
260 MoonCaptureBoostStatusCallback() = default;
261 virtual ~MoonCaptureBoostStatusCallback() = default;
262 virtual void OnMoonCaptureBoostStatusChanged(MoonCaptureBoostStatus status) = 0;
263 MoonCaptureBoostStatus currentStatus = UNKNOWN;
264 };
265
266 class FeatureDetectionStatusCallback {
267 public:
268 enum FeatureDetectionStatus { IDLE = 0, ACTIVE, UNKNOWN };
269
270 FeatureDetectionStatusCallback() = default;
271 virtual ~FeatureDetectionStatusCallback() = default;
272 virtual void OnFeatureDetectionStatusChanged(SceneFeature feature, FeatureDetectionStatus status) = 0;
273 virtual bool IsFeatureSubscribed(SceneFeature feature) = 0;
274
UpdateStatus(SceneFeature feature,FeatureDetectionStatus status)275 inline bool UpdateStatus(SceneFeature feature, FeatureDetectionStatus status)
276 {
277 std::lock_guard<std::mutex> lock(featureStatusMapMutex_);
278 auto it = featureStatusMap_.find(feature);
279 if (it == featureStatusMap_.end()) {
280 featureStatusMap_[feature] = status;
281 return true;
282 } else if (it->second != status) {
283 it->second = status;
284 return true;
285 }
286 return false;
287 }
288
SetFeatureStatus(int8_t featureStatus)289 inline void SetFeatureStatus(int8_t featureStatus)
290 {
291 featureStatus_ = featureStatus;
292 }
293
GetFeatureStatus()294 inline int8_t GetFeatureStatus() const
295 {
296 return featureStatus_;
297 }
298 private:
299 std::atomic<int8_t> featureStatus_ = -1;
300 std::mutex featureStatusMapMutex_;
301 std::unordered_map<SceneFeature, FeatureDetectionStatus> featureStatusMap_;
302 };
303
304 class CaptureSessionCallback : public CaptureSessionCallbackStub {
305 public:
306 CaptureSession* captureSession_ = nullptr;
CaptureSessionCallback()307 CaptureSessionCallback() : captureSession_(nullptr) {}
308
CaptureSessionCallback(CaptureSession * captureSession)309 explicit CaptureSessionCallback(CaptureSession* captureSession) : captureSession_(captureSession) {}
310
~CaptureSessionCallback()311 ~CaptureSessionCallback()
312 {
313 captureSession_ = nullptr;
314 }
315
316 int32_t OnError(int32_t errorCode) override;
317 };
318
319 class PressureStatusCallback : public PressureStatusCallbackStub {
320 public:
321 CaptureSession* captureSession_ = nullptr;
PressureStatusCallback()322 PressureStatusCallback() : captureSession_(nullptr) {}
323
PressureStatusCallback(CaptureSession * captureSession)324 explicit PressureStatusCallback(CaptureSession* captureSession) : captureSession_(captureSession) {}
325
~PressureStatusCallback()326 ~PressureStatusCallback()
327 {
328 captureSession_ = nullptr;
329 }
330
331 int32_t OnPressureStatusChanged(PressureStatus status) override;
332 };
333
334 class ControlCenterEffectStatusCallback : public ControlCenterEffectStatusCallbackStub {
335 public:
336 wptr<CaptureSession> captureSession_;
ControlCenterEffectStatusCallback()337 ControlCenterEffectStatusCallback() : captureSession_() {}
338
ControlCenterEffectStatusCallback(wptr<CaptureSession> captureSession)339 explicit ControlCenterEffectStatusCallback(wptr<CaptureSession> captureSession)
340 : captureSession_(captureSession) {}
341
342 int32_t OnControlCenterEffectStatusChanged(const ControlCenterStatusInfo& statusInfo) override;
343 };
344
345 class SmoothZoomCallback {
346 public:
347 SmoothZoomCallback() = default;
348 virtual ~SmoothZoomCallback() = default;
349 virtual void OnSmoothZoom(int32_t duration) = 0;
350 };
351
352 class AbilityCallback {
353 public:
354 AbilityCallback() = default;
355 virtual ~AbilityCallback() = default;
356 virtual void OnAbilityChange() = 0;
357 };
358
359 struct ARStatusInfo {
360 std::vector<int32_t> laserData;
361 float lensFocusDistance;
362 int32_t sensorSensitivity;
363 uint32_t exposureDurationValue;
364 int64_t timestamp;
365 };
366
367 class ARCallback {
368 public:
369 ARCallback() = default;
370 virtual ~ARCallback() = default;
371 virtual void OnResult(const ARStatusInfo &arStatusInfo) const = 0;
372 };
373
374 class EffectSuggestionCallback {
375 public:
376 EffectSuggestionCallback() = default;
377 virtual ~EffectSuggestionCallback() = default;
378 virtual void OnEffectSuggestionChange(EffectSuggestionType effectSuggestionType) = 0;
379 bool isFirstReport = true;
380 EffectSuggestionType currentType = EffectSuggestionType::EFFECT_SUGGESTION_NONE;
381 };
382
383 struct LcdFlashStatusInfo {
384 bool isLcdFlashNeeded;
385 int32_t lcdCompensation;
386 };
387
388 class LcdFlashStatusCallback {
389 public:
390 LcdFlashStatusCallback() = default;
391 virtual ~LcdFlashStatusCallback() = default;
392 virtual void OnLcdFlashStatusChanged(LcdFlashStatusInfo lcdFlashStatusInfo) = 0;
SetLcdFlashStatusInfo(const LcdFlashStatusInfo lcdFlashStatusInfo)393 void SetLcdFlashStatusInfo(const LcdFlashStatusInfo lcdFlashStatusInfo)
394 {
395 std::lock_guard<std::mutex> lock(mutex_);
396 lcdFlashStatusInfo_ = lcdFlashStatusInfo;
397 }
GetLcdFlashStatusInfo()398 LcdFlashStatusInfo GetLcdFlashStatusInfo()
399 {
400 std::lock_guard<std::mutex> lock(mutex_);
401 return lcdFlashStatusInfo_;
402 }
403
404 private:
405 LcdFlashStatusInfo lcdFlashStatusInfo_ = { .isLcdFlashNeeded = true, .lcdCompensation = -1 };
406 std::mutex mutex_;
407 };
408
409 class AutoDeviceSwitchCallback {
410 public:
411 AutoDeviceSwitchCallback() = default;
412 virtual ~AutoDeviceSwitchCallback() = default;
413 virtual void OnAutoDeviceSwitchStatusChange(bool isDeviceSwitched, bool isDeviceCapabilityChanged) const = 0 ;
414 };
415
416 class FoldCallback : public FoldServiceCallbackStub {
417 public:
FoldCallback(wptr<CaptureSession> captureSession)418 explicit FoldCallback(wptr<CaptureSession> captureSession) : captureSession_(captureSession) {}
419 int32_t OnFoldStatusChanged(const FoldStatus status) override;
420
421 private:
422 wptr<CaptureSession> captureSession_ = nullptr;
423 };
424
425 struct EffectSuggestionStatus {
426 EffectSuggestionType type;
427 bool status;
428 };
429
FloatIsEqual(float x,float y)430 inline bool FloatIsEqual(float x, float y)
431 {
432 const float EPSILON = 0.000001;
433 return std::fabs(x - y) < EPSILON;
434 }
435
ConfusingNumber(float data)436 inline float ConfusingNumber(float data)
437 {
438 const float factor = 20;
439 return data * factor;
440 }
441
442 class CaptureSession : public RefBase {
443 public:
444 class CaptureSessionMetadataResultProcessor : public MetadataResultProcessor {
445 public:
CaptureSessionMetadataResultProcessor(wptr<CaptureSession> session)446 explicit CaptureSessionMetadataResultProcessor(wptr<CaptureSession> session) : session_(session) {}
447 void ProcessCallbacks(
448 const uint64_t timestamp, const std::shared_ptr<OHOS::Camera::CameraMetadata>& result) override;
449
450 private:
451 wptr<CaptureSession> session_;
452 };
453
454 explicit CaptureSession(sptr<ICaptureSession>& captureSession);
455 virtual ~CaptureSession();
456
457 /**
458 * @brief Begin the capture session config.
459 */
460 int32_t BeginConfig();
461
462 /**
463 * @brief Commit the capture session config.
464 */
465 virtual int32_t CommitConfig();
466
467 /**
468 * @brief Determine if the given Input can be added to session.
469 *
470 * @param CaptureInput to be added to session.
471 */
472 virtual bool CanAddInput(sptr<CaptureInput>& input);
473
474 /**
475 * @brief Add CaptureInput for the capture session.
476 *
477 * @param CaptureInput to be added to session.
478 */
479 int32_t AddInput(sptr<CaptureInput>& input);
480
481 /**
482 * @brief Determine if the given Ouput can be added to session.
483 *
484 * @param CaptureOutput to be added to session.
485 */
486 virtual bool CanAddOutput(sptr<CaptureOutput>& output);
487
488 /**
489 * @brief Add CaptureOutput for the capture session.
490 *
491 * @param CaptureOutput to be added to session.
492 */
493 virtual int32_t AddOutput(sptr<CaptureOutput> &output);
494
495 /**
496 * @brief Remove CaptureInput for the capture session.
497 *
498 * @param CaptureInput to be removed from session.
499 */
500 int32_t RemoveInput(sptr<CaptureInput>& input);
501
502 /**
503 * @brief Remove CaptureOutput for the capture session.
504 *
505 * @param CaptureOutput to be removed from session.
506 */
507 int32_t RemoveOutput(sptr<CaptureOutput>& output);
508
509 /**
510 * @brief Starts session and preview.
511 */
512 int32_t Start();
513
514 /**
515 * @brief Stop session and preview..
516 */
517 int32_t Stop();
518
519 /**
520 * @brief Set the session callback for the capture session.
521 *
522 * @param SessionCallback pointer to be triggered.
523 */
524 void SetCallback(std::shared_ptr<SessionCallback> callback);
525
526 /**
527 * @brief Set the pressure callback for the capture session.
528 *
529 * @param PressureCallback pointer to be triggered.
530 */
531 void SetPressureCallback(std::shared_ptr<PressureCallback>);
532
533 /**
534 * @brief Set the control center effect status callback for the capture session.
535 *
536 * @param ControlCenterEffectStatusCallback pointer to be triggered.
537 */
538 void SetControlCenterEffectStatusCallback(std::shared_ptr<ControlCenterEffectCallback> callback);
539
540 /**
541 * @brief Unset the control center effect status callback for the capture session.
542 */
543 void UnSetControlCenterEffectStatusCallback();
544
545 /**
546 * @brief Get the application callback information.
547 *
548 * @return Returns the pointer to SessionCallback set by application.
549 */
550 std::shared_ptr<SessionCallback> GetApplicationCallback();
551
552 /**
553 * @brief Get the pressure callback information.
554 *
555 * @return Returns the pointer to PressureCallback set by application.
556 */
557 std::shared_ptr<PressureCallback> GetPressureCallback();
558
559 /**
560 * @brief Get the control center effect callback information.
561 *
562 * @return Returns the pointer to ControlCenterEffectCallback set by application.
563 */
564 std::shared_ptr<ControlCenterEffectCallback> GetControlCenterEffectCallback();
565
566 /**
567 * @brief Get the ExposureCallback.
568 *
569 * @return Returns the pointer to ExposureCallback.
570 */
571 std::shared_ptr<ExposureCallback> GetExposureCallback();
572
573 /**
574 * @brief Get the FocusCallback.
575 *
576 * @return Returns the pointer to FocusCallback.
577 */
578 std::shared_ptr<FocusCallback> GetFocusCallback();
579
580 /**
581 * @brief Get the MacroStatusCallback.
582 *
583 * @return Returns the pointer to MacroStatusCallback.
584 */
585 std::shared_ptr<MacroStatusCallback> GetMacroStatusCallback();
586
587 /**
588 * @brief Get the MoonCaptureBoostStatusCallback.
589 *
590 * @return Returns the pointer to MoonCaptureBoostStatusCallback.
591 */
592 std::shared_ptr<MoonCaptureBoostStatusCallback> GetMoonCaptureBoostStatusCallback();
593
594 /**
595 * @brief Get the FeatureDetectionStatusCallback.
596 *
597 * @return Returns the pointer to FeatureDetectionStatusCallback.
598 */
599 std::shared_ptr<FeatureDetectionStatusCallback> GetFeatureDetectionStatusCallback();
600
601 /**
602 * @brief Get the SmoothZoomCallback.
603 *
604 * @return Returns the pointer to SmoothZoomCallback.
605 */
606 std::shared_ptr<SmoothZoomCallback> GetSmoothZoomCallback();
607
608 /**
609 * @brief Releases CaptureSession instance.
610 * @return Returns errCode.
611 */
612 int32_t Release();
613
614 /**
615 * @brief create new device control setting.
616 */
617 void LockForControl();
618
619 /**
620 * @brief submit device control setting.
621 *
622 * @return Returns CAMERA_OK is success.
623 */
624 int32_t UnlockForControl();
625
626 /**
627 * @brief Get the supported video sabilization modes.
628 *
629 * @return Returns vector of CameraVideoStabilizationMode supported stabilization modes.
630 */
631 std::vector<VideoStabilizationMode> GetSupportedStabilizationMode();
632
633 /**
634 * @brief Get the supported video sabilization modes.
635 * @param vector of CameraVideoStabilizationMode supported stabilization modes.
636 * @return Returns errCode.
637 */
638 int32_t GetSupportedStabilizationMode(std::vector<VideoStabilizationMode>& modes);
639
640 /**
641 * @brief Query whether given stabilization mode supported.
642 *
643 * @param VideoStabilizationMode stabilization mode to query.
644 * @return True is supported false otherwise.
645 */
646 bool IsVideoStabilizationModeSupported(VideoStabilizationMode stabilizationMode);
647
648 /**
649 * @brief Query whether given stabilization mode supported.
650 *
651 * @param VideoStabilizationMode stabilization mode to query.
652 * @param bool True is supported false otherwise.
653 * @return errCode.
654 */
655 int32_t IsVideoStabilizationModeSupported(VideoStabilizationMode stabilizationMode, bool& isSupported);
656
657 /**
658 * @brief Get the current Video Stabilizaion mode.
659 *
660 * @return Returns current Video Stabilizaion mode.
661 */
662 VideoStabilizationMode GetActiveVideoStabilizationMode();
663
664 /**
665 * @brief Get the current Video Stabilizaion mode.
666 * @param current Video Stabilizaion mode.
667 * @return errCode
668 */
669 int32_t GetActiveVideoStabilizationMode(VideoStabilizationMode& mode);
670
671 /**
672 * @brief Set the Video Stabilizaion mode.
673 * @param VideoStabilizationMode stabilization mode to set.
674 * @return errCode
675 */
676 int32_t SetVideoStabilizationMode(VideoStabilizationMode stabilizationMode);
677
678 /**
679 * @brief Get the supported exposure modes.
680 *
681 * @return Returns vector of ExposureMode supported exposure modes.
682 */
683 std::vector<ExposureMode> GetSupportedExposureModes();
684
685 /**
686 * @brief Get the supported exposure modes.
687 * @param vector of ExposureMode supported exposure modes.
688 * @return errCode.
689 */
690 int32_t GetSupportedExposureModes(std::vector<ExposureMode>& exposureModes);
691
692 /**
693 * @brief Query whether given exposure mode supported.
694 *
695 * @param ExposureMode exposure mode to query.
696 * @return True is supported false otherwise.
697 */
698 bool IsExposureModeSupported(ExposureMode exposureMode);
699
700 /**
701 * @brief Query whether given exposure mode supported.
702 *
703 * @param ExposureMode exposure mode to query.
704 * @param bool True is supported false otherwise.
705 * @return errCode.
706 */
707 int32_t IsExposureModeSupported(ExposureMode exposureMode, bool& isSupported);
708
709 /**
710 * @brief Set exposure mode.
711 * @param ExposureMode exposure mode to be set.
712 * @return errCode
713 */
714 int32_t SetExposureMode(ExposureMode exposureMode);
715
716 /**
717 * @brief Get the current exposure mode.
718 *
719 * @return Returns current exposure mode.
720 */
721 ExposureMode GetExposureMode();
722
723 /**
724 * @brief Get the current exposure mode.
725 * @param ExposureMode current exposure mode.
726 * @return errCode.
727 */
728 int32_t GetExposureMode(ExposureMode& exposureMode);
729
730 /**
731 * @brief Set the centre point of exposure area.
732 * @param Point which specifies the area to expose.
733 * @return errCode
734 */
735 int32_t SetMeteringPoint(Point exposurePoint);
736
737 /**
738 * @brief Get centre point of exposure area.
739 *
740 * @return Returns current exposure point.
741 */
742 Point GetMeteringPoint();
743
744 /**
745 * @brief Get centre point of exposure area.
746 * @param Point current exposure point.
747 * @return errCode
748 */
749 int32_t GetMeteringPoint(Point& exposurePoint);
750
751 /**
752 * @brief Get exposure compensation range.
753 *
754 * @return Returns supported exposure compensation range.
755 */
756 std::vector<float> GetExposureBiasRange();
757
758 /**
759 * @brief Get exposure compensation range.
760 * @param vector of exposure bias range.
761 * @return errCode.
762 */
763 int32_t GetExposureBiasRange(std::vector<float>& exposureBiasRange);
764
765 /**
766 * @brief Set exposure compensation value.
767 * @param exposure compensation value to be set.
768 * @return errCode.
769 */
770 int32_t SetExposureBias(float exposureBias);
771
772 /**
773 * @brief Get exposure compensation value.
774 *
775 * @return Returns current exposure compensation value.
776 */
777 float GetExposureValue();
778
779 /**
780 * @brief Get exposure compensation value.
781 * @param exposure current exposure compensation value .
782 * @return Returns errCode.
783 */
784 int32_t GetExposureValue(float& exposure);
785
786 /**
787 * @brief Set the exposure callback.
788 * which will be called when there is exposure state change.
789 *
790 * @param The ExposureCallback pointer.
791 */
792 void SetExposureCallback(std::shared_ptr<ExposureCallback> exposureCallback);
793
794 /**
795 * @brief This function is called when there is exposure state change
796 * and process the exposure state callback.
797 *
798 * @param result metadata got from callback from service layer.
799 */
800 void ProcessAutoExposureUpdates(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
801
802 /**
803 * @brief Get the supported Focus modes.
804 *
805 * @return Returns vector of FocusMode supported exposure modes.
806 */
807 std::vector<FocusMode> GetSupportedFocusModes();
808
809 /**
810 * @brief Get the supported Focus modes.
811 * @param vector of FocusMode supported.
812 * @return Returns errCode.
813 */
814 int32_t GetSupportedFocusModes(std::vector<FocusMode>& modes);
815
816 /**
817 * @brief Query whether given focus mode supported.
818 *
819 * @param camera_focus_mode_enum_t focus mode to query.
820 * @return True is supported false otherwise.
821 */
822 bool IsFocusModeSupported(FocusMode focusMode);
823
824 /**
825 * @brief Query whether given focus mode supported.
826 *
827 * @param camera_focus_mode_enum_t focus mode to query.
828 * @param bool True is supported false otherwise.
829 * @return Returns errCode.
830 */
831 int32_t IsFocusModeSupported(FocusMode focusMode, bool& isSupported);
832
833 /**
834 * @brief Set Focus mode.
835 *
836 * @param FocusMode focus mode to be set.
837 * @return Returns errCode.
838 */
839 int32_t SetFocusMode(FocusMode focusMode);
840
841 /**
842 * @brief Get the current focus mode.
843 *
844 * @return Returns current focus mode.
845 */
846 FocusMode GetFocusMode();
847
848 /**
849 * @brief Get the current focus mode.
850 * @param FocusMode current focus mode.
851 * @return Returns errCode.
852 */
853 int32_t GetFocusMode(FocusMode& focusMode);
854
855 /**
856 * @brief Set the focus callback.
857 * which will be called when there is focus state change.
858 *
859 * @param The ExposureCallback pointer.
860 */
861 void SetFocusCallback(std::shared_ptr<FocusCallback> focusCallback);
862
863 /**
864 * @brief This function is called when there is focus state change
865 * and process the focus state callback.
866 *
867 * @param result metadata got from callback from service layer.
868 */
869 void ProcessAutoFocusUpdates(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
870
871 /**
872 * @brief Set the Focus area.
873 *
874 * @param Point which specifies the area to focus.
875 * @return Returns errCode.
876 */
877 int32_t SetFocusPoint(Point focusPoint);
878
879 /**
880 * @brief Get centre point of focus area.
881 *
882 * @return Returns current focus point.
883 */
884 Point GetFocusPoint();
885
886 /**
887 * @brief Get centre point of focus area.
888 * @param Point current focus point.
889 * @return Returns errCode.
890 */
891 int32_t GetFocusPoint(Point& focusPoint);
892
893 /**
894 * @brief Get focal length.
895 *
896 * @return Returns focal length value.
897 */
898 float GetFocalLength();
899
900 /**
901 * @brief Get focal length.
902 * @param focalLength current focal length compensation value .
903 * @return Returns errCode.
904 */
905 int32_t GetFocalLength(float& focalLength);
906
907 /**
908 * @brief Get the vector of focus range types.
909 * @param types vector of focus range types.
910 * @return Returns errCode.
911 */
912 int32_t GetSupportedFocusRangeTypes(std::vector<FocusRangeType>& types);
913
914 /**
915 * @brief Get the vector of focus driven types.
916 * @param types vector of focus driven types.
917 * @return Returns errCode.
918 */
919 int32_t GetSupportedFocusDrivenTypes(std::vector<FocusDrivenType>& types);
920
921 /**
922 * @brief Set the smooth zoom callback.
923 * which will be called when there is smooth zoom change.
924 *
925 * @param The SmoothZoomCallback pointer.
926 */
927 void SetSmoothZoomCallback(std::shared_ptr<SmoothZoomCallback> smoothZoomCallback);
928
929 /**
930 * @brief Get the supported Focus modes.
931 *
932 * @return Returns vector of camera_focus_mode_enum_t supported exposure modes.
933 */
934 std::vector<FlashMode> GetSupportedFlashModes();
935
936 /**
937 * @brief Get the supported Focus modes.
938 * @param vector of camera_focus_mode_enum_t supported exposure modes.
939 * @return Returns errCode.
940 */
941 virtual int32_t GetSupportedFlashModes(std::vector<FlashMode>& flashModes);
942
943 /**
944 * @brief Check whether camera has flash.
945 */
946 bool HasFlash();
947
948 /**
949 * @brief Check whether camera has flash.
950 * @param bool True is has flash false otherwise.
951 * @return Returns errCode.
952 */
953 int32_t HasFlash(bool& hasFlash);
954
955 /**
956 * @brief Query whether given flash mode supported.
957 *
958 * @param camera_flash_mode_enum_t flash mode to query.
959 * @return True if supported false otherwise.
960 */
961 bool IsFlashModeSupported(FlashMode flashMode);
962
963 /**
964 * @brief Query whether given flash mode supported.
965 *
966 * @param camera_flash_mode_enum_t flash mode to query.
967 * @param bool True if supported false otherwise.
968 * @return errCode.
969 */
970 int32_t IsFlashModeSupported(FlashMode flashMode, bool& isSupported);
971
972 /**
973 * @brief Get the current flash mode.
974 *
975 * @return Returns current flash mode.
976 */
977 FlashMode GetFlashMode();
978
979 /**
980 * @brief Get the current flash mode.
981 * @param current flash mode.
982 * @return Returns errCode.
983 */
984 virtual int32_t GetFlashMode(FlashMode& flashMode);
985
986 /**
987 * @brief Set flash mode.
988 *
989 * @param camera_flash_mode_enum_t flash mode to be set.
990 * @return Returns errCode.
991 */
992 virtual int32_t SetFlashMode(FlashMode flashMode);
993
994 /**
995 * @brief Get the supported Zoom Ratio range.
996 *
997 * @return Returns vector<float> of supported Zoom ratio range.
998 */
999 std::vector<float> GetZoomRatioRange();
1000
1001 /**
1002 * @brief Get the supported Zoom Ratio range.
1003 *
1004 * @param vector<float> of supported Zoom ratio range.
1005 * @return Returns errCode.
1006 */
1007 int32_t GetZoomRatioRange(std::vector<float>& zoomRatioRange);
1008
1009 /**
1010 * @brief Get the current Zoom Ratio.
1011 *
1012 * @return Returns current Zoom Ratio.
1013 */
1014 float GetZoomRatio();
1015
1016 /**
1017 * @brief Get the current Zoom Ratio.
1018 * @param zoomRatio current Zoom Ratio.
1019 * @return Returns errCode.
1020 */
1021 int32_t GetZoomRatio(float& zoomRatio);
1022
1023 /**
1024 * @brief Set Zoom ratio.
1025 *
1026 * @param Zoom ratio to be set.
1027 * @return Returns errCode.
1028 */
1029 int32_t SetZoomRatio(float zoomRatio);
1030
1031 /**
1032 * @brief Prepare Zoom change.
1033 *
1034 * @return Returns errCode.
1035 */
1036 int32_t PrepareZoom();
1037
1038 /**
1039 * @brief UnPrepare Zoom hange.
1040 *
1041 * @return Returns errCode.
1042 */
1043 int32_t UnPrepareZoom();
1044
1045 /**
1046 * @brief Set Smooth Zoom.
1047 *
1048 * @param Target smooth zoom ratio.
1049 * @param Smooth zoom type.
1050 * @return Returns errCode.
1051 */
1052 int32_t SetSmoothZoom(float targetZoomRatio, uint32_t smoothZoomType);
1053
1054 /**
1055 * @brief Set Metadata Object types.
1056 *
1057 * @param set of camera_face_detect_mode_t types.
1058 */
1059 void SetCaptureMetadataObjectTypes(std::set<camera_face_detect_mode_t> metadataObjectTypes);
1060
1061 /**
1062 * @brief Get the supported filters.
1063 *
1064 * @return Returns the array of filter.
1065 */
1066 std::vector<FilterType> GetSupportedFilters();
1067
1068 /**
1069 * @brief Verify ability for supported meta.
1070 *
1071 * @return Returns errorcode.
1072 */
1073 int32_t VerifyAbility(uint32_t ability);
1074
1075 /**
1076 * @brief Get the current filter.
1077 *
1078 * @return Returns the array of filter.
1079 */
1080 FilterType GetFilter();
1081
1082 /**
1083 * @brief Set the filter.
1084 */
1085 void SetFilter(FilterType filter);
1086
1087 /**
1088 * @brief Get the supported beauty type.
1089 *
1090 * @return Returns the array of beautytype.
1091 */
1092 std::vector<BeautyType> GetSupportedBeautyTypes();
1093
1094 /**
1095 * @brief Get the supported beauty range.
1096 *
1097 * @return Returns the array of beauty range.
1098 */
1099 std::vector<int32_t> GetSupportedBeautyRange(BeautyType type);
1100
1101 /**
1102 * @brief Set the beauty.
1103 */
1104 void SetBeauty(BeautyType type, int value);
1105
1106 /**
1107 * @brief Gets supported portrait theme type.
1108 * @param vector of PortraitThemeType supported portraitTheme type.
1109 * @return Returns errCode.
1110 */
1111 int32_t GetSupportedPortraitThemeTypes(std::vector<PortraitThemeType>& types);
1112
1113 /**
1114 * @brief Checks whether portrait theme is supported.
1115 * @param isSupported True if supported false otherwise.
1116 * @return Returns errCode.
1117 */
1118 int32_t IsPortraitThemeSupported(bool &isSupported);
1119
1120 /**
1121 * @brief Checks whether portrait theme is supported.
1122 *
1123 * @return True if supported false otherwise.
1124 */
1125 bool IsPortraitThemeSupported();
1126
1127 /**
1128 * @brief Gets supported rotations.
1129 * @param vector of supported rotations.
1130 * @return Returns errCode.
1131 */
1132 int32_t GetSupportedVideoRotations(std::vector<int32_t>& supportedRotation);
1133
1134 /**
1135 * @brief Checks whether rotation is supported.
1136 * @param isSupported True if supported false otherwise.
1137 * @return Returns errCode.
1138 */
1139 int32_t IsVideoRotationSupported(bool &isSupported);
1140
1141 /**
1142 * @brief Checks whether rotation is supported.
1143 *
1144 * @return True if supported false otherwise.
1145 */
1146 bool IsVideoRotationSupported();
1147
1148 /**
1149 * @brief Sets a rotation type for a camera device.
1150 * @param rotation Potation to be sety.
1151 * @return Returns errCode.
1152 */
1153 int32_t SetVideoRotation(int32_t rotation);
1154
1155 /**
1156 * @brief Get the supported color spaces.
1157 *
1158 * @return Returns supported color spaces.
1159 */
1160 std::vector<ColorSpace> GetSupportedColorSpaces();
1161
1162 /**
1163 * @brief Get current color space.
1164 *
1165 * @return Returns current color space.
1166 */
1167 int32_t GetActiveColorSpace(ColorSpace& colorSpace);
1168
1169 /**
1170 * @brief Set the color space.
1171 */
1172 int32_t SetColorSpace(ColorSpace colorSpace);
1173
1174 /**
1175 * @brief Get the supported color effect.
1176 *
1177 * @return Returns supported color effects.
1178 */
1179 std::vector<ColorEffect> GetSupportedColorEffects();
1180
1181 /**
1182 * @brief Checks whether control center is supported.
1183 *
1184 * @return Is control center supported.
1185 */
1186 bool IsControlCenterSupported();
1187
1188 /**
1189 * @brief Get the supported effect types.
1190 *
1191 * @return Returns supported efftect types.
1192 */
1193 std::vector<ControlCenterEffectType> GetSupportedEffectTypes();
1194
1195 /**
1196 * @brief Enable control center.
1197 */
1198 void EnableControlCenter(bool isEnable);
1199
1200 /**
1201 * @brief Set Focus istance.
1202 *
1203 * @param distance to be set.
1204 * @return Returns errCode.
1205 */
1206 int32_t SetFocusDistance(float distance);
1207
1208 /**
1209 * @brief Get the current FocusDistance.
1210 * @param distance current Focus Distance.
1211 * @return Returns errCode.
1212 */
1213 float GetMinimumFocusDistance();
1214
1215 /**
1216 * @brief Check current status is support macro or not.
1217 */
1218 bool IsMacroSupported();
1219
1220 /**
1221 * @brief Enable macro lens.
1222 */
1223 int32_t EnableMacro(bool isEnable);
1224
1225 /**
1226 * @brief Check current status is support motion photo.
1227 */
1228 bool IsMovingPhotoSupported();
1229
1230 /**
1231 * @brief Enable motion photo.
1232 */
1233 int32_t EnableMovingPhoto(bool isEnable);
1234
1235 /**
1236 * @brief Enable moving photo mirror.
1237 */
1238 int32_t EnableMovingPhotoMirror(bool isMirror, bool isConfig);
1239
1240 /**
1241 * @brief Check current status is support moon capture boost or not.
1242 */
1243 bool IsMoonCaptureBoostSupported();
1244
1245 /**
1246 * @brief Enable or disable moon capture boost ability.
1247 */
1248 int32_t EnableMoonCaptureBoost(bool isEnable);
1249
1250 /**
1251 * @brief Check current status is support target feature or not.
1252 */
1253 bool IsFeatureSupported(SceneFeature feature);
1254
1255 /**
1256 * @brief Enable or disable target feature ability.
1257 */
1258 int32_t EnableFeature(SceneFeature feature, bool isEnable);
1259
1260 /**
1261 * @brief Set the moon detect status callback.
1262 * which will be called when there is moon detect state change.
1263 *
1264 * @param The MoonCaptureBoostStatusCallback pointer.
1265 */
1266 void SetMoonCaptureBoostStatusCallback(std::shared_ptr<MoonCaptureBoostStatusCallback> callback);
1267
1268 /**
1269 * @brief This function is called when there is macro status change
1270 * and process the macro status callback.
1271 *
1272 * @param result Metadata got from callback from service layer.
1273 */
1274 void ProcessMacroStatusChange(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1275
1276 /**
1277 * @brief This function is called when there is moon detect status change
1278 * and process the moon detect status callback.
1279 *
1280 * @param result Metadata got from callback from service layer.
1281 */
1282 void ProcessMoonCaptureBoostStatusChange(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1283
1284 /**
1285 * @brief This function is called when there is low light detect status change
1286 * and process the low light detect status callback.
1287 *
1288 * @param result Metadata got from callback from service layer.
1289 */
1290 void ProcessLowLightBoostStatusChange(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1291
1292 /**
1293 * @brief Check current status is support moon capture boost or not.
1294 */
1295 bool IsLowLightBoostSupported();
1296
1297 /**
1298 * @brief Enable or disable moon capture boost ability.
1299 */
1300 int32_t EnableLowLightBoost(bool isEnable);
1301
1302 /**
1303 * @brief Enable or disable moon capture boost ability.
1304 */
1305 int32_t EnableLowLightDetection(bool isEnable);
1306
1307 /**
1308 * @brief Verify that the output configuration is legitimate.
1309 *
1310 * @param outputProfile The target profile.
1311 * @param outputType The type of output profile.
1312 *
1313 * @return True if the profile is supported, false otherwise.
1314 */
1315 bool ValidateOutputProfile(Profile& outputProfile, CaptureOutputType outputType);
1316
1317 /**
1318 * @brief Check the preconfig type is supported or not.
1319 *
1320 * @param preconfigType The target preconfig type.
1321 * @param preconfigRatio The target ratio enum
1322 *
1323 * @return True if the preconfig type is supported, false otherwise.
1324 */
1325 virtual bool CanPreconfig(PreconfigType preconfigType, ProfileSizeRatio preconfigRatio);
1326
1327 /**
1328 * @brief Set the preconfig type.
1329 *
1330 * @param preconfigType The target preconfig type.
1331 * @param preconfigRatio The target ratio enum
1332 *
1333 * @return Camera error code.
1334 */
1335 virtual int32_t Preconfig(PreconfigType preconfigType, ProfileSizeRatio preconfigRatio);
1336
1337 /**
1338 * @brief Get whether or not commit config.
1339 *
1340 * @return Returns whether or not commit config.
1341 */
1342 bool IsSessionCommited();
1343 bool SetBeautyValue(BeautyType beautyType, int32_t value);
1344 /**
1345 * @brief Get whether or not commit config.
1346 *
1347 * @return Returns whether or not commit config.
1348 */
1349 bool IsSessionConfiged();
1350
1351 /**
1352 * @brief Get whether or not start session.
1353 *
1354 * @return Returns whether or not start session.
1355 */
1356 bool IsSessionStarted();
1357
1358 /**
1359 * @brief Set FrameRate Range.
1360 *
1361 * @return Returns whether or not commit config.
1362 */
1363 int32_t SetFrameRateRange(const std::vector<int32_t>& frameRateRange);
1364
1365 /**
1366 * @brief Set camera sensor sensitivity.
1367 * @param sensitivity sensitivity value to be set.
1368 * @return errCode.
1369 */
1370 int32_t SetSensorSensitivity(uint32_t sensitivity);
1371
1372 /**
1373 * @brief Get camera sensor sensitivity.
1374 * @param sensitivity current sensitivity value.
1375 * @return Returns errCode.
1376 */
1377 int32_t GetSensorSensitivityRange(std::vector<int32_t> &sensitivityRange);
1378
1379 /**
1380 * @brief Get exposure time range.
1381 * @param vector of exposure time range.
1382 * @return errCode.
1383 */
1384 int32_t GetSensorExposureTimeRange(std::vector<uint32_t> &sensorExposureTimeRange);
1385
1386 /**
1387 * @brief Set exposure time value.
1388 * @param exposure compensation value to be set.
1389 * @return errCode.
1390 */
1391 int32_t SetSensorExposureTime(uint32_t sensorExposureTime);
1392
1393 /**
1394 * @brief Get exposure time value.
1395 * @param exposure current exposure time value .
1396 * @return Returns errCode.
1397 */
1398 int32_t GetSensorExposureTime(uint32_t &sensorExposureTime);
1399
1400 /**
1401 * @brief Get sensor module type
1402 * @param moduleType sensor module type.
1403 * @return Returns errCode.
1404 */
1405 int32_t GetModuleType(uint32_t &moduleType);
1406
1407 /**
1408 * @brief Set ar mode.
1409 * @param isEnable switch to control ar mode.
1410 * @return errCode
1411 */
1412 int32_t SetARMode(bool isEnable);
1413
1414 /**
1415 * @brief Set the ar callback.
1416 * which will be called when there is ar info update.
1417 *
1418 * @param arCallback ARCallback pointer.
1419 */
1420 void SetARCallback(std::shared_ptr<ARCallback> arCallback);
1421
1422 /**
1423 * @brief Get the ARCallback.
1424 *
1425 * @return Returns the pointer to ARCallback.
1426 */
1427 std::shared_ptr<ARCallback> GetARCallback();
1428
1429 /**
1430 * @brief Set roate camera flag that been fited.
1431 * @param isHasFitedRotation switch to control ar mode.
1432 * @return errCode
1433 */
1434 int32_t SetHasFitedRotation(bool isHasFitedRotation);
1435
1436 /**
1437 * @brief Get Session Functions.
1438 *
1439 * @param previewProfiles to be searched.
1440 * @param photoProfiles to be searched.
1441 * @param videoProfiles to be searched.
1442 */
1443 std::vector<sptr<CameraAbility>> GetSessionFunctions(std::vector<Profile>& previewProfiles,
1444 std::vector<Profile>& photoProfiles,
1445 std::vector<VideoProfile>& videoProfiles,
1446 bool isForApp = true);
1447
1448 /**
1449 * @brief Get Session Conflict Functions.
1450 *
1451 */
1452 std::vector<sptr<CameraAbility>> GetSessionConflictFunctions();
1453
1454 /**
1455 * @brief Get CameraOutput Capabilities.
1456 *
1457 */
1458 std::vector<sptr<CameraOutputCapability>> GetCameraOutputCapabilities(sptr<CameraDevice> &camera);
1459
1460 /**
1461 * @brief CreateCameraAbilityContainer.
1462 *
1463 */
1464 void CreateCameraAbilityContainer();
1465
1466 /**
1467 * @brief This function is called when there is effect suggestion type change
1468 * and process the effect suggestion callback.
1469 *
1470 * @param result metadata got from callback from service layer.
1471 */
1472 void ProcessEffectSuggestionTypeUpdates(const std::shared_ptr<OHOS::Camera::CameraMetadata> &result);
1473
1474 /**
1475 * @brief Get the supported portrait effects.
1476 *
1477 * @return Returns the array of portraiteffect.
1478 */
1479 std::vector<PortraitEffect> GetSupportedPortraitEffects();
1480
1481 /**
1482 * @brief Get the supported virtual apertures.
1483 * @param apertures returns the array of virtual aperture.
1484 * @return Error code.
1485 */
1486 int32_t GetSupportedVirtualApertures(std::vector<float>& apertures);
1487
1488 /**
1489 * @brief Get the supported physical apertures.
1490 * @param apertures returns the array of physical aperture.
1491 * @return Error code.
1492 */
1493 int32_t GetSupportedPhysicalApertures(std::vector<std::vector<float>>& apertures);
1494
1495 /**
1496 * @brief Set quality prioritization.
1497 *
1498 * @param QualityPrioritization quality prioritization to be set.
1499 * @return Return errCode.
1500 */
1501 int32_t SetQualityPrioritization(QualityPrioritization qualityPrioritization);
1502
1503 void SetMode(SceneMode modeName);
1504 SceneMode GetMode();
1505 SceneFeaturesMode GetFeaturesMode();
1506 std::vector<SceneFeaturesMode> GetSubFeatureMods();
1507 bool IsSetEnableMacro();
1508 sptr<CaptureOutput> GetMetaOutput();
1509 void ProcessSnapshotDurationUpdates(const uint64_t timestamp,
1510 const std::shared_ptr<OHOS::Camera::CameraMetadata> &result);
1511
1512 virtual std::shared_ptr<OHOS::Camera::CameraMetadata> GetMetadata();
1513
1514 void GetMetadataFromService(sptr<CameraDevice> device);
1515
1516 void ExecuteAbilityChangeCallback();
1517
1518 void SetAbilityCallback(std::shared_ptr<AbilityCallback> abilityCallback);
1519 void ProcessAREngineUpdates(const uint64_t timestamp,
1520 const std::shared_ptr<OHOS::Camera::CameraMetadata> &result);
1521
1522 void EnableDeferredType(DeferredDeliveryImageType deferredType, bool isEnableByUser);
1523 void EnableAutoDeferredVideoEnhancement(bool isEnableByUser);
1524 void SetUserId();
1525 bool IsMovingPhotoEnabled();
1526 bool IsImageDeferred();
1527 bool IsVideoDeferred();
1528
1529 int32_t EnableAutoHighQualityPhoto(bool enabled);
1530 int32_t EnableAutoCloudImageEnhancement(bool enabled);
1531
1532 virtual bool CanSetFrameRateRange(int32_t minFps, int32_t maxFps, CaptureOutput* curOutput);
1533 bool CanSetFrameRateRangeForOutput(int32_t minFps, int32_t maxFps, CaptureOutput* curOutput);
1534 int32_t AddSecureOutput(sptr<CaptureOutput> &output);
1535
1536 int32_t EnableAutoAigcPhoto(bool enabled);
1537
1538 void EnableOfflinePhoto();
1539
1540 // White Balance
1541 /**
1542 * @brief Get Metering mode.
1543 * @param vector of Metering Mode.
1544 * @return errCode.
1545 */
1546 int32_t GetSupportedWhiteBalanceModes(std::vector<WhiteBalanceMode>& modes);
1547
1548 /**
1549 * @brief Query whether given white-balance mode supported.
1550 *
1551 * @param camera_focus_mode_enum_t white-balance mode to query.
1552 * @param bool True if supported false otherwise.
1553 * @return errCode.
1554 */
1555 int32_t IsWhiteBalanceModeSupported(WhiteBalanceMode mode, bool &isSupported);
1556
1557 /**
1558 * @brief Set WhiteBalanceMode.
1559 * @param mode WhiteBalanceMode to be set.
1560 * @return errCode.
1561 */
1562 int32_t SetWhiteBalanceMode(WhiteBalanceMode mode);
1563
1564 /**
1565 * @brief Get WhiteBalanceMode.
1566 * @param mode current WhiteBalanceMode .
1567 * @return Returns errCode.
1568 */
1569 int32_t GetWhiteBalanceMode(WhiteBalanceMode& mode);
1570
1571 /**
1572 * @brief Get ManualWhiteBalance Range.
1573 * @param whiteBalanceRange supported Manual WhiteBalance range .
1574 * @return Returns errCode.
1575 */
1576 int32_t GetManualWhiteBalanceRange(std::vector<int32_t> &whiteBalanceRange);
1577
1578 /**
1579 * @brief Is Manual WhiteBalance Supported.
1580 * @param isSupported is Support Manual White Balance .
1581 * @return Returns errCode.
1582 */
1583 int32_t IsManualWhiteBalanceSupported(bool &isSupported);
1584
1585 /**
1586 * @brief Set Manual WhiteBalance.
1587 * @param wbValue WhiteBalance value to be set.
1588 * @return Returns errCode.
1589 */
1590 int32_t SetManualWhiteBalance(int32_t wbValue);
1591
1592 /**
1593 * @brief Get ManualWhiteBalance.
1594 * @param wbValue WhiteBalance value to be get.
1595 * @return Returns errCode.
1596 */
1597 int32_t GetManualWhiteBalance(int32_t &wbValue);
1598
GetMetadataResultProcessor()1599 inline std::shared_ptr<MetadataResultProcessor> GetMetadataResultProcessor()
1600 {
1601 return metadataResultProcessor_;
1602 }
1603
GetInputDevice()1604 inline sptr<CaptureInput> GetInputDevice()
1605 {
1606 std::lock_guard<std::mutex> lock(inputDeviceMutex_);
1607 return innerInputDevice_;
1608 }
1609
GetCaptureSession()1610 inline sptr<ICaptureSession> GetCaptureSession()
1611 {
1612 std::lock_guard<std::mutex> lock(captureSessionMutex_);
1613 return innerCaptureSession_;
1614 }
1615
1616 int32_t SetPreviewRotation(std::string &deviceClass);
1617
1618 /**
1619 * @brief Checks if the LCD flash feature is supported.
1620 *
1621 * This function determines whether the current system or device supports the LCD flash feature.
1622 * It returns `true` if the feature is supported; otherwise, it returns `false`.
1623 *
1624 * @return `true` if the LCD flash feature is supported; `false` otherwise.
1625 */
1626 bool IsLcdFlashSupported();
1627
1628 void ProcessLcdFlashStatusUpdates(const std::shared_ptr<OHOS::Camera::CameraMetadata> &result);
1629
1630 /**
1631 * @brief Retrieves the current LCD flash status callback.
1632 *
1633 * This function returns a shared pointer to the `LcdFlashStatusCallback` object that is used for receiving
1634 * notifications or callbacks related to the LCD flash status.
1635 *
1636 * @return A `std::shared_ptr<LcdFlashStatusCallback>` pointing to the current LCD flash status callback.
1637 * If no callback is set, it may return a `nullptr`.
1638 */
1639 std::shared_ptr<LcdFlashStatusCallback> GetLcdFlashStatusCallback();
1640 void EnableFaceDetection(bool enable);
1641 /**
1642 * @brief Checks if tripod detection is supported.
1643 *
1644 * This function determines whether the current system or device supports tripod detection functionality.
1645 * It returns `true` if the feature is supported, otherwise `false`.
1646 *
1647 * @return `true` if tripod detection is supported; `false` otherwise.
1648 */
1649 bool IsTripodDetectionSupported();
1650
1651 /**
1652 * @brief Enables or disables tripod stabilization.
1653 *
1654 * This function enables or disables the tripod stabilization feature based on the provided `enabled` flag.
1655 *
1656 * @param enabled A boolean flag that indicates whether to enable or disable tripod stabilization.
1657 *
1658 * @return Returns an `int32_t` value indicating the success or failure of the operation.
1659 * Typically, a return value of 0 indicates success, while a non-zero value indicates an error.
1660 */
1661 int32_t EnableTripodStabilization(bool enabled);
1662
1663 void ProcessTripodStatusChange(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1664
1665 int32_t EnableRawDelivery(bool enabled);
1666
1667 /**
1668 * @brief Checks if the automatic switchover device is supported.
1669 *
1670 * @return true if supported; false otherwise.
1671 */
1672 bool IsAutoDeviceSwitchSupported();
1673
1674 /**
1675 * @brief Enables or disables the automatic switchover device.
1676 *
1677 * @param isEnable True to enable, false to disable.
1678 * @return 0 on success, or a negative error code on failure.
1679 */
1680 int32_t EnableAutoDeviceSwitch(bool isEnable);
1681
1682 /**
1683 * @brief Switches the current device to a different one.
1684 *
1685 * @return true if the switch was successful; false if it failed or is not supported.
1686 */
1687 bool SwitchDevice();
1688
1689 /**
1690 * @brief Enables or disables the automatic switchover device.
1691 *
1692 * @param isEnable True to enable, false to disable.
1693 */
1694 void SetIsAutoSwitchDeviceStatus(bool isEnable);
1695
1696 /**
1697 * @brief Checks if the automatic switchover device is enabled.
1698 *
1699 * @return True if enabled, false otherwise.
1700 */
1701 bool GetIsAutoSwitchDeviceStatus();
1702
1703 /**
1704 * @brief Sets the callback for automatic device switching.
1705 *
1706 * @param autoDeviceSwitchCallback A shared pointer to the callback.
1707 */
1708 void SetAutoDeviceSwitchCallback(shared_ptr<AutoDeviceSwitchCallback> autoDeviceSwitchCallback);
1709
1710 /**
1711 * @brief Gets the current automatic device switch callback.
1712 *
1713 * @return A shared pointer to the callback, or nullptr if not set.
1714 */
1715 shared_ptr<AutoDeviceSwitchCallback> GetAutoDeviceSwitchCallback();
1716
SetDeviceCapabilityChangeStatus(bool isDeviceCapabilityChanged)1717 inline void SetDeviceCapabilityChangeStatus(bool isDeviceCapabilityChanged)
1718 {
1719 isDeviceCapabilityChanged_ = isDeviceCapabilityChanged;
1720 }
1721
GetDeviceCapabilityChangeStatus()1722 inline bool GetDeviceCapabilityChangeStatus()
1723 {
1724 return isDeviceCapabilityChanged_;
1725 }
1726
1727 /**
1728 * @brief Adds a function to the mapping with the specified control tag.
1729 *
1730 * This function is used to register a callback that will be executed
1731 * when the automatic switchover device is enabled. The control target
1732 * must be set prior to switching the device. After the device is switched,
1733 * the target needs to be reset to HAL.
1734 *
1735 * @note This functionality is applicable only for SceneMode::CAPTURE
1736 * and SceneMode::VIDEO modes.
1737 *
1738 * @param ctrlTag The control tag associated with the function.
1739 * @param func The function to be added to the map, which will be called
1740 * when the corresponding control tag is triggered.
1741 */
1742 void AddFunctionToMap(std::string ctrlTag, std::function<void()> func);
1743 void ExecuteAllFunctionsInMap();
1744 void EnableAutoFrameRate(bool isEnable);
1745
1746 /**
1747 * @brief Set the macro status callback.
1748 * which will be called when there is macro state change.
1749 *
1750 * @param The MacroStatusCallback pointer.
1751 */
1752 void SetMacroStatusCallback(std::shared_ptr<MacroStatusCallback> callback);
1753 protected:
1754
1755 static const std::unordered_map<camera_awb_mode_t, WhiteBalanceMode> metaWhiteBalanceModeMap_;
1756 static const std::unordered_map<WhiteBalanceMode, camera_awb_mode_t> fwkWhiteBalanceModeMap_;
1757
1758 static const std::unordered_map<LightPaintingType, CameraLightPaintingType> fwkLightPaintingTypeMap_;
1759 static const std::unordered_map<CameraLightPaintingType, LightPaintingType> metaLightPaintingTypeMap_;
1760 static const std::unordered_map<TripodStatus, FwkTripodStatus> metaTripodStatusMap_;
1761
1762 std::shared_ptr<OHOS::Camera::CameraMetadata> changedMetadata_;
1763 Profile photoProfile_;
1764 Profile previewProfile_;
1765 std::map<BeautyType, std::vector<int32_t>> beautyTypeAndRanges_;
1766 std::map<BeautyType, int32_t> beautyTypeAndLevels_;
1767 std::shared_ptr<MetadataResultProcessor> metadataResultProcessor_ = nullptr;
1768 bool isImageDeferred_ = false;
1769 std::atomic<bool> isRawImageDelivery_ { false };
1770 bool isVideoDeferred_ = false;
1771 std::atomic<bool> isMovingPhotoEnabled_ { false };
1772
1773 std::shared_ptr<AbilityCallback> abilityCallback_;
1774 std::atomic<uint32_t> exposureDurationValue_ = 0;
1775
1776 float apertureValue_ = 0.0;
1777
1778 std::mutex sessionCallbackMutex_;
1779 std::shared_ptr<MacroStatusCallback> macroStatusCallback_;
1780 std::shared_ptr<FeatureDetectionStatusCallback> featureDetectionStatusCallback_;
1781 std::shared_ptr<EffectSuggestionCallback> effectSuggestionCallback_;
1782 std::shared_ptr<LcdFlashStatusCallback> lcdFlashStatusCallback_;
1783 std::atomic<bool> isSmoothZooming_ = false;
1784 std::atomic<float> targetZoomRatio_ = -1.0;
1785 float focusDistance_ = 0.0;
1786 static const std::unordered_map<CameraEffectSuggestionType, EffectSuggestionType> metaEffectSuggestionTypeMap_;
1787
ClearPreconfigProfiles()1788 inline void ClearPreconfigProfiles()
1789 {
1790 std::lock_guard<std::mutex> lock(preconfigProfilesMutex_);
1791 preconfigProfiles_ = nullptr;
1792 }
1793
SetPreconfigProfiles(std::shared_ptr<PreconfigProfiles> preconfigProfiles)1794 inline void SetPreconfigProfiles(std::shared_ptr<PreconfigProfiles> preconfigProfiles)
1795 {
1796 std::lock_guard<std::mutex> lock(preconfigProfilesMutex_);
1797 preconfigProfiles_ = preconfigProfiles;
1798 }
1799
GetPreconfigProfiles()1800 inline std::shared_ptr<PreconfigProfiles> GetPreconfigProfiles()
1801 {
1802 std::lock_guard<std::mutex> lock(preconfigProfilesMutex_);
1803 return preconfigProfiles_;
1804 }
1805
SetInputDevice(sptr<CaptureInput> inputDevice)1806 inline void SetInputDevice(sptr<CaptureInput> inputDevice)
1807 {
1808 std::lock_guard<std::mutex> lock(inputDeviceMutex_);
1809 innerInputDevice_ = inputDevice;
1810 }
1811
GetCameraAbilityContainer()1812 inline sptr<CameraAbilityContainer> GetCameraAbilityContainer()
1813 {
1814 std::lock_guard<std::mutex> lock(abilityContainerMutex_);
1815 return cameraAbilityContainer_;
1816 }
1817
SetCaptureSession(sptr<ICaptureSession> captureSession)1818 inline void SetCaptureSession(sptr<ICaptureSession> captureSession)
1819 {
1820 std::lock_guard<std::mutex> lock(captureSessionMutex_);
1821 innerCaptureSession_ = captureSession;
1822 }
1823
IsSupportSpecSearch()1824 inline bool IsSupportSpecSearch()
1825 {
1826 return supportSpecSearch_.load();
1827 }
1828
1829 virtual std::shared_ptr<PreconfigProfiles> GeneratePreconfigProfiles(
1830 PreconfigType preconfigType, ProfileSizeRatio preconfigRatio);
1831
1832 CameraPosition GetUsedAsPosition();
1833
1834 private:
1835 std::mutex switchDeviceMutex_;
1836 std::mutex functionMapMutex_;
1837 std::mutex changeMetaMutex_;
1838 std::mutex captureSessionMutex_;
1839 sptr<ICaptureSession> innerCaptureSession_ = nullptr;
1840 std::shared_ptr<SessionCallback> appCallback_;
1841 std::shared_ptr<PressureCallback> appPressureCallback_;
1842 std::shared_ptr<ControlCenterEffectCallback> appControlCenterEffectStatusCallback_;
1843 sptr<ICaptureSessionCallback> captureSessionCallback_;
1844 sptr<IPressureStatusCallback> pressureStatusCallback_;
1845 sptr<IControlCenterEffectStatusCallback> controlCenterEffectStatusCallback_;
1846 std::shared_ptr<ExposureCallback> exposureCallback_;
1847 std::shared_ptr<FocusCallback> focusCallback_;
1848 std::shared_ptr<MoonCaptureBoostStatusCallback> moonCaptureBoostStatusCallback_;
1849 std::shared_ptr<SmoothZoomCallback> smoothZoomCallback_;
1850 std::shared_ptr<ARCallback> arCallback_;
1851 std::shared_ptr<AutoDeviceSwitchCallback> autoDeviceSwitchCallback_;
1852 sptr<IFoldServiceCallback> foldStatusCallback_ = nullptr;
1853 std::vector<int32_t> skinSmoothBeautyRange_;
1854 std::vector<int32_t> faceSlendorBeautyRange_;
1855 std::vector<int32_t> skinToneBeautyRange_;
1856 std::mutex captureOutputSetsMutex_;
1857 std::set<wptr<CaptureOutput>, RefBaseCompare<CaptureOutput>> captureOutputSets_;
1858
1859 std::mutex inputDeviceMutex_;
1860 std::mutex chooseDeviceMutex_;
1861 sptr<CaptureInput> innerInputDevice_ = nullptr;
1862 volatile bool isSetMacroEnable_ = false;
1863 volatile bool isSetMoonCaptureBoostEnable_ = false;
1864 volatile bool isSetTripodDetectionEnable_ = false;
1865 volatile bool isSetSecureOutput_ = false;
1866 std::atomic<bool> isSetLowLightBoostEnable_ = false;
1867 static const std::unordered_map<camera_focus_state_t, FocusCallback::FocusState> metaFocusStateMap_;
1868 static const std::unordered_map<camera_exposure_state_t, ExposureCallback::ExposureState> metaExposureStateMap_;
1869
1870 static const std::unordered_map<camera_filter_type_t, FilterType> metaFilterTypeMap_;
1871 static const std::unordered_map<FilterType, camera_filter_type_t> fwkFilterTypeMap_;
1872 static const std::unordered_map<BeautyType, camera_device_metadata_tag_t> fwkBeautyControlMap_;
1873 static const std::unordered_map<camera_device_metadata_tag_t, BeautyType> metaBeautyControlMap_;
1874 sptr<CaptureOutput> metaOutput_ = nullptr;
1875 sptr<CaptureOutput> photoOutput_;
1876 std::atomic<int32_t> prevDuration_ = 0;
1877 sptr<CameraDeathRecipient> deathRecipient_ = nullptr;
1878 bool isColorSpaceSetted_ = false;
1879 atomic<bool> isDeferTypeSetted_ = false;
1880 atomic<bool> isAutoSwitchDevice_ = false;
1881 atomic<bool> isDeviceCapabilityChanged_ = false;
1882 atomic<bool> canAddFuncToMap_ = true;
1883 bool isControlCenterEnabled_ = false;
1884
1885 // Only for the SceneMode::CAPTURE and SceneMode::VIDEO mode
1886 map<std::string, std::function<void()>> functionMap;
1887
1888 std::mutex preconfigProfilesMutex_;
1889 std::shared_ptr<PreconfigProfiles> preconfigProfiles_ = nullptr;
1890
1891 // private tag
1892 uint32_t HAL_CUSTOM_AR_MODE = 0;
1893 uint32_t HAL_CUSTOM_LASER_DATA = 0;
1894 uint32_t HAL_CUSTOM_SENSOR_MODULE_TYPE = 0;
1895 uint32_t HAL_CUSTOM_LENS_FOCUS_DISTANCE = 0;
1896 uint32_t HAL_CUSTOM_SENSOR_SENSITIVITY = 0;
1897
1898 std::mutex abilityContainerMutex_;
1899 sptr<CameraAbilityContainer> cameraAbilityContainer_ = nullptr;
1900 atomic<bool> supportSpecSearch_ = false;
1901 void CheckSpecSearch();
1902 bool CheckLightStatus();
1903 void PopulateProfileLists(std::vector<Profile>& photoProfileList,
1904 std::vector<Profile>& previewProfileList,
1905 std::vector<VideoProfile>& videoProfileList);
1906 void PopulateSpecIdMaps(sptr<CameraDevice> device, int32_t modeName,
1907 std::map<int32_t, std::vector<Profile>>& specIdPreviewMap,
1908 std::map<int32_t, std::vector<Profile>>& specIdPhotoMap,
1909 std::map<int32_t, std::vector<VideoProfile>>& specIdVideoMap);
1910 // Make sure you know what you are doing, you'd better to use {GetMode()} function instead of this variable.
1911 SceneMode currentMode_ = SceneMode::NORMAL;
1912 SceneMode guessMode_ = SceneMode::NORMAL;
1913 std::mutex moonCaptureBoostFeatureMutex_;
1914 std::shared_ptr<MoonCaptureBoostFeature> moonCaptureBoostFeature_ = nullptr;
1915 std::shared_ptr<MoonCaptureBoostFeature> GetMoonCaptureBoostFeature();
1916 void SetGuessMode(SceneMode mode);
1917 int32_t UpdateSetting(std::shared_ptr<OHOS::Camera::CameraMetadata> changedMetadata);
1918 Point CoordinateTransform(Point point);
1919 int32_t CalculateExposureValue(float exposureValue);
1920 Point VerifyFocusCorrectness(Point point);
1921 int32_t ConfigureOutput(sptr<CaptureOutput>& output);
1922 int32_t ConfigurePreviewOutput(sptr<CaptureOutput>& output);
1923 int32_t ConfigurePhotoOutput(sptr<CaptureOutput>& output);
1924 int32_t ConfigureVideoOutput(sptr<CaptureOutput>& output);
1925 std::shared_ptr<Profile> GetMaxSizePhotoProfile(ProfileSizeRatio sizeRatio);
1926 std::shared_ptr<Profile> GetPreconfigPreviewProfile();
1927 std::shared_ptr<Profile> GetPreconfigPhotoProfile();
1928 std::shared_ptr<VideoProfile> GetPreconfigVideoProfile();
1929 void CameraServerDied(pid_t pid);
1930 void InsertOutputIntoSet(sptr<CaptureOutput>& output);
1931 void RemoveOutputFromSet(sptr<CaptureOutput>& output);
1932 void OnSettingUpdated(std::shared_ptr<OHOS::Camera::CameraMetadata> changedMetadata);
1933 void OnResultReceived(std::shared_ptr<OHOS::Camera::CameraMetadata> changedMetadata);
1934 ColorSpaceInfo GetSupportedColorSpaceInfo();
1935 void UpdateDeviceDeferredability();
1936 void ProcessProfilesAbilityId(const SceneMode supportModes);
1937 void ProcessFocusDistanceUpdates(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1938 void FindTagId();
1939 bool CheckFrameRateRangeWithCurrentFps(int32_t curMinFps, int32_t curMaxFps, int32_t minFps, int32_t maxFps);
1940 void SessionRemoveDeathRecipient();
1941 int32_t AdaptOutputVideoHighFrameRate(sptr<CaptureOutput>& output, sptr<ICaptureSession>& captureSession);
1942 sptr<CameraDevice> FindFrontCamera();
1943 void StartVideoOutput();
1944 bool StopVideoOutput();
1945 void CreateAndSetFoldServiceCallback();
1946 int32_t DoSpecSearch(std::vector<float>& zoomRatioRange);
1947 void AdjustRenderFit();
1948 };
1949 } // namespace CameraStandard
1950 } // namespace OHOS
1951 #endif // OHOS_CAMERA_CAPTURE_SESSION_H
1952