diff --git a/api/@ohos.multimedia.camera.d.ts b/api/@ohos.multimedia.camera.d.ts index 18c9ad1114e260e8815a209e9f199aff24ac1b89..eab5e5cd3432521c776c4b9ff8af1c06072d91a1 100644 --- a/api/@ohos.multimedia.camera.d.ts +++ b/api/@ohos.multimedia.camera.d.ts @@ -74,6 +74,92 @@ declare namespace camera { CAMERA_STATUS_UNAVAILABLE } + /** + * Profile for camera streams. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface Profile { + /** + * Camera format. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly format: CameraFormat; + /** + * Picture size. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly size: Size; + } + + /** + * Frame rate range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface FrameRateRange { + /** + * Min frame rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly min: number; + /** + * Max frame rate. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly max: number; + } + + /** + * Video profile. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface VideoProfile extends Profile { + /** + * Frame rate in unit fps (frames per second). + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly frameRateRanges: Array; + } + + /** + * Camera output capability. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraOutputCapability { + /** + * Preview profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly previewProfiles: Array; + /** + * Photo profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly photoProfiles: Array; + /** + * Video profiles. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly videoProfiles: Array; + /** + * All the supported metadata Object Types. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + readonly supportedMetadataObjectTypes: Array; + } + /** * Camera manager object. * @since 9 @@ -81,40 +167,112 @@ declare namespace camera { */ interface CameraManager { /** - * Gets all camera descriptions. + * Gets supported camera descriptions. * @param callback Callback used to return the array of supported cameras. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameras(callback: AsyncCallback>): void; + getSupportedCameras(callback: AsyncCallback>): void; /** - * Gets all camera descriptions. + * Gets supported camera descriptions. * @return Promise used to return an array of supported cameras. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameras(): Promise>; + getSupportedCameras(): Promise>; + + /** + * Gets supported output capability for specific camera. + * @param camera Camera device. + * @param callback Callback used to return the camera output capability. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void; + + /** + * Gets supported output capability for specific camera. + * @param camera Camera device. + * @return Promise used to return the camera output capability. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getSupportedOutputCapability(camera: CameraDevice): Promise; + + /** + * Determine wether camera is muted. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isCameraMuted(callback: AsyncCallback): void; + + /** + * Determine wether camera is muted. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isCameraMuted(): Promise; + + /** + * Determine wether camera mute is supported. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + isCameraMuteSupported(callback: AsyncCallback): void; + + /** + * Determine wether camera mute is supported. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + isCameraMuteSupported(): Promise; + + /** + * Mute camera. + * @param mute Mute camera if TRUE, otherwise unmute camera. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + muteCamera(mute: boolean, callback: AsyncCallback): void; + + /** + * Mute camera. + * @param mute Mute camera if TRUE, otherwise unmute camera. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + muteCamera(mute: boolean): Promise; /** - * Creates a CameraInput instance by camera id. - * @param cameraId Camera ID used to create the instance. + * 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(cameraId: string, callback: AsyncCallback): void; + createCameraInput(camera: CameraDevice, callback: AsyncCallback): void; /** - * Creates a CameraInput instance by camera id. - * @param cameraId Camera ID used to create the instance. + * Creates a CameraInput instance by camera. + * @param camera Camera device used to create the instance. * @return Promise used to return the CameraInput instance. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core * @permission ohos.permission.CAMERA */ - createCameraInput(cameraId: string): Promise; + createCameraInput(camera: CameraDevice): Promise; /** * Creates a CameraInput instance by camera position and type. @@ -138,6 +296,118 @@ declare namespace 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; + + /** + * Creates a PreviewOutput instance. + * @param profile Preview output profile. + * @param surfaceId Surface object id used in camera photo output. + * @return Promise used to return the PreviewOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createPreviewOutput(profile: Profile, surfaceId: string): Promise; + + /** + * Creates a deferred PreviewOutput instance. + * @param profile Preview output profile. + * @param callback Callback used to return the PreviewOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createDeferredPreviewOutput(profile: Profile, callback: AsyncCallback): void; + + /** + * Creates a deferred PreviewOutput instance. + * @param profile Preview output profile. + * @return Promise used to return the PreviewOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createDeferredPreviewOutput(profile: Profile): Promise; + + /** + * 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + 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. + * @return Promise used to return the PhotoOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createPhotoOutput(profile: Profile, surfaceId: string): Promise; + + /** + * 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + 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. + * @return Promise used to return the VideoOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createVideoOutput(profile: VideoProfile, surfaceId: string): Promise; + + /** + * Creates a MetadataOutput instance. + * @param metadataObjectTypes Array of MetadataObjectType. + * @param callback Callback used to return the MetadataOutput instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void; + + /** + * Creates a MetadataOutput instance. + * @param metadataObjectTypes Array of MetadataObjectType. + * @return 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; + + /** + * Gets a CaptureSession instance. + * @return Promise used to return the CaptureSession instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + createCaptureSession(): Promise; + /** * Subscribes camera status change event callback. * @param type Event type. @@ -146,6 +416,16 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ on(type: 'cameraStatus', callback: AsyncCallback): void; + + /** + * Subscribes camera mute change event callback. + * @param type Event type. + * @param callback Callback used to get the camera mute change. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + * @systemapi + */ + on(type: 'cameraMute', callback: AsyncCallback): void; } /** @@ -159,7 +439,7 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - camera: Camera; + camera: CameraDevice; /** * Current camera status. * @since 9 @@ -265,11 +545,11 @@ declare namespace camera { } /** - * Camera object. + * Camera device object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface Camera { + interface CameraDevice { /** * Camera id attribute. * @since 9 @@ -317,252 +597,156 @@ declare namespace camera { } /** - * Camera input object. + * Point parameter. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface CameraInput { + interface Point { /** - * Gets camera id. - * @param callback Callback used to return the camera ID. + * x co-ordinate * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameraId(callback: AsyncCallback): void; - + x: number; /** - * Gets camera id. - * @return Promise used to return the camera ID. + * y co-ordinate * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getCameraId(): Promise; + y: number; + } + /** + * Camera input object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraInput { /** - * Check if device has flash light. - * @param callback Callback used to return the flash light support status. + * Open camera. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - hasFlash(callback: AsyncCallback): void; + open(callback: AsyncCallback): void; /** - * Check if device has flash light. - * @return Promise used to return the flash light support status. + * Open camera. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - hasFlash(): Promise; + open(): Promise; /** - * Checks whether a specified flash mode is supported. - * @param flashMode Flash mode. - * @param callback Callback used to return the flash light support status. + * Close camera. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; + close(callback: AsyncCallback): void; /** - * Checks whether a specified flash mode is supported. - * @param flashMode Flash mode - * @return Promise used to return flash mode support status. + * Close camera. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - isFlashModeSupported(flashMode: FlashMode): Promise; + close(): Promise; /** - * Gets current flash mode. - * @param callback Callback used to return the current flash mode. + * Releases instance. + * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getFlashMode(callback: AsyncCallback): void; + release(callback: AsyncCallback): void; /** - * Gets current flash mode. - * @return Promise used to return the flash mode. + * Releases instance. + * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - getFlashMode(): Promise; + release(): Promise; /** - * Sets flash mode. - * @param flashMode Target flash mode. - * @param callback Callback used to return the result. + * Subscribes error event callback. + * @param type Event type. + * @param camera Camera device. + * @param callback Callback used to get the camera input errors. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; + on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; + } + /** + * Enum for CameraInput error code. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum CameraInputErrorCode { /** - * Sets flash mode. - * @param flashMode Target flash mode. - * @return Promise used to return the result. + * Unknown error. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - setFlashMode(flashMode: FlashMode): Promise; - + ERROR_UNKNOWN = -1, /** - * Checks whether a specified focus mode is supported. - * @param afMode Focus mode. - * @param callback Callback used to return the device focus support status. + * No permission. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; - + ERROR_NO_PERMISSION, /** - * Checks whether a specified focus mode is supported. - * @param afMode Focus mode. - * @return Promise used to return the focus mode support status. + * Camera device preempted. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - isFocusModeSupported(afMode: FocusMode): Promise; - + ERROR_DEVICE_PREEMPTED, /** - * Gets current focus mode. - * @param callback Callback used to return the current focus mode. + * Camera device disconnected. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - getFocusMode(callback: AsyncCallback): void; - + ERROR_DEVICE_DISCONNECTED, /** - * Gets current focus mode. - * @return Promise used to return the focus mode. + * Camera device in use. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - getFocusMode(): Promise; - + ERROR_DEVICE_IN_USE, /** - * 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. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setFocusMode(afMode: FocusMode): Promise; - - /** - * Gets all supported zoom ratio range. - * @param callback Callback used to return the zoom ratio range. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getZoomRatioRange(callback: AsyncCallback>): void; - - /** - * Gets all supported zoom ratio range. - * @return Promise used to return the zoom ratio range. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getZoomRatioRange(): Promise>; - - /** - * Gets zoom ratio. - * @param callback Callback used to return the current zoom ratio value. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getZoomRatio(callback: AsyncCallback): void; - - /** - * Gets zoom ratio. - * @return Promise used to return the zoom ratio value. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - getZoomRatio(): Promise; - - /** - * Sets zoom ratio. - * @param zoomRatio Target zoom ratio. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; - - /** - * Sets zoom ratio. - * @param zoomRatio Target zoom ratio. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - setZoomRatio(zoomRatio: number): Promise; - - /** - * Releases instance. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - release(callback: AsyncCallback): void; - - /** - * Releases instance. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - release(): Promise; - - /** - * Subscribes focus status change event callback. - * @param type Event type. - * @param callback Callback used to get the focus state change. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - on(type: 'focusStateChange', callback: AsyncCallback): void; - - /** - * Subscribes error event callback. - * @param type Event type. - * @param callback Callback used to get the camera input errors. + * Driver error. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; + ERROR_DRIVER_ERROR, } /** - * Enum for CameraInput error code. + * Camera input error object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - enum CameraInputErrorCode { - /** - * Unknown error. - * @since 9 - */ - ERROR_UNKNOWN = -1 + interface CameraInputError extends Error { + code: CameraInputErrorCode; } /** - * Camera input error object. + * Enum for camera format type. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface CameraInputError extends Error { - code: CameraInputErrorCode; + enum CameraFormat { + /** + * YUV 420 Format. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_FORMAT_YUV_420_SP = 1003, + + /** + * JPEG Format. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + CAMERA_FORMAT_JPEG = 2000 } /** @@ -597,6 +781,28 @@ declare namespace camera { FLASH_MODE_ALWAYS_OPEN } + /** + * Enum for exposure mode. + * @since 9 + */ + enum ExposureMode { + /** + * Lock exposure mode. + * @since 9 + */ + EXPOSURE_MODE_LOCKED = 0, + /** + * Auto exposure mode. + * @since 9 + */ + EXPOSURE_MODE_AUTO, + /** + * Continuous automatic exposure. + * @since 9 + */ + EXPOSURE_MODE_CONTINUOUS_AUTO + } + /** * Enum for focus mode. * @since 9 @@ -656,22 +862,59 @@ declare namespace camera { } /** - * Gets a CaptureSession instance. - * @param context Current application context. - * @param callback Callback used to return the CaptureSession instance. + * Enum for exposure state. * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core */ - function createCaptureSession(context: Context, callback: AsyncCallback): void; + enum ExposureState { + /** + * Scan state. + * @since 8 + */ + EXPOSURE_STATE_SCAN = 0, + /** + * Converged state. + * @since 8 + */ + EXPOSURE_STATE_CONVERGED + } /** - * Gets a CaptureSession instance. - * @param context Current application context. - * @return Promise used to return the CaptureSession instance. + * Enum for video stabilization mode. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - function createCaptureSession(context: Context): Promise; + enum VideoStabilizationMode { + /** + * Turn off video stablization. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + OFF = 0, + /** + * LOW mode provides basic stabilization effect. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + LOW, + /** + * MIDDLE mode means algorithms can achieve better effects than LOW mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + MIDDLE, + /** + * HIGH mode means algorithms can achieve better effects than MIDDLE mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + HIGH, + /** + * Camera HDF can select mode automatically. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + AUTO + } /** * Capture session object. @@ -712,180 +955,176 @@ declare namespace camera { commitConfig(): Promise; /** - * Adds a camera input. + * Check whether the camera input can be added. * @param cameraInput Target camera input to add. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addInput(cameraInput: CameraInput, callback: AsyncCallback): void; + canAddInput(cameraInput: CameraInput, callback: AsyncCallback): void; /** - * Adds a camera input. + * Check whether the camera input can be added. * @param cameraInput Target camera input to add. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addInput(cameraInput: CameraInput): Promise; + canAddInput(cameraInput: CameraInput): Promise; /** - * Adds a camera preview output. - * @param previewOutput Target camera preview output to add. + * 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 */ - addOutput(previewOutput: PreviewOutput, callback: AsyncCallback): void; + addInput(cameraInput: CameraInput, callback: AsyncCallback): void; /** - * Adds a camera preview output. - * @param previewOutput Target camera preview output to add. + * Adds a camera input. + * @param cameraInput Target camera input to add. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addOutput(previewOutput: PreviewOutput): Promise; + addInput(cameraInput: CameraInput): Promise; /** - * Adds a camera photo output. - * @param photoOutput Target camera photo output to add. + * 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 */ - addOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + removeInput(cameraInput: CameraInput, callback: AsyncCallback): void; /** - * Adds a camera photo output. - * @param photoOutput Target camera photo output to add. + * Removes a camera input. + * @param cameraInput Target camera input to remove. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addOutput(photoOutput: PhotoOutput): Promise; + removeInput(cameraInput: CameraInput): Promise; /** - * Adds a camera video output. - * @param videoOutput Target camera video output to add. + * Check whether the camera output can be added. + * @param cameraOutput Target camera output to add. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + canAddOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; /** - * Adds a camera video output. - * @param videoOutput Target camera video output to add. + * Check whether the camera output can be added. + * @param cameraInput Target camera output to add. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - addOutput(videoOutput: VideoOutput): Promise; + canAddOutput(cameraOutput: CameraOutput): Promise; /** - * Removes a camera input. - * @param cameraInput Target camera input to remove. + * 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 */ - removeInput(cameraInput: CameraInput, callback: AsyncCallback): void; + addOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; /** - * Removes a camera input. - * @param cameraInput Target camera input to remove. + * Adds a camera output. + * @param cameraOutput Target camera output to add. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeInput(cameraInput: CameraInput): Promise; + addOutput(cameraOutput: CameraOutput): Promise; /** - * Removes a camera preview output. - * @param previewOutput Target camera preview output to remove. + * 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 */ - removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback): void; + removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void; /** - * Removes a camera preview output. - * @param previewOutput Target camera preview output to remove. + * Removes a camera output. + * @param previewOutput Target camera output to remove. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(previewOutput: PreviewOutput): Promise; + removeOutput(cameraOutput: CameraOutput): Promise; /** - * Removes a camera photo output. - * @param photoOutput Target camera photo output to remove. + * Starts capture session. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; + start(callback: AsyncCallback): void; /** - * Removes a camera photo output. - * @param photoOutput Target camera photo output to remove. + * Starts capture session. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(photoOutput: PhotoOutput): Promise; + start(): Promise; /** - * Removes a camera video output. - * @param videoOutput Target camera video output to remove. + * Stops capture session. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; + stop(callback: AsyncCallback): void; /** - * Removes a camera video output. - * @param videoOutput Target camera video output to remove. + * Stops capture session. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - removeOutput(videoOutput: VideoOutput): Promise; + stop(): Promise; /** - * Starts capture session. + * Lock the session for exclusive control. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - start(callback: AsyncCallback): void; + lockForControl(callback: AsyncCallback): void; /** - * Starts capture session. + * Lock the session for exclusive control. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - start(): Promise; + lockForControl(): Promise; /** - * Stops capture session. + * Unlock the session after exclusive control. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - stop(callback: AsyncCallback): void; + unlockForControl(callback: AsyncCallback): void; /** - * Stops capture session. + * Unlock the session after exclusive control. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - stop(): Promise; + unlockForControl(): Promise; /** * Release capture session instance. @@ -904,72 +1143,551 @@ declare namespace camera { release(): Promise; /** - * Subscribes error event callback. - * @param type Event type. - * @param callback Callback used to get the capture session errors. + * Check if device has flash light. + * @param callback Callback used to return the flash light support status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - on(type: 'error', callback: ErrorCallback): void; - } + hasFlash(callback: AsyncCallback): void; - /** - * Enum for CaptureSession error code. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - enum CaptureSessionErrorCode { - ERROR_UNKNOWN = -1 - } + /** + * Check if device has flash light. + * @return Promise used to return the flash light support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + hasFlash(): Promise; - /** - * Capture session error object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface CaptureSessionError extends Error { - code: CaptureSessionErrorCode; - } + /** + * Checks whether a specified flash mode is supported. + * @param flashMode Flash mode. + * @param callback Callback used to return the flash light support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; - /** - * Creates a PreviewOutput instance. - * @param surfaceId Surface object id used in camera preview output. - * @param callback Callback used to return the PreviewOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; + /** + * Checks whether a specified flash mode is supported. + * @param flashMode Flash mode + * @return Promise used to return flash mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isFlashModeSupported(flashMode: FlashMode): Promise; - /** - * Creates a PreviewOutput instance. - * @param surfaceId Surface object id used in camera preview output. - * @return Promise used to return the PreviewOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createPreviewOutput(surfaceId: string): Promise; + /** + * Gets current flash mode. + * @param callback Callback used to return the current flash mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFlashMode(callback: AsyncCallback): void; + + /** + * Gets current flash mode. + * @return 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; + + /** + * Sets flash mode. + * @param flashMode Target flash mode. + * @return 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 + */ + isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void; + + /** + * Checks whether a specified exposure mode is supported. + * @param aeMode Exposure mode + * @return Promise used to return exposure mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isExposureModeSupported(aeMode: ExposureMode): Promise; + + /** + * 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. + * @return 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void; + + /** + * Sets Exposure mode. + * @param aeMode Exposure mode + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setExposureMode(aeMode: ExposureMode): Promise; + + /** + * Gets current metering point. + * @param callback Callback used to return the current metering point. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getMeteringPoint(callback: AsyncCallback): void; + + /** + * Gets current metering point. + * @return Promise used to return the current metering point. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getMeteringPoint(): Promise; + + /** + * 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 + * @return 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 compenstation range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureBiasRange(callback: AsyncCallback>): void; + + /** + * Query the exposure compensation range. + * @return Promise used to return the array of compenstation range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureBiasRange(): Promise>; + + /** + * Set exposure compensation. + * @param exposureBias Exposure compensation + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setExposureBias(exposureBias: number, callback: AsyncCallback): void; + + /** + * Set exposure compensation. + * @param exposureBias Exposure compensation + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setExposureBias(exposureBias: number): Promise; + + /** + * Query the exposure value. + * @param callback Callback used to return the exposure value. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getExposureValue(callback: AsyncCallback): void; + + /** + * Query the exposure value. + * @return 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; + + /** + * Checks whether a specified focus mode is supported. + * @param afMode Focus mode. + * @return Promise used to return the focus mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isFocusModeSupported(afMode: FocusMode): Promise; + + /** + * Gets current focus mode. + * @param callback Callback used to return the current focus mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocusMode(callback: AsyncCallback): void; + + /** + * Gets current focus mode. + * @return Promise used to return the focus mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocusMode(): Promise; + + /** + * 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. + * @return 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 + */ + setFocusPoint(point: Point, callback: AsyncCallback): void; + + /** + * Sets focus point. + * @param afMode Target focus point. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setFocusPoint(point: Point): Promise; + + /** + * 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. + * @return 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getFocalLength(callback: AsyncCallback): void; + + /** + * Gets current focal length. + * @return 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getZoomRatioRange(callback: AsyncCallback>): void; + + /** + * Gets all supported zoom ratio range. + * @return Promise used to return the zoom ratio range. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getZoomRatioRange(): Promise>; + + /** + * Gets zoom ratio. + * @param callback Callback used to return the current zoom ratio value. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getZoomRatio(callback: AsyncCallback): void; + + /** + * Gets zoom ratio. + * @return Promise used to return the zoom ratio value. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getZoomRatio(): Promise; + + /** + * Sets zoom ratio. + * @param zoomRatio Target zoom ratio. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; + + /** + * Sets zoom ratio. + * @param zoomRatio Target zoom ratio. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setZoomRatio(zoomRatio: number): Promise; + + /** + * 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isVideoStablizationModeSupported(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. + * @return Promise used to return flash mode support status. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + isVideoStablizationModeSupported(vsMode: VideoStabilizationMode): Promise; + + /** + * Query the video stabilization mode currently in use. + * @param callback Callback used to return the current video stabilization mode. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getActiveVideoStabilizationMode(callback: AsyncCallback): void; + + /** + * Query the video stabilization mode currently in use. + * @return 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 + */ + setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void; + + /** + * Set video stabilization mode. + * @param mode video stabilization mode to set. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + setVideoStabilizationMode(mode: VideoStabilizationMode): Promise; + + /** + * Subscribes focus status change event callback. + * @param type Event type. + * @param callback Callback used to get the focus state change. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'focusStateChange', callback: AsyncCallback): void; + + /** + * Subscribes exposure status change event callback. + * @param type Event type. + * @param callback Callback used to get the exposure state change. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'exposureStateChange', callback: AsyncCallback): void; + + /** + * Subscribes error event callback. + * @param type Event type. + * @param callback Callback used to get the capture session errors. + * @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, + /** + * Timeout error. + * @since 9 + */ + ERROR_TIMEOUT, + } + + /** + * Capture session error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CaptureSessionError extends Error { + code: CaptureSessionErrorCode; + } + + /** + * Camera output object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface CameraOutput { + /** + * Release output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(callback: AsyncCallback): void; + + /** + * Release output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + release(): Promise; + } + + /** + * Preview output object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface PreviewOutput extends CameraOutput { + /** + * Add surface id for output instance. + * @param surfaceId Surface object id used in camera preview output. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addDeferredSurface(surfaceId: string, callback: AsyncCallback): void; + + /** + * Add surface id for output instance. + * @param surfaceId Surface object id used in camera preview output. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + addDeferredSurface(surfaceId: string): Promise; + + /** + * Start output instance. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(callback: AsyncCallback): void; + + /** + * Start output instance. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(): Promise; - /** - * Preview output object. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - interface PreviewOutput { /** - * Release output instance. + * Stop output instance. * @param callback Callback used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(callback: AsyncCallback): void; + stop(callback: AsyncCallback): void; /** - * Release output instance. + * Stop output instance. * @return Promise used to return the result. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(): Promise; + stop(): Promise; /** * Subscribes frame start event callback. @@ -1005,7 +1723,11 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ enum PreviewOutputErrorCode { - ERROR_UNKNOWN = -1 + /** + * Unknown error. + * @since 9 + */ + ERROR_UNKNOWN = -1, } /** @@ -1017,24 +1739,6 @@ declare namespace camera { code: PreviewOutputErrorCode; } - /** - * Creates a PhotoOutput instance. - * @param surfaceId Surface object id used in camera photo output. - * @param callback Callback used to return the PhotoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; - - /** - * Creates a PhotoOutput instance. - * @param surfaceId Surface object id used in camera photo output. - * @return Promise used to return the PhotoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createPhotoOutput(surfaceId: string): Promise; - /** * Enumerates the image rotation angles. * @since 9 @@ -1070,6 +1774,26 @@ declare namespace camera { ROTATION_270 = 270 } + interface Location { + /** + * Latitude. + * @since 9 + */ + latitude: number; + + /** + * Longitude. + * @since 9 + */ + longitude: number; + + /** + * Altitude. + * @since 9 + */ + altitude: number; + } + /** * Enumerates the image quality levels. * @since 9 @@ -1109,12 +1833,27 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ quality?: QualityLevel; + /** * Photo rotation. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ rotation?: ImageRotation; + + /** + * Photo location. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + location?: Location; + + /** + * Set the mirror photo function switch, default to false. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + mirror?: boolean; } /** @@ -1122,7 +1861,23 @@ declare namespace camera { * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface PhotoOutput { + interface PhotoOutput extends CameraOutput { + /** + * Get default capture setting. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getDefaultCaptureSetting(callback: AsyncCallback): void; + + /** + * Get default capture setting. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getDefaultCaptureSetting(): Promise; + /** * Start capture output. * @param callback Callback used to return the result. @@ -1150,20 +1905,20 @@ declare namespace camera { capture(setting?: PhotoCaptureSetting): Promise; /** - * Release output instance. - * @param callback Callback used to return the result. + * Check whether to support mirror photo. + * @param callback Callback used to return the mirror support status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(callback: AsyncCallback): void; + isMirrorSupported(callback: AsyncCallback): void; /** - * Release output instance. - * @return Promise used to return the result. + * Check whether to support mirror photo. + * @return Promise used to return the mirror support status. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - release(): Promise; + isMirrorSupported(): Promise; /** * Subscribes capture start event callback. @@ -1248,7 +2003,26 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ enum PhotoOutputErrorCode { - ERROR_UNKNOWN = -1 + /** + * Unknown error. + * @since 9 + */ + ERROR_UNKNOWN = -1, + /** + * Driver error. + * @since 9 + */ + ERROR_DRIVER_ERROR, + /** + * Insufficient resources. + * @since 9 + */ + ERROR_INSUFFICIENT_RESOURCES, + /** + * Timeout error. + * @since 9 + */ + ERROR_TIMEOUT, } /** @@ -1260,30 +2034,12 @@ declare namespace camera { code: PhotoOutputErrorCode; } - /** - * Creates a VideoOutput instance. - * @param surfaceId Surface object id used in camera video output. - * @param callback Callback used to return the VideoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createVideoOutput(surfaceId: string, callback: AsyncCallback): void; - - /** - * Creates a VideoOutput instance. - * @param surfaceId Surface object id used in camera video output. - * @return Promise used to return the VideoOutput instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - function createVideoOutput(surfaceId: string): Promise; - /** * Video output object. * @since 9 * @syscap SystemCapability.Multimedia.Camera.Core */ - interface VideoOutput { + interface VideoOutput extends CameraOutput { /** * Start video output. * @param callback Callback used to return the result. @@ -1292,7 +2048,7 @@ declare namespace camera { */ start(callback: AsyncCallback): void; - /** + /** * Start video output. * @return Promise used to return the result. * @since 9 @@ -1316,22 +2072,6 @@ declare namespace camera { */ stop(): Promise; - /** - * Release output instance. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - release(callback: AsyncCallback): void; - - /** - * Release output instance. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Camera.Core - */ - release(): Promise; - /** * Subscribes frame start event callback. * @param type Event type. @@ -1366,7 +2106,16 @@ declare namespace camera { * @syscap SystemCapability.Multimedia.Camera.Core */ enum VideoOutputErrorCode { - ERROR_UNKNOWN = -1 + /** + * Unknown error. + * @since 9 + */ + ERROR_UNKNOWN = -1, + /** + * Driver error. + * @since 9 + */ + ERROR_DRIVER_ERROR, } /** @@ -1377,6 +2126,196 @@ declare namespace camera { interface VideoOutputError extends Error { code: VideoOutputErrorCode; } + + /** + * Metadata object type. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + enum MetadataObjectType { + FACE_DETECTION = 0 + } + + /** + * Rectangle definition. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface Rect { + /** + * X coordinator of top left point. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + topLeftX: number; + /** + * Y coordinator of top left point. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + topLeftY: number; + /** + * Width of this rectangle. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + width: number; + /** + * Height of this rectangle. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + height: number; + } + + /** + * Metadata object basis. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + 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. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getTimestamp(): Promise; + + /** + * Get the axis-aligned bounding box of detected metadata object. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getBoundingBox(callback: AsyncCallback): void; + + /** + * Get the axis-aligned bounding box of detected metadata object. + * @param Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + getBoundingBox(): Promise; + } + + /** + * Metadata face object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface MetadataFaceObject extends MetadataObject { + } + + /** + * Metadata Output object + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface MetadataOutput extends CameraOutput { + /** + * Start output metadata + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(callback: AsyncCallback): void; + + /** + * Start output metadata + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + start(): Promise; + + /** + * Stop output metadata + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(callback: AsyncCallback): void; + + /** + * Stop output metadata + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + stop(): Promise; + + /** + * Subscribes to metadata objects available event callback. + * @param type Event type. + * @param callback Callback used to get the available metadata objects. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + on(type: 'metadataObjectsAvailable', callback: AsyncCallback>): void; + + /** + * Subscribes error event callback. + * @param type Event type. + * @param callback Callback used to get the video output errors. + * @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, + } + + /** + * Metadata output error object. + * @since 9 + * @syscap SystemCapability.Multimedia.Camera.Core + */ + interface MetadataOutputError extends Error { + code: MetadataOutputErrorCode; + } } export default camera;