From 5e2416824607c41a426e0aa99b0e561396104f1d Mon Sep 17 00:00:00 2001 From: cold_yixiu Date: Mon, 5 Dec 2022 17:30:32 +0800 Subject: [PATCH] camera interface adjust for errorcode Signed-off-by: cold_yixiu --- api/@ohos.multimedia.camera.d.ts | 911 ++++++++----------------------- 1 file changed, 224 insertions(+), 687 deletions(-) diff --git a/api/@ohos.multimedia.camera.d.ts b/api/@ohos.multimedia.camera.d.ts index dc5e379fd6..222864e39a 100644 --- a/api/@ohos.multimedia.camera.d.ts +++ b/api/@ohos.multimedia.camera.d.ts @@ -26,20 +26,13 @@ declare namespace camera { /** * Creates a CameraManager instance. * @param context Current application context. - * @param callback Callback used to return the CameraManager instance. + * @returns CameraManager instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect + * @throws { BusinessError } 7400201 - Camera service fatal error. */ - function getCameraManager(context: Context, callback: AsyncCallback): void; - - /** - * Creates a CameraManager instance. - * @param context Current application context. - * @returns Promise used to return the CameraManager instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function getCameraManager(context: Context): Promise; + function getCameraManager(context: Context): CameraManager; /** * Enum for camera status. @@ -160,44 +153,80 @@ declare namespace camera { } /** - * Camera manager object. + * Enum for camera error code. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface CameraManager { + enum CameraErrorCode { /** - * Gets supported camera descriptions. - * @param callback Callback used to return the array of supported cameras. + * Parameter missing or parameter type incorrect * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - getSupportedCameras(callback: AsyncCallback>): void; - + INVALID_ARGUMENT = 7400101, /** - * Gets supported camera descriptions. - * @returns Promise used to return an array of supported cameras. + * Operation not allow. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - getSupportedCameras(): Promise>; + OPERATION_NOT_ALLOWED = 7400102, + /** + * Session not config. + * @since 9 + */ + SESSION_NOT_CONFIG = 7400103, + /** + * Session not running. + * @since 9 + */ + SESSION_NOT_RUNNING = 7400104, + /** + * Session config locked. + * @since 9 + */ + SESSION_CONFIG_LOCKED = 7400105, + /** + * Device setting locked. + * @since 9 + */ + DEVICE_SETTING_LOCKED = 7400106, + /** + * Can not use camera cause of conflict. + * @since 9 + */ + CONFILICT_CAMERA = 7400107, + /** + * Camera disabled cause of security reason. + * @since 9 + */ + DEVICE_DISABLED = 7400108, + /** + * Camera service fatal error. + * @since 9 + */ + SERVICE_FATAL_ERROR = 7400201 + } + /** + * Camera manager object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraManager { /** - * Gets supported output capability for specific camera. - * @param camera Camera device. - * @param callback Callback used to return the camera output capability. + * Gets supported camera descriptions. + * @returns An array of supported cameras. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void; + getSupportedCameras(): Array; /** * Gets supported output capability for specific camera. * @param camera Camera device. - * @returns Promise used to return the camera output capability. + * @returns The camera output capability. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getSupportedOutputCapability(camera: CameraDevice): Promise; + getSupportedOutputCapability(camera: CameraDevice): CameraOutputCapability; /** * Determine whether camera is muted. @@ -228,138 +257,77 @@ declare namespace camera { /** * Creates a CameraInput instance by camera. * @param camera Camera device used to create the instance. - * @param callback Callback used to return the CameraInput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - * @permission ohos.permission.CAMERA - */ - createCameraInput(camera: CameraDevice, callback: AsyncCallback): void; - - /** - * Creates a CameraInput instance by camera. - * @param camera Camera device used to create the instance. - * @returns Promise used to return the CameraInput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - * @permission ohos.permission.CAMERA - */ - createCameraInput(camera: CameraDevice): Promise; - - /** - * Creates a CameraInput instance by camera position and type. - * @param position Target camera position. - * @param type Target camera type. - * @param callback Callback used to return the CameraInput instance. + * @returns The CameraInput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect * @permission ohos.permission.CAMERA */ - createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; + createCameraInput(camera: CameraDevice): CameraInput; /** * Creates a CameraInput instance by camera position and type. * @param position Target camera position. * @param type Target camera type. - * @returns Promise used to return the CameraInput instance. + * @returns The CameraInput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect * @permission ohos.permission.CAMERA */ - createCameraInput(position: CameraPosition, type: CameraType): Promise; - - /** - * Creates a PreviewOutput instance. - * @param profile Preview output profile. - * @param surfaceId Surface object id used in camera photo output. - * @param callback Callback used to return the PreviewOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void; + createCameraInput(position: CameraPosition, type: CameraType): CameraInput; /** * Creates a PreviewOutput instance. * @param profile Preview output profile. * @param surfaceId Surface object id used in camera photo output. - * @returns Promise used to return the PreviewOutput instance. + * @returns The PreviewOutput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect */ - createPreviewOutput(profile: Profile, surfaceId: string): Promise; + createPreviewOutput(profile: Profile, surfaceId: string): PreviewOutput; /** * Creates a PhotoOutput instance. * @param profile Photo output profile. * @param surfaceId Surface object id used in camera photo output. - * @param callback Callback used to return the PhotoOutput instance. + * @returns The PhotoOutput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect */ - createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void; - - /** - * Creates a PhotoOutput instance. - * @param profile Photo output profile. - * @param surfaceId Surface object id used in camera photo output. - * @returns Promise used to return the PhotoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - createPhotoOutput(profile: Profile, surfaceId: string): Promise; + createPhotoOutput(profile: Profile, surfaceId: string): PhotoOutput; /** * Creates a VideoOutput instance. * @param profile Video profile. * @param surfaceId Surface object id used in camera video output. - * @param callback Callback used to return the VideoOutput instance. + * @returns The VideoOutput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect */ - createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void; - - /** - * Creates a VideoOutput instance. - * @param profile Video profile. - * @param surfaceId Surface object id used in camera video output. - * @returns Promise used to return the VideoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - createVideoOutput(profile: VideoProfile, surfaceId: string): Promise; + createVideoOutput(profile: VideoProfile, surfaceId: string): VideoOutput; /** * Creates a MetadataOutput instance. * @param metadataObjectTypes Array of MetadataObjectType. - * @param callback Callback used to return the MetadataOutput instance. + * @returns The MetadataOutput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect */ - createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void; - - /** - * Creates a MetadataOutput instance. - * @param metadataObjectTypes Array of MetadataObjectType. - * @returns Promise used to return the MetadataOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - createMetadataOutput(metadataObjectTypes: Array): Promise; - - /** - * Gets a CaptureSession instance. - * @param callback Callback used to return the CaptureSession instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - createCaptureSession(callback: AsyncCallback): void; + createMetadataOutput(metadataObjectTypes: Array): MetadataOutput; /** * Gets a CaptureSession instance. - * @returns Promise used to return the CaptureSession instance. + * @returns The CaptureSession instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ - createCaptureSession(): Promise; + createCaptureSession(): CaptureSession; /** * Subscribes camera status change event callback. @@ -434,11 +402,11 @@ declare namespace camera { */ enum CameraType { /** - * Unspecified camera type + * Default camera type * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_TYPE_UNSPECIFIED = 0, + CAMERA_TYPE_DEFAULT = 0, /** * Wide camera @@ -580,6 +548,9 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400107 - Can not use camera cause of conflict. + * @throws { BusinessError } 7400108 - Camera disabled cause of security reason. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ open(callback: AsyncCallback): void; @@ -588,6 +559,9 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400107 - Can not use camera cause of conflict. + * @throws { BusinessError } 7400108 - Camera disabled cause of security reason. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ open(): Promise; @@ -596,6 +570,7 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ close(callback: AsyncCallback): void; @@ -604,25 +579,10 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ close(): Promise; - /** - * Releases instance. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - release(callback: AsyncCallback): void; - - /** - * Releases instance. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - release(): Promise; - /** * Subscribes error event callback. * @param type Event type. @@ -631,54 +591,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; - } - - /** - * Enum for CameraInput error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum CameraInputErrorCode { - /** - * Unknown error. - * @since 9 - */ - ERROR_UNKNOWN = -1, - /** - * No permission. - * @since 9 - */ - ERROR_NO_PERMISSION = 0, - /** - * Camera device preempted. - * @since 9 - */ - ERROR_DEVICE_PREEMPTED = 1, - /** - * Camera device disconnected. - * @since 9 - */ - ERROR_DEVICE_DISCONNECTED = 2, - /** - * Camera device in use. - * @since 9 - */ - ERROR_DEVICE_IN_USE = 3, - /** - * Driver error. - * @since 9 - */ - ERROR_DRIVER_ERROR = 4, - } - - /** - * Camera input error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface CameraInputError extends Error { - code: CameraInputErrorCode; + on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; } /** @@ -692,7 +605,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - CAMERA_FORMAT_RGBA_8888 = 3, + CAMERA_FORMAT_RGBA_8888 = 3, /** * YUV 420 Format. @@ -867,25 +780,19 @@ declare namespace camera { interface CaptureSession { /** * Begin capture session config. - * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400105 - Session config locked. */ - beginConfig(callback: AsyncCallback): void; - - /** - * Begin capture session config. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - beginConfig(): Promise; + beginConfig(): void; /** * Commit capture session config. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400102 - Operation not allow. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ commitConfig(callback: AsyncCallback): void; @@ -894,86 +801,58 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400102 - Operation not allow. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ commitConfig(): Promise; /** * Adds a camera input. * @param cameraInput Target camera input to add. - * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect + * @throws { BusinessError } 7400102 - Operation not allow. */ - addInput(cameraInput: CameraInput, callback: AsyncCallback): void; - - /** - * Adds a camera input. - * @param cameraInput Target camera input to add. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - addInput(cameraInput: CameraInput): Promise; - - /** - * Removes a camera input. - * @param cameraInput Target camera input to remove. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - removeInput(cameraInput: CameraInput, callback: AsyncCallback): void; + addInput(cameraInput: CameraInput): void; /** * Removes a camera input. * @param cameraInput Target camera input to remove. - * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect + * @throws { BusinessError } 7400102 - Operation not allow. */ - removeInput(cameraInput: CameraInput): Promise; + removeInput(cameraInput: CameraInput): void; /** * Adds a camera output. * @param cameraOutput Target camera output to add. - * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect + * @throws { BusinessError } 7400102 - Operation not allow. */ - addOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; - - /** - * Adds a camera output. - * @param cameraOutput Target camera output to add. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - addOutput(cameraOutput: CameraOutput): Promise; + addOutput(cameraOutput: CameraOutput): void; /** * Removes a camera output. * @param previewOutput Target camera output to remove. - * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect + * @throws { BusinessError } 7400102 - Operation not allow. */ - removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; - - /** - * Removes a camera output. - * @param previewOutput Target camera output to remove. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - removeOutput(cameraOutput: CameraOutput): Promise; + removeOutput(cameraOutput: CameraOutput): void; /** * Starts capture session. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ start(callback: AsyncCallback): void; @@ -982,6 +861,8 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ start(): Promise; @@ -990,6 +871,7 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ stop(callback: AsyncCallback): void; @@ -998,6 +880,7 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ stop(): Promise; @@ -1006,6 +889,7 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ release(callback: AsyncCallback): void; @@ -1014,416 +898,229 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ release(): Promise; /** * Check if device has flash light. - * @param callback Callback used to return the flash light support status. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - hasFlash(callback: AsyncCallback): void; - - /** - * Check if device has flash light. - * @returns Promise used to return the flash light support status. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - hasFlash(): Promise; - - /** - * Checks whether a specified flash mode is supported. - * @param flashMode Flash mode. - * @param callback Callback used to return the flash light support status. + * @returns The flash light support status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; + hasFlash(): boolean; /** * Checks whether a specified flash mode is supported. * @param flashMode Flash mode - * @returns Promise used to return flash mode support status. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - isFlashModeSupported(flashMode: FlashMode): Promise; - - /** - * Gets current flash mode. - * @param callback Callback used to return the current flash mode. + * @returns Is the flash mode supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getFlashMode(callback: AsyncCallback): void; + isFlashModeSupported(flashMode: FlashMode): boolean; /** * Gets current flash mode. - * @returns Promise used to return the flash mode. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getFlashMode(): Promise; - - /** - * Sets flash mode. - * @param flashMode Target flash mode. - * @param callback Callback used to return the result. + * @returns The current flash mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; + getFlashMode(): FlashMode; /** * Sets flash mode. * @param flashMode Target flash mode. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setFlashMode(flashMode: FlashMode): Promise; - - /** - * Checks whether a specified exposure mode is supported. - * @param aeMode Exposure mode. - * @param callback Callback used to return the exposure mode support status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void; + setFlashMode(flashMode: FlashMode): void; /** * Checks whether a specified exposure mode is supported. * @param aeMode Exposure mode - * @returns Promise used to return exposure mode support status. + * @returns Is the exposure mode supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - isExposureModeSupported(aeMode: ExposureMode): Promise; + isExposureModeSupported(aeMode: ExposureMode): boolean; /** * Gets current exposure mode. - * @param callback Callback used to return the current exposure mode. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getExposureMode(callback: AsyncCallback): void; - - /** - * Gets current exposure mode. - * @returns Promise used to return the current exposure mode. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getExposureMode(): Promise; - - /** - * Sets exposure mode. - * @param aeMode Exposure mode - * @param callback Callback used to return the result. + * @returns The current exposure mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void; + getExposureMode(): ExposureMode; /** * Sets Exposure mode. * @param aeMode Exposure mode - * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - setExposureMode(aeMode: ExposureMode): Promise; + setExposureMode(aeMode: ExposureMode): void; /** * Gets current metering point. - * @param callback Callback used to return the current metering point. + * @returns The current metering point. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getMeteringPoint(callback: AsyncCallback): void; - - /** - * Gets current metering point. - * @returns Promise used to return the current metering point. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getMeteringPoint(): Promise; + getMeteringPoint(): Point; /** * Set the center point of the metering area. - * @param point Metering point - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setMeteringPoint(point: Point, callback: AsyncCallback): void; - - /** - * Set the center point of the metering area. - * @param point metering point - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setMeteringPoint(point: Point): Promise; - - /** - * Query the exposure compensation range. - * @param callback Callback used to return the array of compensation range. + * @param point metering point * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getExposureBiasRange(callback: AsyncCallback>): void; + setMeteringPoint(point: Point): void; /** * Query the exposure compensation range. - * @returns Promise used to return the array of compensation range. + * @returns The array of compenstation range. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getExposureBiasRange(): Promise>; + getExposureBiasRange(): Array; /** * Set exposure compensation. * @param exposureBias Exposure compensation - * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - setExposureBias(exposureBias: number, callback: AsyncCallback): void; - - /** - * Set exposure compensation. - * @param exposureBias Exposure compensation - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setExposureBias(exposureBias: number): Promise; + setExposureBias(exposureBias: number): void; /** * Query the exposure value. - * @param callback Callback used to return the exposure value. + * @returns The exposure value. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getExposureValue(callback: AsyncCallback): void; + getExposureValue(): number; /** - * Query the exposure value. - * @returns Promise used to return the exposure value. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getExposureValue(): Promise; - - /** * Checks whether a specified focus mode is supported. * @param afMode Focus mode. - * @param callback Callback used to return the device focus support status. + * @returns Is the focus mode supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; - - /** - * Checks whether a specified focus mode is supported. - * @param afMode Focus mode. - * @returns Promise used to return the focus mode support status. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - isFocusModeSupported(afMode: FocusMode): Promise; + isFocusModeSupported(afMode: FocusMode): boolean; /** * Gets current focus mode. - * @param callback Callback used to return the current focus mode. + * @returns The current focus mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getFocusMode(callback: AsyncCallback): void; - - /** - * Gets current focus mode. - * @returns Promise used to return the focus mode. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getFocusMode(): Promise; + getFocusMode(): FocusMode; /** * Sets focus mode. * @param afMode Target focus mode. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; - - /** - * Sets focus mode. - * @param afMode Target focus mode. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setFocusMode(afMode: FocusMode): Promise; - - /** - * Sets focus point. - * @param point Target focus point. - * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - setFocusPoint(point: Point, callback: AsyncCallback): void; + setFocusMode(afMode: FocusMode): void; /** * Sets focus point. * @param afMode Target focus point. - * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - setFocusPoint(point: Point): Promise; + setFocusPoint(point: Point): void; /** * Gets current focus point. - * @param callback Callback used to return the current focus point. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getFocusPoint(callback: AsyncCallback): void; - - /** - * Gets current focus point. - * @returns Promise used to return the current focus point. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getFocusPoint(): Promise; - - /** - * Gets current focal length. - * @param callback Callback used to return the current focal point. + * @returns The current focus point. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getFocalLength(callback: AsyncCallback): void; + getFocusPoint(): Point; /** * Gets current focal length. - * @returns Promise used to return the current focal point. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getFocalLength(): Promise; - - /** - * Gets all supported zoom ratio range. - * @param callback Callback used to return the zoom ratio range. + * @returns The current focal point. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getZoomRatioRange(callback: AsyncCallback>): void; + getFocalLength(): number; /** * Gets all supported zoom ratio range. - * @returns Promise used to return the zoom ratio range. + * @returns The zoom ratio range. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getZoomRatioRange(): Promise>; + getZoomRatioRange(): Array; /** * Gets zoom ratio. - * @param callback Callback used to return the current zoom ratio value. + * @returns The zoom ratio value. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getZoomRatio(callback: AsyncCallback): void; - - /** - * Gets zoom ratio. - * @returns Promise used to return the zoom ratio value. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getZoomRatio(): Promise; + getZoomRatio(): number; /** * Sets zoom ratio. * @param zoomRatio Target zoom ratio. - * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; - - /** - * Sets zoom ratio. - * @param zoomRatio Target zoom ratio. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setZoomRatio(zoomRatio: number): Promise; + setZoomRatio(zoomRatio: number): void; /** * Check whether the specified video stabilization mode is supported. * @param vsMode Video Stabilization mode. - * @param callback Callback used to return if video stablization mode is supported. + * @returns Is flash mode supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback): void; - - /** - * Check whether the specified video stabilization mode is supported. - * @param callback Callback used to return if video stablization mode is supported. - * @returns Promise used to return flash mode support status. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise; + isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): boolean; /** * Query the video stabilization mode currently in use. - * @param callback Callback used to return the current video stabilization mode. + * @returns The current video stabilization mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - getActiveVideoStabilizationMode(callback: AsyncCallback): void; + getActiveVideoStabilizationMode(): VideoStabilizationMode; - /** - * Query the video stabilization mode currently in use. - * @returns Promise used to return the current video stabilization mode. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getActiveVideoStabilizationMode(): Promise; - /** * Set video stabilization mode. * @param mode video stabilization mode to set. - * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ - setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void; - - /** - * Set video stabilization mode. - * @param mode video stabilization mode to set. - * @returns Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setVideoStabilizationMode(mode: VideoStabilizationMode): Promise; + setVideoStabilizationMode(mode: VideoStabilizationMode): void; /** * Subscribes focus status change event callback. @@ -1441,39 +1138,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; - } - - /** - * Enum for CaptureSession error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum CaptureSessionErrorCode { - /** - * Unknown error. - * @since 9 - */ - ERROR_UNKNOWN = -1, - /** - * Insufficient resources. - * @since 9 - */ - ERROR_INSUFFICIENT_RESOURCES = 0, - /** - * Timeout error. - * @since 9 - */ - ERROR_TIMEOUT = 1, - } - - /** - * Capture session error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface CaptureSessionError extends Error { - code: CaptureSessionErrorCode; + on(type: 'error', callback: ErrorCallback): void; } /** @@ -1487,6 +1152,7 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ release(callback: AsyncCallback): void; @@ -1495,6 +1161,7 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400201 - Camera service fatal error. */ release(): Promise; } @@ -1510,6 +1177,7 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ start(callback: AsyncCallback): void; @@ -1518,6 +1186,7 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. */ start(): Promise; @@ -1562,29 +1231,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; - } - - /** - * Enum for preview output error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum PreviewOutputErrorCode { - /** - * Unknown error. - * @since 9 - */ - ERROR_UNKNOWN = -1, - } - - /** - * Preview output error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface PreviewOutputError extends Error { - code: PreviewOutputErrorCode; + on(type: 'error', callback: ErrorCallback): void; } /** @@ -1715,42 +1362,52 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400104 - Session not running. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ capture(callback: AsyncCallback): void; /** * Start capture output. - * @param setting Photo capture settings. - * @param callback Callback used to return the result. + * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400104 - Session not running. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ - capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; + capture(): Promise; /** * Start capture output. * @param setting Photo capture settings. - * @returns Promise used to return the result. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect + * @throws { BusinessError } 7400104 - Session not running. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ - capture(setting?: PhotoCaptureSetting): Promise; + capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; /** - * Check whether to support mirror photo. - * @param callback Callback used to return the mirror support status. + * Start capture output. + * @param setting Photo capture settings. + * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400101 - Parameter missing or parameter type incorrect + * @throws { BusinessError } 7400104 - Session not running. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ - isMirrorSupported(callback: AsyncCallback): void; + capture(setting?: PhotoCaptureSetting): Promise; /** * Check whether to support mirror photo. - * @returns Promise used to return the mirror support status. + * @returns Is the mirror supported. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - isMirrorSupported(): Promise; + isMirrorSupported(): boolean; /** * Subscribes capture start event callback. @@ -1786,7 +1443,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; + on(type: 'error', callback: ErrorCallback): void; } /** @@ -1829,43 +1486,6 @@ declare namespace camera { frameCount: number; } - /** - * Enum for photo output error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum PhotoOutputErrorCode { - /** - * Unknown error. - * @since 9 - */ - ERROR_UNKNOWN = -1, - /** - * Driver error. - * @since 9 - */ - ERROR_DRIVER_ERROR = 0, - /** - * Insufficient resources. - * @since 9 - */ - ERROR_INSUFFICIENT_RESOURCES = 1, - /** - * Timeout error. - * @since 9 - */ - ERROR_TIMEOUT = 2 - } - - /** - * Photo output error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface PhotoOutputError extends Error { - code: PhotoOutputErrorCode; - } - /** * Video output object. * @since 9 @@ -1877,6 +1497,8 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ start(callback: AsyncCallback): void; @@ -1885,6 +1507,8 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ start(): Promise; @@ -1929,34 +1553,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; - } - - /** - * Enum for video output error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum VideoOutputErrorCode { - /** - * Unknown error. - * @since 9 - */ - ERROR_UNKNOWN = -1, - /** - * Driver error. - * @since 9 - */ - ERROR_DRIVER_ERROR = 0 - } - - /** - * Video output error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface VideoOutputError extends Error { - code: VideoOutputErrorCode; + on(type: 'error', callback: ErrorCallback): void; } /** @@ -2009,60 +1606,23 @@ declare namespace camera { */ interface MetadataObject { /** - * Get current metadata object type. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getType(callback: AsyncCallback): void; - - /** - * Get current metadata object type. - * @param Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getType(): Promise; - - /** - * Get current metadata object timestamp in milliseconds. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getTimestamp(callback: AsyncCallback): void; - - /** - * Get current metadata object timestamp in milliseconds. - * @param Promise used to return the result. + * Metadata object type. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getTimestamp(): Promise; - + readonly type: MetadataObjectType; /** - * Get the axis-aligned bounding box of detected metadata object. - * @param callback Callback used to return the result. + * Metadata object timestamp in milliseconds. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getBoundingBox(callback: AsyncCallback): void; - + readonly timestamp: number; /** - * Get the axis-aligned bounding box of detected metadata object. - * @param Promise used to return the result. + * The axis-aligned bounding box of detected metadata object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getBoundingBox(): Promise; - } - - /** - * Metadata face object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface MetadataFaceObject extends MetadataObject { + readonly boundingBox: Rect; } /** @@ -2076,6 +1636,8 @@ declare namespace camera { * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ start(callback: AsyncCallback): void; @@ -2084,6 +1646,8 @@ declare namespace camera { * @returns Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core + * @throws { BusinessError } 7400103 - Session not config. + * @throws { BusinessError } 7400201 - Camera service fatal error. */ start(): Promise; @@ -2119,34 +1683,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; - } - - /** - * Enum for metadata output error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum MetadataOutputErrorCode { - /** - * Unknown errors. - * @since 9 - */ - ERROR_UNKNOWN = -1, - /** - * Insufficient resources. - * @since 9 - */ - ERROR_INSUFFICIENT_RESOURCES = 0 - } - - /** - * Metadata output error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface MetadataOutputError extends Error { - code: MetadataOutputErrorCode; + on(type: 'error', callback: ErrorCallback): void; } } -- Gitee