diff --git a/frameworks/taihe/idl/ohos.multimedia.camera.taihe b/frameworks/taihe/idl/ohos.multimedia.camera.taihe index b9907a39aeb844edf66e05d13bf44a52647e36b8..823cd002669eee7d4dc58f08bc3242ea3b9170d2 100644 --- a/frameworks/taihe/idl/ohos.multimedia.camera.taihe +++ b/frameworks/taihe/idl/ohos.multimedia.camera.taihe @@ -479,17 +479,17 @@ interface PreviewOutput : CameraOutput { OnSketchStatusChanged(callback:(err: @sts_type("BusinessError") Opaque, data: SketchStatusData)=> void): void; OffSketchStatusChanged(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: SketchStatusData)=> void>): void; - GetActiveProfile(): Profile; - GetSupportedFrameRates(): Array; - GetActiveFrameRate(): FrameRateRange; + GetActiveProfile(): Optional; + GetSupportedFrameRates(): Optional>; + GetActiveFrameRate(): Optional; SetFrameRate(minFps: i32, maxFps: i32): void; GetPreviewRotation(displayRotation: i32): ImageRotation; SetPreviewRotation(previewRotation: ImageRotation, isDisplayLocked: Optional): void; AttachSketchSurface(surfaceId: String): void; EnableSketch(enabled: bool): void; AddDeferredSurface(surfaceId: String): void; - IsSketchSupported(): bool; - GetSketchRatio(): f64; + IsSketchSupported(): Optional; + GetSketchRatio(): Optional; } interface CameraInput { @@ -557,15 +557,15 @@ interface CameraInput { } interface FlashQuery { - HasFlash(): bool; - IsFlashModeSupported(flashMode: FlashMode): bool; - IsLcdFlashSupported(): bool; + HasFlash(): Optional; + IsFlashModeSupported(flashMode: FlashMode): Optional; + IsLcdFlashSupported(): Optional; } interface Flash : FlashQuery { EnableLcdFlash(enabled: bool): void; SetFlashMode(flashMode: FlashMode): void; - GetFlashMode(): FlashMode; + GetFlashMode(): Optional; } enum SmoothZoomMode : i32 { @@ -573,12 +573,12 @@ enum SmoothZoomMode : i32 { } interface ZoomQuery { - GetZoomRatioRange(): Array; - GetZoomPointInfos(): Array; + GetZoomRatioRange(): Optional>; + GetZoomPointInfos(): Optional>; } interface Zoom : ZoomQuery { - GetZoomRatio(): f64; + GetZoomRatio(): Optional; SetZoomRatio(zoomRatio: f64): void; PrepareZoom(): void; UnprepareZoom(): void; @@ -610,9 +610,9 @@ interface Session { ReleaseSync(); SetUsage(usage: UsageType, enabled: bool): void; - GetCameraOutputCapabilities(camera: CameraDevice): Array; - CanAddInput(cameraInput: CameraInput): bool; - CanAddOutput(cameraOutput: CameraOutput): bool; + GetCameraOutputCapabilities(camera: CameraDevice): Optional>; + CanAddInput(cameraInput: CameraInput): Optional; + CanAddOutput(cameraOutput: CameraOutput): Optional; } struct LcdFlashStatus { @@ -662,7 +662,7 @@ enum EffectSuggestionType: i32 { interface PhotoSession : Session, Flash, Zoom, AutoExposure, AutoDeviceSwitch, ColorManagement, Focus, Macro, WhiteBalance { Preconfig(preconfigType: PreconfigType, preconfigRatio: Optional): void; - CanPreconfig(preconfigType: PreconfigType, preconfigRatio: Optional): bool; + CanPreconfig(preconfigType: PreconfigType, preconfigRatio: Optional): Optional; @!sts_inject_into_interface("on(type: string, callback: (err: BusinessError)=> void): void;") @!sts_inject_into_interface("on(type: string, callback: (err: BusinessError, data: object)=> void): void;") @!sts_inject_into_interface("on(type: string, featureType: SceneFeatureType, callback: (err: BusinessError, data: object)=> void): void;") @@ -753,8 +753,8 @@ interface PhotoSession : Session, Flash, Zoom, AutoExposure, AutoDeviceSwitch, C OnEffectSuggestionChange(callback: (err: @sts_type("BusinessError") Opaque, data: EffectSuggestionType)=> void): void; OffEffectSuggestionChange(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: EffectSuggestionType)=> void>): void; - GetSessionFunctions(outputCapability: CameraOutputCapability): Array; - GetSessionConflictFunctions(): Array; + GetSessionFunctions(outputCapability: CameraOutputCapability): Optional>; + GetSessionConflictFunctions(): Optional>; GetSpecificImplPtr(): i64; } @@ -849,7 +849,7 @@ struct FocusTrackingInfo { interface VideoSession : Session, Flash, Zoom, Stabilization, ColorManagement, AutoExposure, AutoDeviceSwitch, Focus, WhiteBalance, Macro { Preconfig(preconfigType: PreconfigType, preconfigRatio: Optional): void; - CanPreconfig(preconfigType: PreconfigType, preconfigRatio: Optional): bool; + CanPreconfig(preconfigType: PreconfigType, preconfigRatio: Optional): Optional; @!sts_inject_into_interface("on(type: string, callback: (data: object)=> void): void;") @!sts_inject_into_interface("on(type: string, callback: (err: BusinessError, data: object)=> void): void;") @!sts_inject_into_class("""on(type: string, callback: object): void { @@ -931,8 +931,8 @@ interface VideoSession : Session, Flash, Zoom, Stabilization, ColorManagement, A OffEffectSuggestionChange(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: EffectSuggestionType)=> void>): void; SetQualityPrioritization(quality : QualityPrioritization) : void; - GetSessionFunctions(outputCapability: CameraOutputCapability): Array; - GetSessionConflictFunctions(): Array; + GetSessionFunctions(outputCapability: CameraOutputCapability): Optional>; + GetSessionConflictFunctions(): Optional>; GetSpecificImplPtr(): i64; } @@ -1045,8 +1045,8 @@ interface PortraitPhotoSession : Session, Flash, AutoExposure, Focus, Zoom, Beau OnLcdFlashStatus(callback: (err: @sts_type("BusinessError") Opaque, data: LcdFlashStatus)=> void): void; OffLcdFlashStatus(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: LcdFlashStatus)=> void>): void; - GetSessionFunctions(outputCapability: CameraOutputCapability): Array; - GetSessionConflictFunctions(): Array; + GetSessionFunctions(outputCapability: CameraOutputCapability): Optional>; + GetSessionConflictFunctions(): Optional>; } interface PortraitPhotoConflictFunctions : ZoomQuery, PortraitQuery, ApertureQuery { @@ -1190,7 +1190,7 @@ interface SlowMotionVideoSession : Session, Flash, AutoExposure, Focus, Zoom, Co OnSlowMotionStatus(callback: (err: @sts_type("BusinessError") Opaque, data: SlowMotionStatus)=> void): void; OffSlowMotionStatus(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: SlowMotionStatus)=> void>): void; - IsSlowMotionDetectionSupported(): bool; + IsSlowMotionDetectionSupported(): Optional; SetSlowMotionDetectionArea(area: Rect): void; } @@ -1350,17 +1350,17 @@ interface LightPaintingPhotoSession : Session, Flash, Focus, Zoom, ColorEffect { OnSmoothZoomInfoAvailable(callback: (err: @sts_type("BusinessError") Opaque, data: SmoothZoomInfo)=> void): void; OffSmoothZoomInfoAvailable(callback: Optional<(err: @sts_type("BusinessError") Opaque, data: SmoothZoomInfo)=> void>): void; - GetSupportedLightPaintingTypes(): Array; + GetSupportedLightPaintingTypes(): Optional>; SetLightPaintingType(type: LightPaintingType): void; - GetLightPaintingType(): LightPaintingType; + GetLightPaintingType(): Optional; } interface EffectSuggestion { SetEffectSuggestionStatus(status: Array): void; UpdateEffectSuggestion(type: EffectSuggestionType, enabled: bool): void; EnableEffectSuggestion(enabled: bool): void; - IsEffectSuggestionSupported(): bool; - GetSupportedEffectSuggestionTypes(): Array; + IsEffectSuggestionSupported(): Optional; + GetSupportedEffectSuggestionTypes(): Optional>; } interface QuickShotPhotoSession : Session, AutoExposure, ColorEffect, ColorManagement, EffectSuggestion, Flash, Focus, Zoom { @@ -1542,11 +1542,11 @@ interface TimeLapsePhotoSession : Session, Focus, ManualFocus, AutoExposure, Man SetTimeLapsePreviewType(type: TimeLapsePreviewType): void; SetTimeLapseInterval(interval: i32): void; - GetTimeLapseInterval(): i32; + GetTimeLapseInterval(): Optional; SetTimeLapseRecordState(state: TimeLapseRecordState): void; //GetTimeLapseRecordState(): TimeLapseRecordState; - GetSupportedTimeLapseIntervalRange(): Array; - IsTryAENeeded(): bool; + GetSupportedTimeLapseIntervalRange(): Optional>; + IsTryAENeeded(): Optional; StartTryAE(): void; StopTryAE(): void; } @@ -1575,40 +1575,40 @@ union SessionUnion { } interface CameraManager { - GetSupportedCameras(): Array; - GetSupportedSceneModes(camera: CameraDevice): Array; - GetSupportedOutputCapability(camera: CameraDevice, mode: SceneMode): CameraOutputCapability; + GetSupportedCameras(): Optional>; + GetSupportedSceneModes(camera: CameraDevice): Optional>; + GetSupportedOutputCapability(camera: CameraDevice, mode: SceneMode): Optional; Prelaunch(): void; PreSwitchCamera(cameraId: String): void; - IsTorchSupported(): bool; - IsPrelaunchSupported(camera: CameraDevice): bool; - IsCameraMuted(): bool; - IsCameraMuteSupported(): bool; - GetTorchMode(): TorchMode; + IsTorchSupported(): Optional; + IsPrelaunchSupported(camera: CameraDevice): Optional; + IsCameraMuted(): Optional; + IsCameraMuteSupported(): Optional; + GetTorchMode(): Optional; SetTorchMode(mode: TorchMode): void; - CreateSession(mode: SceneMode): SessionUnion; - CreateDeferredPreviewOutput(profile: Optional): PreviewOutput; + CreateSession(mode: SceneMode): Optional; + CreateDeferredPreviewOutput(profile: Optional): Optional; MuteCameraPersistent(mute: bool, type: PolicyType): void; SetPrelaunchConfig(prelaunchConfig: PrelaunchConfig): void; - GetCameraConcurrentInfos(cameras: Array): Array; + GetCameraConcurrentInfos(cameras: Array): Optional>; @overload("createCameraInput") - CreateCameraInputWithCameraDevice(camera: CameraDevice): CameraInput; + CreateCameraInputWithCameraDevice(camera: CameraDevice): Optional; @overload("createCameraInput") - CreateCameraInputWithPosition(position: CameraPosition, type: CameraType): CameraInput; + CreateCameraInputWithPosition(position: CameraPosition, type: CameraType): Optional; @overload("createPreviewOutput") - CreatePreviewOutput(profile: Profile, surfaceId: String): PreviewOutput; + CreatePreviewOutput(profile: Profile, surfaceId: String): Optional; @overload("createPreviewOutput") - CreatePreviewOutputWithoutProfile(surfaceId: String): PreviewOutput; - CreatePhotoOutput(profile: Optional): PhotoOutput; + CreatePreviewOutputWithoutProfile(surfaceId: String): Optional; + CreatePhotoOutput(profile: Optional): Optional; @overload("createVideoOutput") - CreateVideoOutput(profile: VideoProfile, surfaceId: String): VideoOutput; + CreateVideoOutput(profile: VideoProfile, surfaceId: String): Optional; @overload("createVideoOutput") - CreateVideoOutputWithoutProfile(surfaceId: String): VideoOutput; - CreateDepthDataOutput(profile: DepthProfile): DepthDataOutput; + CreateVideoOutputWithoutProfile(surfaceId: String): Optional; + CreateDepthDataOutput(profile: DepthProfile): Optional; @overload("createMetadataOutput") - CreateMetadataOutput(metadataObjectTypes: Array): MetadataOutput; + CreateMetadataOutput(metadataObjectTypes: Array): Optional; IsTorchModeSupported(mode: TorchMode): bool; - GetCameraDevice(position: CameraPosition, type: CameraType): CameraDevice; + GetCameraDevice(position: CameraPosition, type: CameraType): Optional; @!sts_inject_into_interface("on(type: string, callback: (err: BusinessError, data: object)=> void): void;") @!sts_inject_into_class("""on(type: string, callback: object): void { @@ -1667,20 +1667,20 @@ interface VideoOutput : CameraOutput { StopSync(): void; EnableAutoVideoFrameRate(enabled: bool): void; - IsAutoVideoFrameRateSupported(): bool; - IsMirrorSupported(): bool; + IsAutoVideoFrameRateSupported(): Optional; + IsMirrorSupported(): Optional; EnableMirror(enabled: bool): void; - GetSupportedFrameRates(): Array; - GetActiveFrameRate(): FrameRateRange; - IsAutoDeferredVideoEnhancementSupported(): bool; - IsAutoDeferredVideoEnhancementEnabled(): bool; + GetSupportedFrameRates(): Optional>; + GetActiveFrameRate(): Optional; + IsAutoDeferredVideoEnhancementSupported(): Optional; + IsAutoDeferredVideoEnhancementEnabled(): Optional; SetRotation(rotation: ImageRotation): void; - IsRotationSupported(): bool; - GetSupportedRotations(): Array; - GetActiveProfile(): VideoProfile; + IsRotationSupported(): Optional; + GetSupportedRotations(): Optional>; + GetActiveProfile(): Optional; SetFrameRate(minFps: i32, maxFps: i32): void; - GetVideoRotation(deviceDegree: i32): ImageRotation; - GetSupportedVideoMetaTypes(): Array; + GetVideoRotation(deviceDegree: i32): Optional; + GetSupportedVideoMetaTypes(): Optional>; AttachMetaSurface(surfaceId: String, type: VideoMetaType): void; EnableAutoDeferredVideoEnhancement(enabled: bool): void; @@ -2138,29 +2138,29 @@ interface PhotoOutput : CameraOutput { CaptureSyncWithSetting(setting: PhotoCaptureSetting): void; EnableMirror(enabled: bool): void; - IsMirrorSupported(): bool; - GetActiveProfile(): Profile; + IsMirrorSupported(): Optional; + GetActiveProfile(): Optional; EnableOffline(): void; - IsOfflineSupported(): bool; + IsOfflineSupported(): Optional; EnableMovingPhoto(enabled: bool): void; - IsMovingPhotoSupported(): bool; - GetPhotoRotation(deviceDegree: i32): ImageRotation; + IsMovingPhotoSupported(): Optional; + GetPhotoRotation(deviceDegree: i32): Optional; EnableAutoCloudImageEnhancement(enabled: bool): void; - IsAutoCloudImageEnhancementSupported(): bool; + IsAutoCloudImageEnhancementSupported(): Optional; EnableQuickThumbnail(enabled: bool): void; - IsDepthDataDeliverySupported(): bool; + IsDepthDataDeliverySupported(): Optional; EnableDepthDataDelivery(enabled: bool): void; EnableAutoHighQualityPhoto(enabled: bool): void; - IsAutoHighQualityPhotoSupported(): bool; + IsAutoHighQualityPhotoSupported(): Optional; EnableRawDelivery(enabled: bool): void; - IsRawDeliverySupported(): bool; + IsRawDeliverySupported(): Optional; SetMovingPhotoVideoCodecType(codecType: VideoCodecType): void; GetSupportedMovingPhotoVideoCodecTypes(): Array; ConfirmCapture(); - IsDeferredImageDeliverySupported(type: DeferredDeliveryImageType): bool; - IsQuickThumbnailSupported(): bool; + IsDeferredImageDeliverySupported(type: DeferredDeliveryImageType): Optional; + IsQuickThumbnailSupported(): Optional; DeferImageDelivery(type: DeferredDeliveryImageType): void; - IsDeferredImageDeliveryEnabled(type: DeferredDeliveryImageType): bool; + IsDeferredImageDeliveryEnabled(type: DeferredDeliveryImageType): Optional; } enum VideoCodecType : i32{ @@ -2179,152 +2179,151 @@ struct PhysicalAperture { } interface AutoExposureQuery { - GetExposureBiasRange(): Array; - IsExposureModeSupported(aeMode: ExposureMode): bool; - IsExposureMeteringModeSupported(aeMeteringMode: ExposureMeteringMode): bool; + GetExposureBiasRange(): Optional>; + IsExposureModeSupported(aeMode: ExposureMode): Optional; + IsExposureMeteringModeSupported(aeMeteringMode: ExposureMeteringMode): Optional; } interface AutoExposure : AutoExposureQuery { SetExposureBias(exposureBias: f64): void; SetExposureMeteringMode(aeMeteringMode: ExposureMeteringMode): void; - GetExposureMeteringMode(): ExposureMeteringMode; - GetExposureValue(): f64; - GetMeteringPoint(): Point; + GetExposureMeteringMode(): Optional; + GetExposureValue(): Optional; + GetMeteringPoint(): Optional; SetMeteringPoint(point: Point): void; - GetExposureMode(): ExposureMode; + GetExposureMode(): Optional; SetExposureMode(aeMode: ExposureMode): void; } interface PortraitQuery { - GetSupportedPortraitEffects(): Array; + GetSupportedPortraitEffects(): Optional>; } interface Portrait : PortraitQuery { SetPortraitEffect(effect: PortraitEffect): void; - GetPortraitEffect(): PortraitEffect; + GetPortraitEffect(): Optional; } interface BeautyQuery { - GetSupportedPortraitThemeTypes(): Array; - IsPortraitThemeSupported(): bool; - GetSupportedBeautyTypes(): Array; - GetSupportedBeautyRange(type: BeautyType): Array; + GetSupportedPortraitThemeTypes(): Optional>; + IsPortraitThemeSupported(): Optional; + GetSupportedBeautyTypes(): Optional>; + GetSupportedBeautyRange(type: BeautyType): Optional>; } interface Beauty : BeautyQuery { SetPortraitThemeType(type: PortraitThemeType): void; - GetBeauty(type: BeautyType): i32; + GetBeauty(type: BeautyType): Optional; SetBeauty(type: BeautyType, value: i32): void; } interface ColorManagementQuery { - GetSupportedColorSpaces(): Array<@sts_type("colorSpaceManager.ColorSpace") Opaque>; + GetSupportedColorSpaces(): Optional>; } interface ColorManagement : ColorManagementQuery { SetColorSpace(colorSpace: @sts_type("colorSpaceManager.ColorSpace") Opaque): void; - GetActiveColorSpace(): @sts_type("colorSpaceManager.ColorSpace") Opaque; + GetActiveColorSpace(): Optional<@sts_type("colorSpaceManager.ColorSpace") Opaque>; } interface DepthFusionQuery { - IsDepthFusionSupported(): bool; - GetDepthFusionThreshold(): Array; + IsDepthFusionSupported(): Optional; + GetDepthFusionThreshold(): Optional>; } interface DepthFusion : DepthFusionQuery { EnableDepthFusion(enabled: bool): void; - IsDepthFusionEnabled(): bool; + IsDepthFusionEnabled(): Optional; } interface FocusQuery { - IsFocusRangeTypeSupported(type: FocusRangeType): bool; - IsFocusDrivenTypeSupported(type: FocusDrivenType): bool; - IsFocusModeSupported(afMode: FocusMode): bool; - IsFocusAssistSupported(): bool; + IsFocusRangeTypeSupported(type: FocusRangeType): Optional; + IsFocusDrivenTypeSupported(type: FocusDrivenType): Optional; + IsFocusModeSupported(afMode: FocusMode): Optional; + IsFocusAssistSupported(): Optional; } interface Focus : FocusQuery { SetFocusDriven(type: FocusDrivenType): void; - GetFocusDriven(): FocusDrivenType; + GetFocusDriven(): Optional; SetFocusRange(type: FocusRangeType): void; - GetFocusRange(): FocusRangeType; + GetFocusRange(): Optional; SetFocusAssist(enabled: bool): void; - GetFocusMode(): FocusMode; + GetFocusMode(): Optional; SetFocusMode(afMode: FocusMode): void; - GetFocusPoint(): Point; + GetFocusPoint(): Optional; SetFocusPoint(point: Point): void; - GetFocalLength(): f64; + GetFocalLength(): Optional; } interface StabilizationQuery { - IsVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): bool; + IsVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Optional; } interface Stabilization : StabilizationQuery { - GetActiveVideoStabilizationMode(): VideoStabilizationMode; + GetActiveVideoStabilizationMode(): Optional; SetVideoStabilizationMode(mode: VideoStabilizationMode): void; } interface ManualExposureQuery { - GetSupportedExposureRange(): Array; + GetSupportedExposureRange(): Optional>; } interface ManualExposure : ManualExposureQuery{ - GetExposure(): i32; + GetExposure(): Optional; SetExposure(exposure: i32): void; } interface ManualFocus { - GetFocusDistance(): f64; + GetFocusDistance(): Optional; SetFocusDistance(distance: f64): void; } interface WhiteBalanceQuery { - IsWhiteBalanceModeSupported(mode: WhiteBalanceMode): bool; - GetWhiteBalanceRange(): Array; + IsWhiteBalanceModeSupported(mode: WhiteBalanceMode): Optional; + GetWhiteBalanceRange(): Optional>; } interface WhiteBalance : WhiteBalanceQuery { SetWhiteBalance(whiteBalance: i32): void; - GetWhiteBalance(): i32; + GetWhiteBalance(): Optional; SetWhiteBalanceMode(mode: WhiteBalanceMode): void; - GetWhiteBalanceMode(): WhiteBalanceMode; + GetWhiteBalanceMode(): Optional; } interface ManualIsoQuery { - GetIsoRange(): Array; - IsManualIsoSupported(): bool; + GetIsoRange(): Optional>; + IsManualIsoSupported(): Optional; } interface ManualIso : ManualIsoQuery { SetIso(iso: i32): void; - GetIso(): i32; + GetIso(): Optional; } interface ColorEffectQuery { - GetSupportedColorEffects(): Array; + GetSupportedColorEffects(): Optional>; } interface ColorEffect : ColorEffectQuery { SetColorEffect(type: ColorEffectType): void; - GetColorEffect(): ColorEffectType; - + GetColorEffect(): Optional; } interface ApertureQuery { - GetSupportedPhysicalApertures(): Array; - GetSupportedVirtualApertures(): Array; + GetSupportedPhysicalApertures(): Optional>; + GetSupportedVirtualApertures(): Optional>; } interface Aperture : ApertureQuery { SetVirtualAperture(aperture: f64): void; - GetVirtualAperture(): f64; + GetVirtualAperture(): Optional; SetPhysicalAperture(aperture: f64): void; - GetPhysicalAperture(): f64; + GetPhysicalAperture(): Optional; } interface MacroQuery { - IsMacroSupported(): bool; + IsMacroSupported(): Optional; } interface Macro : MacroQuery { @@ -2332,7 +2331,7 @@ interface Macro : MacroQuery { } interface SceneDetectionQuery { - IsSceneFeatureSupported(type: SceneFeatureType): bool; + IsSceneFeatureSupported(type: SceneFeatureType): Optional; } interface SceneDetection : SceneDetectionQuery { @@ -2340,16 +2339,16 @@ interface SceneDetection : SceneDetectionQuery { } interface ColorReservationQuery { - GetSupportedColorReservationTypes(): Array; + GetSupportedColorReservationTypes(): Optional>; } interface ColorReservation : ColorReservationQuery { SetColorReservation(type: ColorReservationType): void; - GetColorReservation(): ColorReservationType; + GetColorReservation(): Optional; } interface AutoDeviceSwitchQuery { - IsAutoDeviceSwitchSupported(): bool; + IsAutoDeviceSwitchSupported(): Optional; } interface AutoDeviceSwitch : AutoDeviceSwitchQuery { diff --git a/frameworks/taihe/include/input/camera_manager_taihe.h b/frameworks/taihe/include/input/camera_manager_taihe.h index 98ed99436ccf645d425f9404cadee0a333a0c494..d7ff80fa61c7b3826334335a9760a2465db73495 100644 --- a/frameworks/taihe/include/input/camera_manager_taihe.h +++ b/frameworks/taihe/include/input/camera_manager_taihe.h @@ -84,18 +84,18 @@ public: CameraManagerImpl(); ~CameraManagerImpl() {} - array GetSupportedCameras(); - array GetSupportedSceneModes(CameraDevice const& camera); - CameraOutputCapability GetSupportedOutputCapability(CameraDevice const& camera, SceneMode mode); + optional> GetSupportedCameras(); + optional> GetSupportedSceneModes(CameraDevice const& camera); + optional GetSupportedOutputCapability(CameraDevice const& camera, SceneMode mode); void Prelaunch(); void PreSwitchCamera(string_view cameraId); - bool IsTorchSupported(); - bool IsCameraMuted(); - bool IsCameraMuteSupported(); - bool IsPrelaunchSupported(CameraDevice const& camera); - TorchMode GetTorchMode(); + optional IsTorchSupported(); + optional IsCameraMuted(); + optional IsCameraMuteSupported(); + optional IsPrelaunchSupported(CameraDevice const& camera); + optional GetTorchMode(); void SetTorchMode(TorchMode mode); - SessionUnion CreateSession(SceneMode mode); + optional CreateSession(SceneMode mode); void MuteCameraPersistent(bool mute, PolicyType type); void OnCameraMute(callback_view callback); void OffCameraMute(optional_view> callback); @@ -105,19 +105,19 @@ public: void OffFoldStatusChange(optional_view> callback); void OnTorchStatusChange(callback_view callback); void OffTorchStatusChange(optional_view> callback); - PreviewOutput CreatePreviewOutput(Profile const& profile, string_view surfaceId) ; - PreviewOutput CreatePreviewOutputWithoutProfile(string_view surfaceId); - PreviewOutput CreateDeferredPreviewOutput(optional_view profile); - PhotoOutput CreatePhotoOutput(optional_view profile); - VideoOutput CreateVideoOutput(VideoProfile const& profile, string_view surfaceId); - VideoOutput CreateVideoOutputWithoutProfile(string_view surfaceId); - CameraInput CreateCameraInputWithCameraDevice(CameraDevice const& camera); - CameraInput CreateCameraInputWithPosition(CameraPosition position, CameraType type); - DepthDataOutput CreateDepthDataOutput(DepthProfile const& profile); - MetadataOutput CreateMetadataOutput(array_view metadataObjectTypes); - array GetCameraConcurrentInfos(array_view cameras); + optional CreatePreviewOutput(Profile const& profile, string_view surfaceId) ; + optional CreatePreviewOutputWithoutProfile(string_view surfaceId); + optional CreateDeferredPreviewOutput(optional_view profile); + optional CreatePhotoOutput(optional_view profile); + optional CreateVideoOutput(VideoProfile const& profile, string_view surfaceId); + optional CreateVideoOutputWithoutProfile(string_view surfaceId); + optional CreateCameraInputWithCameraDevice(CameraDevice const& camera); + optional CreateCameraInputWithPosition(CameraPosition position, CameraType type); + optional CreateDepthDataOutput(DepthProfile const& profile); + optional CreateMetadataOutput(array_view metadataObjectTypes); + optional> GetCameraConcurrentInfos(array_view cameras); void SetPrelaunchConfig(PrelaunchConfig const& prelaunchConfig); - CameraDevice GetCameraDevice(CameraPosition position, CameraType type); + optional GetCameraDevice(CameraPosition position, CameraType type); void RegisterCameraMuteCallbackListener(const std::string& eventName, std::shared_ptr callback, bool isOnce); void UnregisterCameraMuteCallbackListener(const std::string& eventName, std::shared_ptr callback); diff --git a/frameworks/taihe/include/mode/light_painting_photo_session_taihe.h b/frameworks/taihe/include/mode/light_painting_photo_session_taihe.h index d29535fec812bcfc6bf22d95ec168c508cc60c83..19ebe74a88639ca25841449d25f954868857608b 100644 --- a/frameworks/taihe/include/mode/light_painting_photo_session_taihe.h +++ b/frameworks/taihe/include/mode/light_painting_photo_session_taihe.h @@ -37,9 +37,9 @@ public: } } ~LightPaintingPhotoSessionImpl() = default; - array GetSupportedLightPaintingTypes(); + optional> GetSupportedLightPaintingTypes(); void SetLightPaintingType(LightPaintingType type); - LightPaintingType GetLightPaintingType(); + optional GetLightPaintingType(); private: sptr lightPaintingSession_ = nullptr; }; diff --git a/frameworks/taihe/include/mode/night_photo_session_taihe.h b/frameworks/taihe/include/mode/night_photo_session_taihe.h index a0f0a4374c8d965fa192795457c57afcc9d28738..59052f1004ecadbbb23d97dfe96a902346f57873 100644 --- a/frameworks/taihe/include/mode/night_photo_session_taihe.h +++ b/frameworks/taihe/include/mode/night_photo_session_taihe.h @@ -38,9 +38,9 @@ public: } } ~NightPhotoSessionImpl() = default; - int32_t GetExposure() override; + optional GetExposure() override; void SetExposure(int32_t exposure) override; - array GetSupportedExposureRange() override; + optional> GetSupportedExposureRange() override; private: sptr nightSession_ = nullptr; }; diff --git a/frameworks/taihe/include/mode/photo_session_taihe.h b/frameworks/taihe/include/mode/photo_session_taihe.h index ff8b747b4a4ef51a5bc551e80813dfd9bd64cf8a..e07d5470614e39323e501583b184e649e00b75d5 100644 --- a/frameworks/taihe/include/mode/photo_session_taihe.h +++ b/frameworks/taihe/include/mode/photo_session_taihe.h @@ -39,9 +39,9 @@ public: } ~PhotoSessionImpl() = default; void Preconfig(PreconfigType preconfigType, optional_view preconfigRatio); - bool CanPreconfig(PreconfigType preconfigType, optional_view preconfigRatio); - taihe::array GetSessionFunctions(CameraOutputCapability const& outputCapability); - taihe::array GetSessionConflictFunctions(); + optional CanPreconfig(PreconfigType preconfigType, optional_view preconfigRatio); + optional> GetSessionFunctions(CameraOutputCapability const& outputCapability); + optional> GetSessionConflictFunctions(); inline int64_t GetSpecificImplPtr() { return reinterpret_cast(this); diff --git a/frameworks/taihe/include/mode/portrait_photo_session_taihe.h b/frameworks/taihe/include/mode/portrait_photo_session_taihe.h index 4b360ff1c4003d70804407744e0b98faddb02e55..d7449e8c6b1464acacf6df4127be9e2dff8648f0 100644 --- a/frameworks/taihe/include/mode/portrait_photo_session_taihe.h +++ b/frameworks/taihe/include/mode/portrait_photo_session_taihe.h @@ -38,11 +38,11 @@ public: } } ~PortraitPhotoSessionImpl() = default; - array GetSupportedPortraitEffects() override; + optional> GetSupportedPortraitEffects() override; void SetPortraitEffect(PortraitEffect effect) override; - PortraitEffect GetPortraitEffect() override; - taihe::array GetSessionFunctions(CameraOutputCapability const& outputCapability); - taihe::array GetSessionConflictFunctions(); + optional GetPortraitEffect() override; + optional> GetSessionFunctions(CameraOutputCapability const& outputCapability); + optional> GetSessionConflictFunctions(); private: sptr portraitSession_ = nullptr; }; diff --git a/frameworks/taihe/include/mode/professional_session_taihe.h b/frameworks/taihe/include/mode/professional_session_taihe.h index 517e469ba448fe9718590b2ef6ecb082f0e37ddc..1c2b18c254988dd7108c74ef187dd2e817d6b991 100644 --- a/frameworks/taihe/include/mode/professional_session_taihe.h +++ b/frameworks/taihe/include/mode/professional_session_taihe.h @@ -84,14 +84,14 @@ public: } virtual ~ProfessionalSessionImpl() = default; void SetFocusAssist(bool enabled) override; - array GetIsoRange() override; + optional> GetIsoRange() override; void SetIso(int32_t iso) override; - int32_t GetIso() override; - bool IsFocusAssistSupported() override; - bool IsManualIsoSupported() override; - ExposureMeteringMode GetExposureMeteringMode() override; + optional GetIso() override; + optional IsFocusAssistSupported() override; + optional IsManualIsoSupported() override; + optional GetExposureMeteringMode() override; void SetExposureMeteringMode(ExposureMeteringMode aeMeteringMode) override; - bool IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) override; + optional IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) override; private: sptr professionSession_ = nullptr; diff --git a/frameworks/taihe/include/mode/slow_motion_video_session_taihe.h b/frameworks/taihe/include/mode/slow_motion_video_session_taihe.h index 91a85ffff83ed4d67a2efe52723508fb98439675..1f9ca47c0c15fbbf4e4750e1a06393598cb6174e 100644 --- a/frameworks/taihe/include/mode/slow_motion_video_session_taihe.h +++ b/frameworks/taihe/include/mode/slow_motion_video_session_taihe.h @@ -50,7 +50,7 @@ public: } } ~SlowMotionVideoSessionImpl() = default; - bool IsSlowMotionDetectionSupported(); + optional IsSlowMotionDetectionSupported(); void SetSlowMotionDetectionArea(ohos::multimedia::camera::Rect const& area); std::shared_ptr slowMotionState_ = nullptr; private: diff --git a/frameworks/taihe/include/mode/time_lapse_photo_session_taihe.h b/frameworks/taihe/include/mode/time_lapse_photo_session_taihe.h index 2630ee3599a2e5e4beba223b362b28cb31968fcc..fa6cdc2f78e254fb9d3816f451776069109238a7 100644 --- a/frameworks/taihe/include/mode/time_lapse_photo_session_taihe.h +++ b/frameworks/taihe/include/mode/time_lapse_photo_session_taihe.h @@ -85,28 +85,28 @@ public: void SetTimeLapsePreviewType(ohos::multimedia::camera::TimeLapsePreviewType type); void SetTimeLapseInterval(int32_t interval); - int32_t GetTimeLapseInterval(); + optional GetTimeLapseInterval(); void SetTimeLapseRecordState(ohos::multimedia::camera::TimeLapseRecordState state); - array GetSupportedTimeLapseIntervalRange(); + optional> GetSupportedTimeLapseIntervalRange(); void StartTryAE(); void StopTryAE(); - bool IsTryAENeeded(); + optional IsTryAENeeded(); void SetIso(int32_t iso) override; - int32_t GetIso() override; - int32_t GetExposure() override; + optional GetIso() override; + optional GetExposure() override; void SetExposure(int32_t exposure) override; - array GetIsoRange() override; - bool IsManualIsoSupported() override; - bool IsWhiteBalanceModeSupported(WhiteBalanceMode mode) override; + optional> GetIsoRange() override; + optional IsManualIsoSupported() override; + optional IsWhiteBalanceModeSupported(WhiteBalanceMode mode) override; void SetWhiteBalance(int32_t whiteBalance) override; - int32_t GetWhiteBalance() override; + optional GetWhiteBalance() override; void SetWhiteBalanceMode(WhiteBalanceMode mode) override; - WhiteBalanceMode GetWhiteBalanceMode() override; - ExposureMeteringMode GetExposureMeteringMode() override; + optional GetWhiteBalanceMode() override; + optional GetExposureMeteringMode() override; void SetExposureMeteringMode(ExposureMeteringMode aeMeteringMode) override; - bool IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) override; - array GetSupportedExposureRange() override; - array GetWhiteBalanceRange() override; + optional IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) override; + optional> GetSupportedExposureRange() override; + optional> GetWhiteBalanceRange() override; private: sptr timeLapsePhotoSession_ = nullptr; diff --git a/frameworks/taihe/include/mode/video_session_taihe.h b/frameworks/taihe/include/mode/video_session_taihe.h index 6f2ad994f7954e529c4f580ec4beccd48f7f3703..d21bb3a2fe93e6164495856c5fb40ff62053a2c4 100644 --- a/frameworks/taihe/include/mode/video_session_taihe.h +++ b/frameworks/taihe/include/mode/video_session_taihe.h @@ -40,9 +40,9 @@ public: ~VideoSessionImpl() = default; void SetQualityPrioritization(QualityPrioritization quality); void Preconfig(PreconfigType preconfigType, optional_view preconfigRatio); - bool CanPreconfig(PreconfigType preconfigType, optional_view preconfigRatio); - taihe::array GetSessionFunctions(CameraOutputCapability const& outputCapability); - taihe::array GetSessionConflictFunctions(); + optional CanPreconfig(PreconfigType preconfigType, optional_view preconfigRatio); + optional> GetSessionFunctions(CameraOutputCapability const& outputCapability); + optional> GetSessionConflictFunctions(); inline int64_t GetSpecificImplPtr() { return reinterpret_cast(this); diff --git a/frameworks/taihe/include/output/photo_output_taihe.h b/frameworks/taihe/include/output/photo_output_taihe.h index 7f4b05a3672dde1bb5543922f0d60d5d9f8634e6..7b141141967996a3a2ba1815cbf6c73ee87182f6 100644 --- a/frameworks/taihe/include/output/photo_output_taihe.h +++ b/frameworks/taihe/include/output/photo_output_taihe.h @@ -277,30 +277,30 @@ public: void BurstCaptureSync(PhotoCaptureSetting const& setting); bool GetEnableMirror(); void EnableMirror(bool enabled); - bool IsMirrorSupported(); - Profile GetActiveProfile(); + optional IsMirrorSupported(); + optional GetActiveProfile(); void EnableOffline(); - bool IsOfflineSupported(); + optional IsOfflineSupported(); void EnableMovingPhoto(bool enabled); - bool IsMovingPhotoSupported(); - ImageRotation GetPhotoRotation(int32_t deviceDegree); + optional IsMovingPhotoSupported(); + optional GetPhotoRotation(int32_t deviceDegree); void EnableQuickThumbnail(bool enabled); OHOS::sptr GetPhotoOutput(); void EnableAutoCloudImageEnhancement(bool enabled); bool isAutoCloudImageEnhancementSupported(); - bool IsDepthDataDeliverySupported(); + optional IsDepthDataDeliverySupported(); void EnableDepthDataDelivery(bool enabled); - bool IsAutoHighQualityPhotoSupported(); + optional IsAutoHighQualityPhotoSupported(); void EnableAutoHighQualityPhoto(bool enabled); - bool IsAutoCloudImageEnhancementSupported(); + optional IsAutoCloudImageEnhancementSupported(); void EnableRawDelivery(bool enabled); - bool IsRawDeliverySupported(); + optional IsRawDeliverySupported(); void SetMovingPhotoVideoCodecType(VideoCodecType codecType); array GetSupportedMovingPhotoVideoCodecTypes(); void ConfirmCapture(); - bool IsDeferredImageDeliverySupported(DeferredDeliveryImageType type); - bool IsDeferredImageDeliveryEnabled(DeferredDeliveryImageType type); - bool IsQuickThumbnailSupported(); + optional IsDeferredImageDeliverySupported(DeferredDeliveryImageType type); + optional IsDeferredImageDeliveryEnabled(DeferredDeliveryImageType type); + optional IsQuickThumbnailSupported(); void DeferImageDelivery(DeferredDeliveryImageType type); static uint32_t photoOutputTaskId_; diff --git a/frameworks/taihe/include/output/preview_output_taihe.h b/frameworks/taihe/include/output/preview_output_taihe.h index b747ab03e5bf0be11c442438becc40647cc83f1b..f13cd3bf6fac7c93f9f6ad519d7ba71181608665 100644 --- a/frameworks/taihe/include/output/preview_output_taihe.h +++ b/frameworks/taihe/include/output/preview_output_taihe.h @@ -60,13 +60,13 @@ public: PreviewOutputImpl(OHOS::sptr output); ~PreviewOutputImpl() = default; void AddDeferredSurface(string_view surfaceId); - bool IsSketchSupported(); + optional IsSketchSupported(); void ReleaseSync() override; void EnableSketch(bool enabled); - double GetSketchRatio(); - array GetSupportedFrameRates(); - Profile GetActiveProfile(); - FrameRateRange GetActiveFrameRate(); + optional GetSketchRatio(); + optional> GetSupportedFrameRates(); + optional GetActiveProfile(); + optional GetActiveFrameRate(); void SetFrameRate(int32_t minFps, int32_t maxFps); ImageRotation GetPreviewRotation(int32_t displayRotation); void SetPreviewRotation(ImageRotation previewRotation, optional_view isDisplayLocked); diff --git a/frameworks/taihe/include/output/video_output_taihe.h b/frameworks/taihe/include/output/video_output_taihe.h index e4cd1e82ec6b8053dc211bfd24e7fab499842e61..ff6615fe8e0ff67cb134ef0b073b76ac491caf6a 100644 --- a/frameworks/taihe/include/output/video_output_taihe.h +++ b/frameworks/taihe/include/output/video_output_taihe.h @@ -69,21 +69,21 @@ public: void ReleaseSync() override; void EnableAutoVideoFrameRate(bool enabled); - bool IsAutoVideoFrameRateSupported(); - bool IsMirrorSupported(); + optional IsAutoVideoFrameRateSupported(); + optional IsMirrorSupported(); void EnableMirror(bool enabled); - bool IsAutoDeferredVideoEnhancementSupported(); - bool IsAutoDeferredVideoEnhancementEnabled(); - array GetSupportedFrameRates(); - FrameRateRange GetActiveFrameRate(); - VideoProfile GetActiveProfile(); + optional IsAutoDeferredVideoEnhancementSupported(); + optional IsAutoDeferredVideoEnhancementEnabled(); + optional> GetSupportedFrameRates(); + optional GetActiveFrameRate(); + optional GetActiveProfile(); void SetFrameRate(int32_t minFps, int32_t maxFps); void SetRotation(ImageRotation rotation); - bool IsRotationSupported(); - array GetSupportedRotations(); - ImageRotation GetVideoRotation(int32_t deviceDegree); + optional IsRotationSupported(); + optional> GetSupportedRotations(); + optional GetVideoRotation(int32_t deviceDegree); void AttachMetaSurface(string_view surfaceId, VideoMetaType type); - array GetSupportedVideoMetaTypes(); + optional> GetSupportedVideoMetaTypes(); void EnableAutoDeferredVideoEnhancement(bool enabled); const EmitterFunctions& GetEmitterFunctions() override; diff --git a/frameworks/taihe/include/query/camera_query_taihe.h b/frameworks/taihe/include/query/camera_query_taihe.h index 5d57e765ab8fd62f03b057142b2c9c46f6e7abdf..0a76889cac67aa8c7acadc189a9a63e04ea219ed 100644 --- a/frameworks/taihe/include/query/camera_query_taihe.h +++ b/frameworks/taihe/include/query/camera_query_taihe.h @@ -49,9 +49,9 @@ class FlashQueryImpl : virtual public SessionBase, virtual public FunctionBase { public: explicit FlashQueryImpl() {} virtual ~FlashQueryImpl() = default; - bool HasFlash(); - bool IsFlashModeSupported(FlashMode flashMode); - bool IsLcdFlashSupported(); + optional HasFlash(); + optional IsFlashModeSupported(FlashMode flashMode); + optional IsLcdFlashSupported(); }; class FlashImpl : public FlashQueryImpl { @@ -60,22 +60,22 @@ public: virtual ~FlashImpl() = default; void EnableLcdFlash(bool enabled); void SetFlashMode(FlashMode flashMode); - FlashMode GetFlashMode(); + optional GetFlashMode(); }; class ZoomQueryImpl : virtual public SessionBase, virtual public FunctionBase { public: explicit ZoomQueryImpl() {} virtual ~ZoomQueryImpl() = default; - array GetZoomRatioRange(); - array GetZoomPointInfos(); + optional> GetZoomRatioRange(); + optional> GetZoomPointInfos(); }; class ZoomImpl : public ZoomQueryImpl { public: explicit ZoomImpl() {} virtual ~ZoomImpl() = default; - double GetZoomRatio(); + optional GetZoomRatio(); void SetZoomRatio(double zoomRatio); void PrepareZoom(); void UnprepareZoom(); @@ -86,7 +86,7 @@ class ColorReservationQueryImpl : virtual public SessionBase { public: explicit ColorReservationQueryImpl() {} virtual ~ColorReservationQueryImpl() = default; - virtual array GetSupportedColorReservationTypes(); + virtual optional> GetSupportedColorReservationTypes(); }; class ColorReservationImpl : public ColorReservationQueryImpl { @@ -94,17 +94,17 @@ public: explicit ColorReservationImpl() {} virtual ~ColorReservationImpl() = default; void SetColorReservation(ColorReservationType type); - ColorReservationType GetColorReservation(); + optional GetColorReservation(); }; class FocusQueryImpl : virtual public SessionBase, virtual public FunctionBase { public: explicit FocusQueryImpl() {} virtual ~FocusQueryImpl() = default; - bool IsFocusRangeTypeSupported(FocusRangeType type); - bool IsFocusDrivenTypeSupported(FocusDrivenType type); - bool IsFocusModeSupported(FocusMode afMode); - virtual bool IsFocusAssistSupported(); + optional IsFocusRangeTypeSupported(FocusRangeType type); + optional IsFocusDrivenTypeSupported(FocusDrivenType type); + optional IsFocusModeSupported(FocusMode afMode); + virtual optional IsFocusAssistSupported(); }; class FocusImpl : public FocusQueryImpl { @@ -112,14 +112,14 @@ public: explicit FocusImpl() {} virtual ~FocusImpl() = default; void SetFocusDriven(FocusDrivenType type); - FocusDrivenType GetFocusDriven(); + optional GetFocusDriven(); void SetFocusRange(FocusRangeType type); - FocusRangeType GetFocusRange(); + optional GetFocusRange(); virtual void SetFocusAssist(bool enabled); - Point GetFocusPoint(); + optional GetFocusPoint(); void SetFocusPoint(Point const& point); - double GetFocalLength(); - FocusMode GetFocusMode(); + optional GetFocalLength(); + optional GetFocusMode(); void SetFocusMode(FocusMode afMode); }; @@ -127,14 +127,14 @@ class StabilizationQueryImpl : virtual public SessionBase, virtual public Functi public: explicit StabilizationQueryImpl() {} virtual ~StabilizationQueryImpl() = default; - bool IsVideoStabilizationModeSupported(VideoStabilizationMode vsMode); + optional IsVideoStabilizationModeSupported(VideoStabilizationMode vsMode); }; class StabilizationImpl : public StabilizationQueryImpl { public: explicit StabilizationImpl() {} virtual ~StabilizationImpl() = default; - VideoStabilizationMode GetActiveVideoStabilizationMode(); + optional GetActiveVideoStabilizationMode(); void SetVideoStabilizationMode(VideoStabilizationMode mode); }; @@ -142,10 +142,10 @@ class BeautyQueryImpl : virtual public SessionBase, virtual public FunctionBase public: explicit BeautyQueryImpl() {} virtual ~BeautyQueryImpl() = default; - array GetSupportedPortraitThemeTypes(); - array GetSupportedBeautyTypes(); - array GetSupportedBeautyRange(BeautyType type); - bool IsPortraitThemeSupported(); + optional> GetSupportedPortraitThemeTypes(); + optional> GetSupportedBeautyTypes(); + optional> GetSupportedBeautyRange(BeautyType type); + optional IsPortraitThemeSupported(); }; class BeautyImpl : public BeautyQueryImpl { @@ -153,7 +153,7 @@ public: explicit BeautyImpl() {} virtual ~BeautyImpl() = default; void SetPortraitThemeType(PortraitThemeType type); - int32_t GetBeauty(BeautyType type); + optional GetBeauty(BeautyType type); void SetBeauty(BeautyType type, int32_t value); }; @@ -161,9 +161,9 @@ class AutoExposureQueryImpl : virtual public SessionBase, virtual public Functio public: explicit AutoExposureQueryImpl() {} virtual ~AutoExposureQueryImpl() = default; - array GetExposureBiasRange(); - bool IsExposureModeSupported(ExposureMode aeMode); - virtual bool IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode); + optional> GetExposureBiasRange(); + optional IsExposureModeSupported(ExposureMode aeMode); + virtual optional IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode); }; class AutoExposureImpl : public AutoExposureQueryImpl { @@ -172,11 +172,11 @@ public: virtual ~AutoExposureImpl() = default; void SetExposureBias(double exposureBias); virtual void SetExposureMeteringMode(ExposureMeteringMode aeMeteringMode); - virtual ExposureMeteringMode GetExposureMeteringMode(); - double GetExposureValue(); - Point GetMeteringPoint(); + virtual optional GetExposureMeteringMode(); + optional GetExposureValue(); + optional GetMeteringPoint(); void SetMeteringPoint(Point const& point); - ExposureMode GetExposureMode(); + optional GetExposureMode(); void SetExposureMode(ExposureMode aeMode); }; @@ -184,7 +184,7 @@ class ColorManagementQueryImpl : virtual public SessionBase, virtual public Func public: explicit ColorManagementQueryImpl() {} virtual ~ColorManagementQueryImpl() = default; - array GetSupportedColorSpaces(); + optional> GetSupportedColorSpaces(); }; class ColorManagementImpl : public ColorManagementQueryImpl { @@ -192,14 +192,14 @@ public: explicit ColorManagementImpl() {} virtual ~ColorManagementImpl() = default; void SetColorSpace(uintptr_t colorSpace); - uintptr_t GetActiveColorSpace(); + optional GetActiveColorSpace(); }; class SceneDetectionQueryImpl : virtual public SessionBase, virtual public FunctionBase { public: explicit SceneDetectionQueryImpl() {} virtual ~SceneDetectionQueryImpl() = default; - bool IsSceneFeatureSupported(SceneFeatureType type); + optional IsSceneFeatureSupported(SceneFeatureType type); }; class SceneDetectionImpl : public SceneDetectionQueryImpl { @@ -213,8 +213,8 @@ class WhiteBalanceQueryImpl : virtual public SessionBase { public: explicit WhiteBalanceQueryImpl() {} virtual ~WhiteBalanceQueryImpl() = default; - virtual bool IsWhiteBalanceModeSupported(WhiteBalanceMode mode); - virtual array GetWhiteBalanceRange(); + virtual optional IsWhiteBalanceModeSupported(WhiteBalanceMode mode); + virtual optional> GetWhiteBalanceRange(); }; class WhiteBalanceImpl : public WhiteBalanceQueryImpl { @@ -222,23 +222,23 @@ public: explicit WhiteBalanceImpl() {} virtual ~WhiteBalanceImpl() = default; virtual void SetWhiteBalance(int32_t whiteBalance); - virtual int32_t GetWhiteBalance(); + virtual optional GetWhiteBalance(); virtual void SetWhiteBalanceMode(WhiteBalanceMode mode); - virtual WhiteBalanceMode GetWhiteBalanceMode(); + virtual optional GetWhiteBalanceMode(); }; class ManualExposureQueryImpl : virtual public SessionBase, virtual public FunctionBase { public: explicit ManualExposureQueryImpl() {} virtual ~ManualExposureQueryImpl() = default; - virtual array GetSupportedExposureRange(); + virtual optional> GetSupportedExposureRange(); }; class ManualExposureImpl : public ManualExposureQueryImpl { public: explicit ManualExposureImpl() {} virtual ~ManualExposureImpl() = default; - virtual int32_t GetExposure(); + virtual optional GetExposure(); virtual void SetExposure(int32_t exposure); }; @@ -246,7 +246,7 @@ class ColorEffectQueryImpl : virtual public SessionBase, virtual public Function public: explicit ColorEffectQueryImpl() {} virtual ~ColorEffectQueryImpl() = default; - array GetSupportedColorEffects(); + optional> GetSupportedColorEffects(); }; class ColorEffectImpl : public ColorEffectQueryImpl { @@ -254,15 +254,15 @@ public: explicit ColorEffectImpl() {} virtual ~ColorEffectImpl() = default; void SetColorEffect(ColorEffectType type); - ColorEffectType GetColorEffect(); + optional GetColorEffect(); }; class ManualIsoQueryImpl : virtual public SessionBase { public: explicit ManualIsoQueryImpl() {} virtual ~ManualIsoQueryImpl() = default; - virtual array GetIsoRange(); - virtual bool IsManualIsoSupported(); + virtual optional> GetIsoRange(); + virtual optional IsManualIsoSupported(); }; class ManualIsoImpl : public ManualIsoQueryImpl { @@ -270,15 +270,15 @@ public: explicit ManualIsoImpl() {} virtual ~ManualIsoImpl() = default; virtual void SetIso(int32_t iso); - virtual int32_t GetIso(); + virtual optional GetIso(); }; class ApertureQueryImpl : virtual public SessionBase, virtual public FunctionBase { public: explicit ApertureQueryImpl() {} virtual ~ApertureQueryImpl() = default; - array GetSupportedPhysicalApertures(); - array GetSupportedVirtualApertures(); + optional> GetSupportedPhysicalApertures(); + optional> GetSupportedVirtualApertures(); }; class ApertureImpl : public ApertureQueryImpl { @@ -286,9 +286,9 @@ public: explicit ApertureImpl() {} virtual ~ApertureImpl() = default; void SetVirtualAperture(double aperture); - double GetVirtualAperture(); + optional GetVirtualAperture(); void SetPhysicalAperture(double aperture); - double GetPhysicalAperture(); + optional GetPhysicalAperture(); }; class EffectSuggestionImpl : virtual public SessionBase { @@ -298,15 +298,15 @@ public: void SetEffectSuggestionStatus(array_view status); void UpdateEffectSuggestion(EffectSuggestionType type, bool enabled); void EnableEffectSuggestion(bool enabled); - bool IsEffectSuggestionSupported(); - array GetSupportedEffectSuggestionTypes(); + optional IsEffectSuggestionSupported(); + optional> GetSupportedEffectSuggestionTypes(); }; class MacroQueryImpl : virtual public SessionBase, virtual public FunctionBase { public: explicit MacroQueryImpl() {} virtual ~MacroQueryImpl() = default; - bool IsMacroSupported(); + optional IsMacroSupported(); }; class MacroImpl : public MacroQueryImpl { @@ -320,7 +320,7 @@ class ManualFocusImpl : virtual public SessionBase { public: explicit ManualFocusImpl() {} virtual ~ManualFocusImpl() = default; - double GetFocusDistance(); + optional GetFocusDistance(); void SetFocusDistance(double distance); }; @@ -328,7 +328,7 @@ class PortraitQueryImpl : virtual public SessionBase, virtual public FunctionBas public: explicit PortraitQueryImpl() {} virtual ~PortraitQueryImpl() = default; - virtual array GetSupportedPortraitEffects(); + virtual optional> GetSupportedPortraitEffects(); }; class PortraitImpl : public PortraitQueryImpl { @@ -336,15 +336,15 @@ public: explicit PortraitImpl() {} virtual ~PortraitImpl() = default; virtual void SetPortraitEffect(PortraitEffect effect); - virtual PortraitEffect GetPortraitEffect(); + virtual optional GetPortraitEffect(); }; class DepthFusionQueryImpl : virtual public SessionBase, virtual public FunctionBase { public: explicit DepthFusionQueryImpl() {} virtual ~DepthFusionQueryImpl() = default; - bool IsDepthFusionSupported(); - array GetDepthFusionThreshold(); + optional IsDepthFusionSupported(); + optional> GetDepthFusionThreshold(); }; class DepthFusionImpl : public DepthFusionQueryImpl { @@ -352,14 +352,14 @@ public: explicit DepthFusionImpl() {} virtual ~DepthFusionImpl() = default; void EnableDepthFusion(bool enabled); - bool IsDepthFusionEnabled(); + optional IsDepthFusionEnabled(); }; class AutoDeviceSwitchQueryImpl : virtual public SessionBase { public: explicit AutoDeviceSwitchQueryImpl() {} virtual ~AutoDeviceSwitchQueryImpl() = default; - bool IsAutoDeviceSwitchSupported(); + optional IsAutoDeviceSwitchSupported(); }; class AutoDeviceSwitchImpl : public AutoDeviceSwitchQueryImpl { diff --git a/frameworks/taihe/include/session/camera_session_taihe.h b/frameworks/taihe/include/session/camera_session_taihe.h index 447cf62f1896ab658d941622b5eb7dcb9f49a120..c15b7ecf8f6de739cd3a3afb6b050c07654a9637 100644 --- a/frameworks/taihe/include/session/camera_session_taihe.h +++ b/frameworks/taihe/include/session/camera_session_taihe.h @@ -144,9 +144,9 @@ public: void AddOutput(weak::CameraOutput cameraOutput); void RemoveOutput(weak::CameraOutput cameraOutput); void SetUsage(UsageType usage, bool enabled); - array GetCameraOutputCapabilities(CameraDevice const& camera); - bool CanAddInput(weak::CameraInput cameraInput); - bool CanAddOutput(weak::CameraOutput cameraOutput); + optional> GetCameraOutputCapabilities(CameraDevice const& camera); + optional CanAddInput(weak::CameraInput cameraInput); + optional CanAddOutput(weak::CameraOutput cameraOutput); const EmitterFunctions& GetEmitterFunctions() override; diff --git a/frameworks/taihe/src/input/camera_manager_taihe.cpp b/frameworks/taihe/src/input/camera_manager_taihe.cpp index 14fd540e8c726b9f3a0288ba66a093bd7a325c35..3a7672864ab1e57c19c4a8986062c0a9fa105480 100644 --- a/frameworks/taihe/src/input/camera_manager_taihe.cpp +++ b/frameworks/taihe/src/input/camera_manager_taihe.cpp @@ -193,17 +193,17 @@ CameraManagerImpl::CameraManagerImpl() cameraManager_ = OHOS::CameraStandard::CameraManager::GetInstance(); } -array CameraManagerImpl::GetSupportedCameras() +optional> CameraManagerImpl::GetSupportedCameras() { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional>(std::nullopt), "failed to getSupportedCameras, cameraManager is nullprt"); std::vector> cameraObjList = cameraManager_->GetSupportedCameras(); - return CameraUtilsTaihe::ToTaiheArrayCameraDevice(cameraObjList); + return optional>(std::in_place, CameraUtilsTaihe::ToTaiheArrayCameraDevice(cameraObjList)); } -array CameraManagerImpl::GetSupportedSceneModes(CameraDevice const& camera) +optional> CameraManagerImpl::GetSupportedSceneModes(CameraDevice const& camera) { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional>(std::nullopt), "failed to getSupportedSceneModes, cameraManager is nullprt"); sptr cameraDevice = @@ -211,7 +211,7 @@ array CameraManagerImpl::GetSupportedSceneModes(CameraDevice const& c if (cameraDevice == nullptr) { MEDIA_ERR_LOG("CameraManagerImpl::GetSupportedModes get camera info fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "Get camera info fail"); - return array(nullptr, 0); + return optional>(std::nullopt); } std::vector modeObjList = cameraManager_->GetSupportedModes(cameraDevice); for (auto it = modeObjList.begin(); it != modeObjList.end(); it++) { @@ -225,7 +225,7 @@ array CameraManagerImpl::GetSupportedSceneModes(CameraDevice const& c modeObjList.emplace_back(OHOS::CameraStandard::VIDEO); } MEDIA_DEBUG_LOG("CameraManagerNapi::GetSupportedModes size=[%{public}zu]", modeObjList.size()); - return CameraUtilsTaihe::ToTaiheArraySceneMode(modeObjList); + return optional>(std::in_place, CameraUtilsTaihe::ToTaiheArraySceneMode(modeObjList)); } CameraOutputCapability GetCacheAniValue(const std::string& key, bool &isFound) @@ -279,14 +279,10 @@ void CacheSupportedOutputCapability(const std::string& cameraId, int32_t mode, MEDIA_DEBUG_LOG("CacheSupportedOutputCapability cache->%{public}s:%{public}d", key.c_str(), mode); } -CameraOutputCapability CameraManagerImpl::GetSupportedOutputCapability(CameraDevice const& camera, SceneMode mode) +optional CameraManagerImpl::GetSupportedOutputCapability( + CameraDevice const& camera, SceneMode mode) { - CameraOutputCapability nullImpl { - .previewProfiles = array(nullptr, 0), - .photoProfiles = array(nullptr, 0), - .videoProfiles = array(nullptr, 0), - }; - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, nullImpl, + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), "failed to GetSupportedOutputCapability, cameraManager is nullprt"); std::string cameraId = std::string(camera.cameraId); @@ -304,28 +300,28 @@ CameraOutputCapability CameraManagerImpl::GetSupportedOutputCapability(CameraDev } else { MEDIA_ERR_LOG("CreateCameraSessionInstance mode = %{public}d not supported", sceneMode); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "Not support the input mode"); - return nullImpl; + return optional(std::nullopt); } MEDIA_INFO_LOG("GetSupportedOutputCapability SceneMode sceneMode = %{public}d ", sceneMode); if (cameraInfo == nullptr) { MEDIA_ERR_LOG("CameraManagerImpl::GetSupportedOutputCapability get camera info fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "Get camera info fail"); - return nullImpl; + return optional(std::nullopt); } bool isFound = false; CameraOutputCapability cachedResult = GetCachedSupportedOutputCapability(cameraId, sceneMode, isFound); - CHECK_ERROR_RETURN_RET(isFound, cachedResult); + CHECK_ERROR_RETURN_RET(isFound, optional(std::in_place, cachedResult)); auto outputCapability = cameraManager_->GetSupportedOutputCapability(cameraInfo, sceneMode); - CHECK_ERROR_RETURN_RET_LOG(outputCapability == nullptr, nullImpl, + CHECK_ERROR_RETURN_RET_LOG(outputCapability == nullptr, optional(std::nullopt), "failed to create CreateCameraOutputCapability"); outputCapability->RemoveDuplicatesProfiles(); GetSupportedOutputCapabilityAdaptNormalMode(sceneMode, cameraInfo, outputCapability); CacheSupportedOutputCapability(cameraId, sceneMode, outputCapability); CameraOutputCapability result = CameraUtilsTaihe::ToTaiheCameraOutputCapability(outputCapability); - return result; + return optional(std::in_place, result); } void CameraManagerImpl::Prelaunch() @@ -346,47 +342,47 @@ void CameraManagerImpl::PreSwitchCamera(string_view cameraId) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -bool CameraManagerImpl::IsTorchSupported() +optional CameraManagerImpl::IsTorchSupported() { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), "failed to IsTorchSupported, cameraManager is nullprt"); - return cameraManager_->IsTorchSupported(); + return optional(std::in_place, cameraManager_->IsTorchSupported()); } -bool CameraManagerImpl::IsCameraMuted() +optional CameraManagerImpl::IsCameraMuted() { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), "failed to IsCameraMuted, cameraManager is nullprt"); - return cameraManager_->IsCameraMuted(); + return optional(std::in_place, cameraManager_->IsCameraMuted()); } -bool CameraManagerImpl::IsCameraMuteSupported() +optional CameraManagerImpl::IsCameraMuteSupported() { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), "failed to IsCameraMuteSupported, cameraManager is nullprt"); - return cameraManager_->IsCameraMuteSupported(); + return optional(std::in_place, cameraManager_->IsCameraMuteSupported()); } -bool CameraManagerImpl::IsPrelaunchSupported(CameraDevice const& camera) +optional CameraManagerImpl::IsPrelaunchSupported(CameraDevice const& camera) { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), "failed to IsPrelaunchSupported, cameraManager is nullprt"); std::string nativeStr(camera.cameraId); sptr cameraInfo = cameraManager_->GetCameraDeviceFromId(nativeStr); if (cameraInfo != nullptr) { bool isPrelaunchSupported = cameraManager_->IsPrelaunchSupported(cameraInfo); - return isPrelaunchSupported; + return optional(std::in_place, isPrelaunchSupported); } MEDIA_ERR_LOG("CameraManagerImpl::IsPrelaunchSupported cameraInfo is null!"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "cameraInfo is null."); - return false; + return optional(std::nullopt); } -TorchMode CameraManagerImpl::GetTorchMode() +optional CameraManagerImpl::GetTorchMode() { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, TorchMode(static_cast(-1)), + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), "failed to GetTorchMode, cameraManager is nullprt"); - return TorchMode(static_cast(cameraManager_->GetTorchMode())); + return optional(std::in_place, TorchMode(static_cast(cameraManager_->GetTorchMode()))); } void CameraManagerImpl::SetTorchMode(TorchMode mode) @@ -649,10 +645,9 @@ void CameraManagerImpl::MuteCameraPersistent(bool mute, PolicyType type) cameraManager_->MuteCameraPersist(itr->second, mute); } -SessionUnion CameraManagerImpl::CreateSession(SceneMode mode) +optional CameraManagerImpl::CreateSession(SceneMode mode) { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, - SessionUnion::make_session(make_holder(nullptr)), + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), "failed to CreateSession, cameraManager is nullptr"); OHOS::CameraStandard::SceneMode sceneModeInner = OHOS::CameraStandard::NORMAL; std::unordered_map aniToNativeMap = g_aniToNativeSupportedMode; @@ -667,13 +662,14 @@ SessionUnion CameraManagerImpl::CreateSession(SceneMode mode) } else { MEDIA_ERR_LOG("CameraManagerImpl::CreateSession mode = %{public}d not supported", modeValue); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::PARAMETER_ERROR, "Invalid scene mode"); - return SessionUnion::make_session(make_holder( + auto res = SessionUnion::make_session(make_holder( cameraManager_->CreateCaptureSession(OHOS::CameraStandard::NORMAL))); + return optional(std::in_place, res); } - return CreateSessionWithMode(sceneModeInner); + return optional(std::in_place, CreateSessionWithMode(sceneModeInner)); } -PreviewOutput CameraManagerImpl::CreatePreviewOutput(Profile const& profile, string_view surfaceId) +optional CameraManagerImpl::CreatePreviewOutput(Profile const& profile, string_view surfaceId) { OHOS::CameraStandard::Profile innerProfile { static_cast(profile.format.get_value()), @@ -687,8 +683,7 @@ PreviewOutput CameraManagerImpl::CreatePreviewOutput(Profile const& profile, str if (!surface) { surface = OHOS::Media::ImageReceiver::getSurfaceById(innerSurfaceId); } - CHECK_ERROR_RETURN_RET_LOG(surface == nullptr, - (make_holder(nullptr)), "failed to get surface"); + CHECK_ERROR_RETURN_RET_LOG(surface == nullptr, (optional(std::nullopt)), "failed to get surface"); surface->SetUserData(OHOS::CameraStandard::CameraManager::surfaceFormat, std::to_string(innerProfile.GetCameraFormat())); @@ -697,14 +692,15 @@ PreviewOutput CameraManagerImpl::CreatePreviewOutput(Profile const& profile, str innerProfile, surface, &previewOutput); if (retCode != OHOS::CameraStandard::CameraErrorCode::SUCCESS) { CameraUtilsTaihe::ThrowError(retCode, "failed to create preview output"); - return make_holder(nullptr); + return optional(std::nullopt); } CHECK_EXECUTE(previewOutput == nullptr, CameraUtilsTaihe::ThrowError(retCode, "failed to create preview output")); - return make_holder(previewOutput); + auto res = make_holder(previewOutput); + return optional(std::in_place, res); } -PreviewOutput CameraManagerImpl::CreatePreviewOutputWithoutProfile(string_view surfaceId) +optional CameraManagerImpl::CreatePreviewOutputWithoutProfile(string_view surfaceId) { std::string innerSurfaceId = std::string(surfaceId); uint64_t iSurfaceId; @@ -714,28 +710,30 @@ PreviewOutput CameraManagerImpl::CreatePreviewOutputWithoutProfile(string_view s if (!surface) { surface = OHOS::Media::ImageReceiver::getSurfaceById(innerSurfaceId); } - CHECK_ERROR_RETURN_RET_LOG(surface == nullptr, - (make_holder(nullptr)), "failed to get surface"); + CHECK_ERROR_RETURN_RET_LOG(surface == nullptr, (optional(std::nullopt)), "failed to get surface"); OHOS::sptr previewOutput = nullptr; int retCode = OHOS::CameraStandard::CameraManager::GetInstance()->CreatePreviewOutputWithoutProfile( surface, &previewOutput); if (retCode != OHOS::CameraStandard::CameraErrorCode::SUCCESS) { CameraUtilsTaihe::ThrowError(retCode, "failed to create preview output"); - return make_holder(nullptr); + auto res = make_holder(nullptr); + return optional(std::in_place, res); } CHECK_EXECUTE(previewOutput == nullptr, CameraUtilsTaihe::ThrowError(retCode, "failed to create preview output")); - return make_holder(previewOutput); + auto res = make_holder(previewOutput); + return optional(std::in_place, res); } -PreviewOutput CameraManagerImpl::CreateDeferredPreviewOutput(optional_view profile) +optional CameraManagerImpl::CreateDeferredPreviewOutput(optional_view profile) { auto Result = [](OHOS::sptr output) { - return make_holder(output); + auto res = make_holder(output); + return optional(std::in_place, res); }; - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), Result(nullptr), - "SystemApi CreateDeferredPreviewOutputInstance is called!"); - CHECK_ERROR_RETURN_RET_LOG(!(profile.has_value()), Result(nullptr), + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), + optional(std::nullopt), "SystemApi CreateDeferredPreviewOutputInstance is called!"); + CHECK_ERROR_RETURN_RET_LOG(!(profile.has_value()), optional(std::nullopt), "CreateDeferredPreviewOutput args is invalid!"); OHOS::CameraStandard::Profile innerProfile { static_cast(profile.value().format.get_value()), @@ -743,14 +741,16 @@ PreviewOutput CameraManagerImpl::CreateDeferredPreviewOutput(optional_view previewOutput = nullptr; previewOutput = OHOS::CameraStandard::CameraManager::GetInstance()->CreateDeferredPreviewOutput(innerProfile); - CHECK_ERROR_RETURN_RET_LOG(previewOutput == nullptr, Result(nullptr), "failed to create previewOutput"); + CHECK_ERROR_RETURN_RET_LOG(previewOutput == nullptr, optional(std::nullopt), + "failed to create previewOutput"); return Result(previewOutput); } -PhotoOutput CameraManagerImpl::CreatePhotoOutput(optional_view profile) +optional CameraManagerImpl::CreatePhotoOutput(optional_view profile) { auto Result = [](OHOS::sptr output) { - return make_holder(output); + auto res = make_holder(output); + return optional(std::in_place, res); }; OHOS::sptr photoSurface = OHOS::Surface::CreateSurfaceAsConsumer("photoOutput"); CHECK_ERROR_RETURN_RET_LOG(photoSurface == nullptr, @@ -791,7 +791,7 @@ PhotoOutput CameraManagerImpl::CreatePhotoOutput(optional_view profile) } } -VideoOutput CameraManagerImpl::CreateVideoOutput(VideoProfile const& profile, string_view surfaceId) +optional CameraManagerImpl::CreateVideoOutput(VideoProfile const& profile, string_view surfaceId) { OHOS::CameraStandard::VideoProfile videoProfile{ static_cast(profile.base.format.get_value()), @@ -803,21 +803,21 @@ VideoOutput CameraManagerImpl::CreateVideoOutput(VideoProfile const& profile, st std::istringstream iss(innerSurfaceId); iss >> iSurfaceId; OHOS::sptr surface = OHOS::SurfaceUtils::GetInstance()->GetSurface(iSurfaceId); - CHECK_ERROR_RETURN_RET_LOG(surface == nullptr, (make_holder(nullptr)), + CHECK_ERROR_RETURN_RET_LOG(surface == nullptr, (optional(std::nullopt)), "failed to get surface from SurfaceUtils"); surface->SetUserData(OHOS::CameraStandard::CameraManager::surfaceFormat, std::to_string(videoProfile.GetCameraFormat())); OHOS::sptr videoOutput = nullptr; int retCode = OHOS::CameraStandard::CameraManager::GetInstance()->CreateVideoOutput(videoProfile, surface, &videoOutput); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), - (make_holder(nullptr))); - CHECK_ERROR_RETURN_RET_LOG(videoOutput == nullptr, (make_holder(nullptr)), + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), (optional(std::nullopt))); + CHECK_ERROR_RETURN_RET_LOG(videoOutput == nullptr, (optional(std::nullopt)), "failed to create VideoOutput"); - return make_holder(videoOutput); + auto res = make_holder(videoOutput); + return optional(std::in_place, res); } -MetadataOutput CameraManagerImpl::CreateMetadataOutput(array_view metadataObjectTypes) +optional CameraManagerImpl::CreateMetadataOutput(array_view metadataObjectTypes) { std::vector innerMetadataObjectTypes; for (const auto& item : metadataObjectTypes) { @@ -827,54 +827,54 @@ MetadataOutput CameraManagerImpl::CreateMetadataOutput(array_view metadataOutput = nullptr; int retCode = OHOS::CameraStandard::CameraManager::GetInstance()->CreateMetadataOutput( metadataOutput, innerMetadataObjectTypes); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), - (taihe::make_holder(nullptr))); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), (optional(std::nullopt))); CHECK_ERROR_RETURN_RET_LOG(metadataOutput == nullptr, - (taihe::make_holder(nullptr)), "failed to create MetadataOutput"); - - return taihe::make_holder(metadataOutput); + (optional(std::nullopt)), "failed to create MetadataOutput"); + auto res = taihe::make_holder(metadataOutput); + return optional(std::in_place, res); } -VideoOutput CameraManagerImpl::CreateVideoOutputWithoutProfile(string_view surfaceId) +optional CameraManagerImpl::CreateVideoOutputWithoutProfile(string_view surfaceId) { std::string innerSurfaceId = std::string(surfaceId); uint64_t iSurfaceId; std::istringstream iss(innerSurfaceId); iss >> iSurfaceId; OHOS::sptr surface = OHOS::SurfaceUtils::GetInstance()->GetSurface(iSurfaceId); - CHECK_ERROR_RETURN_RET_LOG(surface == nullptr, (make_holder(nullptr)), + CHECK_ERROR_RETURN_RET_LOG(surface == nullptr, (optional(std::nullopt)), "failed to get surface from SurfaceUtils"); OHOS::sptr videoOutput = nullptr; int retCode = OHOS::CameraStandard::CameraManager::GetInstance()->CreateVideoOutputWithoutProfile(surface, &videoOutput); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), - (make_holder(nullptr))); - CHECK_ERROR_RETURN_RET_LOG(videoOutput == nullptr, (make_holder(nullptr)), + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), (optional(std::nullopt))); + CHECK_ERROR_RETURN_RET_LOG(videoOutput == nullptr, (optional(std::nullopt)), "failed to create VideoOutput"); - return make_holder(videoOutput); + auto res = make_holder(videoOutput); + return optional(std::in_place, res); } -CameraInput CameraManagerImpl::CreateCameraInputWithCameraDevice(CameraDevice const& camera) +optional CameraManagerImpl::CreateCameraInputWithCameraDevice(CameraDevice const& camera) { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, (make_holder(nullptr)), + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, (optional(std::nullopt)), "cameraManager_ is nullptr"); std::string cameraId = std::string(camera.cameraId); OHOS::sptr cameraInfo = cameraManager_->GetCameraDeviceFromId(cameraId); if (cameraInfo == nullptr) { MEDIA_ERR_LOG("cameraInfo is null"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::CameraErrorCode::INVALID_ARGUMENT, "cameraInfo is null"); - return make_holder(nullptr); + return optional(std::nullopt); } OHOS::sptr cameraInput = nullptr; int retCode = cameraManager_->CreateCameraInput(cameraInfo, &cameraInput); CHECK_EXECUTE(retCode != OHOS::CameraStandard::CameraErrorCode::SUCCESS, CameraUtilsTaihe::ThrowError(retCode, "CreateCameraInput failed.")); - return make_holder(cameraInput); + auto res = make_holder(cameraInput); + return optional(std::in_place, res); } -CameraInput CameraManagerImpl::CreateCameraInputWithPosition(CameraPosition position, CameraType type) +optional CameraManagerImpl::CreateCameraInputWithPosition(CameraPosition position, CameraType type) { - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, (make_holder(nullptr)), + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, (optional(std::nullopt)), "cameraManager_ is nullptr"); int32_t cameraPosition = static_cast(position.get_value()); int32_t cameraType = static_cast(type.get_value()); @@ -884,22 +884,22 @@ CameraInput CameraManagerImpl::CreateCameraInputWithPosition(CameraPosition posi if (cameraInfo == nullptr) { MEDIA_ERR_LOG("cameraInfo is null"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::CameraErrorCode::INVALID_ARGUMENT, "cameraInfo is null"); - return make_holder(nullptr); + return optional(std::nullopt); } OHOS::sptr cameraInput = nullptr; int retCode = cameraManager_->CreateCameraInput(cameraInfo, &cameraInput); CHECK_EXECUTE(retCode != OHOS::CameraStandard::CameraErrorCode::SUCCESS, CameraUtilsTaihe::ThrowError(retCode, "CreateCameraInput failed.")); - return make_holder(cameraInput); + auto res = make_holder(cameraInput); + return optional(std::in_place, res); } -DepthDataOutput CameraManagerImpl::CreateDepthDataOutput(DepthProfile const& profile) +optional CameraManagerImpl::CreateDepthDataOutput(DepthProfile const& profile) { - auto Result = [](OHOS::sptr output, OHOS::sptr surface) { - return make_holder(output, surface); - }; - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, Result(nullptr, nullptr), "cameraManager_ is nullptr"); + + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), + "cameraManager_ is nullptr"); OHOS::CameraStandard::CameraFormat cameraFormat = static_cast(profile.format.get_value()); OHOS::CameraStandard::DepthDataAccuracy depthDataAccuracy = @@ -914,13 +914,15 @@ DepthDataOutput CameraManagerImpl::CreateDepthDataOutput(DepthProfile const& pro OHOS::sptr depthDataSurface = nullptr; MEDIA_INFO_LOG("create surface as consumer"); depthDataSurface = OHOS::Surface::CreateSurfaceAsConsumer("depthDataOutput"); - CHECK_ERROR_RETURN_RET_LOG(depthDataSurface == nullptr, Result(nullptr, nullptr), "failed to get surface"); + CHECK_ERROR_RETURN_RET_LOG(depthDataSurface == nullptr, optional(std::nullopt), + "failed to get surface"); OHOS::sptr surfaceProducer = depthDataSurface->GetProducer(); OHOS::sptr depthDataOutput; int retCode = cameraManager_->CreateDepthDataOutput(depthProfile, surfaceProducer, &depthDataOutput); CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode) || depthDataOutput == nullptr, - Result(nullptr, nullptr), "failed to create CreateDepthDataOutput"); - return Result(depthDataOutput, depthDataSurface); + optional(std::nullopt), "failed to create CreateDepthDataOutput"); + auto ret = make_holder(depthDataOutput, depthDataSurface); + return optional(std::in_place, ret); } void CameraManagerImpl::ProcessCameraInfo(OHOS::sptr& cameraManager, @@ -982,9 +984,9 @@ bool CameraManagerImpl::IsTorchModeSupported(TorchMode mode) return isTorchModeSupported; } -array CameraManagerImpl::GetCameraConcurrentInfos(array_view cameras) +optional> CameraManagerImpl::GetCameraConcurrentInfos(array_view cameras) { - CHECK_DEBUG_RETURN_RET_LOG(cameraManager_ == nullptr, array(nullptr, 0), + CHECK_DEBUG_RETURN_RET_LOG(cameraManager_ == nullptr, optional>(std::nullopt), "failed to GetCameraConcurrentInfos, cameraManager is nullptr"); std::vectorcameraIdv = {}; std::vector cameraConcurrentType = {}; @@ -1002,35 +1004,26 @@ array CameraManagerImpl::GetCameraConcurrentInfos(array_vi bool isSupported = cameraManager_->GetConcurrentType(cameraDeviceArray, cameraConcurrentType); if (isSupported == false) { MEDIA_ERR_LOG("CameraManagerImpl::Camera is not support ConcurrentType"); - return array(nullptr, 0); + return optional>(std::nullopt); } isSupported = cameraManager_->CheckConcurrentExecution(cameraDeviceArray); if (isSupported == false) { MEDIA_ERR_LOG("CameraManagerImpl::Camera is not support ConcurrentType"); - return array(nullptr, 0); + return optional>(std::nullopt); } cameraManager_->GetCameraConcurrentInfos(cameraDeviceArray, cameraConcurrentType, modes, outputCapabilities); - return CameraUtilsTaihe::ToTaiheCameraConcurrentInfoArray( + auto res = CameraUtilsTaihe::ToTaiheCameraConcurrentInfoArray( cameraDeviceArray, cameraConcurrentType, modes, outputCapabilities); + return optional>(std::in_place, res); } -CameraDevice CameraManagerImpl::GetCameraDevice(CameraPosition position, CameraType type) +optional CameraManagerImpl::GetCameraDevice(CameraPosition position, CameraType type) { MEDIA_INFO_LOG("CameraManagerImpl::GetCameraDevice is called"); - std::string defaultString = ""; - CameraDevice cameraTaihe { - .cameraId = CameraUtilsTaihe::ToTaiheString(defaultString), - .cameraPosition = CameraPosition::key_t::CAMERA_POSITION_UNSPECIFIED, - .cameraType = CameraType::key_t::CAMERA_TYPE_DEFAULT, - .connectionType = ConnectionType::key_t::CAMERA_CONNECTION_BUILT_IN, - .isRetractable = optional::make(false), - .hostDeviceType = HostDeviceType::key_t::UNKNOWN_TYPE, - .hostDeviceName = CameraUtilsTaihe::ToTaiheString(defaultString), - .cameraOrientation = 0, - }; - CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, cameraTaihe, "cameraManager_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(cameraManager_ == nullptr, optional(std::nullopt), + "cameraManager_ is nullptr"); int32_t cameraPosition = static_cast(position.get_value()); int32_t cameraType = static_cast(type.get_value()); OHOS::sptr cameraInfo = nullptr; @@ -1039,9 +1032,9 @@ CameraDevice CameraManagerImpl::GetCameraDevice(CameraPosition position, CameraT if (cameraInfo == nullptr) { MEDIA_ERR_LOG("cameraInfo is null"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::CameraErrorCode::SERVICE_FATL_ERROR, "cameraInfo is null"); - return cameraTaihe; + return optional(std::nullopt); } - return CameraUtilsTaihe::ToTaiheCameraDevice(cameraInfo); + return optional(std::in_place, CameraUtilsTaihe::ToTaiheCameraDevice(cameraInfo)); } CameraManager getCameraManager(uintptr_t context) diff --git a/frameworks/taihe/src/mode/light_painting_photo_session_taihe.cpp b/frameworks/taihe/src/mode/light_painting_photo_session_taihe.cpp index b32b68f358de7c5654853cd92d7eec8fbe15da3b..79c35b9f739a328923853f62ff5bc1efd7d0bca7 100644 --- a/frameworks/taihe/src/mode/light_painting_photo_session_taihe.cpp +++ b/frameworks/taihe/src/mode/light_painting_photo_session_taihe.cpp @@ -21,21 +21,22 @@ namespace Ani { namespace Camera { using namespace taihe; -array LightPaintingPhotoSessionImpl::GetSupportedLightPaintingTypes() +optional> LightPaintingPhotoSessionImpl::GetSupportedLightPaintingTypes() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(nullptr, 0), "SystemApi GetSupportedLightPaintings is called!"); + optional>(std::nullopt), "SystemApi GetSupportedLightPaintings is called!"); if (lightPaintingSession_ == nullptr) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "failed to SetLightPaintingType, lightPaintingSession_ is nullptr"); - return array(nullptr, 0); + return optional>(std::nullopt); } std::vector lightPaintingTypes; int32_t retCode = lightPaintingSession_->GetSupportedLightPaintings(lightPaintingTypes); - CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0), - "GetSupportedLightPaintings fail %{public}d", retCode); - return CameraUtilsTaihe::ToTaiheArrayEnum( + CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), + optional>(std::nullopt), "GetSupportedLightPaintings fail %{public}d", retCode); + auto ret = CameraUtilsTaihe::ToTaiheArrayEnum( lightPaintingTypes); + return optional>(std::in_place, ret); } void LightPaintingPhotoSessionImpl::SetLightPaintingType(LightPaintingType type) @@ -55,19 +56,19 @@ void LightPaintingPhotoSessionImpl::SetLightPaintingType(LightPaintingType type) CHECK_ERROR_RETURN_LOG(!CameraUtilsTaihe::CheckError(retCode), "SetLightPainting fail %{public}d", retCode); } -LightPaintingType LightPaintingPhotoSessionImpl::GetLightPaintingType() +optional LightPaintingPhotoSessionImpl::GetLightPaintingType() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - LightPaintingType(static_cast(-1)), "SystemApi GetLightPaintingType is called!"); + optional(std::nullopt), "SystemApi GetLightPaintingType is called!"); if (lightPaintingSession_ == nullptr) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "failed to SetLightPaintingType, lightPaintingSession_ is nullptr"); - return LightPaintingType(static_cast(-1)); + return optional(std::nullopt); } OHOS::CameraStandard::LightPaintingType lightPainting; int32_t retCode = lightPaintingSession_->GetLightPainting(lightPainting); CHECK_ERROR_PRINT_LOG(!CameraUtilsTaihe::CheckError(retCode), "GetLightPainting fail %{public}d", retCode); - return LightPaintingType(static_cast(lightPainting)); + return optional(std::in_place, LightPaintingType(static_cast(lightPainting))); } } // namespace Camera } // namespace Ani \ No newline at end of file diff --git a/frameworks/taihe/src/mode/night_photo_session_taihe.cpp b/frameworks/taihe/src/mode/night_photo_session_taihe.cpp index 2b61673aeebe6195dc05f360e00be163941570ea..912542bdbbfca53df6cd30c00da789fc968d30e5 100644 --- a/frameworks/taihe/src/mode/night_photo_session_taihe.cpp +++ b/frameworks/taihe/src/mode/night_photo_session_taihe.cpp @@ -21,14 +21,15 @@ namespace Ani { namespace Camera { using namespace taihe; -int32_t NightPhotoSessionImpl::GetExposure() +optional NightPhotoSessionImpl::GetExposure() { - CHECK_ERROR_RETURN_RET_LOG(nightSession_ == nullptr, -1, "GetExposure failed, nightSession_ is nullptr!"); + CHECK_ERROR_RETURN_RET_LOG(nightSession_ == nullptr, optional(std::nullopt), + "GetExposure failed, nightSession_ is nullptr!"); uint32_t exposure; int32_t ret = nightSession_->GetExposure(exposure); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, -1, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: getExposure() Failed", __FUNCTION__); - return static_cast(exposure); + return optional(std::in_place, exposure); } void NightPhotoSessionImpl::SetExposure(int32_t exposure) @@ -40,19 +41,19 @@ void NightPhotoSessionImpl::SetExposure(int32_t exposure) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -array NightPhotoSessionImpl::GetSupportedExposureRange() +optional> NightPhotoSessionImpl::GetSupportedExposureRange() { - CHECK_ERROR_RETURN_RET_LOG(nightSession_ == nullptr, {}, + CHECK_ERROR_RETURN_RET_LOG(nightSession_ == nullptr, optional>(std::nullopt), "GetSupportedExposureRange failed, nightSession_ is nullptr!"); std::vector range; int32_t ret = nightSession_->GetExposureRange(range); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, {}, - "%{public}s: GetSupportedExposureRange() Failed", __FUNCTION__); + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, + optional>(std::nullopt), "%{public}s: GetSupportedExposureRange() Failed", __FUNCTION__); std::vector resRange; for (auto item : range) { resRange.push_back(static_cast(item)); } - return array(resRange); + return optional>(std::in_place, resRange); } } // namespace Camera } // namespace Ani \ No newline at end of file diff --git a/frameworks/taihe/src/mode/photo_session_taihe.cpp b/frameworks/taihe/src/mode/photo_session_taihe.cpp index 72c841e6b05266798455eff123b376055414f4aa..5a58b1d16f1d4879f595fe5d9e1a25fc81603aa0 100644 --- a/frameworks/taihe/src/mode/photo_session_taihe.cpp +++ b/frameworks/taihe/src/mode/photo_session_taihe.cpp @@ -35,16 +35,16 @@ void PhotoSessionImpl::Preconfig(PreconfigType preconfigType, optional_view preconfigRatio) +optional PhotoSessionImpl::CanPreconfig(PreconfigType preconfigType, optional_view preconfigRatio) { - CHECK_ERROR_RETURN_RET_LOG(photoSession_ == nullptr, false, "photoSession_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(photoSession_ == nullptr, optional(std::nullopt), "photoSession_ is nullptr"); OHOS::CameraStandard::ProfileSizeRatio profileSizeRatio = OHOS::CameraStandard::ProfileSizeRatio::UNSPECIFIED; if (preconfigRatio.has_value()) { profileSizeRatio = static_cast(preconfigRatio.value().get_value()); } bool retCode = photoSession_->CanPreconfig( static_cast(preconfigType.get_value()), profileSizeRatio); - return retCode; + return optional(std::in_place, retCode); } array CreateFunctionsPhotoFunctionsArray( @@ -72,7 +72,7 @@ array CreateFunctionsPhotoConflictFunctionsArray( return array(functionsArray); } -taihe::array PhotoSessionImpl::GetSessionFunctions(CameraOutputCapability const& outputCapability) +optional> PhotoSessionImpl::GetSessionFunctions(CameraOutputCapability const& outputCapability) { MEDIA_INFO_LOG("PhotoSessionImpl::GetSessionFunctions is called"); std::vector previewProfiles; @@ -80,19 +80,21 @@ taihe::array PhotoSessionImpl::GetSessionFunctions(CameraOutputC std::vector videoProfiles; CameraUtilsTaihe::ToNativeCameraOutputCapability(outputCapability, previewProfiles, photoProfiles, videoProfiles); - CHECK_ERROR_RETURN_RET_LOG(photoSession_ == nullptr, {}, "photoSession_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(photoSession_ == nullptr, optional>(std::nullopt), + "photoSession_ is nullptr"); auto cameraFunctionsList = photoSession_->GetSessionFunctions(previewProfiles, photoProfiles, videoProfiles); auto result = CreateFunctionsPhotoFunctionsArray(cameraFunctionsList); - return result; + return optional>(std::in_place, result); } -taihe::array PhotoSessionImpl::GetSessionConflictFunctions() +optional> PhotoSessionImpl::GetSessionConflictFunctions() { MEDIA_INFO_LOG("GetSessionConflictFunctions is called"); - CHECK_ERROR_RETURN_RET_LOG(photoSession_ == nullptr, {}, "photoSession_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(photoSession_ == nullptr, + optional>(std::nullopt), "photoSession_ is nullptr"); auto conflictFunctionsList = photoSession_->GetSessionConflictFunctions(); auto result = CreateFunctionsPhotoConflictFunctionsArray(conflictFunctionsList); - return result; + return optional>(std::in_place, result); } } // namespace Camera } // namespace Ani \ No newline at end of file diff --git a/frameworks/taihe/src/mode/portrait_photo_session_taihe.cpp b/frameworks/taihe/src/mode/portrait_photo_session_taihe.cpp index 2e14c7e933d13d0bf10f4ca500ef0e062c403682..84d5c9aa6e46657ee6b4f60f80ac001acd5e7eaf 100644 --- a/frameworks/taihe/src/mode/portrait_photo_session_taihe.cpp +++ b/frameworks/taihe/src/mode/portrait_photo_session_taihe.cpp @@ -48,7 +48,7 @@ array CreateFunctionsPortraitPhotoConflictFuncti return array(functionsArray); } -array PortraitPhotoSessionImpl::GetSessionFunctions( +optional> PortraitPhotoSessionImpl::GetSessionFunctions( CameraOutputCapability const& outputCapability) { MEDIA_INFO_LOG("PortraitPhotoSessionImpl::GetSessionFunctions is called"); @@ -57,27 +57,30 @@ array PortraitPhotoSessionImpl::GetSessionFunctions( std::vector videoProfiles; CameraUtilsTaihe::ToNativeCameraOutputCapability(outputCapability, previewProfiles, photoProfiles, videoProfiles); - CHECK_ERROR_RETURN_RET_LOG(portraitSession_ == nullptr, {}, "portraitSession_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(portraitSession_ == nullptr, + optional>(std::nullopt), "portraitSession_ is nullptr"); auto cameraFunctionsList = portraitSession_->GetSessionFunctions(previewProfiles, photoProfiles, videoProfiles); auto result = CreateFunctionsPortraitPhotoFunctionsArray(cameraFunctionsList); - return result; + return optional>(std::in_place, result); } -array PortraitPhotoSessionImpl::GetSessionConflictFunctions() +optional> PortraitPhotoSessionImpl::GetSessionConflictFunctions() { MEDIA_INFO_LOG("GetSessionConflictFunctions is called"); - CHECK_ERROR_RETURN_RET_LOG(portraitSession_ == nullptr, {}, "portraitSession_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(portraitSession_ == nullptr, + optional>(std::nullopt), "portraitSession_ is nullptr"); auto conflictFunctionsList = portraitSession_->GetSessionConflictFunctions(); auto result = CreateFunctionsPortraitPhotoConflictFunctionsArray(conflictFunctionsList); - return result; + return optional>(std::in_place, result); } -array PortraitPhotoSessionImpl::GetSupportedPortraitEffects() +optional> PortraitPhotoSessionImpl::GetSupportedPortraitEffects() { - CHECK_ERROR_RETURN_RET_LOG(portraitSession_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(portraitSession_ == nullptr, optional>(std::nullopt), "GetSupportedPortraitEffects portraitSession_ is null"); std::vector PortraitEffects = portraitSession_->GetSupportedPortraitEffects(); - return CameraUtilsTaihe::ToTaiheArrayEnum(PortraitEffects); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayEnum(PortraitEffects)); } void PortraitPhotoSessionImpl::SetPortraitEffect(PortraitEffect effect) @@ -89,13 +92,13 @@ void PortraitPhotoSessionImpl::SetPortraitEffect(PortraitEffect effect) portraitSession_->UnlockForControl(); } -PortraitEffect PortraitPhotoSessionImpl::GetPortraitEffect() +optional PortraitPhotoSessionImpl::GetPortraitEffect() { MEDIA_DEBUG_LOG("GetPortraitEffect is called"); - PortraitEffect errType = PortraitEffect(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(portraitSession_ == nullptr, errType, "GetPortraitEffect portraitSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(portraitSession_ == nullptr, optional(std::nullopt), + "GetPortraitEffect portraitSession_ is null"); OHOS::CameraStandard::PortraitEffect portaitEffect = portraitSession_->GetPortraitEffect(); - return PortraitEffect(static_cast(portaitEffect)); + return optional(std::in_place, PortraitEffect(static_cast(portaitEffect))); } } // namespace Camera } // namespace Ani \ No newline at end of file diff --git a/frameworks/taihe/src/mode/professional_session_taihe.cpp b/frameworks/taihe/src/mode/professional_session_taihe.cpp index 380f12f021222ed6d7f943dacc6feae3b32b672b..347cc7ffd1ceaea51a0b001867362dcecd382f0d 100644 --- a/frameworks/taihe/src/mode/professional_session_taihe.cpp +++ b/frameworks/taihe/src/mode/professional_session_taihe.cpp @@ -35,15 +35,15 @@ void ProfessionalSessionImpl::SetFocusAssist(bool enabled) professionSession_->UnlockForControl(); } -array ProfessionalSessionImpl::GetIsoRange() +optional> ProfessionalSessionImpl::GetIsoRange() { - CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, optional>(std::nullopt), "GetIsoRange failed, professionSession_ is nullptr!"); std::vector vecIsoList; int32_t retCode = professionSession_->GetIsoRange(vecIsoList); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); MEDIA_INFO_LOG("ProfessionalSessionImpl::GetIsoRange len = %{public}zu", vecIsoList.size()); - return array(vecIsoList); + return optional>(std::in_place, vecIsoList); } void ProfessionalSessionImpl::SetIso(int32_t iso) @@ -55,43 +55,43 @@ void ProfessionalSessionImpl::SetIso(int32_t iso) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -int32_t ProfessionalSessionImpl::GetIso() +optional ProfessionalSessionImpl::GetIso() { int32_t iso = -1; - CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, iso, + CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, optional(std::nullopt), "GetIso failed, professionSession_ is nullptr!"); int32_t ret = professionSession_->GetISO(iso); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, iso, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: GetIso() Failed", __FUNCTION__); - return iso; + return optional(std::in_place, iso); } -bool ProfessionalSessionImpl::IsFocusAssistSupported() +optional ProfessionalSessionImpl::IsFocusAssistSupported() { - CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, optional(std::nullopt), "IsFocusAssistSupported failed, professionSession_ is nullptr!"); - return false; + return optional(std::nullopt); } -bool ProfessionalSessionImpl::IsManualIsoSupported() +optional ProfessionalSessionImpl::IsManualIsoSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), false, + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), "SystemApi IsManualIsoSupported is called!"); - CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, optional(std::nullopt), "IsManualIsoSupported failed, professionSession_ is nullptr!"); - return professionSession_->IsManualIsoSupported(); + return optional(std::in_place, professionSession_->IsManualIsoSupported()); } -bool ProfessionalSessionImpl::IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) +optional ProfessionalSessionImpl::IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) { - CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, optional(std::nullopt), "IsExposureMeteringModeSupported failed, professionSession_ is nullptr!"); bool supported = false; int32_t ret = professionSession_->IsMeteringModeSupported( static_cast(aeMeteringMode.get_value()), supported); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, false, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: IsExposureMeteringModeSupported() Failed", __FUNCTION__); - return supported; + return optional(std::in_place, supported); } void ProfessionalSessionImpl::SetExposureMeteringMode(ExposureMeteringMode aeMeteringMode) @@ -103,16 +103,16 @@ void ProfessionalSessionImpl::SetExposureMeteringMode(ExposureMeteringMode aeMet professionSession_->UnlockForControl(); } -ExposureMeteringMode ProfessionalSessionImpl::GetExposureMeteringMode() +optional ProfessionalSessionImpl::GetExposureMeteringMode() { - ExposureMeteringMode errType = ExposureMeteringMode(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, errType, + CHECK_ERROR_RETURN_RET_LOG(professionSession_ == nullptr, optional(std::nullopt), "GetExposureMeteringMode timeLapsePhotoSession_ is null"); OHOS::CameraStandard::MeteringMode mode; int32_t ret = professionSession_->GetMeteringMode(mode); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, errType, - "%{public}s: GetExposureMeteringMode() Failed", __FUNCTION__); - return ExposureMeteringMode(static_cast(mode)); + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, + optional(std::nullopt), "%{public}s: GetExposureMeteringMode() Failed", __FUNCTION__); + return optional(std::in_place, + ExposureMeteringMode(static_cast(mode))); } void ProfessionalSessionImpl::RegisterIsoInfoCallbackListener(const std::string& eventName, diff --git a/frameworks/taihe/src/mode/slow_motion_video_session_taihe.cpp b/frameworks/taihe/src/mode/slow_motion_video_session_taihe.cpp index 6996744370b67501206f30bf895b0db4108719b9..ae5b89e6a448aab440667fd9f51c49d4d945f3ca 100644 --- a/frameworks/taihe/src/mode/slow_motion_video_session_taihe.cpp +++ b/frameworks/taihe/src/mode/slow_motion_video_session_taihe.cpp @@ -66,12 +66,12 @@ void SlowMotionVideoSessionImpl::UnregisterSlowMotionStateCb( MEDIA_INFO_LOG("UnregisterSlowMotionStateCb success"); } -bool SlowMotionVideoSessionImpl::IsSlowMotionDetectionSupported() +optional SlowMotionVideoSessionImpl::IsSlowMotionDetectionSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), false, + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), "SystemApi IsSlowMotionDetectionSupported is called!"); - CHECK_ERROR_RETURN_RET_LOG(slowMotionSession_ == nullptr, false, "slowMotionSession_ is null"); - return slowMotionSession_->IsSlowMotionDetectionSupported(); + CHECK_ERROR_RETURN_RET_LOG(slowMotionSession_ == nullptr, optional(std::nullopt), "slowMotionSession_ is null"); + return optional(std::in_place, slowMotionSession_->IsSlowMotionDetectionSupported()); } void SlowMotionVideoSessionImpl::SetSlowMotionDetectionArea(ohos::multimedia::camera::Rect const& area) diff --git a/frameworks/taihe/src/mode/time_lapse_photo_session_taihe.cpp b/frameworks/taihe/src/mode/time_lapse_photo_session_taihe.cpp index 51f24a031e67b424d961cf36eba94d77b28440ae..c5674d3fdbf1d430cfd9066b1ed0e992777f683e 100644 --- a/frameworks/taihe/src/mode/time_lapse_photo_session_taihe.cpp +++ b/frameworks/taihe/src/mode/time_lapse_photo_session_taihe.cpp @@ -212,36 +212,36 @@ void TimeLapsePhotoSessionImpl::SetTimeLapseInterval(int32_t interval) "%{public}s: SetTimeLapseInterval() Failed", __FUNCTION__); } -int32_t TimeLapsePhotoSessionImpl::GetTimeLapseInterval() +optional TimeLapsePhotoSessionImpl::GetTimeLapseInterval() { int32_t interval = -1; - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, interval, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), "GetTimeLapseInterval failed, timeLapsePhotoSession_ is nullptr!"); int32_t ret = timeLapsePhotoSession_->GetTimeLapseInterval(interval); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, interval, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: GetTimeLapseInterval() Failed", __FUNCTION__); - return interval; + return optional(std::in_place, interval); } -array TimeLapsePhotoSessionImpl::GetSupportedTimeLapseIntervalRange() +optional> TimeLapsePhotoSessionImpl::GetSupportedTimeLapseIntervalRange() { - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional>(std::nullopt), "GetSupportedTimeLapseIntervalRange failed, timeLapsePhotoSession_ is nullptr!"); std::vector range; int32_t retCode = timeLapsePhotoSession_->GetSupportedTimeLapseIntervalRange(range); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); - return array(range); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); + return optional>(std::in_place, array(range)); } -bool TimeLapsePhotoSessionImpl::IsWhiteBalanceModeSupported(WhiteBalanceMode mode) +optional TimeLapsePhotoSessionImpl::IsWhiteBalanceModeSupported(WhiteBalanceMode mode) { bool isSupported = false; - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, - isSupported, "SetWhiteBalance captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), + "SetWhiteBalance captureSession_ is null"); int32_t retCode = timeLapsePhotoSession_->IsWhiteBalanceModeSupported( static_cast(mode.get_value()), isSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), isSupported); - return isSupported; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } void TimeLapsePhotoSessionImpl::SetWhiteBalanceMode(WhiteBalanceMode mode) @@ -252,15 +252,15 @@ void TimeLapsePhotoSessionImpl::SetWhiteBalanceMode(WhiteBalanceMode mode) timeLapsePhotoSession_->UnlockForControl(); } -WhiteBalanceMode TimeLapsePhotoSessionImpl::GetWhiteBalanceMode() +optional TimeLapsePhotoSessionImpl::GetWhiteBalanceMode() { - WhiteBalanceMode errType = WhiteBalanceMode(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, - errType, "GetWhiteBalanceMode timeLapsePhotoSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), + "GetWhiteBalanceMode timeLapsePhotoSession_ is null"); OHOS::CameraStandard::WhiteBalanceMode whiteBalanceMode; int32_t retCode = timeLapsePhotoSession_->GetWhiteBalanceMode(whiteBalanceMode); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), errType); - return WhiteBalanceMode(static_cast(whiteBalanceMode)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, + WhiteBalanceMode(static_cast(whiteBalanceMode))); } void TimeLapsePhotoSessionImpl::SetWhiteBalance(int32_t whiteBalance) @@ -274,15 +274,15 @@ void TimeLapsePhotoSessionImpl::SetWhiteBalance(int32_t whiteBalance) "%{public}s: SetWhiteBalance Failed", __FUNCTION__); } -int32_t TimeLapsePhotoSessionImpl::GetWhiteBalance() +optional TimeLapsePhotoSessionImpl::GetWhiteBalance() { int32_t balance = -1; - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, balance, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), "GetWhiteBalance failed, timeLapsePhotoSession_ is nullptr!"); int32_t ret = timeLapsePhotoSession_->GetWhiteBalance(balance); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, balance, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: getWhiteBalance() Failed", __FUNCTION__); - return balance; + return optional(std::in_place, balance); } void TimeLapsePhotoSessionImpl::SetTimeLapseRecordState(ohos::multimedia::camera::TimeLapseRecordState state) @@ -306,26 +306,26 @@ void TimeLapsePhotoSessionImpl::SetIso(int32_t iso) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -int32_t TimeLapsePhotoSessionImpl::GetIso() +optional TimeLapsePhotoSessionImpl::GetIso() { int32_t iso = -1; - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, iso, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), "GetIso failed, timeLapsePhotoSession_ is nullptr!"); int32_t ret = timeLapsePhotoSession_->GetIso(iso); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, iso, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: GetIso() Failed", __FUNCTION__); - return iso; + return optional(std::in_place, iso); } -int32_t TimeLapsePhotoSessionImpl::GetExposure() +optional TimeLapsePhotoSessionImpl::GetExposure() { - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, -1, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), "GetExposure failed, timeLapsePhotoSession_ is nullptr!"); uint32_t exposure; int32_t ret = timeLapsePhotoSession_->GetExposure(exposure); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, -1, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: getExposure() Failed", __FUNCTION__); - return static_cast(exposure); + return optional(std::in_place, exposure); } void TimeLapsePhotoSessionImpl::SetExposure(int32_t exposure) @@ -337,15 +337,15 @@ void TimeLapsePhotoSessionImpl::SetExposure(int32_t exposure) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -bool TimeLapsePhotoSessionImpl::IsTryAENeeded() +optional TimeLapsePhotoSessionImpl::IsTryAENeeded() { - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), "IsTryAENeeded failed, timeLapsePhotoSession_ is nullptr!"); bool needed = false; int32_t ret = timeLapsePhotoSession_->IsTryAENeeded(needed); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, false, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: IsTryAENeeded() Failed", __FUNCTION__); - return needed; + return optional(std::in_place, needed); } void TimeLapsePhotoSessionImpl::StartTryAE() @@ -367,26 +367,26 @@ void TimeLapsePhotoSessionImpl::StopTryAE() CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -array TimeLapsePhotoSessionImpl::GetIsoRange() +optional> TimeLapsePhotoSessionImpl::GetIsoRange() { - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional>(std::nullopt), "GetIsoRange failed, timeLapsePhotoSession_ is nullptr!"); std::vector vecIsoList; int32_t retCode = timeLapsePhotoSession_->GetIsoRange(vecIsoList); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); MEDIA_INFO_LOG("TimeLapsePhotoSessionImpl::GetIsoRange len = %{public}zu", vecIsoList.size()); - return array(vecIsoList); + return optional>(std::in_place, vecIsoList); } -bool TimeLapsePhotoSessionImpl::IsManualIsoSupported() +optional TimeLapsePhotoSessionImpl::IsManualIsoSupported() { - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), "IsManualIsoSupported failed, timeLapsePhotoSession_ is nullptr!"); bool supported = false; int32_t ret = timeLapsePhotoSession_->IsManualIsoSupported(supported); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, false, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: isManualIsoSupported() Failed", __FUNCTION__); - return supported; + return optional(std::in_place, supported); } void TimeLapsePhotoSessionImpl::SetExposureMeteringMode(ExposureMeteringMode aeMeteringMode) @@ -400,54 +400,54 @@ void TimeLapsePhotoSessionImpl::SetExposureMeteringMode(ExposureMeteringMode aeM "%{public}s: SetExposureMeteringMode() Failed", __FUNCTION__); } -ExposureMeteringMode TimeLapsePhotoSessionImpl::GetExposureMeteringMode() +optional TimeLapsePhotoSessionImpl::GetExposureMeteringMode() { - ExposureMeteringMode errType = ExposureMeteringMode(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, errType, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), "GetExposureMeteringMode timeLapsePhotoSession_ is null"); OHOS::CameraStandard::MeteringMode mode; int32_t ret = timeLapsePhotoSession_->GetExposureMeteringMode(mode); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, errType, - "%{public}s: GetExposureMeteringMode() Failed", __FUNCTION__); - return ExposureMeteringMode(static_cast(mode)); + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, + optional(std::nullopt), "%{public}s: GetExposureMeteringMode() Failed", __FUNCTION__); + return optional(std::in_place, + ExposureMeteringMode(static_cast(mode))); } -bool TimeLapsePhotoSessionImpl::IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) +optional TimeLapsePhotoSessionImpl::IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) { - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional(std::nullopt), "IsExposureMeteringModeSupported failed, timeLapsePhotoSession_ is nullptr!"); bool supported = false; int32_t ret = timeLapsePhotoSession_->IsExposureMeteringModeSupported( static_cast(aeMeteringMode.get_value()), supported); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, false, + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, optional(std::nullopt), "%{public}s: IsExposureMeteringModeSupported() Failed", __FUNCTION__); - return supported; + return optional (std::in_place, supported); } -array TimeLapsePhotoSessionImpl::GetSupportedExposureRange() +optional> TimeLapsePhotoSessionImpl::GetSupportedExposureRange() { - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, {}, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional>(std::nullopt), "GetSupportedExposureRange failed, timeLapsePhotoSession_ is nullptr!"); std::vector range; int32_t ret = timeLapsePhotoSession_->GetSupportedExposureRange(range); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, {}, - "%{public}s: GetSupportedExposureRange() Failed", __FUNCTION__); + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, + optional>(std::nullopt), "%{public}s: GetSupportedExposureRange() Failed", __FUNCTION__); std::vector resRange; for (auto item : range) { resRange.push_back(static_cast(item)); } - return array(resRange); + return optional>(std::in_place, resRange); } -array TimeLapsePhotoSessionImpl::GetWhiteBalanceRange() +optional> TimeLapsePhotoSessionImpl::GetWhiteBalanceRange() { - CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, {}, + CHECK_ERROR_RETURN_RET_LOG(timeLapsePhotoSession_ == nullptr, optional>(std::nullopt), "GetWhiteBalanceRange failed, timeLapsePhotoSession_ is nullptr!"); std::vector range; int32_t ret = timeLapsePhotoSession_->GetWhiteBalanceRange(range); - CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, {}, - "%{public}s: getWhiteBalanceRange() Failed", __FUNCTION__); - return array(range); + CHECK_ERROR_RETURN_RET_LOG(ret != OHOS::CameraStandard::CameraErrorCode::SUCCESS, + optional>(std::nullopt), "%{public}s: getWhiteBalanceRange() Failed", __FUNCTION__); + return optional>(std::in_place, range); } } // namespace Ani } // namespace Camera \ No newline at end of file diff --git a/frameworks/taihe/src/mode/video_session_taihe.cpp b/frameworks/taihe/src/mode/video_session_taihe.cpp index 65041cc831578fc774515690d0df25deb713c274..3992b6b9768a3f49596405bb83e0a4f532fc1152 100644 --- a/frameworks/taihe/src/mode/video_session_taihe.cpp +++ b/frameworks/taihe/src/mode/video_session_taihe.cpp @@ -44,16 +44,16 @@ void VideoSessionImpl::Preconfig(PreconfigType preconfigType, optional_view preconfigRatio) +optional VideoSessionImpl::CanPreconfig(PreconfigType preconfigType, optional_view preconfigRatio) { - CHECK_ERROR_RETURN_RET_LOG(videoSession_ == nullptr, false, "videoSession_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(videoSession_ == nullptr, optional(std::nullopt), "videoSession_ is nullptr"); OHOS::CameraStandard::ProfileSizeRatio profileSizeRatio = OHOS::CameraStandard::ProfileSizeRatio::UNSPECIFIED; if (preconfigRatio.has_value()) { profileSizeRatio = static_cast(preconfigRatio.value().get_value()); } bool retCode = videoSession_->CanPreconfig( static_cast(preconfigType.get_value()), profileSizeRatio); - return retCode; + return optional(std::in_place, retCode); } array CreateFunctionsVideoFunctionsArray( @@ -81,7 +81,7 @@ array CreateFunctionsVideoConflictFunctionsArray( return array(functionsArray); } -array VideoSessionImpl::GetSessionFunctions(CameraOutputCapability const& outputCapability) +optional> VideoSessionImpl::GetSessionFunctions(CameraOutputCapability const& outputCapability) { MEDIA_INFO_LOG("VideoSessionImpl::GetSessionFunctions is called"); std::vector previewProfiles; @@ -90,19 +90,21 @@ array VideoSessionImpl::GetSessionFunctions(CameraOutputCapabili CameraUtilsTaihe::ToNativeCameraOutputCapability(outputCapability, previewProfiles, photoProfiles, videoProfileList); - CHECK_ERROR_RETURN_RET_LOG(videoSession_ == nullptr, {}, "videoSession_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(videoSession_ == nullptr, optional>(std::nullopt), + "videoSession_ is nullptr"); auto cameraFunctionsList = videoSession_->GetSessionFunctions(previewProfiles, photoProfiles, videoProfileList); auto result = CreateFunctionsVideoFunctionsArray(cameraFunctionsList); - return result; + return optional>(std::in_place, result); } -array VideoSessionImpl::GetSessionConflictFunctions() +optional> VideoSessionImpl::GetSessionConflictFunctions() { MEDIA_INFO_LOG("GetSessionConflictFunctions is called"); - CHECK_ERROR_RETURN_RET_LOG(videoSession_ == nullptr, {}, "videoSession_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(videoSession_ == nullptr, optional>(std::nullopt), + "videoSession_ is nullptr"); auto conflictFunctionsList = videoSession_->GetSessionConflictFunctions(); auto result = CreateFunctionsVideoConflictFunctionsArray(conflictFunctionsList); - return result; + return optional>(std::in_place, result); } } // namespace Camera } // namespace Ani \ No newline at end of file diff --git a/frameworks/taihe/src/output/photo_output_taihe.cpp b/frameworks/taihe/src/output/photo_output_taihe.cpp index ccda5e29a006be97d5c20d10ae675ef9af2bd5e4..5e5cae98ef5ffc1b3b644ff63f9a3f04359dd396 100644 --- a/frameworks/taihe/src/output/photo_output_taihe.cpp +++ b/frameworks/taihe/src/output/photo_output_taihe.cpp @@ -1922,17 +1922,17 @@ void PhotoOutputImpl::EnableMirror(bool enabled) "PhotoOutputImpl::EnableMirror fail %{public}d", retCode); } -bool PhotoOutputImpl::IsMirrorSupported() +optional PhotoOutputImpl::IsMirrorSupported() { if (photoOutput_ == nullptr) { MEDIA_ERR_LOG("PhotoOutputImpl::IsMirrorSupported get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } - return photoOutput_->IsMirrorSupported(); + return optional(std::in_place, photoOutput_->IsMirrorSupported()); } -Profile PhotoOutputImpl::GetActiveProfile() +optional PhotoOutputImpl::GetActiveProfile() { Profile res { .size = { @@ -1941,14 +1941,16 @@ Profile PhotoOutputImpl::GetActiveProfile() }, .format = CameraFormat::key_t::CAMERA_FORMAT_YUV_420_SP, }; - CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, res, "GetActiveProfile failed, photoOutput_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, optional(std::nullopt), + "GetActiveProfile failed, photoOutput_ is nullptr"); auto profile = photoOutput_->GetPhotoProfile(); - CHECK_ERROR_RETURN_RET_LOG(profile == nullptr, res, "GetActiveProfile failed, profile is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(profile == nullptr, optional(std::nullopt), + "GetActiveProfile failed, profile is nullptr"); CameraFormat cameraFormat = CameraUtilsTaihe::ToTaiheCameraFormat(profile->GetCameraFormat()); res.size.height = profile->GetSize().height; res.size.width = profile->GetSize().width; res.format = cameraFormat; - return res; + return optional(std::in_place, res); } void PhotoOutputImpl::EnableMovingPhoto(bool enabled) @@ -1963,27 +1965,28 @@ void PhotoOutputImpl::EnableMovingPhoto(bool enabled) CHECK_ERROR_RETURN_LOG(retCode != 0 && !CameraUtilsTaihe::CheckError(retCode), "EnableMovingPhoto failed"); } -bool PhotoOutputImpl::IsMovingPhotoSupported() +optional PhotoOutputImpl::IsMovingPhotoSupported() { CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, - false, "IsMovingPhotoSupported failed, photoOutput_ is nullptr"); + optional(std::nullopt), "IsMovingPhotoSupported failed, photoOutput_ is nullptr"); auto session = photoOutput_->GetSession(); - CHECK_ERROR_RETURN_RET_LOG(session == nullptr, false, "EnableMovingPhoto session is null"); - return session->IsMovingPhotoSupported(); + CHECK_ERROR_RETURN_RET_LOG(session == nullptr, optional(std::nullopt), "EnableMovingPhoto session is null"); + return optional(std::in_place, session->IsMovingPhotoSupported()); } -ImageRotation PhotoOutputImpl::GetPhotoRotation(int32_t deviceDegree) +optional PhotoOutputImpl::GetPhotoRotation(int32_t deviceDegree) { - CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, ImageRotation(static_cast(-1)), + CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, optional(std::nullopt), "GetPhotoRotation failed, photoOutput_ is nullptr"); int32_t retCode = photoOutput_->GetPhotoRotation(deviceDegree); if (retCode == OHOS::CameraStandard::SERVICE_FATL_ERROR) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::SERVICE_FATL_ERROR, "GetPhotoRotation Camera service fatal error."); - return ImageRotation(static_cast(-1)); + return optional(std::nullopt); } int32_t taiheRetCode = CameraUtilsTaihe::ToTaiheImageRotation(retCode); - return ImageRotation(static_cast(taiheRetCode)); + auto res = ImageRotation(static_cast(taiheRetCode)); + return optional(std::in_place, res); } void PhotoOutputImpl::EnableQuickThumbnail(bool enabled) @@ -2004,12 +2007,13 @@ void PhotoOutputImpl::EnableOffline() photoOutput_->EnableOfflinePhoto(); } -bool PhotoOutputImpl::IsOfflineSupported() +optional PhotoOutputImpl::IsOfflineSupported() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsOfflineSupported is called!"); - CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, false, "IsOfflineSupported failed, photoOutput_ is nullptr"); - return photoOutput_->IsOfflineSupported(); + optional(std::nullopt), "SystemApi IsOfflineSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, optional(std::nullopt), + "IsOfflineSupported failed, photoOutput_ is nullptr"); + return optional(std::in_place, photoOutput_->IsOfflineSupported()); } OHOS::sptr PhotoOutputImpl::GetPhotoOutput() @@ -2159,35 +2163,35 @@ void PhotoOutputImpl::EnableAutoCloudImageEnhancement(bool enabled) MEDIA_DEBUG_LOG("PhotoOutputImpl::EnableAutoCloudImageEnhancement success"); } -bool PhotoOutputImpl::IsAutoCloudImageEnhancementSupported() +optional PhotoOutputImpl::IsAutoCloudImageEnhancementSupported() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsAutoCloudImageEnhancementSupported is called!"); + optional(std::nullopt), "SystemApi IsAutoCloudImageEnhancementSupported is called!"); MEDIA_DEBUG_LOG("PhotoOutputImpl::IsAutoCloudImageEnhancementSupported is called"); if (photoOutput_ == nullptr) { MEDIA_ERR_LOG("PhotoOutputImpl::IsAutoCloudImageEnhancementSupported get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } bool isAutoCloudImageEnhancementSupported = false; int32_t retCode = photoOutput_->IsAutoCloudImageEnhancementSupported(isAutoCloudImageEnhancementSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), false); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); MEDIA_DEBUG_LOG("PhotoOutputImpl::IsAutoCloudImageEnhancementSupported is %{public}d", isAutoCloudImageEnhancementSupported); - return isAutoCloudImageEnhancementSupported; + return optional(std::in_place, isAutoCloudImageEnhancementSupported); } -bool PhotoOutputImpl::IsDepthDataDeliverySupported() +optional PhotoOutputImpl::IsDepthDataDeliverySupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsDepthDataDeliverySupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), + "SystemApi IsDepthDataDeliverySupported is called!"); if (photoOutput_ == nullptr) { MEDIA_ERR_LOG("PhotoOutputImpl::IsDepthDataDeliverySupported get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } - return photoOutput_->IsDepthDataDeliverySupported(); + return optional(std::in_place, photoOutput_->IsDepthDataDeliverySupported()); } void PhotoOutputImpl::EnableDepthDataDelivery(bool enabled) @@ -2204,21 +2208,22 @@ void PhotoOutputImpl::EnableDepthDataDelivery(bool enabled) "PhotoOutputNapi::EnableDepthDataDelivery fail %{public}d", retCode); } -bool PhotoOutputImpl::IsAutoHighQualityPhotoSupported() +optional PhotoOutputImpl::IsAutoHighQualityPhotoSupported() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsAutoHighQualityPhotoSupported is called!"); + optional(std::nullopt), "SystemApi IsAutoHighQualityPhotoSupported is called!"); MEDIA_DEBUG_LOG("PhotoOutputImpl::IsAutoHighQualityPhotoSupported is called"); if (photoOutput_ == nullptr) { MEDIA_ERR_LOG("PhotoOutputImpl::IsAutoHighQualityPhotoSupported get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } int32_t isAutoHighQualityPhotoSupported; int32_t retCode = photoOutput_->IsAutoHighQualityPhotoSupported(isAutoHighQualityPhotoSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), false); - return isAutoHighQualityPhotoSupported != -1; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + auto res = isAutoHighQualityPhotoSupported != -1; + return optional(std::in_place, res); } void PhotoOutputImpl::EnableAutoHighQualityPhoto(bool enabled) @@ -2255,16 +2260,16 @@ void PhotoOutputImpl::EnableRawDelivery(bool enabled) rawPhotoListener_->SaveCallbackReference(CONST_CAPTURE_PHOTO_AVAILABLE, rawCallback_, false); } -bool PhotoOutputImpl::IsRawDeliverySupported() +optional PhotoOutputImpl::IsRawDeliverySupported() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsRawDeliverySupported is called!"); + optional(std::nullopt), "SystemApi IsRawDeliverySupported is called!"); bool isSupported = false; CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, - false, "IsRawDeliverySupported failed, photoOutput_ is nullptr"); + optional(std::nullopt), "IsRawDeliverySupported failed, photoOutput_ is nullptr"); int32_t retCode = photoOutput_->IsRawDeliverySupported(isSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), false); - return isSupported; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } void PhotoOutputImpl::SetMovingPhotoVideoCodecType(VideoCodecType codecType) @@ -2293,42 +2298,42 @@ void PhotoOutputImpl::ConfirmCapture() "PhotoOutputImpl::ConfirmCapture fail %{public}d", retCode); } -bool PhotoOutputImpl::IsDeferredImageDeliverySupported(DeferredDeliveryImageType type) +optional PhotoOutputImpl::IsDeferredImageDeliverySupported(DeferredDeliveryImageType type) { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsDeferredImageDeliverySupported is called!"); + optional(std::nullopt), "SystemApi IsDeferredImageDeliverySupported is called!"); CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, - false, "IsDeferredImageDeliverySupported failed, photoOutput_ is nullptr"); + optional(std::nullopt), "IsDeferredImageDeliverySupported failed, photoOutput_ is nullptr"); int32_t retCode = photoOutput_->IsDeferredImageDeliverySupported( static_cast(type.get_value())); bool isSupported = (retCode == 0); - CHECK_ERROR_RETURN_RET(retCode > 0 && !CameraUtilsTaihe::CheckError(retCode), false); - return isSupported; + CHECK_ERROR_RETURN_RET(retCode > 0 && !CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } -bool PhotoOutputImpl::IsDeferredImageDeliveryEnabled(DeferredDeliveryImageType type) +optional PhotoOutputImpl::IsDeferredImageDeliveryEnabled(DeferredDeliveryImageType type) { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsDeferredImageDeliveryEnabled is called!"); + optional(std::nullopt), "SystemApi IsDeferredImageDeliveryEnabled is called!"); CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, - false, "IsDeferredImageDeliveryEnabled failed, photoOutput_ is nullptr"); + optional(std::nullopt), "IsDeferredImageDeliveryEnabled failed, photoOutput_ is nullptr"); int32_t retCode = photoOutput_->IsDeferredImageDeliveryEnabled( static_cast(type.get_value())); bool isSupported = (retCode == 0); - CHECK_ERROR_RETURN_RET(retCode > 0 && !CameraUtilsTaihe::CheckError(retCode), false); - return isSupported; + CHECK_ERROR_RETURN_RET(retCode > 0 && !CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } -bool PhotoOutputImpl::IsQuickThumbnailSupported() +optional PhotoOutputImpl::IsQuickThumbnailSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsQuickThumbnailSupported is called!"); - CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, - false, "IsQuickThumbnailSupported failed, photoOutput_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), + "SystemApi IsQuickThumbnailSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(photoOutput_ == nullptr, optional(std::nullopt), + "IsQuickThumbnailSupported failed, photoOutput_ is nullptr"); int32_t retCode = photoOutput_->IsQuickThumbnailSupported(); bool isSupported = (retCode == 0); - CHECK_ERROR_RETURN_RET(retCode > 0 && !CameraUtilsTaihe::CheckError(retCode), false); - return isSupported; + CHECK_ERROR_RETURN_RET(retCode > 0 && !CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } void PhotoOutputImpl::DeferImageDelivery(DeferredDeliveryImageType type) diff --git a/frameworks/taihe/src/output/preview_output_taihe.cpp b/frameworks/taihe/src/output/preview_output_taihe.cpp index 117509bd05bfba557d998c8f8808b4ec5e79fc4b..df0269d7c5c836cd64f6206fea4d7a91026665d8 100644 --- a/frameworks/taihe/src/output/preview_output_taihe.cpp +++ b/frameworks/taihe/src/output/preview_output_taihe.cpp @@ -121,15 +121,16 @@ void PreviewOutputImpl::EnableSketch(bool enabled) "PreviewOutputImpl::EnableSketch fail! %{public}d", retCode); } -double PreviewOutputImpl::GetSketchRatio() +optional PreviewOutputImpl::GetSketchRatio() { double ratio = -1.0; - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), ratio, - "SystemApi GetSketchRatio is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), + optional(std::nullopt), "SystemApi GetSketchRatio is called!"); MEDIA_INFO_LOG("PreviewOutputImpl::GetSketchRatio is called"); - CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, ratio, "GetSketchRatio failed, previewOutput_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, optional(std::nullopt), + "GetSketchRatio failed, previewOutput_ is nullptr"); ratio = static_cast(previewOutput_->GetSketchRatio()); - return ratio; + return optional(std::in_place, ratio); } void PreviewOutputImpl::AddDeferredSurface(string_view surfaceId) @@ -156,38 +157,41 @@ void PreviewOutputImpl::AddDeferredSurface(string_view surfaceId) previewOutput_->AddDeferredSurface(surface); } -bool PreviewOutputImpl::IsSketchSupported() +optional PreviewOutputImpl::IsSketchSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), false, - "SystemApi IsSketchSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), + optional(std::nullopt), "SystemApi IsSketchSupported is called!"); MEDIA_INFO_LOG("PreviewOutputImpl::IsSketchSupported is called"); - CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, false, "IsSketchSupported failed, previewOutput_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, optional(std::nullopt), + "IsSketchSupported failed, previewOutput_ is nullptr"); bool isSupported = previewOutput_->IsSketchSupported(); - return isSupported; + return optional(std::in_place, isSupported); } -array PreviewOutputImpl::GetSupportedFrameRates() +optional> PreviewOutputImpl::GetSupportedFrameRates() { - CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, optional>(std::nullopt), "GetSupportedFrameRates failed, previewOutput_ is nullptr"); std::vector> supportedFrameRatesRange = previewOutput_->GetSupportedFrameRates(); - return CameraUtilsTaihe::ToTaiheArrayFrameRateRange(supportedFrameRatesRange); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayFrameRateRange(supportedFrameRatesRange)); } -FrameRateRange PreviewOutputImpl::GetActiveFrameRate() +optional PreviewOutputImpl::GetActiveFrameRate() { FrameRateRange res { .min = -1, .max = -1, }; - CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, res, "GetActiveFrameRate failed, previewOutput_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, + optional(std::nullopt), "GetActiveFrameRate failed, previewOutput_ is nullptr"); std::vector frameRateRange = previewOutput_->GetFrameRateRange(); res.min = frameRateRange[0]; res.max = frameRateRange[1]; - return res; + return optional(std::in_place, res); } -Profile PreviewOutputImpl::GetActiveProfile() +optional PreviewOutputImpl::GetActiveProfile() { Profile res { .size = { @@ -196,14 +200,17 @@ Profile PreviewOutputImpl::GetActiveProfile() }, .format = CameraFormat::key_t::CAMERA_FORMAT_YUV_420_SP, }; - CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, res, "GetActiveProfile failed, previewOutput_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(previewOutput_ == nullptr, optional(std::nullopt), + "GetActiveProfile failed, previewOutput_ is nullptr"); auto profile = previewOutput_->GetPhotoProfile(); - CHECK_ERROR_RETURN_RET_LOG(profile == nullptr, res, "GetActiveProfile failed, profile is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(profile == nullptr, optional(std::nullopt), + "GetActiveProfile failed, profile is nullptr"); CameraFormat cameraFormat = CameraUtilsTaihe::ToTaiheCameraFormat(profile->GetCameraFormat()); res.size.height = profile->GetSize().height; res.size.width = profile->GetSize().width; res.format = cameraFormat; - return res; + auto result = optional(std::in_place, res); + return result; } void PreviewOutputImpl::SetFrameRate(int32_t minFps, int32_t maxFps) diff --git a/frameworks/taihe/src/output/video_output_taihe.cpp b/frameworks/taihe/src/output/video_output_taihe.cpp index 01ccacfef6269d0183554eeb43026240418e4353..6182f8aefdaa78407c31a70f7d8bd3e080cec514 100644 --- a/frameworks/taihe/src/output/video_output_taihe.cpp +++ b/frameworks/taihe/src/output/video_output_taihe.cpp @@ -86,14 +86,14 @@ void VideoOutputImpl::ReleaseSync() CAMERA_FINISH_ASYNC_TRACE(asyncContext->funcName, asyncContext->taskId); } -bool VideoOutputImpl::IsMirrorSupported() +optional VideoOutputImpl::IsMirrorSupported() { if (videoOutput_ == nullptr) { MEDIA_ERR_LOG("VideoOutputImpl::IsMirrorSupported get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } - return videoOutput_->IsMirrorSupported(); + return optional(std::in_place, videoOutput_->IsMirrorSupported()); } void VideoOutputImpl::EnableMirror(bool enabled) @@ -108,16 +108,16 @@ void VideoOutputImpl::EnableMirror(bool enabled) "VideoOutputImpl::EnableAutoHighQualityPhoto fail %{public}d", retCode); } -bool VideoOutputImpl::IsAutoVideoFrameRateSupported() +optional VideoOutputImpl::IsAutoVideoFrameRateSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), false, + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), "SystemApi IsAutoVideoFrameRateSupported is called!"); if (videoOutput_ == nullptr) { MEDIA_ERR_LOG("VideoOutputImpl::EnableAutoVideoFrameRate get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } - return videoOutput_->IsAutoVideoFrameRateSupported(); + return optional(std::in_place, videoOutput_->IsAutoVideoFrameRateSupported()); } void VideoOutputImpl::EnableAutoVideoFrameRate(bool enabled) @@ -134,62 +134,66 @@ void VideoOutputImpl::EnableAutoVideoFrameRate(bool enabled) "VideoOutputImpl::EnableAutoVideoFrameRate fail %{public}d", retCode); } -bool VideoOutputImpl::IsAutoDeferredVideoEnhancementSupported() +optional VideoOutputImpl::IsAutoDeferredVideoEnhancementSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), false, + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), "SystemApi IsAutoDeferredVideoEnhancementSupported is called!"); if (videoOutput_ == nullptr) { MEDIA_ERR_LOG("VideoOutputImpl::IsAutoDeferredVideoEnhancementSupported get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } int32_t res = videoOutput_->IsAutoDeferredVideoEnhancementSupported(); if (res > 1) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::SERVICE_FATL_ERROR, "inner fail"); - return false; + return optional(std::nullopt); } - return res == 1; + return optional(std::in_place, (res == 1)); } -bool VideoOutputImpl::IsAutoDeferredVideoEnhancementEnabled() +optional VideoOutputImpl::IsAutoDeferredVideoEnhancementEnabled() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), false, + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), "SystemApi IsAutoDeferredVideoEnhancementEnabled is called!"); if (videoOutput_ == nullptr) { MEDIA_ERR_LOG("VideoOutputImpl::IsAutoDeferredVideoEnhancementEnabled get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } int32_t res = videoOutput_->IsAutoDeferredVideoEnhancementEnabled(); if (res > 1) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::SERVICE_FATL_ERROR, "inner fail"); - return false; + return optional(std::nullopt); } - return res == 1; + return optional(std::in_place, (res == 1)); } -array VideoOutputImpl::GetSupportedFrameRates() +optional> VideoOutputImpl::GetSupportedFrameRates() { - CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, optional>(std::nullopt), "GetSupportedFrameRates failed, videoOutput_ is nullptr"); std::vector> supportedFrameRatesRange = videoOutput_->GetSupportedFrameRates(); - return CameraUtilsTaihe::ToTaiheArrayFrameRateRange(supportedFrameRatesRange); + auto res = optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayFrameRateRange(supportedFrameRatesRange)); + return res; } -FrameRateRange VideoOutputImpl::GetActiveFrameRate() +optional VideoOutputImpl::GetActiveFrameRate() { FrameRateRange res { .min = -1, .max = -1, }; - CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, res, "GetActiveFrameRate failed, videoOutput_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, optional(std::nullopt), + "GetActiveFrameRate failed, videoOutput_ is nullptr"); std::vector frameRateRange = videoOutput_->GetFrameRateRange(); res.min = frameRateRange[0]; res.max = frameRateRange[1]; - return res; + auto result = optional(std::in_place, res); + return result; } -VideoProfile VideoOutputImpl::GetActiveProfile() +optional VideoOutputImpl::GetActiveProfile() { VideoProfile res { .base = { @@ -204,9 +208,11 @@ VideoProfile VideoOutputImpl::GetActiveProfile() .max = -1, }, }; - CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, res, "GetActiveProfile failed, videoOutput_ is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, optional(std::nullopt), + "GetActiveProfile failed, videoOutput_ is nullptr"); auto profile = videoOutput_->GetVideoProfile(); - CHECK_ERROR_RETURN_RET_LOG(profile == nullptr, res, "GetActiveProfile failed, profile is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(profile == nullptr, optional(std::nullopt), + "GetActiveProfile failed, profile is nullptr"); CameraFormat cameraFormat = CameraUtilsTaihe::ToTaiheCameraFormat(profile->GetCameraFormat()); res.base.size.height = profile->GetSize().height; res.base.size.width = profile->GetSize().width; @@ -214,7 +220,7 @@ VideoProfile VideoOutputImpl::GetActiveProfile() auto frameRates = profile->GetFrameRates(); res.frameRateRange.min = frameRates[0] >= frameRates[1] ? frameRates[1] : frameRates[0]; res.frameRateRange.max = frameRates[0] >= frameRates[1] ? frameRates[0] : frameRates[1]; - return res; + return optional(std::in_place, res); } void VideoOutputImpl::SetFrameRate(int32_t minFps, int32_t maxFps) @@ -243,54 +249,56 @@ void VideoOutputImpl::SetRotation(ImageRotation rotation) "VideoOutputImpl::SetRotation fail %{public}d", retCode); } -bool VideoOutputImpl::IsRotationSupported() +optional VideoOutputImpl::IsRotationSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), false, + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), "SystemApi IsRotationSupported is called!"); if (videoOutput_ == nullptr) { MEDIA_ERR_LOG("VideoOutputImpl::IsRotationSupported get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return false; + return optional(std::nullopt); } bool isSupported = false; int32_t retCode = videoOutput_->IsRotationSupported(isSupported); - CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), false, + CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt), "VideoOutputImpl::IsRotationSupported fail %{public}d", retCode); - return isSupported; + return optional(std::in_place, isSupported); } -array VideoOutputImpl::GetSupportedRotations() +optional> VideoOutputImpl::GetSupportedRotations() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(nullptr, 0), "SystemApi GetSupportedRotations is called!"); + optional>(std::nullopt), "SystemApi GetSupportedRotations is called!"); if (videoOutput_ == nullptr) { MEDIA_ERR_LOG("VideoOutputImpl::GetSupportedRotations get native object fail"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "get native object fail"); - return array(nullptr, 0); + return optional>(std::nullopt); } std::vector supportedRotations; int32_t retCode = videoOutput_->GetSupportedRotations(supportedRotations); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); - return CameraUtilsTaihe::ToTaiheArrayEnum(supportedRotations); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); + auto ret = optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayEnum(supportedRotations)); + return ret; } -ImageRotation VideoOutputImpl::GetVideoRotation(int32_t deviceDegree) +optional VideoOutputImpl::GetVideoRotation(int32_t deviceDegree) { - CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, ImageRotation(static_cast(-1)), + CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, optional(std::nullopt), "GetVideoRotation failed, videoOutput_ is nullptr"); int32_t retCode = videoOutput_->GetVideoRotation(deviceDegree); if (retCode == OHOS::CameraStandard::SERVICE_FATL_ERROR) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::SERVICE_FATL_ERROR, "GetVideoRotation Camera service fatal error."); - return ImageRotation(static_cast(-1)); + return optional(std::nullopt); } if (retCode == OHOS::CameraStandard::INVALID_ARGUMENT) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "GetVideoRotation Camera invalid argument."); - return ImageRotation(static_cast(-1)); + return optional(std::nullopt); } int32_t taiheRetCode = CameraUtilsTaihe::ToTaiheImageRotation(retCode); - return ImageRotation(static_cast(taiheRetCode)); + return optional(std::in_place, ImageRotation(static_cast(taiheRetCode)));; } void VideoOutputImpl::AttachMetaSurface(string_view surfaceId, VideoMetaType type) @@ -304,12 +312,13 @@ void VideoOutputImpl::AttachMetaSurface(string_view surfaceId, VideoMetaType typ videoOutput_->AttachMetaSurface(surface, static_cast(type.get_value())); } -array VideoOutputImpl::GetSupportedVideoMetaTypes() +optional> VideoOutputImpl::GetSupportedVideoMetaTypes() { - CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(videoOutput_ == nullptr, optional>(std::nullopt), "GetSupportedVideoMetaTypes failed, videoOutput_ is nullptr"); std::vector videoMetaTypes = videoOutput_->GetSupportedVideoMetaTypes(); - return CameraUtilsTaihe::ToTaiheArrayEnum(videoMetaTypes); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayEnum(videoMetaTypes)); } void VideoCallbackListener::OnError(int32_t errorCode) const diff --git a/frameworks/taihe/src/query/camera_query_taihe.cpp b/frameworks/taihe/src/query/camera_query_taihe.cpp index f65db4164450b836ab30632dadd7ae9d89aae23a..cb9d27beb66a1536172e26f8a7285332d4a4cdcf 100644 --- a/frameworks/taihe/src/query/camera_query_taihe.cpp +++ b/frameworks/taihe/src/query/camera_query_taihe.cpp @@ -27,61 +27,62 @@ namespace Ani { namespace Camera { -bool FlashQueryImpl::HasFlash() +optional FlashQueryImpl::HasFlash() { MEDIA_DEBUG_LOG("HasFlash is called"); if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, "HasFlash failed, captureSession is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "HasFlash failed, captureSession is nullptr"); bool isSupported = false; int retCode = captureSession_->HasFlash(isSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), false); - return isSupported; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "HasFlash failed, cameraAbility_ is nullptr"); - return cameraAbility_->HasFlash(); + return optional(std::in_place, cameraAbility_->HasFlash()); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } -bool FlashQueryImpl::IsFlashModeSupported(FlashMode flashMode) +optional FlashQueryImpl::IsFlashModeSupported(FlashMode flashMode) { OHOS::CameraStandard::FlashMode mode = static_cast(flashMode.get_value()); if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "IsFlashModeSupported failed, captureSession_ is nullptr"); bool isSupported = false; captureSession_->LockForControl(); int retCode = captureSession_->IsFlashModeSupported(mode, isSupported); captureSession_->UnlockForControl(); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), false); - return isSupported; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsFlashModeSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsFlashModeSupported(mode); + return optional(std::in_place, cameraAbility_->IsFlashModeSupported(mode)); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } -bool FlashQueryImpl::IsLcdFlashSupported() +optional FlashQueryImpl::IsLcdFlashSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsLcdFlashSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), + "SystemApi IsLcdFlashSupported is called!"); if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, "IsLcdFlashSupported captureSession_ is null"); - return captureSession_->IsLcdFlashSupported(); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "IsLcdFlashSupported captureSession_ is null"); + return optional(std::in_place, captureSession_->IsLcdFlashSupported()); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsLcdFlashSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsLcdFlashSupported(); + return optional(std::in_place, cameraAbility_->IsLcdFlashSupported()); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } @@ -113,64 +114,66 @@ void FlashImpl::SetFlashMode(FlashMode flashMode) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -FlashMode FlashImpl::GetFlashMode() +optional FlashImpl::GetFlashMode() { MEDIA_DEBUG_LOG("GetFlashMode is called"); - FlashMode errType = FlashMode(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, errType, "GetFlashMode captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetFlashMode captureSession_ is null"); OHOS::CameraStandard::FlashMode flashMode; int32_t retCode = captureSession_->GetFlashMode(flashMode); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), errType); - return FlashMode(static_cast(flashMode)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, FlashMode(static_cast(flashMode))); } -array ZoomQueryImpl::GetZoomRatioRange() +optional> ZoomQueryImpl::GetZoomRatioRange() { MEDIA_DEBUG_LOG("GetZoomRatioRange is called"); std::vector vecZoomRatioList; if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, array(0.0), + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), "GetZoomRatioRange failed, captureSession is nullptr"); int retCode = captureSession_->GetZoomRatioRange(vecZoomRatioList); MEDIA_INFO_LOG("GetZoomRatioRange vecZoomRatioList len = %{public}zu", vecZoomRatioList.size()); if (retCode != 0) { CameraUtilsTaihe::ThrowError(retCode, "failed to GetZoomRatioRange, inner GetZoomRatioRange failed"); - return array(0.0); + return optional>(std::nullopt); } std::vector doubleVec(vecZoomRatioList.begin(), vecZoomRatioList.end()); - return array(doubleVec); + return optional>(std::in_place, doubleVec); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(0.0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetZoomRatioRange failed, cameraAbility_ is nullptr"); vecZoomRatioList = cameraAbility_->GetZoomRatioRange(); std::vector doubleVec(vecZoomRatioList.begin(), vecZoomRatioList.end()); - return array(doubleVec); + return optional>(std::in_place, doubleVec); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(0.0); + return optional>(std::nullopt); } } -array ZoomQueryImpl::GetZoomPointInfos() +optional> ZoomQueryImpl::GetZoomPointInfos() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(nullptr, 0), "SystemApi GetZoomPointInfos is called!"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - array(nullptr, 0), "GetZoomPointInfos captureSession_ is null"); + optional> (std::nullopt), "SystemApi GetZoomPointInfos is called!"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), + "GetZoomPointInfos captureSession_ is null"); std::vector vecZoomPointInfoList; int32_t retCode = captureSession_->GetZoomPointInfos(vecZoomPointInfoList); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); - return CameraUtilsTaihe::ToTaiheArrayZoomPointInfo(vecZoomPointInfoList); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayZoomPointInfo(vecZoomPointInfoList)); } -double ZoomImpl::GetZoomRatio() +optional ZoomImpl::GetZoomRatio() { float zoomRatio = -1.0; - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, zoomRatio, "GetZoomRatio failed, captureSession is nullptr"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetZoomRatio failed, captureSession is nullptr"); int32_t retCode = captureSession_->GetZoomRatio(zoomRatio); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), zoomRatio); - return static_cast(zoomRatio); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, zoomRatio); } void ZoomImpl::SetZoomRatio(double zoomRatio) @@ -227,108 +230,116 @@ void ColorReservationImpl::SetColorReservation(ColorReservationType type) CHECK_ERROR_RETURN_LOG(!CameraUtilsTaihe::CheckError(retCode), "SystemApi SetColorReservation is failed called!"); } -ColorReservationType ColorReservationImpl::GetColorReservation() +optional ColorReservationImpl::GetColorReservation() { - ColorReservationType errType = ColorReservationType(static_cast(-1)); CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - errType, "SystemApi GetColorReservation is called!"); + optional(std::nullopt), "SystemApi GetColorReservation is called!"); CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - errType, "GetColorReservation captureSession_ is null"); + optional(std::nullopt), "GetColorReservation captureSession_ is null"); OHOS::CameraStandard::ColorReservationType colorReservationType = OHOS::CameraStandard::ColorReservationType::COLOR_RESERVATION_TYPE_NONE; int32_t retCode = captureSession_->GetColorReservation(colorReservationType); - CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), errType, + CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt), "SystemApi GetColorReservation is failed called!"); - return ColorReservationType(static_cast(colorReservationType)); + auto res = optional(std::in_place, + ColorReservationType(static_cast(colorReservationType))); + return res; } -array ColorReservationQueryImpl::GetSupportedColorReservationTypes() +optional> ColorReservationQueryImpl::GetSupportedColorReservationTypes() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(nullptr, 0), "SystemApi GetSupportedColorReservationTypes is called!"); + optional>(std::nullopt), "SystemApi GetSupportedColorReservationTypes is called!"); CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - array(nullptr, 0), "GetSupportedColorReservationTypes captureSession_ is null"); + optional>(std::nullopt), "GetSupportedColorReservationTypes captureSession_ is null"); std::vector colorReservationTypes; int32_t retCode = captureSession_->GetSupportedColorReservationTypes(colorReservationTypes); - CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), + optional>(std::nullopt), "SystemApi GetSupportedColorReservationTypes is failed called!"); - return CameraUtilsTaihe::ToTaiheArrayEnum( - colorReservationTypes); + auto res = optional>(std::in_place, CameraUtilsTaihe::ToTaiheArrayEnum(colorReservationTypes)); + return res; } -bool FocusQueryImpl::IsFocusRangeTypeSupported(FocusRangeType type) +optional FocusQueryImpl::IsFocusRangeTypeSupported(FocusRangeType type) { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsFocusRangeTypeSupported is called!"); + optional(std::nullopt), "SystemApi IsFocusRangeTypeSupported is called!"); if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG( - captureSession_ == nullptr, false, "IsFocusRangeTypeSupported captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "IsFocusRangeTypeSupported captureSession_ is null"); bool isSupported = false; int32_t retCode = captureSession_->IsFocusRangeTypeSupported( static_cast(type.get_value()), isSupported); CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), - false, "SystemApi IsFocusRangeTypeSupported is failed called!"); - return isSupported; + optional(std::nullopt), "SystemApi IsFocusRangeTypeSupported is failed called!"); + return optional(std::in_place, isSupported); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsFocusRangeTypeSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsFocusRangeTypeSupported( - static_cast(type.get_value())); + auto ret = optional(std::in_place,cameraAbility_->IsFocusRangeTypeSupported( + static_cast(type.get_value()))); + return ret; } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } -bool FocusQueryImpl::IsFocusDrivenTypeSupported(FocusDrivenType type) +optional FocusQueryImpl::IsFocusDrivenTypeSupported(FocusDrivenType type) { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsFocusDrivenTypeSupported is called!"); + optional(std::nullopt), "SystemApi IsFocusDrivenTypeSupported is called!"); if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "IsFocusDrivenTypeSupported captureSession_ is null"); bool isSupported = false; int32_t retCode = captureSession_->IsFocusDrivenTypeSupported( static_cast(type.get_value()), isSupported); CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), - false, "SystemApi IsFocusDrivenTypeSupported is failed called!"); - return isSupported; + optional(std::nullopt), "SystemApi IsFocusDrivenTypeSupported is failed called!"); + return optional(std::in_place, isSupported); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsFocusDrivenTypeSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsFocusDrivenTypeSupported( - static_cast(type.get_value())); + auto res = optional(std::in_place,cameraAbility_->IsFocusDrivenTypeSupported( + static_cast(type.get_value()))); + return res; } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } -bool FocusQueryImpl::IsFocusModeSupported(FocusMode afMode) +optional FocusQueryImpl::IsFocusModeSupported(FocusMode afMode) { if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, "IsFocusModeSupported captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "IsFocusModeSupported captureSession_ is null"); bool isSupported = false; int32_t retCode = captureSession_->IsFocusModeSupported( static_cast(afMode.get_value()), isSupported); CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), - false, "IsFocusModeSupported is failed called!"); - return isSupported; + optional(std::nullopt), "IsFocusModeSupported is failed called!"); + return optional(std::in_place, isSupported); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsFocusModeSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsFocusModeSupported(static_cast(afMode.get_value())); + auto res = optional(std::in_place, cameraAbility_->IsFocusModeSupported( + static_cast(afMode.get_value()))); + return res; } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } -bool FocusQueryImpl::IsFocusAssistSupported() +optional FocusQueryImpl::IsFocusAssistSupported() { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not IsFocusAssistSupported in current session!"); - return false; + return optional(std::nullopt); } void FocusImpl::SetFocusDriven(FocusDrivenType type) @@ -342,18 +353,20 @@ void FocusImpl::SetFocusDriven(FocusDrivenType type) CHECK_ERROR_RETURN_LOG(!CameraUtilsTaihe::CheckError(retCode), "SystemApi SetFocusDriven is failed called!"); } -FocusDrivenType FocusImpl::GetFocusDriven() +optional FocusImpl::GetFocusDriven() { - FocusDrivenType errType = FocusDrivenType(static_cast(-1)); CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - errType, "SystemApi GetFocusDriven is called!"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, errType, "GetFocusDriven captureSession_ is null"); + optional(std::nullopt), "SystemApi GetFocusDriven is called!"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetFocusDriven captureSession_ is null"); OHOS::CameraStandard::FocusDrivenType focusDrivenType = OHOS::CameraStandard::FocusDrivenType::FOCUS_DRIVEN_TYPE_AUTO; int32_t retCode = captureSession_->GetFocusDriven(focusDrivenType); CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), - errType, "SystemApi GetFocusDriven is failed called!"); - return FocusDrivenType(static_cast(focusDrivenType)); + optional(std::nullopt), "SystemApi GetFocusDriven is failed called!"); + auto res = optional(std::in_place, + FocusDrivenType(static_cast(focusDrivenType))); + return res; } void FocusImpl::SetFocusRange(FocusRangeType type) @@ -367,18 +380,20 @@ void FocusImpl::SetFocusRange(FocusRangeType type) CHECK_ERROR_RETURN_LOG(!CameraUtilsTaihe::CheckError(retCode), "SystemApi SetFocusRange is failed called!"); } -FocusRangeType FocusImpl::GetFocusRange() +optional FocusImpl::GetFocusRange() { - FocusRangeType errType = FocusRangeType(static_cast(-1)); CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - errType, "SystemApi GetFocusRange is called!"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, errType, "GetFocusRange captureSession_ is null"); + optional(std::nullopt), "SystemApi GetFocusRange is called!"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetFocusRange captureSession_ is null"); OHOS::CameraStandard::FocusRangeType focusRangeType = OHOS::CameraStandard::FocusRangeType::FOCUS_RANGE_TYPE_AUTO; int32_t retCode = captureSession_->GetFocusRange(focusRangeType); CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), - errType, "SystemApi GetFocusRange is failed called!"); - return FocusRangeType(static_cast(focusRangeType)); + optional(std::nullopt), "SystemApi GetFocusRange is failed called!"); + auto res = optional(std::in_place, + FocusRangeType(static_cast(focusRangeType))); + return res; } void FocusImpl::SetFocusAssist(bool enabled) @@ -387,7 +402,7 @@ void FocusImpl::SetFocusAssist(bool enabled) "can not SetFocusAssist in current session!"); } -Point FocusImpl::GetFocusPoint() +optional FocusImpl::GetFocusPoint() { MEDIA_DEBUG_LOG("GetFocusPoint is called"); OHOS::CameraStandard::Point focusPoint { @@ -398,12 +413,12 @@ Point FocusImpl::GetFocusPoint() .x = -1, .y = -1, }; - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, taiheFocusPoint, "GetFocusPoint captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "GetFocusPoint captureSession_ is null"); int32_t retCode = captureSession_->GetFocusPoint(focusPoint); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), taiheFocusPoint); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); taiheFocusPoint.x = static_cast(focusPoint.x); taiheFocusPoint.y = static_cast(focusPoint.y); - return taiheFocusPoint; + return optional(std::in_place, taiheFocusPoint); } void FocusImpl::SetFocusPoint(Point const& point) @@ -420,14 +435,14 @@ void FocusImpl::SetFocusPoint(Point const& point) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -double FocusImpl::GetFocalLength() +optional FocusImpl::GetFocalLength() { float focalLength = -1.0; MEDIA_DEBUG_LOG("GetFocalLength is called"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, focalLength, "GetFocalLength captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "GetFocalLength captureSession_ is null"); int32_t retCode = captureSession_->GetFocalLength(focalLength); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), focalLength); - return static_cast(focalLength); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, focalLength); } void FocusImpl::SetFocusMode(FocusMode afMode) @@ -442,48 +457,49 @@ void FocusImpl::SetFocusMode(FocusMode afMode) "FlashImpl::SetFocusMode fail %{public}d", retCode); } -FocusMode FocusImpl::GetFocusMode() +optional FocusImpl::GetFocusMode() { MEDIA_DEBUG_LOG("GetFocusMode is called"); - FocusMode errType = FocusMode(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, errType, "GetFocusMode captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetFocusMode captureSession_ is null"); OHOS::CameraStandard::FocusMode focusMode; int32_t retCode = captureSession_->GetFocusMode(focusMode); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), errType); - return FocusMode(static_cast(focusMode)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, FocusMode(static_cast(focusMode))); } -bool StabilizationQueryImpl::IsVideoStabilizationModeSupported(VideoStabilizationMode vsMode) +optional StabilizationQueryImpl::IsVideoStabilizationModeSupported(VideoStabilizationMode vsMode) { if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "IsVideoStabilizationModeSupported captureSession_ is null"); bool isSupported = false; int32_t retCode = captureSession_->IsVideoStabilizationModeSupported( static_cast(vsMode.get_value()), isSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), false); - return isSupported; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsVideoStabilizationModeSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsVideoStabilizationModeSupported( - static_cast(vsMode.get_value())); + auto ret = optional(std::in_place, cameraAbility_->IsVideoStabilizationModeSupported( + static_cast(vsMode.get_value()))); + return ret; } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } -VideoStabilizationMode StabilizationImpl::GetActiveVideoStabilizationMode() +optional StabilizationImpl::GetActiveVideoStabilizationMode() { MEDIA_DEBUG_LOG("GetActiveVideoStabilizationMode is called"); - VideoStabilizationMode errType = VideoStabilizationMode(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, errType, + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "GetActiveVideoStabilizationMode captureSession_ is null"); OHOS::CameraStandard::VideoStabilizationMode videoStabilizationMode; int32_t retCode = captureSession_->GetActiveVideoStabilizationMode(videoStabilizationMode); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), errType); - return VideoStabilizationMode(static_cast(videoStabilizationMode)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + auto res = VideoStabilizationMode(static_cast(videoStabilizationMode)); + return optional(std::in_place, res); } void StabilizationImpl::SetVideoStabilizationMode(VideoStabilizationMode mode) @@ -495,71 +511,76 @@ void StabilizationImpl::SetVideoStabilizationMode(VideoStabilizationMode mode) CHECK_ERROR_RETURN_LOG(!CameraUtilsTaihe::CheckError(retCode), "SetVideoStabilizationMode call Failed!"); } -array BeautyQueryImpl::GetSupportedPortraitThemeTypes() +optional> BeautyQueryImpl::GetSupportedPortraitThemeTypes() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(nullptr, 0), "SystemApi GetSupportedPortraitThemeTypes is called!"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, array(nullptr, 0), + optional>(std::nullopt), "SystemApi GetSupportedPortraitThemeTypes is called!"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), "GetSupportedPortraitThemeTypes captureSession_ is null"); std::vector themeTypes; int32_t retCode = captureSession_->GetSupportedPortraitThemeTypes(themeTypes); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); - return CameraUtilsTaihe::ToTaiheArrayEnum(themeTypes); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); + auto res = optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayEnum(themeTypes)); + return res; } -array BeautyQueryImpl::GetSupportedBeautyTypes() +optional> BeautyQueryImpl::GetSupportedBeautyTypes() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(nullptr, 0), "SystemApi GetSupportedBeautyTypes is called!"); + optional>(std::nullopt), "SystemApi GetSupportedBeautyTypes is called!"); std::vector beautyTypes; if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), "GetSupportedBeautyTypes captureSession_ is null"); beautyTypes = captureSession_->GetSupportedBeautyTypes(); - return CameraUtilsTaihe::ToTaiheArrayEnum(beautyTypes); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayEnum(beautyTypes)); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetSupportedBeautyTypes failed, cameraAbility_ is nullptr"); beautyTypes = cameraAbility_->GetSupportedBeautyTypes(); - return CameraUtilsTaihe::ToTaiheArrayEnum(beautyTypes); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayEnum(beautyTypes)); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(nullptr, 0); + return optional>(std::nullopt); } } -array BeautyQueryImpl::GetSupportedBeautyRange(BeautyType type) +optional> BeautyQueryImpl::GetSupportedBeautyRange(BeautyType type) { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), array(0), - "SystemApi GetSupportedBeautyRange is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), + optional>(std::nullopt), "SystemApi GetSupportedBeautyRange is called!"); std::vector beautyRanges; if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG( - captureSession_ == nullptr, array(0), "GetSupportedBeautyRange captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), + "GetSupportedBeautyRange captureSession_ is null"); beautyRanges = captureSession_->GetSupportedBeautyRange(static_cast(type.get_value())); - return array(beautyRanges); + return optional>(std::in_place, beautyRanges); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetSupportedBeautyRange failed, cameraAbility_ is nullptr"); beautyRanges = cameraAbility_->GetSupportedBeautyRange( static_cast(type.get_value())); - return array(beautyRanges); + return optional>(std::in_place, beautyRanges); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(0); + return optional>(std::nullopt); } } -bool BeautyQueryImpl::IsPortraitThemeSupported() +optional BeautyQueryImpl::IsPortraitThemeSupported() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsPortraitThemeSupported is called!"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, "IsPortraitThemeSupported captureSession_ is null"); + optional(std::nullopt), "SystemApi IsPortraitThemeSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "IsPortraitThemeSupported captureSession_ is null"); bool isSupported; int32_t retCode = captureSession_->IsPortraitThemeSupported(isSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), false); - return false; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::nullopt); } void BeautyImpl::SetPortraitThemeType(PortraitThemeType type) @@ -579,15 +600,16 @@ void BeautyImpl::SetPortraitThemeType(PortraitThemeType type) "BeautyImpl::SetPortraitThemeType fail %{public}d", retCode); } -int32_t BeautyImpl::GetBeauty(BeautyType type) +optional BeautyImpl::GetBeauty(BeautyType type) { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - 0, "SystemApi GetBeauty is called!"); + optional(std::nullopt), "SystemApi GetBeauty is called!"); MEDIA_DEBUG_LOG("GetBeauty is called"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, 0, "BeautyImpl::GetBeauty captureSession_ is null!"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "BeautyImpl::GetBeauty captureSession_ is null!"); int32_t beautyStrength = captureSession_->GetBeauty(static_cast(type.get_value())); - return beautyStrength; + return optional(std::in_place, beautyStrength); } void BeautyImpl::SetBeauty(BeautyType type, int32_t value) @@ -601,54 +623,54 @@ void BeautyImpl::SetBeauty(BeautyType type, int32_t value) captureSession_->UnlockForControl(); } -array AutoExposureQueryImpl::GetExposureBiasRange() +optional> AutoExposureQueryImpl::GetExposureBiasRange() { std::vector vecExposureBiasList; if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - array(nullptr, 0), "GetExposureBiasRange captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), + "GetExposureBiasRange captureSession_ is null"); int32_t retCode = captureSession_->GetExposureBiasRange(vecExposureBiasList); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); std::vector doubleVec(vecExposureBiasList.begin(), vecExposureBiasList.end()); - return array(doubleVec); + return optional>(std::in_place, doubleVec); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetExposureBiasRange failed, cameraAbility_ is nullptr"); vecExposureBiasList = cameraAbility_->GetExposureBiasRange(); std::vector doubleVec(vecExposureBiasList.begin(), vecExposureBiasList.end()); - return array(doubleVec); + return optional>(std::in_place, doubleVec); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(nullptr, 0); + return optional>(std::nullopt); } } -bool AutoExposureQueryImpl::IsExposureModeSupported(ExposureMode aeMode) +optional AutoExposureQueryImpl::IsExposureModeSupported(ExposureMode aeMode) { OHOS::CameraStandard::ExposureMode exposureMode = static_cast(aeMode.get_value()); if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "IsExposureModeSupported captureSession_ is null"); bool isSupported = false; int32_t retCode = captureSession_->IsExposureModeSupported(exposureMode, isSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), false); - return isSupported; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsExposureModeSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsExposureModeSupported(exposureMode); + return optional(std::in_place, cameraAbility_->IsExposureModeSupported(exposureMode)); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } -bool AutoExposureQueryImpl::IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) +optional AutoExposureQueryImpl::IsExposureMeteringModeSupported(ExposureMeteringMode aeMeteringMode) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not IsExposureMeteringModeSupported in current session!"); - return false; + return optional(std::nullopt); } void AutoExposureImpl::SetExposureBias(double exposureBias) @@ -672,27 +694,26 @@ void AutoExposureImpl::SetExposureMeteringMode(ExposureMeteringMode aeMeteringMo return; } -ExposureMeteringMode AutoExposureImpl::GetExposureMeteringMode() +optional AutoExposureImpl::GetExposureMeteringMode() { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not SetExposureMeteringMode in current session!"); - ExposureMeteringMode meteringMode = static_cast(-1); - return meteringMode; + return optional(std::nullopt); } -double AutoExposureImpl::GetExposureValue() +optional AutoExposureImpl::GetExposureValue() { float exposureValue = -1.0; MEDIA_DEBUG_LOG("GetExposureValue is called"); CHECK_ERROR_RETURN_RET_LOG( - captureSession_ == nullptr, exposureValue, "GetExposureValue captureSession_ is null"); + captureSession_ == nullptr, optional(std::nullopt), "GetExposureValue captureSession_ is null"); int32_t retCode = captureSession_->GetExposureValue(exposureValue); - CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), exposureValue, + CHECK_ERROR_RETURN_RET_LOG(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt), "AutoExposureImpl::GetExposureValue fail %{public}d", retCode); - return static_cast(exposureValue); + return optional(std::in_place, exposureValue); } -Point AutoExposureImpl::GetMeteringPoint() +optional AutoExposureImpl::GetMeteringPoint() { MEDIA_DEBUG_LOG("GetMeteringPoint is called"); OHOS::CameraStandard::Point exposurePoint { @@ -704,12 +725,12 @@ Point AutoExposureImpl::GetMeteringPoint() .y = -1, }; CHECK_ERROR_RETURN_RET_LOG( - captureSession_ == nullptr, taiheExposurePoint, "GetMeteringPoint captureSession_ is null"); + captureSession_ == nullptr, optional(std::nullopt), "GetMeteringPoint captureSession_ is null"); int32_t retCode = captureSession_->GetMeteringPoint(exposurePoint); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), taiheExposurePoint); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); taiheExposurePoint.x = static_cast(exposurePoint.x); taiheExposurePoint.y = static_cast(exposurePoint.y); - return taiheExposurePoint; + return optional(std::in_place, taiheExposurePoint); } void AutoExposureImpl::SetMeteringPoint(Point const& point) @@ -737,63 +758,65 @@ void AutoExposureImpl::SetExposureMode(ExposureMode aeMode) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -ExposureMode AutoExposureImpl::GetExposureMode() +optional AutoExposureImpl::GetExposureMode() { MEDIA_DEBUG_LOG("GetExposureMode is called"); - ExposureMode errType = ExposureMode(static_cast(-1)); CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - errType, "GetExposureMode captureSession_ is null"); + optional(std::nullopt), "GetExposureMode captureSession_ is null"); OHOS::CameraStandard::ExposureMode exposureMode; int32_t retCode = captureSession_->GetExposureMode(exposureMode); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), errType); - return ExposureMode(static_cast(exposureMode)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, ExposureMode(static_cast(exposureMode))); } -array ColorManagementQueryImpl::GetSupportedColorSpaces() +optional> ColorManagementQueryImpl::GetSupportedColorSpaces() { std::vector colorSpaces; if (isSessionBase_) { CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - array(nullptr, 0), "GetSupportedColorSpaces captureSession_ is null"); + optional>(std::nullopt), "GetSupportedColorSpaces captureSession_ is null"); colorSpaces = captureSession_->GetSupportedColorSpaces(); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetSupportedColorSpaces failed, cameraAbility_ is nullptr"); colorSpaces = cameraAbility_->GetSupportedColorSpaces(); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(nullptr, 0); + return optional>(std::nullopt); } std::vector vec; ani_enum aniEnum {}; ani_enum_item aniEnumItem {}; ani_env* env = get_env(); CHECK_ERROR_RETURN_RET_LOG(env == nullptr, - array(nullptr, 0), "GetSupportedColorSpaces env is null"); + optional>(std::nullopt), "GetSupportedColorSpaces env is null"); CHECK_ERROR_RETURN_RET_LOG(ANI_OK != env->FindEnum(ENUM_NAME_COLORSPACE, &aniEnum), - array(nullptr, 0), "Find Enum Fail"); + optional>(std::nullopt), "Find Enum Fail"); for (auto item : colorSpaces) { CHECK_ERROR_RETURN_RET_LOG(ANI_OK != env->Enum_GetEnumItemByIndex( aniEnum, reinterpret_cast(static_cast(item)), &aniEnumItem), - array(nullptr, 0), "Find Enum item Fail"); + optional>(std::nullopt), "Find Enum item Fail"); vec.push_back(reinterpret_cast(aniEnumItem)); } - return array(vec); + return optional>(std::in_place, vec); } -uintptr_t ColorManagementImpl::GetActiveColorSpace() +optional ColorManagementImpl::GetActiveColorSpace() { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, 0, "GetActiveColorSpace captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetActiveColorSpace captureSession_ is null"); OHOS::CameraStandard::ColorSpace colorSpace; int32_t retCode = captureSession_->GetActiveColorSpace(colorSpace); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), 0); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); ani_enum aniEnum {}; ani_enum_item aniEnumItem {}; ani_env* env = get_env(); - CHECK_ERROR_RETURN_RET_LOG(env == nullptr, 0, "GetActiveColorSpace env is null"); + CHECK_ERROR_RETURN_RET_LOG(env == nullptr, optional(std::nullopt), "GetActiveColorSpace env is null"); CHECK_ERROR_RETURN_RET_LOG(ANI_OK != env->Enum_GetEnumItemByIndex( - aniEnum, reinterpret_cast(static_cast(colorSpace)), &aniEnumItem), 0, "Find Enum item Fail"); - return reinterpret_cast(aniEnumItem); + aniEnum, reinterpret_cast(static_cast(colorSpace)), &aniEnumItem), + optional(std::nullopt), "Find Enum item Fail"); + auto res = optional(std::in_place, reinterpret_cast(aniEnumItem)); + return res; } void ColorManagementImpl::SetColorSpace(uintptr_t colorSpace) @@ -805,21 +828,23 @@ void ColorManagementImpl::SetColorSpace(uintptr_t colorSpace) "ColorManagementImpl::SetColorSpace fail %{public}d", retCode); } -bool SceneDetectionQueryImpl::IsSceneFeatureSupported(SceneFeatureType type) +optional SceneDetectionQueryImpl::IsSceneFeatureSupported(SceneFeatureType type) { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsSceneFeatureSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), + "SystemApi IsSceneFeatureSupported is called!"); if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - false, "IsSceneFeatureSupported captureSession_ is null"); - return captureSession_->IsFeatureSupported(static_cast(type.get_value())); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "IsSceneFeatureSupported captureSession_ is null"); + return optional(std::in_place, + captureSession_->IsFeatureSupported(static_cast(type.get_value()))); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsSceneFeatureSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsFeatureSupported(static_cast(type.get_value())); + return optional(std::in_place, + cameraAbility_->IsFeatureSupported(static_cast(type.get_value()))); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } @@ -834,23 +859,24 @@ void SceneDetectionImpl::EnableSceneFeature(SceneFeatureType type, bool enabled) "SceneDetectionImpl::EnableSceneFeature fail %{public}d", retCode); } -bool WhiteBalanceQueryImpl::IsWhiteBalanceModeSupported(WhiteBalanceMode mode) +optional WhiteBalanceQueryImpl::IsWhiteBalanceModeSupported(WhiteBalanceMode mode) { bool isSupported = false; - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, isSupported, "SetWhiteBalance captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "SetWhiteBalance captureSession_ is null"); int32_t retCode = captureSession_->IsWhiteBalanceModeSupported( static_cast(mode.get_value()), isSupported); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), isSupported); - return isSupported; + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, isSupported); } -array WhiteBalanceQueryImpl::GetWhiteBalanceRange() +optional> WhiteBalanceQueryImpl::GetWhiteBalanceRange() { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, {}, "SetWhiteBalance captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), + "SetWhiteBalance captureSession_ is null"); std::vector whiteBalanceRange = {}; int32_t retCode = captureSession_->GetManualWhiteBalanceRange(whiteBalanceRange); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), {}); - return array(whiteBalanceRange); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); + return optional>(std::in_place, whiteBalanceRange); } void WhiteBalanceImpl::SetWhiteBalance(int32_t whiteBalance) @@ -862,15 +888,14 @@ void WhiteBalanceImpl::SetWhiteBalance(int32_t whiteBalance) captureSession_->UnlockForControl(); } -int32_t WhiteBalanceImpl::GetWhiteBalance() +optional WhiteBalanceImpl::GetWhiteBalance() { - WhiteBalanceMode errType = WhiteBalanceMode(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - errType, "GetWhiteBalanceMode captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetWhiteBalanceMode captureSession_ is null"); OHOS::CameraStandard::WhiteBalanceMode whiteBalanceMode; int32_t retCode = captureSession_->GetWhiteBalanceMode(whiteBalanceMode); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), errType); - return WhiteBalanceMode(static_cast(whiteBalanceMode)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, WhiteBalanceMode(static_cast(whiteBalanceMode))); } void WhiteBalanceImpl::SetWhiteBalanceMode(WhiteBalanceMode mode) @@ -881,21 +906,21 @@ void WhiteBalanceImpl::SetWhiteBalanceMode(WhiteBalanceMode mode) captureSession_->UnlockForControl(); } -WhiteBalanceMode WhiteBalanceImpl::GetWhiteBalanceMode() +optional WhiteBalanceImpl::GetWhiteBalanceMode() { - WhiteBalanceMode errType = WhiteBalanceMode(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - errType, "GetWhiteBalanceMode captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetWhiteBalanceMode captureSession_ is null"); OHOS::CameraStandard::WhiteBalanceMode whiteBalanceMode; int32_t retCode = captureSession_->GetWhiteBalanceMode(whiteBalanceMode); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), errType); - return WhiteBalanceMode(static_cast(whiteBalanceMode)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, + WhiteBalanceMode(static_cast(whiteBalanceMode))); } -array ManualExposureQueryImpl::GetSupportedExposureRange() +optional> ManualExposureQueryImpl::GetSupportedExposureRange() { if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetSupportedExposureRange failed, cameraAbility_ is nullptr"); std::vector range; range = cameraAbility_->GetSupportedExposureRange(); @@ -903,19 +928,19 @@ array ManualExposureQueryImpl::GetSupportedExposureRange() for (auto item : range) { resRange.push_back(static_cast(item)); } - return array(resRange); + return optional>(std::in_place, resRange); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not GetSupportedExposureRange in current session!"); - return array(0); + return optional>(std::nullopt); } } -int32_t ManualExposureImpl::GetExposure() +optional ManualExposureImpl::GetExposure() { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not GetExposure in current session!"); - return -1; + return optional(std::nullopt); } void ManualExposureImpl::SetExposure(int32_t exposure) @@ -925,22 +950,24 @@ void ManualExposureImpl::SetExposure(int32_t exposure) return; } -array ColorEffectQueryImpl::GetSupportedColorEffects() +optional> ColorEffectQueryImpl::GetSupportedColorEffects() { std::vector colorEffects; if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - array(nullptr, 0), "GetSupportedColorEffects captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), + "GetSupportedColorEffects captureSession_ is null"); colorEffects = captureSession_->GetSupportedColorEffects(); - return CameraUtilsTaihe::ToTaiheArrayEnum(colorEffects); + return optional>(std::in_place, CameraUtilsTaihe::ToTaiheArrayEnum(colorEffects)); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetSupportedColorEffects failed, cameraAbility_ is nullptr"); colorEffects = cameraAbility_->GetSupportedColorEffects(); - return CameraUtilsTaihe::ToTaiheArrayEnum(colorEffects); + return optional>(std::in_place, CameraUtilsTaihe::ToTaiheArrayEnum(colorEffects)); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(nullptr, 0); + return optional>(std::nullopt); } } @@ -952,27 +979,27 @@ void ColorEffectImpl::SetColorEffect(ColorEffectType type) captureSession_->UnlockForControl(); } -ColorEffectType ColorEffectImpl::GetColorEffect() +optional ColorEffectImpl::GetColorEffect() { MEDIA_DEBUG_LOG("GetColorEffect is called"); - ColorEffectType errType = ColorEffectType(static_cast(-1)); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, errType, "GetColorEffect captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetColorEffect captureSession_ is null"); OHOS::CameraStandard::ColorEffect colorEffect = captureSession_->GetColorEffect(); - return ColorEffectType(static_cast(colorEffect)); + return optional(std::in_place, ColorEffectType(static_cast(colorEffect))); } -array ManualIsoQueryImpl::GetIsoRange() +optional> ManualIsoQueryImpl::GetIsoRange() { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not GetIsoRange in current session!"); - return array(nullptr, 0); + return optional>(std::nullopt); } -bool ManualIsoQueryImpl::IsManualIsoSupported() +optional ManualIsoQueryImpl::IsManualIsoSupported() { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not IsManualIsoSupported in current session!"); - return false; + return optional(std::nullopt); } void ManualIsoImpl::SetIso(int32_t iso) @@ -982,59 +1009,60 @@ void ManualIsoImpl::SetIso(int32_t iso) return ; } -int32_t ManualIsoImpl::GetIso() +optional ManualIsoImpl::GetIso() { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not GetIso in current session!"); - return -1; + return optional(std::nullopt); } -array ApertureQueryImpl::GetSupportedPhysicalApertures() +optional> ApertureQueryImpl::GetSupportedPhysicalApertures() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(nullptr, 0), "SystemApi GetSupportedPhysicalApertures is called!"); + optional>(std::nullopt), "SystemApi GetSupportedPhysicalApertures is called!"); std::vector> physicalApertures = {}; if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - array(nullptr, 0), "GetSupportedPhysicalApertures captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), + "GetSupportedPhysicalApertures captureSession_ is null"); int32_t retCode = captureSession_->GetSupportedPhysicalApertures(physicalApertures); MEDIA_INFO_LOG("GetSupportedPhysicalApertures len = %{public}zu", physicalApertures.size()); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); - return CameraUtilsTaihe::ToTaiheArrayPhysicalAperture(physicalApertures); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayPhysicalAperture(physicalApertures)); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetSupportedPhysicalApertures failed, cameraAbility_ is nullptr"); physicalApertures = cameraAbility_->GetSupportedPhysicalApertures(); - return CameraUtilsTaihe::ToTaiheArrayPhysicalAperture(physicalApertures); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayPhysicalAperture(physicalApertures)); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(nullptr, 0); + return optional>(std::nullopt); } } -array ApertureQueryImpl::GetSupportedVirtualApertures() +optional> ApertureQueryImpl::GetSupportedVirtualApertures() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(nullptr, 0), "SystemApi GetSupportedVirtualApertures is called!"); + optional>(std::nullopt), "SystemApi GetSupportedVirtualApertures is called!"); std::vector virtualApertures = {}; if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, - array(nullptr, 0), "GetSupportedVirtualApertures captureSession_ is null"); - + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), + "GetSupportedVirtualApertures captureSession_ is null"); int32_t retCode = captureSession_->GetSupportedVirtualApertures(virtualApertures); MEDIA_INFO_LOG("GetSupportedVirtualApertures virtualApertures len = %{public}zu", virtualApertures.size()); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(nullptr, 0)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); std::vector doubleVec(virtualApertures.begin(), virtualApertures.end()); - return array(doubleVec); + return optional>(std::in_place, doubleVec); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(0.0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetSupportedVirtualApertures failed, cameraAbility_ is nullptr"); virtualApertures = cameraAbility_->GetSupportedVirtualApertures(); std::vector doubleVec(virtualApertures.begin(), virtualApertures.end()); - return array(doubleVec); + return optional>(std::in_place, doubleVec); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(0.0); + return optional>(std::nullopt); } } @@ -1049,17 +1077,17 @@ void ApertureImpl::SetVirtualAperture(double aperture) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -double ApertureImpl::GetVirtualAperture() +optional ApertureImpl::GetVirtualAperture() { float virtualAperture = -1.0; - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), virtualAperture, - "SystemApi GetVirtualAperture is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), + optional(std::nullopt), "SystemApi GetVirtualAperture is called!"); MEDIA_DEBUG_LOG("GetVirtualAperture is called"); CHECK_ERROR_RETURN_RET_LOG( - captureSession_ == nullptr, virtualAperture, "GetVirtualAperture captureSession_ is null"); + captureSession_ == nullptr, optional(std::nullopt), "GetVirtualAperture captureSession_ is null"); int32_t retCode = captureSession_->GetVirtualAperture(virtualAperture); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), virtualAperture); - return static_cast(virtualAperture); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, virtualAperture); } void ApertureImpl::SetPhysicalAperture(double aperture) @@ -1076,17 +1104,17 @@ void ApertureImpl::SetPhysicalAperture(double aperture) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(retCode)); } -double ApertureImpl::GetPhysicalAperture() +optional ApertureImpl::GetPhysicalAperture() { float physicalAperture = -1.0; - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), physicalAperture, - "SystemApi GetPhysicalAperture is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), + optional(std::nullopt), "SystemApi GetPhysicalAperture is called!"); MEDIA_DEBUG_LOG("GetPhysicalAperture is called"); CHECK_ERROR_RETURN_RET_LOG( - captureSession_ == nullptr, physicalAperture, "SetPhysicalAperture captureSession_ is null"); + captureSession_ == nullptr, optional(std::nullopt), "SetPhysicalAperture captureSession_ is null"); int32_t retCode = captureSession_->GetPhysicalAperture(physicalAperture); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), physicalAperture); - return static_cast(physicalAperture); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, physicalAperture); } void EffectSuggestionImpl::SetEffectSuggestionStatus(array_view status) @@ -1133,39 +1161,41 @@ void EffectSuggestionImpl::EnableEffectSuggestion(bool enabled) "EffectSuggestionImpl::EnableEffectSuggestion fail %{public}d", retCode); } -bool EffectSuggestionImpl::IsEffectSuggestionSupported() +optional EffectSuggestionImpl::IsEffectSuggestionSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsEffectSuggestionSupported is called!"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), + "SystemApi IsEffectSuggestionSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "IsEffectSuggestionSupported captureSession_ is null"); - return captureSession_->IsEffectSuggestionSupported(); + return optional(std::in_place, captureSession_->IsEffectSuggestionSupported()); } -array EffectSuggestionImpl::GetSupportedEffectSuggestionTypes() +optional> EffectSuggestionImpl::GetSupportedEffectSuggestionTypes() { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, {}, + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), "GetSupportedEffectSuggestionTypes captureSession_ is null"); std::vector effectSuggestionTypeList = captureSession_->GetSupportedEffectSuggestionType(); - return CameraUtilsTaihe::ToTaiheArrayEnum( - effectSuggestionTypeList); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayEnum(effectSuggestionTypeList)); } -bool MacroQueryImpl::IsMacroSupported() +optional MacroQueryImpl::IsMacroSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsMacroSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), + "SystemApi IsMacroSupported is called!"); if (isSessionBase_) { - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, "IsMacroSupported captureSession_ is null"); - return captureSession_->IsMacroSupported(); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "IsMacroSupported captureSession_ is null"); + return optional(std::in_place, captureSession_->IsMacroSupported()); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsMacroSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsMacroSupported(); + return optional(std::in_place, captureSession_->IsMacroSupported()); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } @@ -1185,13 +1215,14 @@ void MacroImpl::EnableMacro(bool enabled) "MacroImpl::EnableMacro fail %{public}d", retCode); } -double ManualFocusImpl::GetFocusDistance() +optional ManualFocusImpl::GetFocusDistance() { float distance = -1.0; - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, distance, "GetFocusDistance captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), + "GetFocusDistance captureSession_ is null"); int32_t retCode = captureSession_->GetFocusDistance(distance); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), distance); - return static_cast(distance); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional(std::nullopt)); + return optional(std::in_place, distance); } void ManualFocusImpl::SetFocusDistance(double distance) @@ -1202,19 +1233,19 @@ void ManualFocusImpl::SetFocusDistance(double distance) captureSession_->UnlockForControl(); } -array PortraitQueryImpl::GetSupportedPortraitEffects() +optional> PortraitQueryImpl::GetSupportedPortraitEffects() { if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(nullptr, 0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetSupportedPortraitEffects failed, cameraAbility_ is nullptr"); std::vector PortraitEffects = cameraAbility_->GetSupportedPortraitEffects(); - return CameraUtilsTaihe::ToTaiheArrayEnum( - PortraitEffects); + return optional>(std::in_place, + CameraUtilsTaihe::ToTaiheArrayEnum(PortraitEffects)); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not GetSupportedPortraitEffects in current session!"); - return array(nullptr, 0); + return optional>(std::nullopt); } } @@ -1224,61 +1255,60 @@ void PortraitImpl::SetPortraitEffect(PortraitEffect effect) "can not SetPortraitEffect in current session!"); } -PortraitEffect PortraitImpl::GetPortraitEffect() +optional PortraitImpl::GetPortraitEffect() { - PortraitEffect errType = PortraitEffect(static_cast(-1)); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "can not GetPortraitEffect in current session!"); - return errType; + return optional(std::nullopt); } -bool DepthFusionQueryImpl::IsDepthFusionSupported() +optional DepthFusionQueryImpl::IsDepthFusionSupported() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsDepthFusionSupported is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), + "SystemApi IsDepthFusionSupported is called!"); if (isSessionBase_) { if (captureSession_ == nullptr) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "failed to IsDepthFusionSupported, captureSession_ is nullptr"); - return false; + return optional(std::nullopt); } - return captureSession_->IsDepthFusionEnabled(); + return optional(std::in_place, captureSession_->IsDepthFusionEnabled()); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, false, + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional(std::nullopt), "IsDepthFusionSupported failed, cameraAbility_ is nullptr"); - return cameraAbility_->IsDepthFusionSupported(); + return optional(std::in_place, cameraAbility_->IsDepthFusionSupported()); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return false; + return optional(std::nullopt); } } -array DepthFusionQueryImpl::GetDepthFusionThreshold() +optional> DepthFusionQueryImpl::GetDepthFusionThreshold() { CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - array(0.0), "SystemApi GetDepthFusionThreshold is called!"); + optional>(std::nullopt), "SystemApi GetDepthFusionThreshold is called!"); std::vector vecDepthFusionThreshold; if (isSessionBase_) { if (captureSession_ == nullptr) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "failed to GetDepthFusionThreshold, captureSession_ is nullptr"); - return array(0.0); + return optional>(std::nullopt); } int32_t retCode = captureSession_->GetDepthFusionThreshold(vecDepthFusionThreshold); - CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), array(0.0)); + CHECK_ERROR_RETURN_RET(!CameraUtilsTaihe::CheckError(retCode), optional>(std::nullopt)); std::vector doubleVec(vecDepthFusionThreshold.begin(), vecDepthFusionThreshold.end()); - return array(doubleVec); + return optional>(std::in_place, doubleVec); } else if (isFunctionBase_) { - CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, array(0.0), + CHECK_ERROR_RETURN_RET_LOG(cameraAbility_ == nullptr, optional>(std::nullopt), "GetDepthFusionThreshold failed, cameraAbility_ is nullptr"); vecDepthFusionThreshold = cameraAbility_->GetDepthFusionThreshold(); std::vector doubleVec(vecDepthFusionThreshold.begin(), vecDepthFusionThreshold.end()); - return array(doubleVec); + return optional>(std::in_place, doubleVec); } else { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::OPERATION_NOT_ALLOWED, "static binding failed"); - return array(0.0); + return optional>(std::nullopt); + } } -} void DepthFusionImpl::EnableDepthFusion(bool enabled) { @@ -1296,26 +1326,26 @@ void DepthFusionImpl::EnableDepthFusion(bool enabled) "DepthFusionImpl::EnableDepthFusion fail %{public}d", retCode); } -bool DepthFusionImpl::IsDepthFusionEnabled() +optional DepthFusionImpl::IsDepthFusionEnabled() { - CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), - false, "SystemApi IsDepthFusionEnabled is called!"); + CHECK_ERROR_RETURN_RET_LOG(!OHOS::CameraStandard::CameraAniSecurity::CheckSystemApp(), optional(std::nullopt), + "SystemApi IsDepthFusionEnabled is called!"); if (captureSession_ == nullptr) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "failed to IsDepthFusionEnabled, captureSession_ is nullptr"); - return false; + return optional(std::nullopt); } - return captureSession_->IsDepthFusionEnabled(); + return optional(std::in_place, captureSession_->IsDepthFusionEnabled()); } -bool AutoDeviceSwitchQueryImpl::IsAutoDeviceSwitchSupported() +optional AutoDeviceSwitchQueryImpl::IsAutoDeviceSwitchSupported() { if (captureSession_ == nullptr) { CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::INVALID_ARGUMENT, "failed to IsAutoDeviceSwitchSupported, captureSession_ is nullptr"); - return false; + return optional(std::nullopt); } - return captureSession_->IsAutoDeviceSwitchSupported(); + return optional(std::in_place, captureSession_->IsAutoDeviceSwitchSupported()); } void AutoDeviceSwitchImpl::EnableAutoDeviceSwitch(bool enabled) diff --git a/frameworks/taihe/src/session/camera_session_taihe.cpp b/frameworks/taihe/src/session/camera_session_taihe.cpp index 572c5d8d3ebdae3e1a9518215a49c0a542597dec..4d2a89db252093926b4282c851a1368346f5355c 100644 --- a/frameworks/taihe/src/session/camera_session_taihe.cpp +++ b/frameworks/taihe/src/session/camera_session_taihe.cpp @@ -125,29 +125,29 @@ void SessionImpl::AddInput(weak::CameraInput cameraInput) CHECK_ERROR_RETURN(!CameraUtilsTaihe::CheckError(ret)); } -bool SessionImpl::CanAddInput(weak::CameraInput cameraInput) +optional SessionImpl::CanAddInput(weak::CameraInput cameraInput) { MEDIA_DEBUG_LOG("CanAddInput is called"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, "CanAddInput captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "CanAddInput captureSession_ is null"); Ani::Camera::CameraInputImpl* inputImpl = reinterpret_cast(cameraInput->GetSpecificImplPtr()); - CHECK_ERROR_RETURN_RET_LOG(inputImpl == nullptr, false, "CanAddInput inputImpl is null"); + CHECK_ERROR_RETURN_RET_LOG(inputImpl == nullptr, optional(std::nullopt), "CanAddInput inputImpl is null"); sptr captureInput = inputImpl->GetCameraInput(); bool isSupported = captureSession_->CanAddInput(captureInput); - return isSupported; + return optional(std::in_place, isSupported); } -bool SessionImpl::CanAddOutput(weak::CameraOutput cameraOutput) +optional SessionImpl::CanAddOutput(weak::CameraOutput cameraOutput) { MEDIA_DEBUG_LOG("CanAddOutput is called"); - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, false, "CanAddOutput captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional(std::nullopt), "CanAddOutput captureSession_ is null"); Ani::Camera::CameraOutputImpl* outputImpl = reinterpret_cast(cameraOutput->GetSpecificImplPtr()); - CHECK_ERROR_RETURN_RET_LOG(outputImpl == nullptr, false, "CanAddOutput CameraOutputImpl is null"); + CHECK_ERROR_RETURN_RET_LOG(outputImpl == nullptr, optional(std::nullopt), "CanAddOutput CameraOutputImpl is null"); sptr captureOutput = outputImpl->GetCameraOutput(); - CHECK_ERROR_RETURN_RET_LOG(captureOutput == nullptr, false, "CanAddOutput captureOutput is null"); + CHECK_ERROR_RETURN_RET_LOG(captureOutput == nullptr, optional(std::nullopt), "CanAddOutput captureOutput is null"); bool isSupported = captureSession_->CanAddOutput(captureOutput); - return isSupported; + return optional(std::in_place, isSupported); } void SessionImpl::RemoveInput(weak::CameraInput cameraInput) @@ -196,7 +196,7 @@ void SessionImpl::SetUsage(UsageType usage, bool enabled) captureSession_->UnlockForControl(); } -array SessionImpl::GetCameraOutputCapabilities(CameraDevice const& camera) +optional> SessionImpl::GetCameraOutputCapabilities(CameraDevice const& camera) { std::string nativeStr(camera.cameraId); sptr cameraInfo = @@ -204,9 +204,10 @@ array SessionImpl::GetCameraOutputCapabilities(CameraDev if (cameraInfo == nullptr) { MEDIA_ERR_LOG("cameraInfo is null"); CameraUtilsTaihe::ThrowError(OHOS::CameraStandard::SERVICE_FATL_ERROR, "cameraInfo is null."); - return {}; + return optional>(std::nullopt); } - CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, {}, "GetCameraOutputCapabilities captureSession_ is null"); + CHECK_ERROR_RETURN_RET_LOG(captureSession_ == nullptr, optional>(std::nullopt), + "GetCameraOutputCapabilities captureSession_ is null"); std::vector> caplist = captureSession_->GetCameraOutputCapabilities(cameraInfo); std::vector vec; @@ -217,7 +218,7 @@ array SessionImpl::GetCameraOutputCapabilities(CameraDev caplist[i]->RemoveDuplicatesProfiles(); vec.push_back(CameraUtilsTaihe::ToTaiheCameraOutputCapability(caplist[i])); } - return array(vec); + return optional>(std::in_place, vec); } void SessionImpl::OnError(callback_view callback)