diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 8819011c106586b3099116d0c43b7644e09da8a2..fac4104f5cb135b5c5afa45127cdbd488a9a6225 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -71,86 +71,80 @@ Enumerates the camera statuses. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| ------------------------- | ---- | ------------ | -| CAMERA_STATUS_APPEAR | 0 | The camera exists. | -| CAMERA_STATUS_DISAPPEAR | 1 | The camera does not exist.| -| CAMERA_STATUS_AVAILABLE | 2 | The camera is ready. | -| CAMERA_STATUS_UNAVAILABLE | 3 | The camera is not ready.| +| Name | Value | Description | +| ------------------------- | ---- | -------------- | +| CAMERA_STATUS_APPEAR | 0 | A camera appears.| +| CAMERA_STATUS_DISAPPEAR | 1 | The camera disappears. | +| CAMERA_STATUS_AVAILABLE | 2 | The camera is available. | +| CAMERA_STATUS_UNAVAILABLE | 3 | The camera is unavailable. | +## Profile -## CameraPosition - -Enumerates the camera positions. +Defines the camera configuration. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| --------------------------- | ---- | ---------------- | -| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position.| -| CAMERA_POSITION_BACK | 1 | Rear camera. | -| CAMERA_POSITION_FRONT | 2 | Front camera. | +| Name | Type | Read only| Description | +| ------ | ----------------------------- | ---- | ---------- | +| format | [CameraFormat](#cameraformat) | Yes | Output format.| +| size | [Size](#size) | Yes | Resolution. | -## CameraType +## FrameRateRange -Enumerates the camera types. + Defines the frame rate range. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| ----------------------- | ---- | ---------------- | -| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type.| -| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. | -| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. | -| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. | -| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera. | +| Name| Type | Read only| Description | +| ---- | ------ | ---- | ----------------- | +| min | number | Yes | Minimum rate, in fps.| +| max | number | Yes | Maximum rate, in fps.| +## VideoProfile -## ConnectionType - -Enumerates the camera connection types. +Defines the video configuration. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| ---------------------------- | ---- | ------------- | -| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.| -| CAMERA_CONNECTION_REMOTE | 2 | Remote camera. | +| Name | Type | Read only| Description | +| --------------- | --------------------------------- | ---- | ------ | +| frameRateRanges | [FrameRateRange](#frameraterange) | Yes | Frame rate range.| -## Size +## CameraOutputCapability -Defines the image size that can be used in previewing, photographing, and video recording. +Defines the camera output capability. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Type | Readable| Writable| Description | -| ------ | ------ | ---- | ---- | ------------ | -| height | string | Yes | Yes | Image height.| -| width | number | Yes | Yes | Image width.| +| Name | Type | Read only| Description | +| ---------------------------- | ------------------------------------------------- | ---- | -------------------------- | +| previewProfiles | Array<[Profile](#profile)\> | Yes | Supported preview configurations. | +| photoProfiles | Array<[Profile](#profile)\> | Yes | Supported shooting configurations. | +| videoProfiles | Array<[VideoProfile](#videoprofile)\> | Yes | Supported video recording configurations. | +| supportedMetadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Supported metadata object types.| ## CameraManager Implements camera management. Before calling any API in **CameraManager**, you must use **getCameraManager** to obtain a **CameraManager** instance. -### getCameras +### getSupportedCameras -getCameras(callback: AsyncCallback\>): void +getSupportedCameras(callback: AsyncCallback\>): void -Obtains all cameras supported by the device. This API uses an asynchronous callback to return the array of supported cameras. +Obtains supported cameras. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------------------------- | ---- | ------------------------------------ | -| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras.| +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback\> | Yes | Callback used to return the array of supported cameras.| **Example** ```js -cameraManager.getCameras((err, cameras) => { +cameraManager.getSupportedCameras((err, cameras) => { if (err) { console.error('Failed to get the cameras. ${err.message}'); return; @@ -159,1015 +153,986 @@ cameraManager.getCameras((err, cameras) => { }) ``` -### getCameras +### getSupportedCameras -getCameras(): Promise\> +getSupportedCameras(): Promise\> -Obtains all cameras supported by the device. This API uses a promise to return the array of supported cameras. +Obtains supported cameras. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Return value** -| Type | Description | -| ----------------------------------- | ----------------------------- | -| Promise\> | Promise used to return the array of supported cameras.| +| Type | Description | +| ----------------------------------------------- | ----------------------------- | +| Promise\> | Promise used to return the array of supported cameras.| **Example** ```js -cameraManager.getCameras().then((cameraArray) => { +cameraManager.getSupportedCameras().then((cameraArray) => { console.log('Promise returned with an array of supported cameras: ' + cameraArray.length); }) ``` -### createCameraInput - -createCameraInput(cameraId: string, callback: AsyncCallback): void +### getSupportedOutputCapability -Creates a **CameraInput** instance with the specified camera ID. This API uses an asynchronous callback to return the instance. +getSupportedOutputCapability(camera:CameraDevice, callback: AsyncCallback): void -**Required permissions**: ohos.permission.CAMERA +Obtains the output capability supported by a camera. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------- | ---- | ----------------------------------- | -| cameraId | string | Yes | Camera ID used to create the instance. | -| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | ---------------------------------- | +| camera | [CameraDevice](#cameraDevice) | Yes | **CameraDevice** object. | +| callback | AsyncCallback<[CameraOutputCapability](#cameraoutputcapability)\> | Yes | Callback used to return the output capability.| **Example** ```js -cameraManager.createCameraInput(cameraId, (err, cameraInput) => { +cameraManager.getSupportedOutputCapability(cameraDevice, (err, cameras) => { if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); + console.error('Failed to get the cameras. ${err.message}'); return; } - console.log('Callback returned with the CameraInput instance.'); + console.log('Callback returned with an array of supported outputCapability'); }) ``` -### createCameraInput - -createCameraInput(cameraId: string): Promise +### getSupportedOutputCapability -Creates a **CameraInput** instance with the specified camera ID. This API uses a promise to return the instance. +getSupportedOutputCapability(camera:CameraDevice): Promise -**Required permissions**: ohos.permission.CAMERA +Obtains the output capability supported by a camera. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------ | ---- | ------------ | -| cameraId | string | Yes | Camera ID used to create the instance.| +| Name | Type | Mandatory| Description | +| ------ | ----------------------------- | ---- | ------------------ | +| camera | [CameraDevice](#cameraDevice) | Yes | **CameraDevice** object.| **Return value** -| Type | Description | -| ------------------------------------- | ---------------------------------------- | -| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.| +| Type | Description | +| ----------------------------------------------------------- | --------------------------------------------- | +| Promise<[CameraOutputCapability](#cameraoutputcapability)\> | Promise used to return the output capability.| + **Example** ```js -cameraManager.createCameraInput(cameraId).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance'); +cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => { + console.log('Promise returned with an array of supported outputCapability'); }) ``` -### createCameraInput - -createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void +### getSupportedMetadataObjectType -Creates a **CameraInput** instance with the specified camera position and camera type. This API uses an asynchronous callback to return the instance. +getSupportedMetadataObjectType(callback: AsyncCallback\>): void -**Required permissions**: ohos.permission.CAMERA +Obtains the metadata information supported by this camera. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------- | ---- | ----------------------------------- | -| position | [CameraPosition](#cameraposition) | Yes | Camera position. | -| type | [CameraType](#cameratype) | Yes | Camera type. | -| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------- | +| callback | AsyncCallback\> | Yes | Callback used to return the metadata information.| **Example** ```js -cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => { +cameraManager.getSupportedMetadataObjectType((err, metadataobject) => { if (err) { - console.error('Failed to create the CameraInput instance. ${err.message}'); + console.error('Failed to get the supported metadataObjectType. ${err.message}'); return; } - console.log('Callback returned with the CameraInput instance'); + console.log('Callback returned with an array of supported metadataObjectType.' ); }) ``` -### createCameraInput - -createCameraInput(position: CameraPosition, type: CameraType): Promise +### getSupportedMetadataObjectType -Creates a **CameraInput** instance with the specified camera position and camera type. This API uses a promise to return the instance. +getSupportedMetadataObjectType(camera:CameraDevice): Promise -**Required permissions**: ohos.permission.CAMERA +Obtains the metadata information supported by this camera. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | --------------------------------- | ---- | ---------- | -| position | [CameraPosition](#cameraposition) | Yes | Camera position.| -| type | [CameraType](#cameratype) | Yes | Camera type.| - **Return value** -| Type | Description | -| ------------------------------------- | ---------------------------------------- | -| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.| +| Type | Description | +| ------------------------------------------------------- | ----------------------------------------------------- | +| Promise\> | Promise used to return the metadata information.| + **Example** ```js -cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance.'); +cameraManager.getSupportedMetadataObjectType().then((metadataobject) => { + console.log('Promise returned with an array of supported metadataObjectType.' ); }) ``` -### on('cameraStatus') +### isCameraMuted -on(type: 'cameraStatus', callback: AsyncCallback): void +isCameraMuted(callback: AsyncCallback): void -Listens for camera status changes. This API uses an asynchronous callback to return the camera status changes. +Checks whether this camera is muted. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **cameraStatus**, indicating the camera status change event.| -| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. The value **true** means that the camera is muted, and **false** means the opposite.| **Example** ```js -cameraManager.on('cameraStatus', (err, cameraStatusInfo) => { +cameraManager.isCameraMuted((err, status) => { if (err) { - console.error('Failed to get cameraStatus callback. ${err.message}'); + console.error('Failed to get the cameraMuted status. ${err.message}'); return; } - console.log('camera : ' + cameraStatusInfo.camera.cameraId); - console.log('status: ' + cameraStatusInfo.status); + console.log('Callback returned with cameraMuted status'); }) ``` -## Camera +### isCameraMuted -After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, with camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**. +isCameraMuted(): Promise + +Checks whether this camera is muted. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Type | Read only| Description | -| -------------- | --------------------------------- | ---- | -------------- | -| cameraId | string | Yes | Camera ID. | -| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. | -| cameraType | [CameraType](#cameratype) | Yes | Camera type. | -| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type.| +**Return value** + +| Type | Description | +| ----------------- | --------------------------------------------------- | +| Promise | Promise used to return the result. The value **true** means that the camera is muted, and **false** means the opposite.| + **Example** ```js -async function getCameraInfo("cameraId") { - var cameraManager = await camera.getCameraManager(context); - var cameras = await cameraManager.getCameras(); - var cameraObj = cameras[0]; - var cameraId = cameraObj.cameraId; - var cameraPosition = cameraObj.cameraPosition; - var cameraType = cameraObj.cameraType; - var connectionType = cameraObj.connectionType; -} +cameraManager.isCameraMuted().then((status) => { + console.log('Promise returned with the status whether camera is muted.'); +}) ``` -## CameraStatusInfo - -Describes the camera status information. - -**System capability**: SystemCapability.Multimedia.Camera.Core - -| Name | Type | Description | -| ------ | ----------------------------- | ---------- | -| camera | [Camera](#camera) | Camera object.| -| status | [CameraStatus](#camerastatus) | Camera status.| - - -## CameraInput +### isCameraMuteSupported -Implements a **CameraInput** instance. Before calling any API in **CameraInput**, you must create a **CameraInput** instance. +isCameraMuteSupported(callback: AsyncCallback): void -### getCameraId +Checks whether this camera can be muted. This API uses an asynchronous callback to return the result. -getCameraId(callback: AsyncCallback\): void +This is a system API. -Obtains the camera ID based on which this **CameraInput** instance is created. This API uses an asynchronous callback to return the camera ID. +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the camera ID.| +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the result. The value **true** means that the camera can be muted, and **false** means the opposite.| **Example** ```js -cameraInput.getCameraId((err, cameraId) => { +cameraManager.isCameraMuteSupported((err, status) => { if (err) { - console.error('Failed to get the camera ID. ${err.message}'); + console.error('Failed to get the cameraMuteSupported. ${err.message}'); return; } - console.log('Callback returned with the camera ID: ' + cameraId); + console.log('Callback returned with the status whether cameraMuteSupported.'); }) ``` -### getCameraId +### isCameraMuteSupported + +isCameraMuteSupported(): Promise + +Checks whether this camera can be muted. This API uses a promise to return the result. -getCameraId(): Promise +This is a system API. -Obtains the camera ID based on which this **CameraInput** instance is created. This API uses a promise to return the camera ID. +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core **Return value** -| Type | Description | -| ---------------- | ----------------------------- | -| Promise | Promise used to return the camera ID.| +| Type | Description | +| ----------------- | ------------------------------------------------------- | +| Promise | Promise used to return the result. The value **true** means that the camera can be muted, and **false** means the opposite.| + **Example** ```js -cameraInput.getCameraId().then((cameraId) => { - console.log('Promise returned with the camera ID:' + cameraId); +cameraManager.isCameraMuteSupported().then((status) => { + console.log('Promise returned with the status whether cameraMuteSupported.'); }) ``` +### muteCamera -### hasFlash +muteCamera(mute:boolean, callback: AsyncCallback): void -hasFlash(callback: AsyncCallback): void +Mutes this camera. This API uses an asynchronous callback to return the result. -Checks whether the device has flash light. This API uses an asynchronous callback to return the result. +This is a system API. + +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback | Yes | Callback used to return the flash light support status. The value **true** means that the device has flash light.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------ | +| mute | boolean | Yes | Whether to mute the camera. The value **true** means to mute the camera, and **false** means the opposite. | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -cameraInput.hasFlash((err, status) => { +cameraManager.muteCamera(isMuted, (err) => { if (err) { - console.error('Failed to check whether the device has flash light. ${err.message}'); + console.error('Failed to mute the camera. ${err.message}'); return; } - console.log('Callback returned with flash light support status: ' + status); + console.log('Callback returned with the muteCamera.'); }) ``` -### hasFlash +### muteCamera -hasFlash(): Promise +muteCamera(mute:boolean): Promise -Checks whether the device has flash light. This API uses a promise to return the result. +Mutes this camera. This API uses a promise to return the result. + +This is a system API. + +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ------- | ---- | -------------- | +| mute | boolean | Yes | Whether to mute the camera. The value **true** means to mute the camera, and **false** means the opposite.| + **Return value** -| Type | Description | -| ----------------- | ------------------------------------------------------- | -| Promise | Promise used to return the flash light support status. The value **true** means that the device has flash light.| +| Type | Description | +| -------------- | --------------------------------------------------- | +| Promise| Promise used to return the result.| + **Example** -```js -cameraInput.hasFlash().then((status) => { - console.log('Promise returned with the flash light support status:' + status); +```js +cameraManager.muteCamera(isMuted).then(() => { + console.log('Promise returned muteCamera.'); }) ``` -### isFlashModeSupported +### createCameraInput -isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void +createCameraInput(camera: CameraDevice, callback: AsyncCallback): void -Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result. +Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses an asynchronous callback to return the result. + +This is a system API. + +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ----------------------- | ---- | ---------------------------------------- | -| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. | -| callback | AsyncCallback | Yes | Callback used to return the flash mode support status. The value **true** means that the specified flash mode is supported.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | ----------------------------------- | +| camera | [CameraDevice](#cameraDevice) | Yes | **CameraDevice** object. | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.| **Example** ```js -cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { +cameraManager.createCameraInput(camera, (err, cameraInput) => { if (err) { - console.error('Failed to check whether the flash mode is supported. ${err.message}'); + console.error('Failed to create the CameraInput instance. ${err.message}'); return; } - console.log('Callback returned with the flash mode support status: ' + status); + console.log('Callback returned with the CameraInput instance.'); }) ``` -### isFlashModeSupported +### createCameraInput -isFlashModeSupported(flashMode: FlashMode): Promise +createCameraInput(camera: CameraDevice): Promise -Checks whether a specified flash mode is supported. This API uses a promise to return the result. +Creates a **CameraInput** instance with the specified **CameraDevice** object. This API uses a promise to return the result. + +This is a system API. + +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ----------------------- | ---- | ---------------- | -| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.| +| Name | Type | Mandatory| Description | +| ------ | ----------------------------- | ---- | ------------------ | +| camera | [CameraDevice](#cameraDevice) | Yes | **CameraDevice** object.| **Return value** -| Type | Description | -| ----------------- | ------------------------------------------------------------ | -| Promise | Promise used to return the flash mode support status. The value **true** means that the specified flash mode is supported.| +| Type | Description | +| ------------------------------------- | ---------------------------------------- | +| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.| **Example** ```js -cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => { - console.log('Promise returned with flash mode support status.' + status); +cameraManager.createCameraInput(camera).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance'); }) ``` -### setFlashMode +### createCameraInput -setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void +createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void -Sets the flash mode. This API uses an asynchronous callback to return the result. +Creates a **CameraInput** instance with the specified camera position and type. This API uses an asynchronous callback to return the result. -Before setting the parameters, do the following checks: +This is a system API. -1. Use [hasFlash](#hasflash) to check whether the device has flash light. -2. Use [isFlashModeSupported](#isflashmodesupported) to check whether the device supports a specified flash mode. +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ----------------------- | ---- | ------------------------ | -| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | ----------------------------------- | +| position | [CameraPosition](#cameraposition) | Yes | Camera position. | +| type | [CameraType](#cameratype) | Yes | Camera type. | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.| **Example** ```js -cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { +cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => { if (err) { - console.error('Failed to set the flash mode ${err.message}'); + console.error('Failed to create the CameraInput instance. ${err.message}'); return; } - console.log('Callback returned with the successful execution of setFlashMode.'); + console.log('Callback returned with the CameraInput instance'); }) ``` -### setFlashMode +### createCameraInput -setFlashMode(flashMode: FlashMode): Promise +createCameraInput(position: CameraPosition, type:CameraType ): Promise -Sets the flash mode. This API uses a promise to return the result. +Creates a **CameraInput** instance with the specified camera position and type. This API uses a promise to return the result. -Before setting the parameters, do the following checks: +This is a system API. -1. Use [hasFlash](#hasflash) to check whether the device has flash light. -2. Use [isFlashModeSupported](#isflashmodesupported) to check whether the device supports a specified flash mode. +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ----------------------- | ---- | ---------------- | -| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------- | ---- | ---------- | +| position | [CameraPosition](#cameraposition) | Yes | Camera position.| +| type | [CameraType](#cameratype) | Yes | Camera type.| **Return value** -| Type | Description | -| -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Type | Description | +| ------------------------------------- | ---------------------------------------- | +| Promise<[CameraInput](#camerainput)\> | Promise used to return the **CameraInput** instance.| **Example** ```js -cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => { - console.log('Promise returned with the successful execution of setFlashMode.'); +cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance'); }) ``` -### getFlashMode +### createPreviewOutput -getFlashMode(callback: AsyncCallback): void +createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void -Obtains the current flash mode. This API uses an asynchronous callback to return the result. +Creates a **PreviewOutput** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | ---------------------------------------- | -| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes | Callback used to return the current flash mode.| +| Name | Type | Mandatory| Description | +| --------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ | +| profile | [Profile](#profile) | Yes | Supported preview configurations. | +| surfaceId | string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.| +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance. | **Example** ```js -cameraInput.getFlashMode((err, flashMode) => { +cameraManager.createPreviewOutput(profile, surfaceId, (err, previewoutput) => { if (err) { - console.error('Failed to get the flash mode ${err.message}'); + console.error('Failed to gcreate previewOutput. ${err.message}'); return; } - console.log('Callback returned with current flash mode: ' + flashMode); + console.log('Callback returned with previewOutput created.'); }) ``` -### getFlashMode +### createPreviewOutput -getFlashMode(): Promise +createPreviewOutput(profile: Profile, surfaceId: string): Promise -Obtains the current flash mode. This API uses a promise to return the result. +Creates a **PreviewOutput** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------------------- | ---- | ------------------------------------------------------------ | +| profile | [Profile](#profile) | Yes | Supported preview configurations. | +| surfaceId | string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)** or **[ImageReceiver](js-apis-image.md#imagereceiver9)**.| + **Return value** -| Type | Description | -| --------------------------------- | --------------------------------------- | -| Promise<[FlashMode](#flashmode)\> | Promise used to return the current flash mode.| +| Type | Description | +| ----------------------------------------- | ------------------------------------------ | +| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.| **Example** ```js -cameraInput.getFlashMode().then((flashMode) => { - console.log('Promise returned with current flash mode : ' + flashMode); +cameraManager.createPreviewOutput(profile, survaceId).then((previewoutput) => { + console.log('Promise returned with previewOutput created.'); }) ``` -### isFocusModeSupported +### createDeferredPreviewOutput -isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void +createDeferredPreviewOutput(profile: Profile, callback: AsyncCallback): void -Checks whether a specified focus mode is supported. This API uses an asynchronous callback to return the result. +Creates a **PreviewOutput** instance without a surface ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | -------------------------------------- | -| afMode | [FocusMode](#focusmode) | Yes | Focus mode. | -| callback | AsyncCallback | Yes | Callback used to return the focus mode support status. The value **true** means that the specified focus mode is supported.| +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------- | ---- | ------------------------------------- | +| profile | [Profile](#profile) | Yes | Supported preview configurations. | +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance.| **Example** ```js -cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => { +cameraManager.createDeferredPreviewOutput(profile, (err, previewoutput) => { if (err) { - console.error('Failed to check whether the focus mode is supported. ${err.message}'); + console.error('Failed to create deferredPreviewOutput. ${err.message}'); return; } - console.log('Callback returned with the focus mode support status: ' + status); + console.log('Callback returned with deferredPreviewOutput created.'); }) ``` -### isFocusModeSupported +### createDeferredPreviewOutput -isFocusModeSupported(afMode: FocusMode): Promise +createDeferredPreviewOutput(profile: Profile): Promise -Checks whether a specified focus mode is supported. This API uses a promise to return the result. +Creates a **PreviewOutput** instance without a surface ID. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ------ | ----------------------- | ---- | ---------------- | -| afMode | [FocusMode](#focusmode) | Yes | Focus mode.| +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | -------------------- | +| profile | [Profile](#profile) | Yes | Supported preview configurations.| **Return value** -| Type | Description | -| ----------------- | ----------------------------------------------------------- | -| Promise | Promise used to return the focus mode support status. The value **true** means that the specified focus mode is supported.| +| Type | Description | +| ----------------------------------------- | ------------------------------------------ | +| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.| **Example** ```js -cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => { - console.log('Promise returned with focus mode support status.' + status); +cameraManager.createDeferredPreviewOutput(profile).then((previewoutput) => { + console.log('Promise returned with DefeerredPreviewOutput created.'); }) ``` -### setFocusMode - -setFocusMode(afMode: FocusMode, callback: AsyncCallback): void +### createPhotoOutput -Sets the focus mode. This API uses an asynchronous callback to return the result. +createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void -Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported. +Creates a **PhotoOutput** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ----------------------- | ---- | ------------------------ | -| afMode | [FocusMode](#focusmode) | Yes | Focus mode. | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | +| profile | [Profile](#profile) | Yes | Supported shooting configurations. | +| surfaceId | string | Yes | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.| +| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes | Callback used to return the **PhotoOutput** instance. | **Example** ```js -cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => { +cameraManager.createPhotoOutput(profile, surfaceId, (err, photooutput) => { if (err) { - console.error('Failed to set the focus mode ${err.message}'); + console.error('Failed to create photoOutput. ${err.message}'); return; } - console.log('Callback returned with the successful execution of setFocusMode.'); + console.log('Callback returned with photoOutput created.'); }) ``` -### setFocusMode - -setFocusMode(afMode: FocusMode): Promise +### createPhotoOutput -Sets the focus mode. This API uses a promise to return the result. +createPhotoOutput(profile: Profile, surfaceId: string): Promise -Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported. +Creates a **PhotoOutput** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ------ | ----------------------- | ---- | ---------------- | -| afMode | [FocusMode](#focusmode) | Yes | Focus mode.| +| Name | Type | Mandatory| Description | +| --------- | ------------------- | ---- | ------------------------------------------------------------ | +| profile | [Profile](#profile) | Yes | Supported shooting configurations. | +| surfaceId | string | Yes | Surface ID, which is obtained from **[ImageReceiver](js-apis-image.md#imagereceiver9)**.| **Return value** -| Type | Description | -| -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Type | Description | +| ------------------------------------- | ---------------------------------------- | +| Promise<[PhotoOutput](#photooutput)\> | Promise used to return the **PhotoOutput** instance.| **Example** ```js -cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => { - console.log('Promise returned with the successful execution of setFocusMode.'); +cameraManager.createPhotoOutput(profile, surfaceId).then((photooutput) => { + console.log('Promise returned with photoOutput created.'); }) ``` -### getFocusMode +### createVideoOutput -getFocusMode(callback: AsyncCallback): void +createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void -Obtains the current focus mode. This API uses an asynchronous callback to return the result. +Creates a **VideoOutput** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | --------------------------------------- | ---- | -------------------------------------- | -| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes | Callback used to return the current focus mode.| +| Name | Type | Mandatory| Description | +| --------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | +| profile | [VideoProfile](#videoprofile) | Yes | Supported video recording configurations. | +| surfaceId | string | Yes | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.| +| callback | AsyncCallback<[VideoOutput](#videooutput)\> | Yes | Callback used to return the **VideoOutput** instance. | **Example** ```js -cameraInput.getFocusMode((err, afMode) => { +cameraManager.createVideoOutput(profile, surfaceId, (err, videooutput) => { if (err) { - console.error('Failed to get the focus mode ${err.message}'); + console.error('Failed to create videoOutput. ${err.message}'); return; } - console.log('Callback returned with current focus mode: ' + afMode); + console.log('Callback returned with an array of supported outputCapability' ); }) ``` -### getFocusMode +### createVideoOutput -getFocusMode(): Promise +createVideoOutput(profile: VideoProfile, surfaceId: string): Promise -Obtains the current focus mode. This API uses a promise to return the result. +Creates a **VideoOutput** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ----------------------------- | ---- | ------------------------------------------------------------ | +| profile | [VideoProfile](#videoprofile) | Yes | Supported video recording configurations. | +| surfaceId | string | Yes | Surface ID, which is obtained from **[VideoRecorder](js-apis-media.md#videorecorder9)**.| + **Return value** -| Type | Description | -| ------------------- | ------------------------------------- | -| Promise | Promise used to return the current focus mode.| +| Type | Description | +| ------------------------------------- | ---------------------------------------- | +| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance.| **Example** ```js -cameraInput.getFocusMode().then((afMode) => { - console.log('Promise returned with current focus mode : ' + afMode); +cameraManager.createVideoOutput(profile, surfaceId).then((videooutput) => { + console.log('Promise returned with videoOutput created.'); }) ``` -### getZoomRatioRange +### createMetadataOutput -getZoomRatioRange\(callback: AsyncCallback\>\): void +createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void -Obtains the zoom ratio range. This API uses an asynchronous callback to return the result. +Creates a **MetadataOutput** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------ | ---- | ------------------------ | -| callback | AsyncCallback\> | Yes | Callback used to return the zoom ratio range.| +| Name | Type | Mandatory| Description | +| ------------------- | ------------------------------------------------- | ---- | -------------------------------------- | +| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Supported metadata object types. | +| callback | AsyncCallback<[MetadataOutput](#metadataoutput)\> | Yes | Callback used to return the **MetadataOutput** instance.| **Example** ```js -cameraInput.getZoomRatioRange((err, zoomRatioRange) => { +cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataoutput) => { if (err) { - console.error('Failed to get the zoom ratio range. ${err.message}'); + console.error('Failed to create metadataOutput. ${err.message}'); return; } - console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); + console.log('Callback returned with metadataOutput created.'); }) ``` -### getZoomRatioRange +### createMetadataOutput -getZoomRatioRange\(\): Promise\> +createMetadataOutput(metadataObjectTypes: Array): Promise -Obtains the zoom ratio range. This API uses a promise to return the result. +Creates a **MetadataOutput** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------------- | ------------------------------------------------- | ---- | ---------------- | +| metadataObjectTypes | Array<[MetadataObjectType](#metadataobjecttype)\> | Yes | Supported metadata object types.| + **Return value** -| Type | Description | -| ------------------------ | ------------------------------------------- | -| Promise\> | Promise used to return the zoom ratio range.| +| Type | Description | +| ------------------------------------------- | ------------------------------------------- | +| Promise<[MetadataOutput](#metadataoutput)\> | Promise used to return the **MetadataOutput** instance.| **Example** ```js -cameraInput.getZoomRatioRange().then((zoomRatioRange) => { - console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); +cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataoutput) => { + console.log('Promise returned with metadataOutput created.'); }) ``` -### setZoomRatio +### createCaptureSession -setZoomRatio(zoomRatio: number, callback: AsyncCallback): void +createCaptureSession(callback: AsyncCallback): void -Sets a zoom ratio. This API uses an asynchronous callback to return the result. +Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | -------------------- | ---- | ------------------------ | -| zoomRatio | number | Yes | Zoom ratio to set. | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | -------------------------------- | +| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes | Callback used to return the **CaptureSession** instance.| **Example** ```js -cameraInput.setZoomRatio(1, (err) => { +cameraManager.createCaptureSession((err, capturesession) => { if (err) { - console.error('Failed to set the zoom ratio value ${err.message}'); + console.error('Failed to create captureSession. ${err.message}'); return; } - console.log('Callback returned with the successful execution of setZoomRatio.'); + console.log('Callback returned with captureSession created.'); }) ``` -### setZoomRatio +### createCaptureSession -setZoomRatio(zoomRatio: number): Promise +createCaptureSession(): Promise -Sets a zoom ratio. This API uses a promise to return the result. +Creates a **CaptureSession** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | ------------ | -| zoomRatio | number | Yes | Zoom ratio to set.| - **Return value** -| Type | Description | -| -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Type | Description | +| ------------------------------------------- | ------------------------------------------- | +| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.| **Example** ```js -cameraInput.setZoomRatio(1).then(() => { - console.log('Promise returned with the successful execution of setZoomRatio.'); +cameraManager.createCaptureSession().then((capturesession) => { + console.log('Promise returned with captureSession created.'); }) ``` -### getZoomRatio +### on('cameraStatus') -getZoomRatio(callback: AsyncCallback): void +on(type: 'cameraStatus', callback: AsyncCallback): void -Obtains the current zoom ratio. This API uses an asynchronous callback to return the result. +Listens for camera status changes. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the current zoom ratio.| +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **cameraStatus**, indicating the camera status change event.| +| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. | **Example** ```js -cameraInput.getZoomRatio((err, zoomRatio) => { +cameraManager.on('cameraStatus', (err, cameraStatusInfo) => { if (err) { - console.error('Failed to get the zoom ratio ${err.message}'); + console.error('Failed to get cameraStatus callback. ${err.message}'); return; } - console.log('Callback returned with current zoom ratio: ' + zoomRatio); + console.log('camera : ' + cameraStatusInfo.camera.cameraId); + console.log('status: ' + cameraStatusInfo.status); }) ``` -### getZoomRatio - -getZoomRatio(): Promise - -Obtains the current zoom ratio. This API uses a promise to return the result. - -**System capability**: SystemCapability.Multimedia.Camera.Core - -**Return value** - -| Type | Description | -| ---------------- | --------------------------- | -| Promise | Promise used to return the current zoom ratio.| +### on('cameraMute') -**Example** - -```js -cameraInput.getZoomRatio().then((zoomRatio) => { - console.log('Promise returned with current zoom ratio : ' + zoomRatio); -}) -``` +on(type: 'cameraMute', callback: AsyncCallback): void -### release +Listens for camera mute status changes. This API uses an asynchronous callback to return the result. -release\(callback: AsyncCallback\): void +This is a system API. -Releases this **CameraInput** instance. This API uses an asynchronous callback to return the result. +**Required permissions**: ohos.permission.CAMERA **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **cameraMute**, indicating the camera mute status change event.| +| callback | AsyncCallback | Yes | Callback used to return the camera mute status. | **Example** ```js -cameraInput.release((err) => { +cameraManager.on('cameraMute', (err, status) => { if (err) { - console.error('Failed to release the CameraInput instance ${err.message}'); + console.error('Failed to get cameraMute callback. ${err.message}'); return; } - console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); -}); + console.log('status: ' + status); +}) ``` -### release - -release(): Promise +## CameraStatusInfo -Releases this **CameraInput** instance. This API uses a promise to return the result. +Describes the camera status information. **System capability**: SystemCapability.Multimedia.Camera.Core -**Return value** +| Name | Type | Description | +| ------ | ----------------------------- | ---------- | +| camera | [CameraDevice](#cameraDevice) | Camera object.| +| status | [CameraStatus](#camerastatus) | Camera status.| -| Type | Description | -| -------------- | --------------------------- | -| Promise | Promise used to return the result.| +## CameraPosition -**Example** +Enumerates the camera positions. -```js -cameraInput.release().then(() => { - console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); -}) -``` +**System capability**: SystemCapability.Multimedia.Camera.Core -### on('focusStateChange') +| Name | Value | Description | +| --------------------------- | ---- | ---------------- | +| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position.| +| CAMERA_POSITION_BACK | 1 | Rear camera. | +| CAMERA_POSITION_FRONT | 2 | Front camera. | -on(type: 'focusStateChange', callback: AsyncCallback): void +## CameraType -Listens for focus state changes. This API uses an asynchronous callback to return the focus state changes. +Enumerates the camera types. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** +| Name | Value | Description | +| ----------------------- | ---- | ------------------ | +| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type. | +| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. | +| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. | +| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. | +| CAMERA_TYPE_TRUE_DEPTH | 4 | Camera with depth of field information.| -| Name | Type | Mandatory| Description | -| :------- | :---------------------------------------- | :--- | :------------------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **focusStateChange**, indicating the focus state change event.| -| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes | Callback used to return the focus state change. | +## ConnectionType -**Example** +Enumerates the camera connection types. -```js -cameraInput.on('focusStateChange', (focusState) => { - console.log('Focus state : ' + focusState); -}) -``` +**System capability**: SystemCapability.Multimedia.Camera.Core -### on('error') +| Name | Value | Description | +| ---------------------------- | ---- | ---------------- | +| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. | +| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB. | +| CAMERA_CONNECTION_REMOTE | 2 | Remote camera.| -on(type: 'error', callback: ErrorCallback): void +## CameraDevice -Listens for **CameraInput** errors. This API uses a callback to return the errors. +Defines the camera device information. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| :------- | :------------------------------- | :--- | :----------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the camera input error event.| -| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the error information. | +| Name | Type | Read only| Description | +| -------------- | --------------------------------- | ---- | ---------------- | +| cameraId | string | Yes | **CameraDevice** object.| +| cameraPosition | [CameraPosition](#cameraposition) | Yes | Camera position. | +| cameraType | [CameraType](#cameratype) | Yes | Camera type. | +| connectionType | [ConnectionType](#connectiontype) | Yes | Camera connection type. | **Example** ```js -cameraInput.on('error', (cameraInputError) => { - console.log('Camera input error code: ' + cameraInputError.code); -}) +async function getCameraInfo("cameraId") { + var cameraManager = await camera.getCameraManager(context); + var cameras = await cameraManager.getSupportedCameras(); + var cameraObj = cameras[0]; + var cameraId = cameraObj.cameraId; + var cameraPosition = cameraObj.cameraPosition; + var cameraType = cameraObj.cameraType; + var connectionType = cameraObj.connectionType; +} ``` -## CameraInputErrorCode - -Enumerates the **CameraInput** error codes. - -**System capability**: SystemCapability.Multimedia.Camera.Core - -| Name | Value | Description | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | Unknown error.| - -## CameraInputError +## Size -Defines a **CameraInput** error object. +Enumerates the camera output capability. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name| Type | Description | -| ---- | ------------------------------------------- | -------------------------- | -| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.| - +| Name | Type | Readable| Writable| Description | +| ------ | ------ | ---- | ---- | ------------------ | +| height | number | Yes | Yes | Image height, in pixels.| +| width | number | Yes | Yes | Image width, in pixel.| -## FlashMode +## Point -Enumerates the flash modes. +Enumerates the point coordinates, which are used for focus and exposure configuration. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| ---------------------- | ---- | ------------ | -| FLASH_MODE_CLOSE | 0 | The flash is off.| -| FLASH_MODE_OPEN | 1 | The flash is on.| -| FLASH_MODE_AUTO | 2 | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.| -| FLASH_MODE_ALWAYS_OPEN | 3 | The flash is steady on.| +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ----------- | +| x | number | Yes | X coordinate of a point.| +| y | number | Yes | Y coordinate of a point.| -## FocusMode +## CameraFormat -Enumerates the focus modes. +Enumerates the camera output format. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| -------------------------- | ---- | ------------------ | -| FOCUS_MODE_MANUAL | 0 | Manual focus. | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus.| -| FOCUS_MODE_AUTO | 2 | Auto focus. | -| FOCUS_MODE_LOCKED | 3 | Locked focus. | - -## FocusState - -Enumerates the focus states. +| Name | Default Value| Description | +| ------------------------ | ------ | ---------------------- | +| CAMERA_FORMAT_YUV_420_SP | 1003 | YUV 420 SP image.| +| CAMERA_FORMAT_JPEG | 2000 | JPEG image. | -**System capability**: SystemCapability.Multimedia.Camera.Core +## CameraInput -| Name | Value | Description | -| --------------------- | ---- | ------------ | -| FOCUS_STATE_SCAN | 0 | Scanning. | -| FOCUS_STATE_FOCUSED | 1 | Focused.| -| FOCUS_STATE_UNFOCUSED | 2 | Unfocused.| +Provides camera information used in **[CaptureSession](#capturesession)**. -## camera.createCaptureSession +### open -createCaptureSession\(context: Context, callback: AsyncCallback\): void +open\(callback: AsyncCallback\): void -Creates a **CaptureSession** instance. This API uses an asynchronous callback to return the instance. +Opens this camera. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------------- | ---- | -------------------------------------- | -| context | Context | Yes | Application context. | -| callback | AsyncCallback<[CaptureSession](#capturesession)\> | Yes | Callback used to return the **CaptureSession** instance.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -camera.createCaptureSession((context), (err, captureSession) => { +cameraInput.open((err) => { if (err) { - console.error('Failed to create the CaptureSession instance. ${err.message}'); + console.error('Failed to open the camera. ${err.message}'); return; } - console.log('Callback returned with the CaptureSession instance.' + captureSession); -}); + console.log('Callback returned with camera opened.'); +}) ``` -## camera.createCaptureSession +### open -createCaptureSession(context: Context\): Promise; +open(): Promise -Creates a **CaptureSession** instance. This API uses a promise to return the instance. +Opens this camera. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| ------- | ------- | ---- | ------------ | -| context | Context | Yes | Application context.| - **Return value** -| Type | Description | -| ------------------------------------------- | ----------------------------------------- | -| Promise<[CaptureSession](#capturesession)\> | Promise used to return the **CaptureSession** instance.| +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| **Example** ```js -camera.createCaptureSession(context).then((captureSession) => { - console.log('Promise returned with the CaptureSession instance'); +cameraInput.open().then(() => { + console.log('Promise returned with camera opened.'); }) ``` -## CaptureSession - -Implements session capture. - -### beginConfig +### close -beginConfig\(callback: AsyncCallback\): void +close\(callback: AsyncCallback\): void -Starts configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Closes this camera. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1180,20 +1145,20 @@ Starts configuration for this **CaptureSession** instance. This API uses an asyn **Example** ```js -captureSession.beginConfig((err) => { +cameraInput.close((err) => { if (err) { - console.error('Failed to start the configuration. ${err.message}'); + console.error('Failed to close the cameras. ${err.message}'); return; } - console.log('Callback invoked to indicate the begin config success.'); -}); + console.log('Callback returned with camera closed.'); +}) ``` -### beginConfig +### close -beginConfig\(\): Promise +close(): Promise -Starts configuration for this **CaptureSession** instance. This API uses a promise to return the result. +Closes this camera. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1201,22 +1166,21 @@ Starts configuration for this **CaptureSession** instance. This API uses a promi | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| - +| Promise| Promise used to return the result.| **Example** ```js -captureSession.beginConfig().then(() => { - console.log('Promise returned to indicate the begin config success.'); +cameraInput.close().then(() => { + console.log('Promise returned with camera closed.'); }) ``` -### commitConfig +### release -commitConfig\(callback: AsyncCallback\): void +release\(callback: AsyncCallback\): void -Commits the configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Releases this camera. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1229,20 +1193,20 @@ Commits the configuration for this **CaptureSession** instance. This API uses an **Example** ```js -captureSession.commitConfig((err) => { +cameraInput.release((err) => { if (err) { - console.error('Failed to commit the configuration. ${err.message}'); + console.error('Failed to release the CameraInput instance ${err.message}'); return; } - console.log('Callback invoked to indicate the commit config success.'); + console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); }); ``` -### commitConfig +### release -commitConfig\(\): Promise +release(): Promise -Commits the configuration for this **CaptureSession** instance. This API uses a promise to return the result. +Releases this camera. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1250,131 +1214,246 @@ Commits the configuration for this **CaptureSession** instance. This API uses a | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Promise| Promise used to return the result.| **Example** ```js -captureSession.commitConfig().then(() => { - console.log('Promise returned to indicate the commit config success.'); +cameraInput.release().then(() => { + console.log('Promise returned to indicate that the CameraInput instance is released successfully.'); }) ``` -### addInput +### on('error') -addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void +on(type: 'error', callback: ErrorCallback): void -Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Listens for **CameraInput** errors. This API uses a callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **error**, indicating the camera input error event.| +| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the result. | **Example** ```js -captureSession.addInput(cameraInput, (err) => { +cameraInput.on('error', (cameraInputError) => { + console.log('Camera input error code: ' + cameraInputError.code); +}) +``` + +## CameraInputErrorCode + +Enumerates the error codes used for camera input. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| ------------------------- | ---- | -------------- | +| ERROR_UNKNOWN | -1 | Unknown error. | +| ERROR_NO_PERMISSION | 0 | You do not have the required permission. | +| ERROR_DEVICE_PREEMPTED | 1 | The camera is preempted. | +| ERROR_DEVICE_DISCONNECTED | 2 | The camera is disconnected.| +| ERROR_DEVICE_IN_USE | 3 | The camera is in use.| +| ERROR_DRIVER_ERROR | 4 | Driver error. | + +## CameraInputError + +Defines an error object used for **[CameraInput](#camerainput)**. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name| Type | Description | +| ---- | --------------------------------------------- | ----------------------- | +| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.| + + +## FlashMode + +Enumerates the flash modes. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| ---------------------- | ---- | ------------ | +| FLASH_MODE_CLOSE | 0 | The flash is off.| +| FLASH_MODE_OPEN | 1 | The flash is on.| +| FLASH_MODE_AUTO | 2 | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.| +| FLASH_MODE_ALWAYS_OPEN | 3 | The flash is steady on.| + +## ExposureMode + +Enumerates the exposure modes. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| ----------------------------- | ---- | -------------- | +| EXPOSURE_MODE_LOCKED | 0 | Exposure locked.| +| EXPOSURE_MODE_AUTO | 1 | Auto exposure.| +| EXPOSURE_MODE_CONTINUOUS_AUTO | 2 | Continuous auto exposure.| + +## FocusMode + +Enumerates the focus modes. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| -------------------------- | ---- | -------------- | +| FOCUS_MODE_MANUAL | 0 | Manual focus. | +| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus.| +| FOCUS_MODE_AUTO | 2 | Auto focus. | +| FOCUS_MODE_LOCKED | 3 | Focus locked. | + +## FocusState + +Enumerates the focus states. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| --------------------- | ---- | ------------ | +| FOCUS_STATE_SCAN | 0 | Focusing. | +| FOCUS_STATE_FOCUSED | 1 | Focused. | +| FOCUS_STATE_UNFOCUSED | 2 | Unfocused.| + +## ExposureState + +Enumerates the exposure states. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| ------------------------ | ---- | ---------- | +| EXPOSURE_STATE_SCAN | 0 | Exposing. | +| EXPOSURE_STATE_CONVERGED | 1 | Exposure converged.| + +## VideoStabilizationMode + +Enumerates the video stabilization modes. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| ------ | ---- | ---------------------------------------------------- | +| OFF | 0 | Video stabilization is disabled. | +| LOW | 1 | The basic video stabilization algorithm is used. | +| MIDDLE | 2 | A video stabilization algorithm with a stabilization effect better than that of the **LOW** type is used. | +| HIGH | 3 | A video stabilization algorithm with a stabilization effect better than that of the **MIDDLE** type is used.| +| AUTO | 4 | Automatic video stabilization is used. | + +## CaptureSession + +Implements a shooting session, which saves all **[CameraInput](#camerainput)** and **[CameraOutput](#cameraoutput)** instances required to run the camera and requests the camera to complete shooting or video recording. + +### beginConfig + +beginConfig\(callback: AsyncCallback\): void + +Starts configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +captureSession.beginConfig((err) => { if (err) { - console.error('Failed to add the CameraInput instance. ${err.message}'); + console.error('Failed to start the configuration. ${err.message}'); return; } - console.log('Callback invoked to indicate that the CameraInput instance is added.'); + console.log('Callback invoked to indicate the begin config success.'); }); ``` -### addInput +### beginConfig -addInput\(cameraInput: CameraInput\): Promise +beginConfig\(\): Promise -Adds a **CameraInput** instance to this **CaptureSession** instance. This API uses a promise to return the result. +Starts configuration for this **CaptureSession** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | --------------------------- | -| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.| - **Return value** | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Promise| Promise used to return the result.| + **Example** ```js -captureSession.addInput(cameraInput).then(() => { - console.log('Promise used to indicate that the CameraInput instance is added.'); +captureSession.beginConfig().then(() => { + console.log('Promise returned to indicate the begin config success.'); }) ``` -### addOutput +### commitConfig -addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void +commitConfig\(callback: AsyncCallback\): void -Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Commits the configuration for this **CaptureSession** instance. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -captureSession.addOutput(previewOutput, (err) => { +captureSession.commitConfig((err) => { if (err) { - console.error('Failed to add the PreviewOutput instance ${err.message}'); + console.error('Failed to commit the configuration. ${err.message}'); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); + console.log('Callback invoked to indicate the commit config success.'); }); ``` -### addOutput +### commitConfig -addOutput\(previewOutput: PreviewOutput\): Promise +commitConfig\(\): Promise -Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result. +Commits the configuration for this **CaptureSession** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to add.| - **Return value** | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Promise| Promise used to return the result.| **Example** ```js -captureSession.addOutput(previewOutput).then(() => { - console.log('Promise used to indicate that the PreviewOutput instance is added.'); +captureSession.commitConfig().then(() => { + console.log('Promise returned to indicate the commit config success.'); }) ``` -### addOutput +### canAddInput -addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void +canAddInput(cameraInput: CameraInput, callback: AsyncCallback): void -Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Checks whether a **[CameraInput](#camerainput)** instance can be added to this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1382,26 +1461,26 @@ Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API us | Name | Type | Mandatory| Description | | ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to add.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -captureSession.addOutput(photoOutput, (err) => { +captureSession.canAddInput(cameraInput, (err, status) => { if (err) { - console.error('Failed to add the PhotoOutput instance ${err.message}'); + console.error('Can not add cameraInput. ${err.message}'); return; } - console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); -}); + console.log('Callback returned with cameraInput can added.'); +}) ``` -### addOutput +### canAddInput -addOutput\(photoOutput: PhotoOutput\): Promise +canAddInput(cameraInput: CameraInput): Promise -Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result. +Checks whether a **[CameraInput](#camerainput)** instance can be added to this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1409,27 +1488,27 @@ Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API us | Name | Type | Mandatory| Description | | ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to add.| +| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.| **Return value** -| Type | Description | -| -------------- | --------------------------- | -| Promise\ | Promise used to return the result.| +| Type | Description | +| ----------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** ```js -captureSession.addOutput(photoOutput).then(() => { - console.log('Promise used to indicate that the PhotoOutput instance is added.'); +captureSession.canAddInput(cameraInput).then(() => { + console.log('Promise returned with cameraInput can added.'); }) ``` -### addOutput +### addInput -addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void +addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1437,26 +1516,26 @@ Adds a **VideoOutput** instance to this **CaptureSession** instance. This API us | Name | Type | Mandatory| Description | | ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to add.| +| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.| | callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -captureSession.addOutput(videoOutput, (err) => { +captureSession.addInput(cameraInput, (err) => { if (err) { - console.error('Failed to add the VideoOutput instance ${err.message}'); + console.error('Failed to add the CameraInput instance. ${err.message}'); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is added.'); + console.log('Callback invoked to indicate that the CameraInput instance is added.'); }); ``` -### addOutput +### addInput -addOutput\(videoOutput: VideoOutput\): Promise +addInput\(cameraInput: CameraInput\): Promise -Adds a **VideoOutput** instance to this **CaptureSession** instance. This API uses a promise to return the result. +Adds a **[CameraInput](#camerainput)** instance to this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1464,19 +1543,19 @@ Adds a **VideoOutput** instance to this **CaptureSession** instance. This API us | Name | Type | Mandatory| Description | | ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to add.| +| cameraInput | [CameraInput](#camerainput) | Yes | **CameraInput** instance to add.| **Return value** | Type | Description | | -------------- | --------------------------- | -| Promise\ | Promise used to return the result.| +| Promise| Promise used to return the result.| **Example** ```js -captureSession.addOutput(videoOutput).then(() => { - console.log('Promise used to indicate that the VideoOutput instance is added.'); +captureSession.addInput(cameraInput).then(() => { + console.log('Promise used to indicate that the CameraInput instance is added.'); }) ``` @@ -1484,7 +1563,7 @@ captureSession.addOutput(videoOutput).then(() => { removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1511,7 +1590,7 @@ captureSession.removeInput(cameraInput, (err) => { removeInput\(cameraInput: CameraInput\): Promise -Removes a **CameraInput** instance from this **CaptureSession** instance. This API uses a promise to return the result. +Removes a **[CameraInput](#camerainput)** instance from this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1523,9 +1602,9 @@ Removes a **CameraInput** instance from this **CaptureSession** instance. This A **Return value** -| Type | Description | -| -------------- | --------------------------- | -| Promise\ | Promise used to return the result.| +| Type | Description | +| --------------- | --------------------------- | +| Promise\ | Promise used to return the result.| **Example** @@ -1535,174 +1614,172 @@ captureSession.removeInput(cameraInput).then(() => { }) ``` -### removeOutput +### canAddOutput -removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void +canAddOutput(cameraOutput: CameraOutput, callback: AsyncCallback\): void -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| ------------ | ----------------------------- | ---- | ---------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to add.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -captureSession.removeOutput(previewOutput, (err) => { +captureSession.canAddOutput(cameraOutput, (err, status) => { if (err) { - console.error('Failed to remove the PreviewOutput instance. ${err.message}'); + console.error('Can not add cameraOutput. ${err.message}'); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is removed.'); -}); + console.log('Callback returned with cameraOutput can added.'); +}) ``` -### removeOutput +### canAddOutput -removeOutput(previewOutput: PreviewOutput): Promise +canAddOutput(cameraOutput: CameraOutput): Promise -Removes a **PreviewOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result. +Checks whether a **[CameraOutput](#cameraoutput)** instance can be added to this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ------------- | ------------------------------- | ---- | ----------------------------- | -| previewOutput | [PreviewOutput](#previewoutput) | Yes | **PreviewOutput** instance to remove.| +| Name | Type | Mandatory| Description | +| ------------ | ----------------------------- | ---- | ---------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to add.| **Return value** -| Type | Description | -| -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Type | Description | +| ----------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** ```js -captureSession.removeOutput(previewOutput).then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is removed.'); +captureSession.canAddOutput(cameraOutput).then(() => { + console.log('Promise returned with cameraOutput can added.'); }) ``` -### removeOutput +### addOutput -removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void +addOutput\(cameraOutput: CameraOutput, callback: AsyncCallback\): void -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to remove.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| ------------ | ----------------------------- | ---- | ---------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to add.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -captureSession.removeOutput(photoOutput, (err) => { +captureSession.addOutput(cameraOutput, (err) => { if (err) { - console.error('Failed to remove the PhotoOutput instance. ${err.message}'); + console.error('Failed to add output. ${err.message}'); return; } - console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); -}); + console.log('Callback returned with output added.'); +}) ``` -### removeOutput +### addOutput -removeOutput(photoOutput: PhotoOutput): Promise +addOutput\(cameraOutput: CameraOutput\): Promise -Removes a **PhotoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result. +Adds a **[CameraOutput](#cameraoutput)** instance to this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | --------------------------- | -| photoOutput | [PhotoOutput](#photooutput) | Yes | **PhotoOutput** instance to remove.| - +| Name | Type | Mandatory| Description | +| ------------ | ----------------------------- | ---- | ---------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to add.| **Return value** | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| - +| Promise| Promise used to return the result.| **Example** ```js -captureSession.removeOutput(photoOutput).then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is removed.'); +captureSession.addOutput(cameraOutput).then(() => { + console.log('Promise returned with cameraOutput added.'); }) ``` ### removeOutput -removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void +removeOutput\(cameraOutput: CameraOutput, callback: AsyncCallback\): void -Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to remove.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| ------------ | ----------------------------- | ---- | ---------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to remove.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -captureSession.removeOutput(videoOutput, (err) => { +captureSession.removeOutput(cameraOutput, (err) => { if (err) { - console.error('Failed to remove the VideoOutput instance. ${err.message}'); + console.error('Failed to remove the CameraOutput instance. ${err.message}'); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is removed.'); + console.log('Callback invoked to indicate that the CameraOutput instance is removed.'); }); ``` ### removeOutput -removeOutput(videoOutput: VideoOutput): Promise +removeOutput(cameraOutput: CameraOutput): Promise -Removes a **VideoOutput** instance from this **CaptureSession** instance. This API uses a promise to return the result. +Removes a **[CameraOutput](#cameraoutput)** instance from this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| ----------- | --------------------------- | ---- | --------------------------- | -| videoOutput | [VideoOutput](#videooutput) | Yes | **VideoOutput** instance to remove.| +| Name | Type | Mandatory| Description | +| ------------ | ----------------------------- | ---- | ---------------------------- | +| cameraOutput | [CameraOutput](#cameraOutput) | Yes | **CameraOutput** instance to remove.| **Return value** | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Promise| Promise used to return the result.| **Example** ```js -captureSession.removeOutput(videoOutput).then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is removed.'); +captureSession.removeOutput(cameraOutput).then(() => { + console.log('Promise returned to indicate that the CameraOutput instance is removed.'); }) ``` @@ -1710,7 +1787,7 @@ captureSession.removeOutput(videoOutput).then(() => { start\(callback: AsyncCallback\): void -Starts this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Starts this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1736,7 +1813,7 @@ captureSession.start((err) => { start\(\): Promise -Starts this **CaptureSession** instance. This API uses a promise to return the result. +Starts this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1744,7 +1821,7 @@ Starts this **CaptureSession** instance. This API uses a promise to return the r | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Promise| Promise used to return the result.| **Example** @@ -1758,13 +1835,12 @@ captureSession.start().then(() => { stop\(callback: AsyncCallback\): void -Stops this **CaptureSession** instance. This API uses an asynchronous callback to return the result. +Stops this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** - | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------ | | callback | AsyncCallback | Yes | Callback used to return the result.| @@ -1785,7 +1861,7 @@ captureSession.stop((err) => { stop(): Promise -Stops this **CaptureSession** instance. This API uses a promise to return the result. +Stops this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1793,7 +1869,7 @@ Stops this **CaptureSession** instance. This API uses a promise to return the re | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Promise| Promise used to return the result.| **Example** @@ -1803,11 +1879,11 @@ captureSession.stop().then(() => { }) ``` -### release +### lockForControl -release\(callback: AsyncCallback\): void +lockForControl(callback: AsyncCallback): void -Releases this **CaptureSession** instance. This API uses an asynchronous callback to return the instance. +Requests to exclusively control the hardware attributes **[CameraInput](#camerainput)** of the camera device. This API uses an asynchronous callback to return the result. After the exclusive control is complete, you must call **[unlockForControl](#unlockforcontrol)** to release the lock. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1820,20 +1896,20 @@ Releases this **CaptureSession** instance. This API uses an asynchronous callbac **Example** ```js -captureSession.release((err) => { +captureSession.lockForControl((err) => { if (err) { - console.error('Failed to release the CaptureSession instance ${err.message}'); + console.error('Failed to lock. ${err.message}'); return; } - console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); -}); + console.log('Locked.'); +}) ``` -### release +### lockForControl -release(): Promise +lockForControl(): Promise -Releases this **CaptureSession** instance. This API uses a promise to return the result. +Requests to exclusively control the hardware attributes **[CameraInput](#camerainput)** of the camera device. This API uses a promise to return the result. After the exclusive control is complete, you must call **[unlockForControl](#unlockforcontrol)** to release the lock. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1841,123 +1917,69 @@ Releases this **CaptureSession** instance. This API uses a promise to return the | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| - -**Example** - -```js -captureSession.release().then(() => { - console.log('Promise returned to indicate that the CaptureSession instance is released successfully.'); -}) -``` - -### on('error') - -on(type: 'error', callback: ErrorCallback): void - -Listens for **CaptureSession** errors. This API uses a callback to return the errors. - -**System capability**: SystemCapability.Multimedia.Camera.Core - -**Parameters** - -| Name | Type | Mandatory| Description | -| :------- | :---------------------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the capture session error event.| -| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | Yes | Callback used to return the error information. | +| Promise| Promise used to return the result.| **Example** ```js -captureSession.on('error', (captureSessionError) => { - console.log('Capture session error code: ' + captureSessionError.code); +captureSession.lockForControl().then(() => { + console.log('Locked.'); }) ``` -## CaptureSessionErrorCode - -Enumerates the **CaptureSession** error codes. - -**System capability**: SystemCapability.Multimedia.Camera.Core - -| Name | Value | Description | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | Unknown error.| - -## CaptureSessionError - -Defines a **CaptureSession** error object. - -**System capability**: SystemCapability.Multimedia.Camera.Core - -| Name| Type | Description | -| ---- | ------------------------------------------- | -------------------------- | -| code | [CaptureSessionError](#capturesessionerror) | **CaptureSession** error code.| - -## camera.createPreviewOutput +### unlockForControl -createPreviewOutput(surfaceId: string, callback: AsyncCallback): void +unlockForControl(callback: AsyncCallback): void -Creates a **PreviewOutput** instance. This API uses an asynchronous callback to return the instance. +Releases the exclusive control on the device configuration. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ----------------------------------------------- | ---- | ------------------------------------- | -| surfaceId | string | Yes | Surface ID received from **XComponent**. | -| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | Yes | Callback used to return the **PreviewOutput** instance.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => { +captureSession.unlockForControl((err) => { if (err) { - console.error('Failed to create the PreviewOutput instance. ${err.message}'); + console.error('Failed to unlock. ${err.message}'); return; } - console.log('Callback returned with previewOutput instance'); -}); + console.log('Unlocked.'); +}) ``` -## camera.createPreviewOutput +### unlockForControl -createPreviewOutput(surfaceId: string): Promise\ +unlockForControl(): Promise -Creates a **PreviewOutput** instance. This API uses a promise to return the instance. +Releases the exclusive control on the device configuration. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | ---------------------------------- | -| surfaceId | string | Yes | Surface ID received from **XComponent**.| - **Return value** -| Type | Description | -| ----------------------------------------- | --------------------------- | -| Promise<[PreviewOutput](#previewoutput)\> | Promise used to return the **PreviewOutput** instance.| +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| **Example** ```js -camera.createPreviewOutput("surfaceId").then((previewOutput) => { - console.log('Promise returned with the PreviewOutput instance'); +captureSession.unlockForControl().then(() => { + console.log('Unlocked.'); }) ``` -## PreviewOutput - -Implements preview output. - ### release -release(callback: AsyncCallback): void +release\(callback: AsyncCallback\): void -Releases this **PreviewOutput** instance. This API uses an asynchronous callback to return the result. +Releases this **CaptureSession**. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1970,12 +1992,12 @@ Releases this **PreviewOutput** instance. This API uses an asynchronous callback **Example** ```js -previewOutput.release((err) => { +captureSession.release((err) => { if (err) { - console.error('Failed to release the PreviewOutput instance ${err.message}'); + console.error('Failed to release the CaptureSession instance ${err.message}'); return; } - console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); + console.log('Callback invoked to indicate that the CaptureSession instance is released successfully.'); }); ``` @@ -1983,7 +2005,7 @@ previewOutput.release((err) => { release(): Promise -Releases this **PreviewOutput** instance. This API uses a promise to return the result. +Releases this **CaptureSession**. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -1991,18 +2013,1565 @@ Releases this **PreviewOutput** instance. This API uses a promise to return the | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| - +| Promise| Promise used to return the result.| **Example** ```js -previewOutput.release().then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); +captureSession.release().then(() => { + console.log('Promise returned to indicate that the CaptureSession instance is released successfully.'); }) ``` -### on('frameStart') +### hasFlash + +hasFlash(callback: AsyncCallback): void + +Checks whether the device has flash light. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the flash light support status. The value **true** means that the device has flash light.| + +**Example** + +```js +cameraInput.hasFlash((err, status) => { + if (err) { + console.error('Failed to check whether the device has flash light. ${err.message}'); + return; + } + console.log('Callback returned with flash light support status: ' + status); +}) +``` + +### hasFlash + +hasFlash(): Promise + +Checks whether the device has flash light. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| ----------------- | ------------------------------------------------------- | +| Promise | Promise used to return the flash light support status. The value **true** means that the device has flash light.| + +**Example** + +```js +cameraInput.hasFlash().then((status) => { + console.log('Promise returned with the flash light support status:' + status); +}) +``` + +### isFlashModeSupported + +isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void + +Checks whether a specified flash mode is supported. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ---------------------------------------- | +| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. | +| callback | AsyncCallback | Yes | Callback used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.| + +**Example** + +```js +cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { + if (err) { + console.error('Failed to check whether the flash mode is supported. ${err.message}'); + return; + } + console.log('Callback returned with the flash mode support status: ' + status); +}) +``` + +### isFlashModeSupported + +isFlashModeSupported(flashMode: FlashMode): Promise + +Checks whether a specified flash mode is supported. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ---------------- | +| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.| + +**Return value** + +| Type | Description | +| ----------------- | ------------------------------------------------------------ | +| Promise | Promise used to return the flash mode support status. The value **true** means that the flash mode is supported, and **false** means the opposite.| + +**Example** + +```js +cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => { + console.log('Promise returned with flash mode support status.' + status); +}) +``` + +### setFlashMode + +setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void + +Sets the flash mode. This API uses an asynchronous callback to return the result. + +Before the setting, do the following checks: + +1. Use **[hasFlash](#hasflash)** to check whether the device has flash light. +2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ------------------------ | +| flashMode | [FlashMode](#flashmode) | Yes | Flash mode. | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { + if (err) { + console.error('Failed to set the flash mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setFlashMode.'); +}) +``` + +### setFlashMode + +setFlashMode(flashMode: FlashMode): Promise + +Sets a flash mode. This API uses a promise to return the result. + +Before the setting, do the following checks: + +1. Use **[hasFlash](#hasflash)** to check whether the device has flash light. +2. Use **[isFlashModeSupported](#isflashmodesupported)** to check whether the device supports the flash mode. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ----------------------- | ---- | ---------------- | +| flashMode | [FlashMode](#flashmode) | Yes | Flash mode.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => { + console.log('Promise returned with the successful execution of setFlashMode.'); +}) +``` + +### getFlashMode + +getFlashMode(callback: AsyncCallback): void + +Obtains the flash mode in use. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<[FlashMode](#flashmode)\> | Yes | Callback used to return the flash mode.| + +**Example** + +```js +cameraInput.getFlashMode((err, flashMode) => { + if (err) { + console.error('Failed to get the flash mode ${err.message}'); + return; + } + console.log('Callback returned with current flash mode: ' + flashMode); +}) +``` + +### getFlashMode + +getFlashMode(): Promise + +Obtains the flash mode in use. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| --------------------------------- | --------------------------------------- | +| Promise<[FlashMode](#flashmode)\> | Promise used to return the flash mode.| + +**Example** + +```js +cameraInput.getFlashMode().then((flashMode) => { + console.log('Promise returned with current flash mode : ' + flashMode); +}) +``` + +### isExposureModeSupported + +isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void; + +Checks whether a specified exposure mode is supported. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------- | ---- | ------------------------------------ | +| aeMode | [ExposureMode](#exposuremode) | Yes | Exposure mode. | +| callback | AsyncCallback | Yes | Callback used to return the exposure mode support status. The value **true** means that the exposure mode is supported, and **false** means the opposite.| + +**Example** + +```js +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { + if (err) { + console.log('Failed to check exposure mode supported ${err.message}'); + return ; + } + console.log('Callback returned with the successful excution of isExposureModeSupported'); +}) +``` + +### isExposureModeSupported + +isExposureModeSupported(aeMode: ExposureMode): Promise + +Checks whether a specified exposure mode is supported. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------ | ----------------------------- | ---- | ---------- | +| aeMode | [ExposureMode](#exposuremode) | Yes | Exposure mode.| + +**Return value** + +| Name | Description | +| ----------------- | ------------------------------------- | +| Promise | Promise used to return the exposure mode support status. The value **true** means that the exposure mode is supported, and **false** means the opposite.| + +**Example** + +```js +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { + console.log('Promise returned with exposure mode supported : ' + isSupported); +}) +``` + +### getExposureMode + +getExposureMode(callback: AsyncCallback): void + +Obtains the exposure mode in use. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------- | ---- | -------------------------------- | +| callback | AsyncCallback<[ExposureMode](#exposuremode)\> | Yes | Callback used to return the exposure mode.| + +**Example** + +```js +cameraInput.getExposureMode((err, exposureMode) => { + if (err) { + console.log('Failed to get the exposure mode ${err.message}'); + return ; + } + console.log('Callback returned with current exposure mode:' + exposureMode); +}) +``` + +### getExposureMode + +getExposureMode(): Promise + +Obtains the exposure mode in use. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Name | Description | +| --------------------------------------- | ----------------------------------- | +| Promise<[ExposureMode](#exposuremode)\> | Promise used to return the exposure mode.| + +**Example** + +```js +cameraInput.getExposureMode().then((exposureMode) => { + console.log('Promise returned with current exposure mode : ' + exposureMode); +}) +``` + +### setExposureMode + +setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void + +Sets an exposure mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------- | ---- | ---------------------------- | +| aeMode | [ExposureMode](#exposuremode) | Yes | Exposure mode. | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { + if (err) { + console.log('Failed to set the exposure mode ${err.message}'); + return ; + } + console.log('Callback returned with the successful excution of setExposureMode'); +}) +``` + +### setExposureMode + +setExposureMode(aeMode: ExposureMode): Promise + +Sets an exposure mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Name | Description | +| -------------- | ------------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then(() => { + console.log('Promise returned with the successful execution of setExposureMode.'); +}) +``` + +### getMeteringPoint + +getMeteringPoint(callback: AsyncCallback): void + +Obtains the center of the metering area. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ------------------------------ | +| callback | AsyncCallback<[Point](#point)\> | Yes | Callback used to return the center of the metering area.| + +**Example** + +```js +cameraInput.getMeteringPoint((err, exposurePoint) => { + if (err) { + console.log('Failed to get the current exposure point ${err.message}'); + return ; + } + console.log('Callback returned with current exposure point:' + exposurePoint); +}) +``` + +### getMeteringPoint + +getMeteringPoint(): Promise + +Obtains the center of the metering area. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Name | Description | +| ------------------------- | --------------------------------- | +| Promise<[Point](#point)\> | Promise used to return the center of the metering area.| + +**Example** + +```js +cameraInput.getMeteringPoint().then((exposurePoint) => { + console.log('Promise returned with current exposure point : ' + exposurePoint); +}) +``` + +### setMeteringPoint + +setMeteringPoint(point: Point, callback: AsyncCallback): void + +Sets the center of the metering area. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------- | -------------------- | ---- | ------------------------ | +| exposurePoint | [Point](#point) | Yes | Exposure point. | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +var Point1 = {x: 1, y: 1}; + +cameraInput.setMeteringPoint(Point1,(err) => { + if (err) { + console.log('Failed to set the exposure point ${err.message}'); + return ; + } + console.log('Callback returned with the successful excution of setMeteringPoint'); +}) +``` + +### setMeteringPoint + +setMeteringPoint(point: Point): Promise + +Sets the center of the metering area. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------- | --------------- | ---- | -------- | +| exposurePoint | [Point](#point) | Yes | Exposure point.| + +**Return value** + +| Name | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the center of the metering area.| + +**Example** + +```js +var Point2 = {x: 2, y: 2}; + +cameraInput.setMeteringPoint(Point2).then(() => { + console.log('Promise returned with the successful execution of setMeteringPoint'); +}) +``` + +### getExposureBiasRange + +getExposureBiasRange(callback: AsyncCallback\>): void + +Obtains the exposure compensation values. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------ | ---- | ---------------------------------- | +| callback | AsyncCallback\> | Yes | Callback used to return the array of compensation values.| + +**Example** + +```js +cameraInput.getExposureBiasRange((err, biasRangeArray) => { + if (err) { + console.log('Failed to get the array of compenstation range ${err.message}'); + return ; + } + console.log('Callback returned with the array of compenstation range: ' + JSON.stringify(biasRangeArray)); +}) +``` + +### getExposureBiasRange + +getExposureBiasRange(): Promise\> + +Obtains the exposure compensation values. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Name | Description | +| ------------------------ | ----------------------------------- | +| Promise\> | Promise used to return the array of compensation values.| + +**Example** + +```js +cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKED).then((isSupported) => { + console.log('Promise returned with exposure mode supported : ' + isSupported); +}) +``` + +### setExposureBias + +setExposureBias(exposureBias: number, callback: AsyncCallback): void + +Sets an exposure compensation value. This API uses an asynchronous callback to return the result. + +Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | -------------------- | ---- | ------------------------ | +| exposureBias | number | Yes | Compensation value. | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +cameraInput.setExposureBias(-4,(err) => { + if (err) { + console.log('Failed to set the exposure bias ${err.message}'); + return ; + } + console.log('Callback returned with the successful excution of setExposureBias'); +}) +``` + +### setExposureBias + +setExposureBias(exposureBias: number): Promise + +Sets an exposure compensation value. This API uses a promise to return the result. + +Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------------ | ------ | ---- | ---------- | +| exposureBias | number | Yes | Compensation value.| + +**Return value** + +| Name | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +cameraInput.setExposureBias(-4).then(() => { + console.log('Promise returned with the successful execution of setExposureBias.'); +}) +``` + +### getExposureValue + +getExposureValue(callback: AsyncCallback): void + +Obtains the exposure value in use. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | -------------------------- | +| callback | AsyncCallback | Yes | Callback used to the exposure value.| + +**Example** + +```js +cameraInput.getExposureValue((err, exposureValue) => { + if (err) { + console.log('Failed to get the exposure value ${err.message}'); + return ; + } + console.log('Callback returned with the exposure value: ' + exposureValue); +}) +``` + +### getExposureValue + +getExposureValue(): Promise + +Obtains the exposure value in use. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Name | Description | +| ---------------- | ----------------------------- | +| Promise | Promise used to the exposure value.| + +**Example** + +```js +cameraInput.getExposureValue().then((exposureValue) => { + console.log('Promise returned with exposure value: ' + exposureValue); +}) +``` + +### isFocusModeSupported + +isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void + +Checks whether a specified focus mode is supported. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | -------------------------------------- | +| afMode | [FocusMode](#focusmode) | Yes | Focus mode. | +| callback | AsyncCallback | Yes | Callback used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.| + +**Example** + +```js +cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => { + if (err) { + console.error('Failed to check whether the focus mode is supported. ${err.message}'); + return; + } + console.log('Callback returned with the focus mode support status: ' + status); +}) +``` + +### isFocusModeSupported + +isFocusModeSupported(afMode: FocusMode): Promise + +Checks whether a specified focus mode is supported. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------ | ----------------------- | ---- | ---------------- | +| afMode | [FocusMode](#focusmode) | Yes | Focus mode.| + +**Return value** + +| Type | Description | +| ----------------- | ----------------------------------------------------------- | +| Promise | Promise used to return the focus mode support status. The value **true** means that the focus mode is supported, and **false** means the opposite.| + +**Example** + +```js +cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => { + console.log('Promise returned with focus mode support status.' + status); +}) +``` + +### setFocusMode + +setFocusMode(afMode: FocusMode, callback: AsyncCallback): void + +Sets a focus mode. This API uses an asynchronous callback to return the result. + +Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------ | +| afMode | [FocusMode](#focusmode) | Yes | Focus mode. | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => { + if (err) { + console.error('Failed to set the focus mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setFocusMode.'); +}) +``` + +### setFocusMode + +setFocusMode(afMode: FocusMode): Promise + +Sets a focus mode. This API uses a promise to return the result. + +Before the setting, use **[isFocusModeSupported](#isfocusmodesupported)** to check whether the focus mode is supported. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ------ | ----------------------- | ---- | ---------------- | +| afMode | [FocusMode](#focusmode) | Yes | Focus mode.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => { + console.log('Promise returned with the successful execution of setFocusMode.'); +}) +``` + +### getFocusMode + +getFocusMode(callback: AsyncCallback): void + +Obtains the focus mode in use. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback<[FocusMode](#focusmode)\> | Yes | Callback used to return the focus mode.| + +**Example** + +```js +cameraInput.getFocusMode((err, afMode) => { + if (err) { + console.error('Failed to get the focus mode ${err.message}'); + return; + } + console.log('Callback returned with current focus mode: ' + afMode); +}) +``` + +### getFocusMode + +getFocusMode(): Promise + +Obtains the focus mode in use. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| ------------------- | ------------------------------------- | +| Promise | Promise used to return the focus mode.| + +**Example** + +```js +cameraInput.getFocusMode().then((afMode) => { + console.log('Promise returned with current focus mode : ' + afMode); +}) +``` + +### setFocusPoint + +setFocusPoint(point: Point, callback: AsyncCallback): void + +Sets a focus point. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| point | [Point](#Point) | Yes | Focus point. | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +var Point1 = {x: 1, y: 1}; + +cameraInput.setFocusPoint(Point1, (err) => { + if (err) { + console.error('Failed to set the focus point ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setFocusPoint.'); +}) +``` + +### setFocusPoint + +setFocusPoint(point: Point): Promise + +Sets a focus point. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----- | --------------- | ---- | ------ | +| point | [Point](#Point) | Yes | Focus point.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +var Point2 = {x: 2, y: 2}; + +cameraInput.setFocusPoint(Point2).then(() => { + console.log('Promise returned with the successful execution of setFocusPoint.'); +}) +``` + +### getFocusPoint + +getFocusPoint(callback: AsyncCallback): void + +Obtains the focus point. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------- | ---- | ---------------------------- | +| callback | AsyncCallback<[Point](#point)\> | Yes | Callback used to return the focus point.| + +**Example** + +```js +cameraInput.getFocusPoint((err, point) => { + if (err) { + console.error('Failed to get the current focus point ${err.message}'); + return; + } + console.log('Callback returned with the current focus point: ' + JSON.stringify(point)); +}) +``` + +### getFocusPoint + +getFocusPoint(): Promise + +Obtains the focus point. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| --------------- | ------------------------------- | +| Promise | Promise used to return the focus point.| + +**Example** + +```js +cameraInput.getFocusPoint().then((point) => { + console.log('Promise returned with the current focus point: ' + JSON.stringify(point)); +}) +``` + +### getFocalLength + +getFocalLength(callback: AsyncCallback): void + +Obtains the focal length. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ---------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the focal length.| + +**Example** + +```js +cameraInput.getFocalLength((err, focalLength) => { + if (err) { + console.error('Failed to get the current focal length ${err.message}'); + return; + } + console.log('Callback returned with the current focal length: ' + focalLength); +}) +``` + +### getFocalLength + +getFocalLength(): Promise + +Obtains the focal length. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| ---------------- | --------------------------- | +| Promise | Promise used to return the focal length.| + +**Example** + +```js +cameraInput.getFocalLength().then((focalLength) => { + console.log('Promise returned with the current focal length: ' + focalLength); +}) +``` + +### getZoomRatioRange + +getZoomRatioRange\(callback: AsyncCallback\>\): void + +Obtains the zoom range. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------ | ---- | ------------------------ | +| callback | AsyncCallback\> | Yes | Callback used to return the zoom range.| + +**Example** + +```js +cameraInput.getZoomRatioRange((err, zoomRatioRange) => { + if (err) { + console.error('Failed to get the zoom ratio range. ${err.message}'); + return; + } + console.log('Callback returned with zoom ratio range: ' + zoomRatioRange.length); +}) +``` + +### getZoomRatioRange + +getZoomRatioRange\(\): Promise\> + +Obtains the zoom range. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| ------------------------ | ------------------------------- | +| Promise\> | Promise used to return the zoom range.| + +**Example** + +```js +cameraInput.getZoomRatioRange().then((zoomRatioRange) => { + console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length); +}) +``` + +### setZoomRatio + +setZoomRatio(zoomRatio: number, callback: AsyncCallback): void + +Sets a zoom ratio. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | -------------------- | ---- | ------------------------ | +| zoomRatio | number | Yes | Zoom ratio. | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +cameraInput.setZoomRatio(1, (err) => { + if (err) { + console.error('Failed to set the zoom ratio value ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setZoomRatio.'); +}) +``` + +### setZoomRatio + +setZoomRatio(zoomRatio: number): Promise + +Sets a zoom ratio. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------ | +| zoomRatio | number | Yes | Zoom ratio.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +cameraInput.setZoomRatio(1).then(() => { + console.log('Promise returned with the successful execution of setZoomRatio.'); +}) +``` + +### getZoomRatio + +getZoomRatio(callback: AsyncCallback): void + +Obtains the zoom ratio in use. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +cameraInput.getZoomRatio((err, zoomRatio) => { + if (err) { + console.error('Failed to get the zoom ratio ${err.message}'); + return; + } + console.log('Callback returned with current zoom ratio: ' + zoomRatio); +}) +``` + +### getZoomRatio + +getZoomRatio(): Promise + +Obtains the zoom ratio in use. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| ---------------- | --------------------------- | +| Promise | Promise used to return the zoom ratio.| + +**Example** + +```js +cameraInput.getZoomRatio().then((zoomRatio) => { + console.log('Promise returned with current zoom ratio : ' + zoomRatio); +}) +``` + +### isVideoStablizationModeSupported + +isVideoStablizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback): void + +Checks whether a specified video stabilization mode is supported. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ------------------------------------ | +| vsMode | [VideoStabilizationMode](#videostabilizationMode) | Yes | Video stabilization mode. | +| callback | AsyncCallback | Yes | Callback used to return whether the video stabilization mode is supported. The value **true** means that the video stabilization mode is supported, and **false** means the opposite.| + +**Example** + +```js +captureSession.isVideoStablizationModeSupported(camera.VideoStabilizationMode.OFF, (err, isSupported) => { + if (err) { + console.error('Failed to check whether video stabilization mode supported. ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of isVideoStabilizationModeSupported: ' + status); +}) +``` + +### isVideoStablizationModeSupported + +isVideoStablizationModeSupported(vsMode: VideoStabilizationMode): Promise + +Checks whether a specified video stabilization mode is supported. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| ----------------- | ----------------------------------------------------- | +| Promise | Promise used to return whether the video stabilization mode is supported. The value **true** means that the video stabilization mode is supported, and **false** means the opposite.| + +**Example** + +```js +captureSession.isVideoStablizationModeSupported(camera.VideoStabilizationMode.OFF).then((isSupported) => { + console.log('Promise returned with video stabilization mode supported: ' + isSupported); +}) +``` + +### getActiveVideoStabilizationMode + +getActiveVideoStabilizationMode(callback: AsyncCallback): void + +Obtains the video stabilization mode in use. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the video stabilization mode.| + +**Example** + +```js +captureSession.getActiveVideoStabilizationMode((err, vsMode) => { + if (err) { + console.error('Failed to get active video stabilization mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of getActiveVideoStabilizationMode.'); +}) +``` + +### getActiveVideoStabilizationMode + +getActiveVideoStabilizationMode(): Promise + +Obtains the video stabilization mode in use. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| -------------------------------- | --------------------------------------------------------- | +| Promise | Promise used to return the video stabilization mode.| + +**Example** + +```js +captureSession.getActiveVideoStabilizationMode().then((vsMode) => { + console.log('Promise returned with the current video stabilization mode: ' + vsMode); +}) +``` + +### setVideoStabilizationMode + +setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void + +Sets a video stabilization mode. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ------------------------ | +| mode | [VideoStabilizationMode](#videostabilizationmode) | Yes | Video stabilization mode.| +| callback | AsyncCallback | Yes | Callback used to return the result. | + +**Example** + +```js +captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF, (err) => { + if (err) { + console.error('Failed to set the video stabilization mode ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of setVideoStabilizationMode.'); +}) +``` + +### setVideoStabilizationMode + +setVideoStabilizationMode(mode: VideoStabilizationMode): Promise + +Sets a video stabilization mode. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name| Type | Mandatory| Description | +| ---- | ------------------------------------------------- | ---- | ------------------------ | +| mode | [VideoStabilizationMode](#videostabilizationmode) | Yes | Video stabilization mode.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------------------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +captureSession.setVideoStabilizationMode(camera.VideoStabilizationMode.OFF).then(() => { + console.log('Promise returned with the successful execution of setVideoStabilizationMode.'); +}) +``` + +### on('focusStateChange') + +on(type: 'focusStateChange', callback: AsyncCallback): void + +Listens for focus state changes. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------- | ---- | -------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **focusStateChange**, indicating the focus state change event.| +| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes | Callback used to return the focus state change. | + +**Example** + +```js +cameraInput.on('focusStateChange', (focusState) => { + console.log('Focus state : ' + focusState); +}) +``` + +### on('exposureStateChange') + +on(type: 'exposureStateChange', callback: AsyncCallback): void + +Listens for exposure state changes. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------- | ---- | ----------------------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'exposureStateChange'**, indicating the exposure state change event.| +| callback | AsyncCallback<[ExposureState](#exposureState)\> | Yes | Callback used to return the exposure state change. | + +**Example** + +```js +cameraInput.on('exposureStateChange', (exposureState) => { + console.log('Exposuer state : ' + exposureState); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback): void + +Listens for **CaptureSession** errors. This API uses a callback to return the errors. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------------- | ---- | --------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **error**, indicating the capture session error event.| +| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | Yes | Callback used to return the error information. | + +**Example** + +```js +captureSession.on('error', (captureSessionError) => { + console.log('Capture session error code: ' + captureSessionError.code); +}) +``` + +## CaptureSessionErrorCode + +Enumerates the error codes used in a **CaptureSession**. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| ---------------------------- | ---- | ---------- | +| ERROR_UNKNOWN | -1 | Unknown error.| +| ERROR_INSUFFICIENT_RESOURCES | 0 | Insufficient resources.| +| ERROR_TIMEOUT | 1 | Timeout. | + +## CaptureSessionError + +Defines a capture session error. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name| Type | Description | +| ---- | ------------------------------------------- | -------------------------- | +| code | [CaptureSessionError](#capturesessionerror) | **CaptureSession** error code.| + +## CameraOutput + +Implements output information used in a **[CaptureSession](#capturesession)**. It is the base class of **output**. + +### release + +release(callback: AsyncCallback): void + +Releases output resources. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +previewOutput.release((err) => { + if (err) { + console.error('Failed to release the PreviewOutput instance ${err.message}'); + return; + } + console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); +}); +``` + +### release + +release(): Promise + +Releases output resources. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +previewOutput.release().then(() => { + console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); +}) +``` + +## PreviewOutput + +Implements preview output. It inherits **[CameraOutput](#cameraoutput)**. + +### addDeferredSurface + +addDeferredSurface(surfaceId: string, callback: AsyncCallback): void + +Adds a surface after a **PreviewOutput** instance is created. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | -------------------- | ---- | ------------------------------------------------------------ | +| surfaceId | string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)**.| +| callback | AsyncCallback | Yes | Callback used to return the result. | + +**Example** + +```js +previewOutput.addDeferredSurface('surfaceId', (err) => { + if (err) { + console.error('Failed to add deferredSurface. ${err.message}'); + return; + } + console.log('Callback returned with deferredSurface added.'); +}) +``` + +### addDeferredSurface + +addDeferredSurface(surfaceId: string): Promise + +Adds a surface after a **PreviewOutput** instance is created. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------------------------------------------------------ | +| surfaceId | string | Yes | Surface ID, which is obtained from **[XComponent](../arkui-ts/ts-basic-components-xcomponent.md)**.| + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +previewOutput.addDeferredSurface('surfaceId').then(() => { + console.log('Promise returned with deferredSurface added.'); +}) +``` + +### start + +start(callback: AsyncCallback): void + +Starts to output preview streams. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +previewOutput.start((err) => { + if (err) { + console.error('Failed to start the previewOutput. ${err.message}'); + return; + } + console.log('Callback returned with previewOutput started.'); +}) +``` + +### start + +start(): Promise + +Starts to output preview streams. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +previewOutput.start().then(() => { + console.log('Promise returned with previewOutput started.'); +}) +``` + +### stop + +stop(callback: AsyncCallback): void + +Stops outputting preview streams. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +previewOutput.stop((err) => { + if (err) { + console.error('Failed to stop the previewOutput. ${err.message}'); + return; + } + console.log('Callback returned with previewOutput stoped.'); +}) +``` + +### stop + +stop(): Promise + +Stops outputting preview streams. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +previewOutput.stop().then(() => { + console.log('Callback returned with previewOutput stoped.'); +}) +``` + +### on('frameStart') on(type: 'frameStart', callback: AsyncCallback): void @@ -2013,8 +3582,8 @@ Listens for preview frame start events. This API uses an asynchronous callback t **Parameters** | Name | Type | Mandatory| Description | -| :------- | :------------------- | :--- | :------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **frameStart**, indicating the preview frame start event.| +| -------- | -------------------- | ---- | -------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **frameStart**, indicating the preview frame start event.| | callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -2036,8 +3605,8 @@ Listens for preview frame end events. This API uses an asynchronous callback to **Parameters** | Name | Type | Mandatory| Description | -| :------- | :------------------- | :--- | :----------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **frameEnd**, indicating the preview frame end event.| +| -------- | -------------------- | ---- | ------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **frameEnd**, indicating the preview frame end event.| | callback | AsyncCallback | Yes | Callback used to return the result. | **Example** @@ -2059,8 +3628,8 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err **Parameters** | Name | Type | Mandatory| Description | -| :------- | :----------------------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the preview output error event.| +| -------- | ------------------------------------------------------------ | ---- | --------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **error**, indicating the preview output error event.| | callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | Yes | Callback used to return the error information. | **Example** @@ -2073,7 +3642,7 @@ previewOutput.on('error', (previewOutputError) => { ## PreviewOutputErrorCode -Enumerates the **PreviewOutput** error codes. +Enumerates the error codes used for preview output. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -2081,203 +3650,450 @@ Enumerates the **PreviewOutput** error codes. | ------------- | ---- | ---------- | | ERROR_UNKNOWN | -1 | Unknown error.| -## PreviewOutputError +## PreviewOutputError -Defines a **PreviewOutput** error object. +Defines the preview output error. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name| Type | Description | -| ---- | ------------------------------------------------- | ---------------------- | +| Name| Type | Description | +| ---- | ------------------------------------------------- | ------------------------- | | code | [PreviewOutputErrorCode](#previewoutputerrorcode) | **PreviewOutput** error code.| -## camera.createPhotoOutput +## ImageRotation + +Enumerates the image rotation angles. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| ------------ | ---- | --------------- | +| ROTATION_0 | 0 | The image rotates 0 degrees. | +| ROTATION_90 | 90 | The image rotates 90 degrees. | +| ROTATION_180 | 180 | The image rotates 180 degrees.| +| ROTATION_270 | 270 | The image rotates 270 degrees.| + +## Location + +Defines geolocation information. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ---------- | +| latitude | number | Yes | Latitude, in degree.| +| longitude | number | Yes | Longitude, in degree.| +| altitude | number | Yes | Altitude, in meter.| + +## QualityLevel + +Enumerates the image quality levels. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Value | Description | +| -------------------- | ---- | -------------- | +| QUALITY_LEVEL_HIGH | 0 | High image quality. | +| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality.| +| QUALITY_LEVEL_LOW | 2 | Low image quality. | + + +## PhotoCaptureSetting + +Defines the settings for photo capture. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +| Name | Type | Mandatory| Default Value | Description | +| -------- | ------------------------------- | ---- | ------------------ | ---------------------- | +| quality | [QualityLevel](#qualitylevel) | No | QUALITY_LEVEL_HIGH | Photo quality. | +| rotation | [ImageRotation](#imagerotation) | No | ROTATION_0 | Rotation angle of the photo. | +| location | [Location](#location) | No | (0,0,0) | Geolocation information of the photo. | +| mirror | boolean | No | false | Whether mirroring is enabled. By default, mirroring is disabled.| + +## PhotoOutput + +Implements output information used in a **CaptureSession**. + +### getDefaultCaptureSetting + +getDefaultCaptureSetting(callback: AsyncCallback): void + +Obtains the default shooting parameters. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<[PhotoCaptureSetting](#photocapturesetting)\> | Yes | Callback used to return the result.| + +**Example** + +```js +photoOutput.getDefaultCaptureSetting((err, photocapturesetting) => { + if (err) { + console.error('Failed to get the defaultCaptureSetting. ${err.message}'); + return; + } + console.log('Callback returned with an array of defaultCaptureSetting.'); +}) +``` + +### getDefaultCaptureSetting + +getDefaultCaptureSetting(): Promise + +Obtains the default shooting parameters. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| ----------------------------------------------------- | --------------------------- | +| Promise<[PhotoCaptureSetting](#photocapturesetting)\> | Promise used to return the result.| + +**Example** + +```js +photoOutput.getDefaultCaptureSetting().then((photocapturesetting) => { + console.log('Callback returned with an array of defaultCaptureSetting.'); +}) +``` + +### capture + +capture(callback: AsyncCallback): void + +Captures a photo with the default shooting parameters. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| + +**Example** + +```js +photoOutput.capture((err) => { + if (err) { + console.error('Failed to capture the photo ${err.message}'); + return; + } + console.log('Callback invoked to indicate the photo capture request success.'); +}); +``` + +### capture -createPhotoOutput(surfaceId: string, callback: AsyncCallback): void +capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void -Creates a **PhotoOutput** instance. This API uses an asynchronous callback to return the instance. +Captures a photo with the specified shooting parameters. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------------------------------- | ---- | ----------------------------------- | -| surfaceId | string | Yes | Surface ID received from **[ImageReceiver](js-apis-image.md#imagereceiver9)**. | -| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | Yes | Callback used to return the **PhotoOutput** instance.| +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------- | ---- | ------------------------ | +| setting | [PhotoCaptureSetting](#photocapturesetting) | Yes | Shooting settings. | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -camera.createPhotoOutput(("surfaceId"), (err, photoOutput) => { +let settings:PhotoCaptureSetting = { + quality = 1, + rotation = 0 +} +photoOutput.capture(settings, (err) => { if (err) { - console.error('Failed to create the PhotoOutput instance. ${err.message}'); + console.error('Failed to capture the photo ${err.message}'); return; } - console.log('Callback returned with the PhotoOutput instance.'); + console.log('Callback invoked to indicate the photo capture request success.'); }); ``` -## camera.createPhotoOutput +### capture -createPhotoOutput(surfaceId: string): Promise +capture(setting?: PhotoCaptureSetting): Promise -Creates a **PhotoOutput** instance. This API uses a promise to return the instance. +Captures a photo with the specified shooting parameters. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | --------------------------------- | -| surfaceId | string | Yes | Surface ID received from **[ImageReceiver](js-apis-image.md#imagereceiver9)**. | +| Name | Type | Mandatory| Description | +| ------- | ------------------------------------------- | ---- | ---------- | +| setting | [PhotoCaptureSetting](#photocapturesetting) | No | Shooting settings.| **Return value** -| Type | Description | -| ------------------------------------- | -------------------------------------- | -| Promise<[PhotoOutput](#photooutput)\> | Promise used to return the **PhotoOutput** instance.| +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + **Example** ```js -camera.createPhotoOutput("surfaceId").then((photoOutput) => { - console.log('Promise returned with PhotoOutput instance'); +photoOutput.capture().then(() => { + console.log('Promise returned to indicate that photo capture request success.'); }) ``` -## ImageRotation -Enumerates the image rotation angles. +### isMirrorSupported + +isMirrorSupported(callback: AsyncCallback): void + +Checks whether mirroring is supported. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| ------------ | ---- | --------------- | -| ROTATION_0 | 0 | The image rotates 0 degrees. | -| ROTATION_90 | 90 | The image rotates 90 degrees. | -| ROTATION_180 | 180 | The image rotates 180 degrees.| -| ROTATION_270 | 270 | The image rotates 270 degrees.| +**Parameters** -## QualityLevel +| Name | Type | Mandatory| Description | +| -------- | ----------------------- | ---- | ------------------------------- | +| callback | AsyncCallback | Yes | Callback used to return the mirroring support status. The value **true** means that mirroring is supported, and **false** means the opposite.| -Enumerates the image quality levels. +**Example** + +```js +captureSession.isMirrorSupported((err, isSupported) => { + if (err) { + console.error('Failed to check mirror is supported ${err.message}'); + return; + } + console.log('Callback returned with the successful execution of isMirrorSupported.'); +}) +``` + +### isMirrorSupported + +isMirrorSupported(): Promise + +Checks whether mirroring is supported. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| -------------------- | ---- | -------------- | -| QUALITY_LEVEL_HIGH | 0 | High image quality. | -| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality.| -| QUALITY_LEVEL_LOW | 2 | Low image quality. | +**Return value** + +| Type | Description | +| ----------------- | ------------------------------------------------- | +| Promise | Promise used to return the mirroring support status. The value **true** means that mirroring is supported, and **false** means the opposite.| + +**Example** + +```js +captureSession.isMirrorSupported().then((isSupported) => { + console.log('Promise returned with mirror supported: ' + isSupported); +}) +``` + +### on('captureStart') + +on(type: 'captureStart', callback: AsyncCallback): void + +Listens for shooting start events. This API uses an asynchronous callback to return the capture ID. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **captureStart**, indicating the shooting start event.| +| callback | AsyncCallback | Yes | Callback used to return the capture ID. | + +**Example** + +```js +photoOutput.on('captureStart', (err, captureId) => { + console.log('photo capture stated, captureId : ' + captureId); +}) +``` + +### on('frameShutter') + +on(type: 'frameShutter', callback: AsyncCallback): void + +Listens for frame shutter events. This API uses an asynchronous callback to return the event information. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **frameShutter**, indicating the frame shutter event.| +| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes | Callback used to return the result. | + +**Example** + +```js +photoOutput.on('frameShutter', (err, frameShutterInfo) => { + console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); + console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); +}) +``` + +### on('captureEnd') + +on(type: 'captureEnd', callback: AsyncCallback): void + +Listens for shooting end events. This API uses an asynchronous callback to return the event information. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------- | ---- | ---------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **captureEnd**, indicating the shooting end event.| +| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes | Callback used to return the result. | + +**Example** + +```js +photoOutput.on('captureEnd', (err, captureEndInfo) => { + console.log('photo capture end, captureId : ' + captureEndInfo.captureId); + console.log('frameCount : ' + captureEndInfo.frameCount); +}) +``` + +### on('error') + +on(type: 'error', callback: ErrorCallback): void + +Listens for **PhotoOutput** errors. This API uses a callback to return the errors. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ----------------------------------------------------- | ---- | ----------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **error**, indicating the photo output error event.| +| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | Yes | Callback used to return the error information. | + +**Example** + +```js +photoOutput.on('error', (err, photoOutputError) => { + console.log('Photo output error code: ' + photoOutputError.code); +}) +``` + +## FrameShutterInfo + +Defines the frame shutter information. + +**System capability**: SystemCapability.Multimedia.Camera.Core +| Name | Type | Mandatory| Description | +| --------- | ------ | ---- | ------------ | +| captureId | number | Yes | ID of this capture action. | +| timestamp | number | Yes | Timestamp when the frame shutter event is triggered.| -## PhotoCaptureSetting +## CaptureEndInfo -Defines the settings for photo capture. +Defines the capture end information. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Type | Mandatory| Description | -| -------- | ------------------------------- | ---- | -------------- | -| quality | [QualityLevel](#qualitylevel) | No | Photo quality. | -| rotation | [ImageRotation](#imagerotation) | No | Rotation angle of the photo.| +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | ---------- | +| captureId | number | Yes | ID of this capture action.| +| frameCount | number | Yes | Number of frames captured. | +## PhotoOutputErrorCode -## PhotoOutput +Enumerates the error codes used for photo output. -Implements photo output. +**System capability**: SystemCapability.Multimedia.Camera.Core -### capture +| Name | Value | Description | +| ---------------------------- | ---- | ------------------ | +| ERROR_UNKNOWN | -1 | Unknown error. | +| ERROR_DRIVER_ERROR | 0 | The driver or hardware is faulty.| +| ERROR_INSUFFICIENT_RESOURCES | 1 | Insufficient resources. | +| ERROR_TIMEOUT | 2 | Timeout. | -capture(callback: AsyncCallback): void +## PhotoOutputError -Captures a photo. This API uses an asynchronous callback to return the result. +Defines a photo output error. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name| Type | Description | +| ---- | ------------------------------------- | ----------------------- | +| code | [PhotoOutputError](#photooutputerror) | **PhotoOutput** error code.| -**Example** +## VideoOutput -```js -photoOutput.capture((err) => { - if (err) { - console.error('Failed to capture the photo ${err.message}'); - return; - } - console.log('Callback invoked to indicate the photo capture request success.'); -}); -``` +Implements output information used in a video recording session. -### capture +### start -capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void +start(callback: AsyncCallback): void -Captures a photo with the specified capture settings. This API uses an asynchronous callback to return the result. +Starts video recording. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ------------------------------------------- | ---- | ------------------------ | -| setting | [PhotoCaptureSetting](#photocapturesetting) | Yes | Photo capture settings. | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -let settings:PhotoCaptureSetting = { - quality = 1, - rotation = 0 -} -photoOutput.capture(settings, (err) => { +videoOutput.start((err) => { if (err) { - console.error('Failed to capture the photo ${err.message}'); + console.error('Failed to start the video output ${err.message}'); return; } - console.log('Callback invoked to indicate the photo capture request success.'); + console.log('Callback invoked to indicate the video output start success.'); }); ``` -### capture +### start -capture(setting?: PhotoCaptureSetting): Promise +start(): Promise -Captures a photo with the specified capture settings. This API uses a promise to return the result. +Starts video recording. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| ------- | ------------------------------------------- | ---- | ---------- | -| setting | [PhotoCaptureSetting](#photocapturesetting) | No | Photo capture settings.| - **Return value** | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Promise| Promise used to return the result.| **Example** ```js -photoOutput.capture().then(() => { - console.log('Promise returned to indicate that photo capture request success.'); +videoOutput.start().then(() => { + console.log('Promise returned to indicate that start method execution success.'); }) ``` -### release +### stop -release(callback: AsyncCallback): void +stop(callback: AsyncCallback): void -Releases this **PhotoOutput** instance. This API uses an asynchronous callback to return the result. +Stops video recording. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -2290,20 +4106,20 @@ Releases this **PhotoOutput** instance. This API uses an asynchronous callback t **Example** ```js -photoOutput.release((err) => { +videoOutput.stop((err) => { if (err) { - console.error('Failed to release the PhotoOutput instance ${err.message}'); + console.error('Failed to stop the video output ${err.message}'); return; } - console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); + console.log('Callback invoked to indicate the video output stop success.'); }); ``` -### release +### stop -release(): Promise +stop(): Promise -Releases this **PhotoOutput** instance. This API uses a promise to return the result. +Stops video recording. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -2311,315 +4127,290 @@ Releases this **PhotoOutput** instance. This API uses a promise to return the re | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| - +| Promise| Promise used to return the result.| **Example** ```js -photoOutput.release().then(() => { - console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.'); +videoOutput.stop().then(() => { + console.log('Promise returned to indicate that stop method execution success.'); }) ``` -### on('captureStart') +### on('frameStart') -on(type: 'captureStart', callback: AsyncCallback): void +on(type: 'frameStart', callback: AsyncCallback): void -Listens for photo capture start events. This API uses an asynchronous callback to return the capture ID. +Listens for video recording start events. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :--------------------- | :--- | :----------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **captureStart**, indicating the photo capture start event.| -| callback | AsyncCallback | Yes | Callback used to return the capture ID. | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **frameStart**, indicating the video recording start event.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -photoOutput.on('captureStart', (err, captureId) => { - console.log('photo capture stated, captureId : ' + captureId); +videoOutput.on('frameStart', () => { + console.log('Video frame started'); }) ``` -### on('frameShutter') +### on('frameEnd') -on(type: 'frameShutter', callback: AsyncCallback): void +on(type: 'frameEnd', callback: AsyncCallback): void -Listens for frame shutter events. This API uses an asynchronous callback to return the event information. +Listens for video recording stop events. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **frameShutter**, indicating the frame shutter event.| -| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **'frameEnd'**, indicating the video recording stop event.| +| callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js -photoOutput.on('frameShutter', (err, frameShutterInfo) => { - console.log('photo capture end, captureId : ' + frameShutterInfo.captureId); - console.log('Timestamp for frame : ' + frameShutterInfo.timestamp); +videoOutput.on('frameEnd', () => { + console.log('Video frame ended'); }) ``` -### on('captureEnd') +### on('error') -on(type: 'captureEnd', callback: AsyncCallback): void +on(type: 'error', callback: ErrorCallback): void -Listens for photo capture end events. This API uses an asynchronous callback to return the event information. +Listens for errors that occur during video recording. This API uses a callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :------------------------------------------------ | :--- | :--------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **captureEnd**, indicating the photo capture end event.| -| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes | Callback used to return the information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------ | ---- | --------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **error**, indicating the video output error event.| +| callback | Callback<[VideoOutputError](#videooutputerror)\> | Yes | Callback used to return the error information. | **Example** ```js -photoOutput.on('captureEnd', (err, captureEndInfo) => { - console.log('photo capture end, captureId : ' + captureEndInfo.captureId); - console.log('frameCount : ' + captureEndInfo.frameCount); +videoOutput.on('error', (VideoOutputError) => { + console.log('Video output error code: ' + VideoOutputError.code); }) ``` -### on('error') - -on(type: 'error', callback: ErrorCallback): void +## VideoOutputErrorCode -Listens for **PhotoOutput** errors. This API uses a callback to return the errors. +Enumerates the error codes used for video recording. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| :------- | :---------------------------------------------------- | :--- | :---------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the photo output error event.| -| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | Yes | Callback used to return the error information. | - -**Example** - -```js -photoOutput.on('error', (err, photoOutputError) => { - console.log('Photo output error code: ' + photoOutputError.code); -}) -``` +| Name | Value | Description | +| ------------------ | ---- | ------------------ | +| ERROR_UNKNOWN | -1 | Unknown error. | +| ERROR_DRIVER_ERROR | 0 | The driver or hardware is faulty.| -## FrameShutterInfo +## VideoOutputError -Defines the frame shutter information. +Defines a video output error. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | ----------------------------- | -| captureId | number | Yes | ID of this capture action.| -| timestamp | number | Yes | Timestamp when the frame shutter event is triggered. | +| Name| Type | Description | +| ---- | ------------------------------------- | ----------------------- | +| code | [PhotoOutputError](#photooutputerror) | **VideoOutput** error code.| -## CaptureEndInfo +## MetadataObjectType -Defines the capture end information. +Enumerates metadata streams. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Type | Mandatory| Description | -| ---------- | ------ | ---- | ----------------------------- | -| captureId | number | Yes | ID of this capture action.| -| frameCount | number | Yes | Number of frames captured. | +| Name | Value | Description | +| -------------- | ---- | ------------------ | +| FACE_DETECTION | 0 | Metadata object type.| -## PhotoOutputErrorCode +## Rect -Enumerates the **PhotoOutput** error codes. +Defines a rectangle. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | Unknown error.| - -## PhotoOutputError +| Name | Type | Description | +| -------- | ------ | --------------------- | +| topLeftX | number | X-axis coordinate of the upper left corner of the rectangle.| +| topLeftY | number | Y-axis coordinate of the upper left corner of the rectangle.| +| width | number | Width of the rectangle. | +| height | number | Height of the rectangle. | -Defines a **PhotoOutput** error object. +## MetadataObject -**System capability**: SystemCapability.Multimedia.Camera.Core - -| Name| Type | Description | -| ---- | ------------------------------------- | ----------------------- | -| code | [PhotoOutputError](#photooutputerror) | **PhotoOutput** error code.| +Implements camera metadata, which is the data source of **[CameraInput](#camerainput)**. -## camera.createVideoOutput +### getType -createVideoOutput(surfaceId: string, callback: AsyncCallback): void +getType(callback: AsyncCallback): void -Creates a **VideoOutput** instance. This API uses an asynchronous callback to return the instance. +Obtains the metadata object type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| --------- | ------------------------------------------- | ---- | ----------------------------------- | -| surfaceId | string | Yes | Surface ID received from **VideoRecorder**. | -| callback | AsyncCallback<[VideoOutput](#videooutput)\> | Yes | Callback used to return the **VideoOutput** instance.| +| Name | Type | Mandatory| Description | +| -------- | --------------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<[MetadataObjectType](#metadataObjectType)\> | Yes | Callback used to return the result.| **Example** ```js -camera.createVideoOutput(("surfaceId"), (err, videoOutput) => { +metadataObject.getType((err, metadataObjectType) => { if (err) { - console.error('Failed to create the VideoOutput instance. ${err.message}'); + console.error('Failed to get type. ${err.message}'); return; } - console.log('Callback returned with the VideoOutput instance'); -}); + console.log('Callback returned with an array of metadataObjectType.'); +}) ``` -## camera.createVideoOutput +### getType -createVideoOutput(surfaceId: string): Promise +getType(): Promise -Creates a **VideoOutput** instance. This API uses a promise to return the instance. +Obtains the metadata object type. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core -**Parameters** - -| Name | Type | Mandatory| Description | -| --------- | ------ | ---- | --------------------------------- | -| surfaceId | string | Yes | Surface ID received from **VideoRecorder**.| - **Return value** -| Type | Description | -| ------------------------------------- | -------------------------------------- | -| Promise<[VideoOutput](#videooutput)\> | Promise used to return the **VideoOutput** instance.| +| Type | Description | +| --------------------------------------------------- | --------------------------- | +| Promise<[MetadataObjectType](#metadataObjectType)\> | Promise used to return the result.| **Example** ```js -camera.createVideoOutput("surfaceId" -).then((videoOutput) => { - console.log('Promise returned with the VideoOutput instance'); +metadataObject.getType().then((metadataObjectType) => { + console.log('Callback returned with an array of metadataObjectType.'); }) ``` -## VideoOutput - -Implements video output. - -### start +### getTimestamp -start(callback: AsyncCallback): void +getTimestamp(callback: AsyncCallback): void -Starts the video output. This API uses an asynchronous callback to return the result. +Obtains the metadata timestamp. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -videoOutput.start((err) => { +metadataObject.getTimestamp((err) => { if (err) { - console.error('Failed to start the video output ${err.message}'); + console.error('Failed to get timestamp. ${err.message}'); return; } - console.log('Callback invoked to indicate the video output start success.'); -}); + console.log('Callback returned with timestamp getted.'); +}) ``` -### start +### getTimestamp -start(): Promise +getTimestamp(): Promise -Starts the video output. This API uses a promise to return the result. +Obtains the metadata timestamp. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Return value** -| Type | Description | -| -------------- | --------------------------- | -| Promise | Promise used to return the result.| - +| Type | Description | +| ----------------- | --------------------------- | +| Promise | Promise used to return the result.| **Example** ```js -videoOutput.start().then(() => { - console.log('Promise returned to indicate that start method execution success.'); +metadataObject.getTimestamp().then(() => { + console.log('Callback returned with timestamp getted.'); }) ``` -### stop +### getBoundingBox -stop(callback: AsyncCallback): void +getBoundingBox(callback: AsyncCallback): void -Stops the video output. This API uses an asynchronous callback to return the result. +Obtains the bounding box of metadata. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| -------- | -------------------- | ---- | ------------------------ | -| callback | AsyncCallback | Yes | Callback used to return the result.| +| Name | Type | Mandatory| Description | +| -------- | ----------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<[Rect](#rect)\> | Yes | Callback used to return the result.| **Example** ```js -videoOutput.stop((err) => { +metadataObject.getBoundingBox((err, rect) => { if (err) { - console.error('Failed to stop the video output ${err.message}'); + console.error('Failed to get boundingBox. ${err.message}'); return; } - console.log('Callback invoked to indicate the video output stop success.'); -}); + console.log('Callback returned with boundingBox getted.'); +}) ``` -### stop +### getBoundingBox -stop(): Promise +getBoundingBox(): Promise -Stops the video output. This API uses a promise to return the result. +Obtains the bounding box of metadata. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Return value** -| Type | Description | -| -------------- | --------------------------- | -| Promise | Promise used to return the result.| +| Type | Description | +| ----------------------- | --------------------------- | +| Promise<[Rect](#rect)\> | Promise used to return the result.| **Example** ```js -videoOutput.start().then(() => { - console.log('Promise returned to indicate that stop method execution success.'); +metadataObject.getBoundingBox().then((rect) => { + console.log('Callback returned with boundingBox getted.'); }) ``` -### release +## MetadataFaceObject -release(callback: AsyncCallback): void +Implements the face object of metadata. It inherits **[MetadataObject](#metadataobject)**. + +## MetadataOutput + +Implements metadata stream. It inherits **[CameraOutput](#cameraoutput)**. + +### start + +start(callback: AsyncCallback): void -Releases this **VideoOutput** instance. This API uses an asynchronous callback to return the result. +Starts to output metadata. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -2632,20 +4423,20 @@ Releases this **VideoOutput** instance. This API uses an asynchronous callback t **Example** ```js -videoOutput.release((err) => { +metadataOutput.start((err) => { if (err) { - console.error('Failed to release the VideoOutput instance ${err.message}'); + console.error('Failed to start metadataOutput. ${err.message}'); return; } - console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); -}); + console.log('Callback returned with metadataOutput started.'); +}) ``` -### release +### start -release(): Promise +start(): Promise -Releases this **VideoOutput** instance. This API uses a promise to return the result. +Starts to output metadata. This API uses a promise to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core @@ -2653,102 +4444,127 @@ Releases this **VideoOutput** instance. This API uses a promise to return the re | Type | Description | | -------------- | --------------------------- | -| Promise | Promise used to return the result.| - +| Promise| Promise used to return the result.| **Example** ```js -videoOutput.release().then(() => { - console.log('Promise returned to indicate that the VideoOutput instance is released successfully.'); +metadataOutput.start().then(() => { + console.log('Callback returned with metadataOutput started.'); }) ``` -### on('frameStart') +### stop -on(type: 'frameStart', callback: AsyncCallback): void +stop(callback: AsyncCallback): void -Listens for video frame start events. This API uses an asynchronous callback to return the event information. +Stops outputting metadata. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :------------------- | :--- | :----------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **frameStart**, indicating the video frame start event.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js -videoOutput.on('frameStart', () => { - console.log('Video frame started'); +metadataOutput.stop((err) => { + if (err) { + console.error('Failed to stop the metadataOutput. ${err.message}'); + return; + } + console.log('Callback returned with metadataOutput stoped.'); }) ``` -### on('frameEnd') +### stop -on(type: 'frameEnd', callback: AsyncCallback): void +stop(): Promise + +Stops outputting metadata. This API uses a promise to return the result. + +**System capability**: SystemCapability.Multimedia.Camera.Core + +**Return value** + +| Type | Description | +| -------------- | --------------------------- | +| Promise| Promise used to return the result.| + +**Example** + +```js +metadataOutput.stop().then(() => { + console.log('Callback returned with metadataOutput stoped.'); +}) +``` -Listens for video frame end events. This API uses an asynchronous callback to return the event information. +### on('metadataObjectsAvailable') + +on(type: 'metadataObjectsAvailable', callback: AsyncCallback\>): void + +Listens for metadata objects. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :------------------- | :--- | :--------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **frameEnd**, indicating the video frame end event.| -| callback | AsyncCallback | Yes | Callback used to return the result. | +| Name | Type | Mandatory| Description | +| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | Yes | Event type. The value is fixed at **'metadataObjectsAvailable'**, that is, the metadata object.| +| callback | Callback\> | Yes | Callback used to return the error information. | **Example** ```js -videoOutput.on('frameEnd', () => { - console.log('Video frame ended'); +metadataOutput.on('metadataObjectsAvailable', (metadataObject) => { + console.log('metadata output error code: ' + metadataObject.code); }) ``` ### on('error') -on(type: 'error', callback: ErrorCallback): void +on(tuype: 'error', callback: ErrorCallback): void -Listens for **VideoOutput** errors. This API uses a callback to return the errors. +Listens for metadata errors. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Multimedia.Camera.Core **Parameters** -| Name | Type | Mandatory| Description | -| :------- | :----------------------------------------------- | :--- | :-------------------------------------------- | -| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the video output error event.| -| callback | Callback<[VideoOutputError](#videooutputerror)\> | Yes | Callback used to return the error information. | +| Name | Type | Mandatory| Description | +| -------- | ------------------------------------------------------ | ---- | --------------------------------------------- | +| type | string | Yes | Event type. The value is fixed at **'error'**, that is, the metadata error.| +| callback | Callback<[MetadataOutputError](#metadataOutputError)\> | Yes | Callback used to return the error information. | **Example** ```js -videoOutput.on('error', (VideoOutputError) => { - console.log('Video output error code: ' + VideoOutputError.code); +metadataOutput.on('error', (metadataOutputError) => { + console.log('Metadata output error code: ' + metadataOutputError.code); }) ``` -## VideoOutputErrorCode +## MetadataOutputErrorCode -Enumerates the **VideoOutput** error codes. +Enumerates the error codes used for metadata output. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name | Value | Description | -| ------------- | ---- | ---------- | -| ERROR_UNKNOWN | -1 | Unknown error.| +| Name | Value | Description | +| ---------------------------- | ---- | ---------- | +| ERROR_UNKNOWN | -1 | Unknown error.| +| ERROR_INSUFFICIENT_RESOURCES | 0 | Insufficient resources.| -## VideoOutputError +## MetadataOutputError -Defines a **VideoOutput** error object. +Defines a metadata output error. **System capability**: SystemCapability.Multimedia.Camera.Core -| Name| Type | Description | -| ---- | ------------------------------------- | ----------------------- | -| code | [PhotoOutputError](#photooutputerror) | **VideoOutput** error code.| +| Name| Type | Description | +| ---- | --------------------------------------------------- | -------------------------- | +| code | [MetadataOutputErrorCode](#MetadataOutputErrorCode) | **MetadataOutput** error code.|