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 * @brief according type to get the strength.
1025 */
1026 int32_t GetBeauty(BeautyType type);
1027
1028 /**
1029 * @brief Get the supported color spaces.
1030 *
1031 * @return Returns supported color spaces.
1032 */
1033 std::vector<ColorSpace> GetSupportedColorSpaces();
1034
1035 /**
1036 * @brief Get current color space.
1037 *
1038 * @return Returns current color space.
1039 */
1040 int32_t GetActiveColorSpace(ColorSpace& colorSpace);
1041
1042 /**
1043 * @brief Set the color space.
1044 */
1045 int32_t SetColorSpace(ColorSpace colorSpace);
1046
1047 /**
1048 * @brief Get the supported color effect.
1049 *
1050 * @return Returns supported color effects.
1051 */
1052 std::vector<ColorEffect> GetSupportedColorEffects();
1053
1054 /**
1055 * @brief Get the current color effect.
1056 *
1057 * @return Returns current color effect.
1058 */
1059 ColorEffect GetColorEffect();
1060
1061 /**
1062 * @brief Set the color effect.
1063 */
1064 void SetColorEffect(ColorEffect colorEffect);
1065
1066 // Focus Distance
1067 /**
1068 * @brief Get the current FocusDistance.
1069 * @param distance current Focus Distance.
1070 * @return Returns errCode.
1071 */
1072 int32_t GetFocusDistance(float& distance);
1073
1074 /**
1075 * @brief Set Focus istance.
1076 *
1077 * @param distance to be set.
1078 * @return Returns errCode.
1079 */
1080 int32_t SetFocusDistance(float distance);
1081
1082 /**
1083 * @brief Get the current FocusDistance.
1084 * @param distance current Focus Distance.
1085 * @return Returns errCode.
1086 */
1087 float GetMinimumFocusDistance();
1088
1089 /**
1090 * @brief Check current status is support macro or not.
1091 */
1092 bool IsMacroSupported();
1093
1094 /**
1095 * @brief Enable macro lens.
1096 */
1097 int32_t EnableMacro(bool isEnable);
1098
1099 /**
1100 * @brief Check current status is support depth fusion or not.
1101 */
1102 bool IsDepthFusionSupported();
1103
1104 /**
1105 * @brief Get the depth fusion supported Zoom Ratio range,
1106 *
1107 * @return Returns vector<float> of depth fusion supported Zoom ratio range.
1108 */
1109 std::vector<float> GetDepthFusionThreshold();
1110
1111 /**
1112 * @brief Get the depth fusion supported Zoom ratio range.
1113 *
1114 * @param vector<float> of depth fusion supported Zoom ratio range.
1115 * @return Returns errCode.
1116 */
1117 int32_t GetDepthFusionThreshold(std::vector<float>& depthFusionThreshold);
1118
1119 /**
1120 * @brief Check curernt status is enabled depth fusion.
1121 */
1122 bool IsDepthFusionEnabled();
1123
1124 /**
1125 * @brief Enable depth fusion.
1126 */
1127 int32_t EnableDepthFusion(bool isEnable);
1128
1129 /**
1130 * @brief Check current status is support motion photo.
1131 */
1132 bool IsMovingPhotoSupported();
1133
1134 /**
1135 * @brief Enable motion photo.
1136 */
1137 int32_t EnableMovingPhoto(bool isEnable);
1138
1139 /**
1140 * @brief Enable moving photo mirror.
1141 */
1142 int32_t EnableMovingPhotoMirror(bool isMirror);
1143
1144 /**
1145 * @brief Check current status is support moon capture boost or not.
1146 */
1147 bool IsMoonCaptureBoostSupported();
1148
1149 /**
1150 * @brief Enable or disable moon capture boost ability.
1151 */
1152 int32_t EnableMoonCaptureBoost(bool isEnable);
1153
1154 /**
1155 * @brief Check current status is support target feature or not.
1156 */
1157 bool IsFeatureSupported(SceneFeature feature);
1158
1159 /**
1160 * @brief Enable or disable target feature ability.
1161 */
1162 int32_t EnableFeature(SceneFeature feature, bool isEnable);
1163
1164 /**
1165 * @brief Set the macro status callback.
1166 * which will be called when there is macro state change.
1167 *
1168 * @param The MacroStatusCallback pointer.
1169 */
1170 void SetMacroStatusCallback(std::shared_ptr<MacroStatusCallback> callback);
1171
1172 /**
1173 * @brief Set the moon detect status callback.
1174 * which will be called when there is moon detect state change.
1175 *
1176 * @param The MoonCaptureBoostStatusCallback pointer.
1177 */
1178 void SetMoonCaptureBoostStatusCallback(std::shared_ptr<MoonCaptureBoostStatusCallback> callback);
1179
1180 /**
1181 * @brief Set the feature detection status callback.
1182 * which will be called when there is feature detection state change.
1183 *
1184 * @param The FeatureDetectionStatusCallback pointer.
1185 */
1186 void SetFeatureDetectionStatusCallback(std::shared_ptr<FeatureDetectionStatusCallback> callback);
1187
1188 void SetEffectSuggestionCallback(std::shared_ptr<EffectSuggestionCallback> effectSuggestionCallback);
1189
1190 /**
1191 * @brief This function is called when there is macro status change
1192 * and process the macro status callback.
1193 *
1194 * @param result Metadata got from callback from service layer.
1195 */
1196 void ProcessMacroStatusChange(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1197
1198 /**
1199 * @brief This function is called when there is moon detect status change
1200 * and process the moon detect status callback.
1201 *
1202 * @param result Metadata got from callback from service layer.
1203 */
1204 void ProcessMoonCaptureBoostStatusChange(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1205
1206 /**
1207 * @brief This function is called when there is low light detect status change
1208 * and process the low light detect status callback.
1209 *
1210 * @param result Metadata got from callback from service layer.
1211 */
1212 void ProcessLowLightBoostStatusChange(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1213
1214 /**
1215 * @brief Check current status is support moon capture boost or not.
1216 */
1217 bool IsLowLightBoostSupported();
1218
1219 /**
1220 * @brief Enable or disable moon capture boost ability.
1221 */
1222 int32_t EnableLowLightBoost(bool isEnable);
1223
1224 /**
1225 * @brief Enable or disable moon capture boost ability.
1226 */
1227 int32_t EnableLowLightDetection(bool isEnable);
1228
1229 /**
1230 * @brief Verify that the output configuration is legitimate.
1231 *
1232 * @param outputProfile The target profile.
1233 * @param outputType The type of output profile.
1234 *
1235 * @return True if the profile is supported, false otherwise.
1236 */
1237 bool ValidateOutputProfile(Profile& outputProfile, CaptureOutputType outputType);
1238
1239 /**
1240 * @brief Check the preconfig type is supported or not.
1241 *
1242 * @param preconfigType The target preconfig type.
1243 * @param preconfigRatio The target ratio enum
1244 *
1245 * @return True if the preconfig type is supported, false otherwise.
1246 */
1247 virtual bool CanPreconfig(PreconfigType preconfigType, ProfileSizeRatio preconfigRatio);
1248
1249 /**
1250 * @brief Set the preconfig type.
1251 *
1252 * @param preconfigType The target preconfig type.
1253 * @param preconfigRatio The target ratio enum
1254 *
1255 * @return Camera error code.
1256 */
1257 virtual int32_t Preconfig(PreconfigType preconfigType, ProfileSizeRatio preconfigRatio);
1258
1259 /**
1260 * @brief Get whether or not commit config.
1261 *
1262 * @return Returns whether or not commit config.
1263 */
1264 bool IsSessionCommited();
1265 bool SetBeautyValue(BeautyType beautyType, int32_t value);
1266 /**
1267 * @brief Get whether or not commit config.
1268 *
1269 * @return Returns whether or not commit config.
1270 */
1271 bool IsSessionConfiged();
1272
1273 /**
1274 * @brief Get whether or not start session.
1275 *
1276 * @return Returns whether or not start session.
1277 */
1278 bool IsSessionStarted();
1279
1280 /**
1281 * @brief Set FrameRate Range.
1282 *
1283 * @return Returns whether or not commit config.
1284 */
1285 int32_t SetFrameRateRange(const std::vector<int32_t>& frameRateRange);
1286
1287 /**
1288 * @brief Set camera sensor sensitivity.
1289 * @param sensitivity sensitivity value to be set.
1290 * @return errCode.
1291 */
1292 int32_t SetSensorSensitivity(uint32_t sensitivity);
1293
1294 /**
1295 * @brief Get camera sensor sensitivity.
1296 * @param sensitivity current sensitivity value.
1297 * @return Returns errCode.
1298 */
1299 int32_t GetSensorSensitivityRange(std::vector<int32_t> &sensitivityRange);
1300
1301 /**
1302 * @brief Get exposure time range.
1303 * @param vector of exposure time range.
1304 * @return errCode.
1305 */
1306 int32_t GetSensorExposureTimeRange(std::vector<uint32_t> &sensorExposureTimeRange);
1307
1308 /**
1309 * @brief Set exposure time value.
1310 * @param exposure compensation value to be set.
1311 * @return errCode.
1312 */
1313 int32_t SetSensorExposureTime(uint32_t sensorExposureTime);
1314
1315 /**
1316 * @brief Get exposure time value.
1317 * @param exposure current exposure time value .
1318 * @return Returns errCode.
1319 */
1320 int32_t GetSensorExposureTime(uint32_t &sensorExposureTime);
1321
1322 /**
1323 * @brief Get sensor module type
1324 * @param moduleType sensor module type.
1325 * @return Returns errCode.
1326 */
1327 int32_t GetModuleType(uint32_t &moduleType);
1328
1329 /**
1330 * @brief Set ar mode.
1331 * @param isEnable switch to control ar mode.
1332 * @return errCode
1333 */
1334 int32_t SetARMode(bool isEnable);
1335
1336 /**
1337 * @brief Set the ar callback.
1338 * which will be called when there is ar info update.
1339 *
1340 * @param arCallback ARCallback pointer.
1341 */
1342 void SetARCallback(std::shared_ptr<ARCallback> arCallback);
1343
1344 /**
1345 * @brief Get the ARCallback.
1346 *
1347 * @return Returns the pointer to ARCallback.
1348 */
1349 std::shared_ptr<ARCallback> GetARCallback();
1350
1351 /**
1352 * @brief Get Session Functions.
1353 *
1354 * @param previewProfiles to be searched.
1355 * @param photoProfiles to be searched.
1356 * @param videoProfiles to be searched.
1357 */
1358 std::vector<sptr<CameraAbility>> GetSessionFunctions(std::vector<Profile>& previewProfiles,
1359 std::vector<Profile>& photoProfiles,
1360 std::vector<VideoProfile>& videoProfiles,
1361 bool isForApp = true);
1362
1363 /**
1364 * @brief Get Session Conflict Functions.
1365 *
1366 */
1367 std::vector<sptr<CameraAbility>> GetSessionConflictFunctions();
1368
1369 /**
1370 * @brief Get CameraOutput Capabilities.
1371 *
1372 */
1373 std::vector<sptr<CameraOutputCapability>> GetCameraOutputCapabilities(sptr<CameraDevice> &camera);
1374
1375 /**
1376 * @brief CreateCameraAbilityContainer.
1377 *
1378 */
1379 void CreateCameraAbilityContainer();
1380
1381 /**
1382 * @brief Get whether effectSuggestion Supported.
1383 *
1384 * @return True if supported false otherwise.
1385 */
1386 bool IsEffectSuggestionSupported();
1387
1388 /**
1389 * @brief Enable EffectSuggestion.
1390 * @param isEnable switch to control Effect Suggestion.
1391 * @return errCode
1392 */
1393 int32_t EnableEffectSuggestion(bool isEnable);
1394
1395 /**
1396 * @brief Get supported EffectSuggestionInfo.
1397 * @return EffectSuggestionInfo parsed from tag
1398 */
1399 EffectSuggestionInfo GetSupportedEffectSuggestionInfo();
1400
1401 /**
1402 * @brief Get supported effectSuggestionType.
1403 * @return EffectSuggestionTypeList which current mode supported.
1404 */
1405 std::vector<EffectSuggestionType> GetSupportedEffectSuggestionType();
1406
1407 /**
1408 * @brief Batch set effect suggestion status.
1409 * @param effectSuggestionStatusList effect suggestion status list to be set.
1410 * @return errCode
1411 */
1412 int32_t SetEffectSuggestionStatus(std::vector<EffectSuggestionStatus> effectSuggestionStatusList);
1413
1414 /**
1415 * @brief Set ar mode.
1416 * @param effectSuggestionType switch to control effect suggestion.
1417 * @param isEnable switch to control effect suggestion status.
1418 * @return errCode
1419 */
1420 int32_t UpdateEffectSuggestion(EffectSuggestionType effectSuggestionType, bool isEnable);
1421
1422 /**
1423 * @brief This function is called when there is effect suggestion type change
1424 * and process the effect suggestion callback.
1425 *
1426 * @param result metadata got from callback from service layer.
1427 */
1428 void ProcessEffectSuggestionTypeUpdates(const std::shared_ptr<OHOS::Camera::CameraMetadata> &result);
1429
1430 /**
1431 * @brief Get the supported portrait effects.
1432 *
1433 * @return Returns the array of portraiteffect.
1434 */
1435 std::vector<PortraitEffect> GetSupportedPortraitEffects();
1436
1437 /**
1438 * @brief Get the supported virtual apertures.
1439 * @param apertures returns the array of virtual aperture.
1440 * @return Error code.
1441 */
1442 int32_t GetSupportedVirtualApertures(std::vector<float>& apertures);
1443
1444 /**
1445 * @brief Get the virtual aperture.
1446 * @param aperture returns the current virtual aperture.
1447 * @return Error code.
1448 */
1449 int32_t GetVirtualAperture(float& aperture);
1450
1451 /**
1452 * @brief Set the virtual aperture.
1453 * @param virtualAperture set virtual aperture value.
1454 * @return Error code.
1455 */
1456 int32_t SetVirtualAperture(const float virtualAperture);
1457
1458 /**
1459 * @brief Get the supported physical apertures.
1460 * @param apertures returns the array of physical aperture.
1461 * @return Error code.
1462 */
1463 int32_t GetSupportedPhysicalApertures(std::vector<std::vector<float>>& apertures);
1464
1465 /**
1466 * @brief Get the physical aperture.
1467 * @param aperture returns current physical aperture.
1468 * @return Error code.
1469 */
1470 int32_t GetPhysicalAperture(float& aperture);
1471
1472 /**
1473 * @brief Set the physical aperture.
1474 * @param physicalAperture set physical aperture value.
1475 * @return Error code.
1476 */
1477 int32_t SetPhysicalAperture(float physicalAperture);
1478
1479 void SetMode(SceneMode modeName);
1480 SceneMode GetMode();
1481 SceneFeaturesMode GetFeaturesMode();
1482 std::vector<SceneFeaturesMode> GetSubFeatureMods();
1483 bool IsSetEnableMacro();
1484 sptr<CaptureOutput> GetMetaOutput();
1485 void ProcessSnapshotDurationUpdates(const uint64_t timestamp,
1486 const std::shared_ptr<OHOS::Camera::CameraMetadata> &result);
1487
1488 virtual std::shared_ptr<OHOS::Camera::CameraMetadata> GetMetadata();
1489
1490 void ExecuteAbilityChangeCallback();
1491 void SetAbilityCallback(std::shared_ptr<AbilityCallback> abilityCallback);
1492 void ProcessAREngineUpdates(const uint64_t timestamp,
1493 const std::shared_ptr<OHOS::Camera::CameraMetadata> &result);
1494
1495 void EnableDeferredType(DeferredDeliveryImageType deferredType, bool isEnableByUser);
1496 void EnableAutoDeferredVideoEnhancement(bool isEnableByUser);
1497 void SetUserId();
1498 bool IsMovingPhotoEnabled();
1499 bool IsImageDeferred();
1500 bool IsVideoDeferred();
1501 virtual bool CanSetFrameRateRange(int32_t minFps, int32_t maxFps, CaptureOutput* curOutput);
1502 bool CanSetFrameRateRangeForOutput(int32_t minFps, int32_t maxFps, CaptureOutput* curOutput);
1503
1504 int32_t EnableAutoHighQualityPhoto(bool enabled);
1505 int32_t EnableAutoCloudImageEnhancement(bool enabled);
1506 int32_t AddSecureOutput(sptr<CaptureOutput> &output);
1507
1508 // White Balance
1509 /**
1510 * @brief Get Metering mode.
1511 * @param vector of Metering Mode.
1512 * @return errCode.
1513 */
1514 int32_t GetSupportedWhiteBalanceModes(std::vector<WhiteBalanceMode>& modes);
1515
1516 /**
1517 * @brief Query whether given white-balance mode supported.
1518 *
1519 * @param camera_focus_mode_enum_t white-balance mode to query.
1520 * @param bool True if supported false otherwise.
1521 * @return errCode.
1522 */
1523 int32_t IsWhiteBalanceModeSupported(WhiteBalanceMode mode, bool &isSupported);
1524
1525 /**
1526 * @brief Set WhiteBalanceMode.
1527 * @param mode WhiteBalanceMode to be set.
1528 * @return errCode.
1529 */
1530 int32_t SetWhiteBalanceMode(WhiteBalanceMode mode);
1531
1532 /**
1533 * @brief Get WhiteBalanceMode.
1534 * @param mode current WhiteBalanceMode .
1535 * @return Returns errCode.
1536 */
1537 int32_t GetWhiteBalanceMode(WhiteBalanceMode& mode);
1538
1539 /**
1540 * @brief Get ManualWhiteBalance Range.
1541 * @param whiteBalanceRange supported Manual WhiteBalance range .
1542 * @return Returns errCode.
1543 */
1544 int32_t GetManualWhiteBalanceRange(std::vector<int32_t> &whiteBalanceRange);
1545
1546 /**
1547 * @brief Is Manual WhiteBalance Supported.
1548 * @param isSupported is Support Manual White Balance .
1549 * @return Returns errCode.
1550 */
1551 int32_t IsManualWhiteBalanceSupported(bool &isSupported);
1552
1553 /**
1554 * @brief Set Manual WhiteBalance.
1555 * @param wbValue WhiteBalance value to be set.
1556 * @return Returns errCode.
1557 */
1558 int32_t SetManualWhiteBalance(int32_t wbValue);
1559
1560 /**
1561 * @brief Get ManualWhiteBalance.
1562 * @param wbValue WhiteBalance value to be get.
1563 * @return Returns errCode.
1564 */
1565 int32_t GetManualWhiteBalance(int32_t &wbValue);
1566
GetMetadataResultProcessor()1567 inline std::shared_ptr<MetadataResultProcessor> GetMetadataResultProcessor()
1568 {
1569 return metadataResultProcessor_;
1570 }
1571
GetInputDevice()1572 inline sptr<CaptureInput> GetInputDevice()
1573 {
1574 std::lock_guard<std::mutex> lock(inputDeviceMutex_);
1575 return innerInputDevice_;
1576 }
1577
1578 int32_t SetPreviewRotation(std::string &deviceClass);
1579
GetCaptureSession()1580 inline sptr<ICaptureSession> GetCaptureSession()
1581 {
1582 std::lock_guard<std::mutex> lock(captureSessionMutex_);
1583 return innerCaptureSession_;
1584 }
1585
1586 /**
1587 * @brief Checks if the LCD flash feature is supported.
1588 *
1589 * This function determines whether the current system or device supports the LCD flash feature.
1590 * It returns `true` if the feature is supported; otherwise, it returns `false`.
1591 *
1592 * @return `true` if the LCD flash feature is supported; `false` otherwise.
1593 */
1594 bool IsLcdFlashSupported();
1595
1596 /**
1597 * @brief Enables or disables the LCD flash feature.
1598 *
1599 * This function enables or disables the LCD flash feature based on the provided `isEnable` flag.
1600 *
1601 * @param isEnable A boolean flag indicating whether to enable (`true`) or disable (`false`) the LCD flash feature.
1602 *
1603 * @return Returns an `int32_t` value indicating the result of the operation.
1604 * Typically, a return value of 0 indicates success, while a non-zero value indicates an error.
1605 */
1606 int32_t EnableLcdFlash(bool isEnable);
1607
1608 /**
1609 * @brief Enables or disables LCD flash detection.
1610 *
1611 * This function enables or disables the detection of the LCD flash feature based on the provided `isEnable` flag.
1612 *
1613 * @param isEnable A boolean flag indicating whether to enable (`true`) or disable (`false`) LCD flash detection.
1614 *
1615 * @return Returns an `int32_t` value indicating the outcome of the operation.
1616 * A return value of 0 typically signifies success, while a non-zero value indicates an error.
1617 */
1618 int32_t EnableLcdFlashDetection(bool isEnable);
1619
1620 void ProcessLcdFlashStatusUpdates(const std::shared_ptr<OHOS::Camera::CameraMetadata> &result);
1621
1622 /**
1623 * @brief Sets the callback for LCD flash status updates.
1624 *
1625 * This function assigns a callback to be invoked whenever there is a change in the LCD flash status.
1626 * The callback is passed as a shared pointer, allowing for shared ownership and automatic memory management.
1627 *
1628 * @param lcdFlashStatusCallback A shared pointer to an LcdFlashStatusCallback object. This callback will
1629 * be called to handle updates related to the LCD flash status. If the callback is already set,
1630 * it will be overwritten with the new one.
1631 */
1632 void SetLcdFlashStatusCallback(std::shared_ptr<LcdFlashStatusCallback> lcdFlashStatusCallback);
1633
1634 /**
1635 * @brief Retrieves the current LCD flash status callback.
1636 *
1637 * This function returns a shared pointer to the `LcdFlashStatusCallback` object that is used for receiving
1638 * notifications or callbacks related to the LCD flash status.
1639 *
1640 * @return A `std::shared_ptr<LcdFlashStatusCallback>` pointing to the current LCD flash status callback.
1641 * If no callback is set, it may return a `nullptr`.
1642 */
1643 std::shared_ptr<LcdFlashStatusCallback> GetLcdFlashStatusCallback();
1644 void EnableFaceDetection(bool enable);
1645 /**
1646 * @brief Checks if tripod detection is supported.
1647 *
1648 * This function determines whether the current system or device supports tripod detection functionality.
1649 * It returns `true` if the feature is supported, otherwise `false`.
1650 *
1651 * @return `true` if tripod detection is supported; `false` otherwise.
1652 */
1653 bool IsTripodDetectionSupported();
1654
1655 /**
1656 * @brief Enables or disables tripod stabilization.
1657 *
1658 * This function enables or disables the tripod stabilization feature based on the provided `enabled` flag.
1659 *
1660 * @param enabled A boolean flag that indicates whether to enable or disable tripod stabilization.
1661 *
1662 * @return Returns an `int32_t` value indicating the success or failure of the operation.
1663 * Typically, a return value of 0 indicates success, while a non-zero value indicates an error.
1664 */
1665 int32_t EnableTripodStabilization(bool enabled);
1666
1667 /**
1668 * @brief Enables or disables tripod detection.
1669 *
1670 * This function enables or disables the tripod detection feature based on the provided `enabled` flag.
1671 *
1672 * @param enabled A boolean flag that specifies whether to enable or disable tripod detection.
1673 *
1674 * @return Returns an `int32_t` value indicating the outcome of the operation.
1675 * A return value of 0 typically indicates success, while a non-zero value indicates an error.
1676 */
1677 int32_t EnableTripodDetection(bool enabled);
1678
1679 void ProcessTripodStatusChange(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1680
1681 int32_t EnableRawDelivery(bool enabled);
1682
1683 /**
1684 * @brief Checks if the automatic switchover device is supported.
1685 *
1686 * @return true if supported; false otherwise.
1687 */
1688 bool IsAutoDeviceSwitchSupported();
1689
1690 /**
1691 * @brief Enables or disables the automatic switchover device.
1692 *
1693 * @param isEnable True to enable, false to disable.
1694 * @return 0 on success, or a negative error code on failure.
1695 */
1696 int32_t EnableAutoDeviceSwitch(bool isEnable);
1697
1698 /**
1699 * @brief Switches the current device to a different one.
1700 *
1701 * @return true if the switch was successful; false if it failed or is not supported.
1702 */
1703 bool SwitchDevice();
1704
1705 /**
1706 * @brief Enables or disables the automatic switchover device.
1707 *
1708 * @param isEnable True to enable, false to disable.
1709 */
1710 void SetIsAutoSwitchDeviceStatus(bool isEnable);
1711
1712 /**
1713 * @brief Checks if the automatic switchover device is enabled.
1714 *
1715 * @return True if enabled, false otherwise.
1716 */
1717 bool GetIsAutoSwitchDeviceStatus();
1718
1719 /**
1720 * @brief Sets the callback for automatic device switching.
1721 *
1722 * @param autoDeviceSwitchCallback A shared pointer to the callback.
1723 */
1724 void SetAutoDeviceSwitchCallback(shared_ptr<AutoDeviceSwitchCallback> autoDeviceSwitchCallback);
1725
1726 /**
1727 * @brief Gets the current automatic device switch callback.
1728 *
1729 * @return A shared pointer to the callback, or nullptr if not set.
1730 */
1731 shared_ptr<AutoDeviceSwitchCallback> GetAutoDeviceSwitchCallback();
1732
SetDeviceCapabilityChangeStatus(bool isDeviceCapabilityChanged)1733 inline void SetDeviceCapabilityChangeStatus(bool isDeviceCapabilityChanged)
1734 {
1735 isDeviceCapabilityChanged_ = isDeviceCapabilityChanged;
1736 }
1737
GetDeviceCapabilityChangeStatus()1738 inline bool GetDeviceCapabilityChangeStatus()
1739 {
1740 return isDeviceCapabilityChanged_;
1741 }
1742
1743 /**
1744 * @brief Adds a function to the mapping with the specified control tag.
1745 *
1746 * This function is used to register a callback that will be executed
1747 * when the automatic switchover device is enabled. The control target
1748 * must be set prior to switching the device. After the device is switched,
1749 * the target needs to be reset to HAL.
1750 *
1751 * @note This functionality is applicable only for SceneMode::CAPTURE
1752 * and SceneMode::VIDEO modes.
1753 *
1754 * @param ctrlTag The control tag associated with the function.
1755 * @param func The function to be added to the map, which will be called
1756 * when the corresponding control tag is triggered.
1757 */
1758 void AddFunctionToMap(std::string ctrlTag, std::function<void()> func);
1759 void ExecuteAllFunctionsInMap();
1760
1761 /**
1762 * @brief Set usage for the capture session.
1763 * @param usage - The capture session usage.
1764 * @param enabled - Enable usage for session if TRUE.
1765 */
1766 void SetUsage(UsageType usageType, bool enabled);
1767
1768 protected:
1769
1770 static const std::unordered_map<camera_awb_mode_t, WhiteBalanceMode> metaWhiteBalanceModeMap_;
1771 static const std::unordered_map<WhiteBalanceMode, camera_awb_mode_t> fwkWhiteBalanceModeMap_;
1772
1773 static const std::unordered_map<LightPaintingType, CameraLightPaintingType> fwkLightPaintingTypeMap_;
1774 static const std::unordered_map<CameraLightPaintingType, LightPaintingType> metaLightPaintingTypeMap_;
1775 static const std::unordered_map<TripodStatus, FwkTripodStatus> metaTripodStatusMap_;
1776 std::shared_ptr<OHOS::Camera::CameraMetadata> changedMetadata_;
1777 Profile photoProfile_;
1778 Profile previewProfile_;
1779 std::map<BeautyType, std::vector<int32_t>> beautyTypeAndRanges_;
1780 std::map<BeautyType, int32_t> beautyTypeAndLevels_;
1781 std::shared_ptr<MetadataResultProcessor> metadataResultProcessor_ = nullptr;
1782 bool isImageDeferred_ = false;
1783 std::atomic<bool> isRawImageDelivery_ { false };
1784 bool isVideoDeferred_ = false;
1785 std::atomic<bool> isMovingPhotoEnabled_ { false };
1786
1787 std::shared_ptr<AbilityCallback> abilityCallback_;
1788 std::atomic<uint32_t> exposureDurationValue_ = 0;
1789
1790 float apertureValue_ = 0.0;
1791
ClearPreconfigProfiles()1792 inline void ClearPreconfigProfiles()
1793 {
1794 std::lock_guard<std::mutex> lock(preconfigProfilesMutex_);
1795 preconfigProfiles_ = nullptr;
1796 }
1797
SetPreconfigProfiles(std::shared_ptr<PreconfigProfiles> preconfigProfiles)1798 inline void SetPreconfigProfiles(std::shared_ptr<PreconfigProfiles> preconfigProfiles)
1799 {
1800 std::lock_guard<std::mutex> lock(preconfigProfilesMutex_);
1801 preconfigProfiles_ = preconfigProfiles;
1802 }
1803
GetPreconfigProfiles()1804 inline std::shared_ptr<PreconfigProfiles> GetPreconfigProfiles()
1805 {
1806 std::lock_guard<std::mutex> lock(preconfigProfilesMutex_);
1807 return preconfigProfiles_;
1808 }
1809
SetInputDevice(sptr<CaptureInput> inputDevice)1810 inline void SetInputDevice(sptr<CaptureInput> inputDevice)
1811 {
1812 std::lock_guard<std::mutex> lock(inputDeviceMutex_);
1813 innerInputDevice_ = inputDevice;
1814 }
1815
GetCameraAbilityContainer()1816 inline sptr<CameraAbilityContainer> GetCameraAbilityContainer()
1817 {
1818 std::lock_guard<std::mutex> lock(abilityContainerMutex_);
1819 return cameraAbilityContainer_;
1820 }
1821
SetCaptureSession(sptr<ICaptureSession> captureSession)1822 inline void SetCaptureSession(sptr<ICaptureSession> captureSession)
1823 {
1824 std::lock_guard<std::mutex> lock(captureSessionMutex_);
1825 innerCaptureSession_ = captureSession;
1826 }
1827
1828 virtual std::shared_ptr<PreconfigProfiles> GeneratePreconfigProfiles(
1829 PreconfigType preconfigType, ProfileSizeRatio preconfigRatio);
1830
1831 private:
1832 std::mutex switchDeviceMutex_;
1833 std::mutex functionMapMutex_;
1834 std::mutex changeMetaMutex_;
1835 std::mutex sessionCallbackMutex_;
1836 std::mutex captureSessionMutex_;
1837 sptr<ICaptureSession> innerCaptureSession_ = nullptr;
1838 std::shared_ptr<SessionCallback> appCallback_;
1839 sptr<ICaptureSessionCallback> captureSessionCallback_;
1840 std::shared_ptr<ExposureCallback> exposureCallback_;
1841 std::shared_ptr<FocusCallback> focusCallback_;
1842 std::shared_ptr<MacroStatusCallback> macroStatusCallback_;
1843 std::shared_ptr<MoonCaptureBoostStatusCallback> moonCaptureBoostStatusCallback_;
1844 std::shared_ptr<FeatureDetectionStatusCallback> featureDetectionStatusCallback_;
1845 std::shared_ptr<SmoothZoomCallback> smoothZoomCallback_;
1846 std::shared_ptr<ARCallback> arCallback_;
1847 std::shared_ptr<EffectSuggestionCallback> effectSuggestionCallback_;
1848 std::shared_ptr<LcdFlashStatusCallback> lcdFlashStatusCallback_;
1849 std::shared_ptr<AutoDeviceSwitchCallback> autoDeviceSwitchCallback_;
1850 sptr<IFoldServiceCallback> foldStatusCallback_ = nullptr;
1851 std::vector<int32_t> skinSmoothBeautyRange_;
1852 std::vector<int32_t> faceSlendorBeautyRange_;
1853 std::vector<int32_t> skinToneBeautyRange_;
1854 std::mutex captureOutputSetsMutex_;
1855 std::set<wptr<CaptureOutput>, RefBaseCompare<CaptureOutput>> captureOutputSets_;
1856
1857 std::mutex inputDeviceMutex_;
1858 sptr<CaptureInput> innerInputDevice_ = nullptr;
1859 volatile bool isSetMacroEnable_ = false;
1860 volatile bool isDepthFusionEnable_ = false;
1861 volatile bool isSetMoonCaptureBoostEnable_ = false;
1862 volatile bool isSetTripodDetectionEnable_ = false;
1863 volatile bool isSetSecureOutput_ = false;
1864 std::atomic<bool> isSetLowLightBoostEnable_ = false;
1865 static const std::unordered_map<camera_focus_state_t, FocusCallback::FocusState> metaFocusStateMap_;
1866 static const std::unordered_map<camera_exposure_state_t, ExposureCallback::ExposureState> metaExposureStateMap_;
1867
1868 static const std::unordered_map<camera_filter_type_t, FilterType> metaFilterTypeMap_;
1869 static const std::unordered_map<FilterType, camera_filter_type_t> fwkFilterTypeMap_;
1870 static const std::unordered_map<BeautyType, camera_device_metadata_tag_t> fwkBeautyControlMap_;
1871 static const std::unordered_map<camera_device_metadata_tag_t, BeautyType> metaBeautyControlMap_;
1872 static const std::unordered_map<CameraEffectSuggestionType, EffectSuggestionType> metaEffectSuggestionTypeMap_;
1873 static const std::unordered_map<EffectSuggestionType, CameraEffectSuggestionType> fwkEffectSuggestionTypeMap_;
1874
1875 sptr<CaptureOutput> metaOutput_ = nullptr;
1876 sptr<CaptureOutput> photoOutput_;
1877 std::atomic<int32_t> prevDuration_ = 0;
1878 sptr<CameraDeathRecipient> deathRecipient_ = nullptr;
1879 bool isColorSpaceSetted_ = false;
1880 atomic<bool> isDeferTypeSetted_ = false;
1881 atomic<bool> isAutoSwitchDevice_ = false;
1882 atomic<bool> isDeviceCapabilityChanged_ = false;
1883 atomic<bool> canAddFuncToMap_ = true;
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 void PopulateProfileLists(std::vector<Profile>& photoProfileList,
1903 std::vector<Profile>& previewProfileList,
1904 std::vector<VideoProfile>& videoProfileList);
1905 void PopulateSpecIdMaps(sptr<CameraDevice> device, int32_t modeName,
1906 std::map<int32_t, std::vector<Profile>>& specIdPreviewMap,
1907 std::map<int32_t, std::vector<Profile>>& specIdPhotoMap,
1908 std::map<int32_t, std::vector<VideoProfile>>& specIdVideoMap);
1909 // Make sure you know what you are doing, you'd better to use {GetMode()} function instead of this variable.
1910 SceneMode currentMode_ = SceneMode::NORMAL;
1911 SceneMode guessMode_ = SceneMode::NORMAL;
1912 std::mutex moonCaptureBoostFeatureMutex_;
1913 std::shared_ptr<MoonCaptureBoostFeature> moonCaptureBoostFeature_ = nullptr;
1914 float focusDistance_ = 0.0;
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 bool IsModeWithVideoStream();
1936 void SetDefaultColorSpace();
1937 void UpdateDeviceDeferredability();
1938 void ProcessProfilesAbilityId(const SceneMode supportModes);
1939 int32_t ProcessCaptureColorSpace(ColorSpaceInfo colorSpaceInfo, ColorSpace& fwkCaptureColorSpace);
1940 void ProcessFocusDistanceUpdates(const std::shared_ptr<OHOS::Camera::CameraMetadata>& result);
1941 void FindTagId();
1942 bool CheckFrameRateRangeWithCurrentFps(int32_t curMinFps, int32_t curMaxFps, int32_t minFps, int32_t maxFps);
1943 void SessionRemoveDeathRecipient();
1944 int32_t AdaptOutputVideoHighFrameRate(sptr<CaptureOutput>& output, sptr<ICaptureSession>& captureSession);
1945 CameraPosition GetUsedAsPosition();
1946 sptr<CameraDevice> FindFrontCamera();
1947 void StartVideoOutput();
1948 bool StopVideoOutput();
1949 void CreateAndSetFoldServiceCallback();
1950 };
1951 } // namespace CameraStandard
1952 } // namespace OHOS
1953 #endif // OHOS_CAMERA_CAPTURE_SESSION_H
1954