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