Multimedia Subsystem Changelog
Camera API Changes
Some functional APIs are added and some others are deprecated to:
- Improve the usability of camera APIs.
- Help you quickly understand camera APIs and use them for development.
- Facilitate expansion of framework functions in later versions, and reduce coupling between framework modules.
You need to refer to the following change description to adapt your application.
Change Impact
JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version.
Key API/Component Changes
Module | Class | Method/Attribute/Enum/Constant | Change Type |
---|---|---|---|
ohos.multimedia.camera | Profile | readonly format:CameraFormat; | Added |
ohos.multimedia.camera | Profile | readonly size: Size; | Added |
ohos.multimedia.camera | FrameRateRange | readonly min: number; | Added |
ohos.multimedia.camera | FrameRateRange | readonly max: number; | Added |
ohos.multimedia.camera | VideoProfile | readonly frameRateRange: FrameRateRange; | Added |
ohos.multimedia.camera | CameraOutputCapability | readonly previewProfiles: Array |
Added |
ohos.multimedia.camera | CameraOutputCapability | readonly photoProfiles: Array |
Added |
ohos.multimedia.camera | CameraOutputCapability | readonly videoProfiles: Array |
Added |
ohos.multimedia.camera | CameraOutputCapability | readonly supportedMetadataObjectTypes: Array |
Added |
ohos.multimedia.camera | CameraManager | getSupportedCameras(callback: AsyncCallback<Array getSupportedCameras(): Promise<Array |
Added |
ohos.multimedia.camera | CameraManager | getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback getSupportedOutputCapability(camera: CameraDevice): Promise |
Added |
ohos.multimedia.camera | CameraManager | isCameraMuted(): boolean; | Added |
ohos.multimedia.camera | CameraManager | isCameraMuteSupported(): boolean; | Added |
ohos.multimedia.camera | CameraManager | muteCamera(mute: boolean): void; | Added |
ohos.multimedia.camera | CameraManager | createCameraInput(camera: CameraDevice, callback: AsyncCallback createCameraInput(camera: CameraDevice): Promise |
Added |
ohos.multimedia.camera | CameraManager | createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback createPreviewOutput(profile: Profile, surfaceId: string): Promise |
Added |
ohos.multimedia.camera | CameraManager | createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback createPhotoOutput(profile: Profile, surfaceId: string): Promise |
Added |
ohos.multimedia.camera | CameraManager | createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback createVideoOutput(profile: VideoProfile, surfaceId: string): Promise |
Added |
ohos.multimedia.camera | CameraManager | createMetadataOutput(metadataObjectTypes: Array createMetadataOutput(metadataObjectTypes: Array |
Added |
ohos.multimedia.camera | CameraManager | createCaptureSession(callback: AsyncCallback createCaptureSession(): Promise |
Added |
ohos.multimedia.camera | CameraManager | on(type: 'cameraMute', callback: AsyncCallback |
Added |
ohos.multimedia.camera | CameraManager | getCameras(callback: AsyncCallback<Array getCameras(): Promise<Array |
Deprecated |
ohos.multimedia.camera | CameraManager | createCameraInput(cameraId: string, callback: AsyncCallback createCameraInput(cameraId: string): Promise |
Deprecated |
ohos.multimedia.camera | CameraManager | createCaptureSession(context: Context, callback: AsyncCallback createCaptureSession(context: Context): Promise |
Deprecated |
ohos.multimedia.camera | CameraManager | createPreviewOutput(surfaceId: string, callback: AsyncCallback createPreviewOutput(surfaceId: string): Promise |
Deprecated |
ohos.multimedia.camera | CameraManager | CreatePhotoOutput(surfaceId: string, callback: AsyncCallback CreatePhotoOutput(surfaceId: string): Promise |
Deprecated |
ohos.multimedia.camera | CameraManager | createVideoOutput(surfaceId: string, callback: AsyncCallback createVideoOutput(surfaceId: string): Promise |
Deprecated |
ohos.multimedia.camera | CameraManager | createMetadataOutput(callback: AsyncCallback createVideoOutput(): Promise |
Deprecated |
ohos.multimedia.camera | CameraStatusInfo | camera: CameraDevice; | Added |
ohos.multimedia.camera | CameraStatusInfo | camera: Camera; | Deprecated |
ohos.multimedia.camera | CameraDevice | interface CameraDevice | Added |
ohos.multimedia.camera | Camera | interface Camera | Deprecated |
ohos.multimedia.camera | CameraInput | open(callback: AsyncCallback open(): Promise |
Added |
ohos.multimedia.camera | CameraInput | close(callback: AsyncCallback close(): Promise |
Added |
ohos.multimedia.camera | CameraInput | on(type: 'error', camera: CameraDevice, callback: ErrorCallback |
Added |
ohos.multimedia.camera | CameraInput | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback isFocusModeSupported(afMode: FocusMode): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getFocusMode(callback: AsyncCallback getFocusMode(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setFocusMode(afMode: FocusMode, callback: AsyncCallback setFocusMode(afMode: FocusMode): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getZoomRatioRange(callback: AsyncCallback<Array getZoomRatioRange(): Promise<Array |
Deprecated |
ohos.multimedia.camera | CameraInput | getZoomRatio(callback: AsyncCallback getZoomRatio(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setZoomRatio(zoomRatio: number, callback: AsyncCallback setZoomRatio(zoomRatio: number): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getCameraId(callback: AsyncCallback getCameraId(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getExposurePoint(callback: AsyncCallback getExposurePoint(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setExposurePoint(exposurePoint: Point, callback: AsyncCallback setExposurePoint(exposurePoint: Point): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | hasFlash(callback: AsyncCallback hasFlash(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback isFlashModeSupported(flashMode: FlashMode): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getFlashMode(callback: AsyncCallback getFlashMode(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setFlashMode(flashMode: FlashMode, callback: AsyncCallback setFlashMode(flashMode: FlashMode): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback isExposureModeSupported(aeMode: ExposureMode): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getExposureMode(callback: AsyncCallback getExposureMode(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setExposureMode(aeMode: ExposureMode, callback: AsyncCallback setExposureMode(aeMode: ExposureMode): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getMeteringPoint(callback: AsyncCallback getMeteringPoint(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setMeteringPoint(point: Point, callback: AsyncCallback setMeteringPoint(point: Point): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getExposureBiasRange(callback: AsyncCallback<Array getExposureBiasRange(): Promise<Array |
Deprecated |
ohos.multimedia.camera | CameraInput | setExposureBias(exposureBias: number, callback: AsyncCallback setExposureBias(exposureBias: number): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getExposureValue(callback: AsyncCallback getExposureValue(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback isFocusModeSupported(afMode: FocusMode): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getFocusMode(callback: AsyncCallback getFocusMode(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setFocusMode(afMode: FocusMode, callback: AsyncCallback setFocusMode(afMode: FocusMode): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setFocusPoint(point: Point, callback: AsyncCallback setFocusPoint(point: Point): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getFocusPoint(callback: AsyncCallback getFocusPoint(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getFocalLength(callback: AsyncCallback getFocalLength(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | getZoomRatioRange(callback: AsyncCallback<Array getZoomRatioRange(): Promise<Array |
Deprecated |
ohos.multimedia.camera | CameraInput | getZoomRatio(callback: AsyncCallback getZoomRatio(): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | setZoomRatio(zoomRatio: number, callback: AsyncCallback setZoomRatio(zoomRatio: number): Promise |
Deprecated |
ohos.multimedia.camera | CameraInput | on(type: 'focusStateChange', callback: AsyncCallback |
Deprecated |
ohos.multimedia.camera | CameraInput | on(type: 'exposureStateChange', callback: AsyncCallback |
Deprecated |
ohos.multimedia.camera | CameraInput | on(type: 'error', callback: ErrorCallback |
Deprecated |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_NO_PERMISSION = 0 | Added |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_PREEMPTED = 1 | Added |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_DISCONNECTED = 2 | Added |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_DEVICE_IN_USE = 3 | Added |
ohos.multimedia.camera | CameraInputErrorCode | ERROR_DRIVER_ERROR = 4 | Added |
ohos.multimedia.camera | CameraFormat | CAMERA_FORMAT_RGBA_8888 = 3 | Added |
ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_AUTO = 1 | Added |
ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_CONTINUOUS_AUTO = 2 | Added |
ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_AUTO | Deprecated |
ohos.multimedia.camera | ExposureMode | EXPOSURE_MODE_CONTINUOUS_AUTO | Deprecated |
ohos.multimedia.camera | VideoStabilizationMode | LOW = 1 | Added |
ohos.multimedia.camera | VideoStabilizationMode | MIDDLE = 2 | Added |
ohos.multimedia.camera | VideoStabilizationMode | HIGH = 3 | Added |
ohos.multimedia.camera | VideoStabilizationMode | AUTO = 4 | Added |
ohos.multimedia.camera | VideoStabilizationMode | LOW | Deprecated |
ohos.multimedia.camera | VideoStabilizationMode | MIDDLE | Deprecated |
ohos.multimedia.camera | VideoStabilizationMode | HIGH | Deprecated |
ohos.multimedia.camera | VideoStabilizationMode | AUTO | Deprecated |
ohos.multimedia.camera | CaptureSession | addOutput(cameraOutput: CameraOutput, callback: AsyncCallback addOutput(cameraOutput: CameraOutput): Promise |
Added |
ohos.multimedia.camera | CaptureSession | removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback removeOutput(cameraOutput: CameraOutput): Promise |
Added |
ohos.multimedia.camera | CaptureSession | isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getActiveVideoStabilizationMode(callback: AsyncCallback getActiveVideoStabilizationMode(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback setVideoStabilizationMode(mode: VideoStabilizationMode): Promise |
Added |
ohos.multimedia.camera | CaptureSession | on(type: 'focusStateChange', callback: AsyncCallback |
Added |
ohos.multimedia.camera | CaptureSession | hasFlash(callback: AsyncCallback hasFlash(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback isFlashModeSupported(flashMode: FlashMode): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getFlashMode(callback: AsyncCallback getFlashMode(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | setFlashMode(flashMode: FlashMode, callback: AsyncCallback setFlashMode(flashMode: FlashMode): Promise |
Added |
ohos.multimedia.camera | CaptureSession | isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback isExposureModeSupported(aeMode: ExposureMode): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getExposureMode(callback: AsyncCallback getExposureMode(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | setExposureMode(aeMode: ExposureMode, callback: AsyncCallback setExposureMode(aeMode: ExposureMode): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getMeteringPoint(callback: AsyncCallback getMeteringPoint(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | setMeteringPoint(point: Point, callback: AsyncCallback setMeteringPoint(point: Point): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getExposureBiasRange(callback: AsyncCallback<Array getExposureBiasRange(): Promise<Array |
Added |
ohos.multimedia.camera | CaptureSession | setExposureBias(exposureBias: number, callback: AsyncCallback setExposureBias(exposureBias: number): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getExposureValue(callback: AsyncCallback getExposureValue(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback isFocusModeSupported(afMode: FocusMode): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getFocusMode(callback: AsyncCallback getFocusMode(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | setFocusMode(afMode: FocusMode, callback: AsyncCallback setFocusMode(afMode: FocusMode): Promise |
Added |
ohos.multimedia.camera | CaptureSession | setFocusPoint(point: Point, callback: AsyncCallback setFocusPoint(point: Point): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getFocusPoint(callback: AsyncCallback getFocusPoint(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getFocalLength(callback: AsyncCallback getFocalLength(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | getZoomRatioRange(callback: AsyncCallback<Array getZoomRatioRange(): Promise<Array |
Added |
ohos.multimedia.camera | CaptureSession | getZoomRatio(callback: AsyncCallback getZoomRatio(): Promise |
Added |
ohos.multimedia.camera | CaptureSession | setZoomRatio(zoomRatio: number, callback: AsyncCallback setZoomRatio(zoomRatio: number): Promise |
Added |
ohos.multimedia.camera | CaptureSession | addOutput(previewOutput: PreviewOutput, callback: AsyncCallback addOutput(previewOutput: PreviewOutput): Promise addOutput(photoOutput: PhotoOutput, callback: AsyncCallback addOutput(photoOutput: PhotoOutput): Promise addOutput(videoOutput: VideoOutput, callback: AsyncCallback addOutput(videoOutput: VideoOutput): Promise |
Deprecated |
ohos.multimedia.camera | CaptureSession | removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback removeOutput(previewOutput: PreviewOutput): Promise removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback removeOutput(photoOutput: PhotoOutput): Promise removeOutput(videoOutput: VideoOutput): Promise removeOutput(metadataOutput: MetadataOutput, callback: AsyncCallback removeOutput(metadataOutput: MetadataOutput): Promise |
Deprecated |
ohos.multimedia.camera | CaptureSessionErrorCode | ERROR_INSUFFICIENT_RESOURCES = 0 | Added |
ohos.multimedia.camera | CaptureSessionErrorCode | ERROR_TIMEOUT = 1 | Added |
ohos.multimedia.camera | CameraOutput | release(callback: AsyncCallback release(): Promise |
Added |
ohos.multimedia.camera | PreviewOutput | start(callback: AsyncCallback start(): Promise |
Added |
ohos.multimedia.camera | PreviewOutput | stop(callback: AsyncCallback stop(): Promise |
Added |
ohos.multimedia.camera | PreviewOutput | release(callback: AsyncCallback release(): Promise |
Deprecated |
ohos.multimedia.camera | PhotoOutput | release(callback: AsyncCallback release(): Promise |
Deprecated |
ohos.multimedia.camera | VideoOutput | release(callback: AsyncCallback release(): Promise |
Deprecated |
ohos.multimedia.camera | PhotoCaptureSetting | mirror?: boolean; | Added |
ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_DRIVER_ERROR = 0 | Added |
ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_INSUFFICIENT_RESOURCES = 1 | Added |
ohos.multimedia.camera | PhotoOutputErrorCode | ERROR_TIMEOUT = 2 | Added |
ohos.multimedia.camera | VideoOutputErrorCode | ERROR_DRIVER_ERROR = 0 | Added |
ohos.multimedia.camera | MetadataObjectType | FACE_DETECTION = 0 | Added |
ohos.multimedia.camera | MetadataObjectType | FACE = 0 | Deprecated |
ohos.multimedia.camera | MetadataOutput | on(type: 'error', callback: ErrorCallback |
Added |
ohos.multimedia.camera | MetadataOutput | setCapturingMetadataObjectTypes(metadataObjectTypes: Array setCapturingMetadataObjectTypes(metadataObjectTypes: Array |
Deprecated |
ohos.multimedia.camera | MetadataOutput | getSupportedMetadataObjectTypes(callback: AsyncCallback<Array getSupportedMetadataObjectTypes(): Promise<Array |
Deprecated |
ohos.multimedia.camera | MetadataOutputErrorCode | ERROR_UNKNOWN = -1 | Added |
ohos.multimedia.camera | MetadataOutputErrorCode | ERROR_INSUFFICIENT_RESOURCES = 0 | Added |
ohos.multimedia.camera | MetadataOutputError | code: MetadataOutputErrorCode; | Added |
Adaptation Guide
In addition to new APIs and deprecated APIs, you need to adapt your application to changed APIs.
In Beta4 and later versions, the following APIs are changed.
New APIs
-
Profile API
Attribute 1: readonly format; type: CameraFormat
Attribute 2: readonly size; type: Size
-
FrameRateRange API
Attribute 1: readonly min; type: number
Attribute 2: readonly max; type: number
-
VideoProfile API (inherited from Profile)
Attribute: readonly frameRateRange; type: FrameRateRange
-
CameraOutputCapability API
Attribute 1: readonly previewProfiles; type: Array
Attribute 2: readonly photoProfiles; type: Array
Attribute 3: readonly videoProfiles; type: Array
Attribute 4: readonly supportedMetadataObjectTypes; type: Array
-
The following APIs are added to CameraManager:
getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback
): void; getSupportedOutputCapability(camera: CameraDevice): Promise
; The code snippet is as follows:
cameraManager.getSupportedCameras().then((cameras) => { let cameraDevice = cameras[0]; cameraManager.getSupportedOutputCapability(cameraDevice, (err, CameraOutputCapability) => { if (err) { console.error(`Failed to get the outputCapability. ${err.message}`); return; } console.log('Callback returned with an array of supported outputCapability'); }) })
cameraManager.getSupportedCameras().then((cameras) => { let cameraDevice = cameras[0]; cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => { console.log('Promise returned with an array of supported outputCapability'); }) })
-
The isCameraMuted(): boolean; API is added to CameraManager.
The code snippet is as follows:
let ismuted = cameraManager.isCameraMuted();
-
The isCameraMuteSupported(): boolean; API is added to CameraManager.
The code snippet is as follows:
let ismutesuppotred = cameraManager.isCameraMuteSupported();
-
The muteCamera(mute: boolean): void; API is added to CameraManager.
The code snippet is as follows:
let mute = true; cameraManager.muteCamera(mute);
-
The on(type: 'cameraMute', callback: AsyncCallback
): void; API is added to CameraManager.The code snippet is as follows:
cameraManager.on('cameraMute', (err, curMuetd) => { if (err) { console.error(`Failed to get cameraMute callback. ${err.message}`); return; } })
-
The open(callback: AsyncCallback
): void; and open(): Promise; APIs are added to CameraInput.The code snippet is as follows:
cameraInput.open((err) => { if (err) { console.error(`Failed to open the camera. ${err.message}`); return; } console.log('Callback returned with camera opened.'); })
cameraInput.open().then(() => { console.log('Promise returned with camera opened.'); })
-
The close(callback: AsyncCallback
): void; and close(): Promise; APIs are added to CameraInput.The code snippet is as follows:
cameraInput.close((err) => { if (err) { console.error(`Failed to close the cameras. ${err.message}`); return; } console.log('Callback returned with camera closed.'); })
cameraInput.close().then(() => { console.log('Promise returned with camera closed.'); })
-
The following enums are added to CameraInputErrorCode:
Enum: ERROR_NO_PERMISSION; value: 0
Enum: ERROR_DEVICE_PREEMPTED; value: 1
Enum: ERROR_DEVICE_DISCONNECTED; value: 2
Enum: ERROR_DEVICE_IN_USE; value: 3
Enum: ERROR_DRIVER_ERROR; value: 4
-
The following enum is added to CameraFormat:
Enum: CAMERA_FORMAT_RGBA_8888; value: 3
-
The getMeteringPoint(callback: AsyncCallback
): void; and getMeteringPoint(): Promise; APIs are added to CaptureSession.The code snippet is as follows:
captureSession.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}`); })
captureSession.getMeteringPoint().then((exposurePoint) => { console.log(`Promise returned with current exposure point : ${exposurePoint}`); })
-
The setMeteringPoint(point: Point, callback: AsyncCallback
): void; and setMeteringPoint(point: Point): Promise; APIs are added to CaptureSession.The code snippet is as follows:
const Point1 = {x: 1, y: 1}; captureSession.setMeteringPoint(Point1,(err) => { if (err) { console.log(`Failed to set the exposure point ${err.message}`); return ; } console.log('Callback returned with the successful execution of setMeteringPoint'); })
const Point2 = {x: 2, y: 2}; captureSession.setMeteringPoint(Point2).then(() => { console.log('Promise returned with the successful execution of setMeteringPoint'); })
-
The following enums are added to CaptureSessionErrorCode:
Enum: ERROR_INSUFFICIENT_RESOURCES; value: 0
Enum: ERROR_TIMEOUT; value: 1
-
The CameraOutput API is added and contains the release(callback: AsyncCallback
): void; and release(): Promise; methods.The sample code (for previewOutput) is as follows:
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.'); });
previewOutput.release().then(() => { console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); })
-
The start(callback: AsyncCallback
): void; and start(): Promise; APIs are added to PreviewOutput.The code snippet is as follows:
previewOutput.start((err) => { if (err) { console.error(`Failed to start the previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput started.'); })
previewOutput.start().then(() => { console.log('Promise returned with previewOutput started.'); })
-
The stop(callback: AsyncCallback
): void; and stop(): Promise; APIs are added to PreviewOutput.The code snippet is as follows:
previewOutput.stop((err) => { if (err) { console.error(`Failed to stop the previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput stopped.'); })
previewOutput.stop().then(() => { console.log('Callback returned with previewOutput stopped.'); })
-
PhotoCaptureSetting API
Attribute 1: mirror?; type: boolean
-
The following enums are added to PhotoOutputErrorCode:
Enum: ERROR_DRIVER_ERROR; value: 0
Enum: ERROR_INSUFFICIENT_RESOURCES; value: 1
Enum: ERROR_TIMEOUT; value: 2
-
The following enum is added to VideoOutputErrorCode:
Enum: ERROR_DRIVER_ERROR; value: 0
-
The on(type: 'error', callback: ErrorCallback
): void; API is added to MetadataOutput.The code snippet is as follows:
metadataOutput.on('error', (metadataOutputError) => { console.log(`Metadata output error code: ${metadataOutputError.code}`); })
-
The following enums are added to MetadataOutputErrorCode.
Enum: ERROR_UNKNOWN; value: -1
Enum: ERROR_INSUFFICIENT_RESOURCES; value: 0
-
MetadataOutputError API
Attribute: code; value: MetadataOutputErrorCode
Deprecated APIs
-
The on(type: 'exposureStateChange', callback: AsyncCallback
): void; API in CameraInput is deprecated. -
The release(callback: AsyncCallback
): void; and release(): Promise; APIs in previewOutput are deprecated. -
The following APIs in metadataOutput are deprecated:
setCapturingMetadataObjectTypes(metadataObjectTypes: Array
, callback: AsyncCallback ): void;
setCapturingMetadataObjectTypes(metadataObjectTypes: Array): Promise ; -
The following APIs in metadataOutput are deprecated:
getSupportedMetadataObjectTypes(callback: AsyncCallback<Array
>): void;
getSupportedMetadataObjectTypes(): Promise<Array>; -
The release(callback: AsyncCallback
): void; and release(): Promise; APIs in PreviewOutput are deprecated. -
The release(callback: AsyncCallback
): void; and release(): Promise; APIs in PhotoOutput are deprecated. -
The release(callback: AsyncCallback
): void; and release(): Promise; APIs in VideoOutput are deprecated. -
The getCameraId(callback: AsyncCallback
): void; and getCameraId(): Promise; APIs in CameraInput are deprecated. -
The getExposurePoint(callback: AsyncCallback
): void; and getExposurePoint(): Promise; APIs in CameraInput are deprecated. -
The setExposurePoint(exposurePoint: Point, callback: AsyncCallback
): void; and setExposurePoint(exposurePoint: Point): Promise; APIs in CameraInput are deprecated.
Changed APIs
-
In CameraManager, the return value of getCameras is changed from Array
to Array , and the API name is changed from getCameras to getSupportedCameras. Therefore, the getCameras(callback: AsyncCallback<Array >): void; and getCameras(): Promise<Array>; APIs are changed to getSupportedCameras(callback: AsyncCallback<Array>): void and getSupportedCameras(): Promise<Array>; .The code snippet is as follows:
cameraManager.getSupportedCameras((err, cameras) => { if (err) { console.error(`Failed to get the cameras. ${err.message}`); return; } console.log(`Callback returned with an array of supported cameras: ${cameras.length}`); })
cameraManager.getSupportedCameras().then((cameras) => { console.log(`Promise returned with an array of supported cameras: ${cameras.length}`); })
-
In CameraManager, the input parameter of createCameraInput is changed from cameraId: string to camera: CameraDevice. Therefore, the createCameraInput(cameraId: string, callback: AsyncCallback
): void; and createCameraInput(cameraId: string): Promise; APIs are changed to createCameraInput(camera: CameraDevice, callback: AsyncCallback): void; and createCameraInput(camera: CameraDevice): Promise; .The code snippet is as follows:
let cameraDevice = cameras[0]; cameraManager.createCameraInput(cameraDevice, (err, cameraInput) => { if (err) { console.error(`Failed to create the CameraInput instance. ${err.message}`); return; } console.log('Callback returned with the CameraInput instance.'); })
let cameraDevice = cameras[0]; cameraManager.createCameraInput(cameraDevice).then((cameraInput) => { console.log('Promise returned with the CameraInput instance'); })
-
In CameraManager, the input parameter profile: Profile is added to createPreviewOutput and the profile parameter is obtained by the getSupportedOutputCapability API. Therefore, the createPreviewOutput(surfaceId: string, callback: AsyncCallback
): void; and createPreviewOutput(surfaceId: string): Promise; APIs are changed to createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void; and createPreviewOutput(profile: Profile, surfaceId: string): Promise; .The code snippet is as follows:
let profile = cameraoutputcapability.previewProfiles[0]; cameraManager.createPreviewOutput(profile, surfaceId, (err, previewOutput) => { if (err) { console.error(`Failed to gcreate previewOutput. ${err.message}`); return; } console.log('Callback returned with previewOutput created.'); })
let profile = cameraoutputcapability.previewProfiles[0]; cameraManager.createPreviewOutput(profile, surfaceId).then((previewOutput) => { console.log('Promise returned with previewOutput created.'); })
-
In CameraManager, the input parameter profile: Profile is added to createPhotoOutput and the profile parameter is obtained by the getSupportedOutputCapability API. Therefore, the CreatePhotoOutput(surfaceId: string, callback: AsyncCallback
): void; and CreatePhotoOutput(surfaceId: string): Promise; APIs are changed to createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void; and createPhotoOutput(profile: Profile, surfaceId: string): Promise; .The code snippet is as follows:
let profile = cameraoutputcapability.photoProfiles[0]; cameraManager.createPhotoOutput(profile, surfaceId, (err, photoOutput) => { if (err) { console.error(`Failed to create photoOutput. ${err.message}`); return; } console.log('Callback returned with photoOutput created.'); })
let profile = cameraoutputcapability.photoProfiles[0]; cameraManager.createPhotoOutput(profile, surfaceId).then((photoOutput) => { console.log('Promise returned with photoOutput created.'); })
-
In CameraManager, the input parameter profile: Profile is added to createVideoOutput and the profile parameter is obtained by the getSupportedOutputCapability API. Therefore, the createVideoOutput(surfaceId: string, callback: AsyncCallback
): void; and createVideoOutput(surfaceId: string): Promise; APIs are changed to createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void; and createVideoOutput(profile: VideoProfile, surfaceId: string): Promise; .The code snippet is as follows:
let profile = cameraoutputcapability.videoProfiles[0]; cameraManager.createVideoOutput(profile, surfaceId, (err, videoOutput) => { if (err) { console.error(`Failed to create videoOutput. ${err.message}`); return; } console.log('Callback returned with an array of supported outputCapability' ); })
let profile = cameraoutputcapability.videoProfiles[0]; cameraManager.createVideoOutput(profile, surfaceId).then((videoOutput) => { console.log('Promise returned with videoOutput created.'); })
-
In CameraManager, the input parameter metadataObjectTypes: Array
is added to createMetadataOutput, and the metadataObjectTypes parameter is obtained by the getSupportedOutputCapability API. Therefore, the function createMetadataOutput(callback: AsyncCallback ): void; and function createMetadataOutput(): Promise; APIs are changed to createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback and createMetadataOutput(metadataObjectTypes: Array): void; ): Promise .; The code snippet is as follows:
let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes; cameraManager.createMetadataOutput(metadataObjectTypes, (err, metadataOutput) => { if (err) { console.error(`Failed to create metadataOutput. ${err.message}`); return; } console.log('Callback returned with metadataOutput created.'); })
let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes; cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataOutput) => { console.log('Promise returned with metadataOutput created.'); })
-
In CameraManager, createCaptureSession does not need to consider the context attribute. Therefore, the createCaptureSession(context: Context, callback: AsyncCallback
): void; and createCaptureSession(context: Context): Promise; APIs are changed to createCaptureSession(callback: AsyncCallback): void; and createCaptureSession(): Promise; .The code snippet is as follows:
cameraManager.createCaptureSession((err, captureSession) => { if (err) { console.error(`Failed to create captureSession. ${err.message}`); return; } console.log('Callback returned with captureSession created.'); })
cameraManager.createCaptureSession().then((captureSession) => { console.log('Promise returned with captureSession created.'); })
-
The type of the camera attribute of the CameraStatusInfo API is changed from Camera to CameraDevice.
-
In CameraInput, the input parameter camera: CameraDevice is added to the on(type: 'error') API. Therefore, the on(type: 'error', callback: ErrorCallback
): void; API is changed to on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; .The code snippet is as follows:
let cameraDevice = cameras[0]; cameraInput.on('error', cameraDevice, (cameraInputError) => { console.log(`Camera input error code: ${cameraInputError.code}`); })
-
The following APIs are moved from CameraInput to CaptureSession:
hasFlash(callback: AsyncCallback
): void;
hasFlash(): Promise; isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback
): void;
isFlashModeSupported(flashMode: FlashMode): Promise; getFlashMode(callback: AsyncCallback
): void;
getFlashMode(): Promise; setFlashMode(flashMode: FlashMode, callback: AsyncCallback
): void;
setFlashMode(flashMode: FlashMode): Promise; isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback
): void;
isExposureModeSupported(aeMode: ExposureMode): Promise; getExposureMode(callback: AsyncCallback
): void;
getExposureMode(): Promise; setExposureMode(aeMode: ExposureMode, callback: AsyncCallback
): void;
setExposureMode(aeMode: ExposureMode): Promise; getMeteringPoint(callback: AsyncCallback
): void;
getMeteringPoint(): Promise; setMeteringPoint(point: Point, callback: AsyncCallback
): void;
setMeteringPoint(point: Point): Promise; getExposureBiasRange(callback: AsyncCallback<Array
>): void;
getExposureBiasRange(): Promise<Array>; setExposureBias(exposureBias: number, callback: AsyncCallback
): void;
setExposureBias(exposureBias: number): Promise; getExposureValue(callback: AsyncCallback
): void;
getExposureValue(): Promise; isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback
): void;
isFocusModeSupported(afMode: FocusMode): Promise; getFocusMode(callback: AsyncCallback
): void;
getFocusMode(): Promise; setFocusMode(afMode: FocusMode, callback: AsyncCallback
): void;
setFocusMode(afMode: FocusMode): Promise; setFocusPoint(point: Point, callback: AsyncCallback
): void;
setFocusPoint(point: Point): Promise; getFocusPoint(callback: AsyncCallback
): void;
getFocusPoint(): Promise; getFocalLength(callback: AsyncCallback
): void;
getFocalLength(): Promise; getZoomRatioRange(callback: AsyncCallback<Array
>): void;
getZoomRatioRange(): Promise<Array>; getZoomRatio(callback: AsyncCallback
): void;
getZoomRatio(): Promise; setZoomRatio(zoomRatio: number, callback: AsyncCallback
): void;
setZoomRatio(zoomRatio: number): Promise; -
The on(type: 'focusStateChange', callback: AsyncCallback
): void; API is moved from CameraInput to CaptureSession.The code snippet is as follows:
captureSession.on('focusStateChange', (focusState) => { console.log(`Focus state : ${focusState}`); })
-
The following enums are added to ExposureMode:
Enum: EXPOSURE_MODE_AUTO; initial value: changed from the default value to 1
Enum: EXPOSURE_MODE_CONTINUOUS_AUTO; initial value: changed from the default value to 2
-
The following enums are added to VideoStabilizationMode:
Enum: LOW; initial value: changed from the default value to 1
Enum: MIDDLE; initial value: changed from the default value to 2
Enum: HIGH; initial value: changed from the default value to 3
Enum: AUTO; initial value: changed from the default value to 4
-
In CaptureSession, the parameter of the addOutput API is changed from the original child class type (PreviewOutput, PhotoOutput, VideoOutput, and MetadataOutput) to the base class type (CameraOutput). After the change, the number of APIs is reduced from 8 to 2.
APIs before change:
addOutput(previewOutput: PreviewOutput, callback: AsyncCallback
): void;
addOutput(previewOutput: PreviewOutput): Promise;
addOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void;
addOutput(photoOutput: PhotoOutput): Promise;
addOutput(videoOutput: VideoOutput, callback: AsyncCallback): void;
addOutput(videoOutput: VideoOutput): Promise;
addOutput(metadataOutput: MetadataOutput, callback: AsyncCallback): void;
addOutput(metadataOutput: MetadataOutput): Promise; APIs after change:
addOutput(cameraOutput: CameraOutput, callback: AsyncCallback
): void;
addOutput(cameraOutput: CameraOutput): Promise; The sample code (for previewOutput) is as follows:
captureSession.addOutput(previewOutput, (err) => { if (err) { console.error(`Failed to add output. ${err.message}`); return; } console.log('Callback returned with output added.'); })
captureSession.addOutput(previewOutput).then(() => { console.log('Promise returned with cameraOutput added.'); })
-
In CaptureSession, the parameter of the removeOutput API is changed from the original child class type (PreviewOutput, PhotoOutput, VideoOutput, and MetadataOutput) to the base class type (CameraOutput). After the change, the number of APIs is reduced from 8 to 2.
APIs before change:
removeOutput(previewOutput: PreviewOutput, callback: AsyncCallback
): void;
removeOutput(previewOutput: PreviewOutput): Promise;
removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void;
removeOutput(photoOutput: PhotoOutput): Promise;
removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void;
removeOutput(videoOutput: VideoOutput): Promise;
removeOutput(metadataOutput: MetadataOutput, callback: AsyncCallback): void;
removeOutput(metadataOutput: MetadataOutput): Promise; APIs after change:
removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback
): void;
removeOutput(cameraOutput: CameraOutput): Promise; The sample code (for previewOutput) is as follows:
captureSession.removeOutput(previewOutput, (err) => { if (err) { console.error(`Failed to remove the CameraOutput instance. ${err.message}`); return; } console.log('Callback invoked to indicate that the CameraOutput instance is removed.'); });
captureSession.removeOutput(previewOutput).then(() => { console.log('Promise returned to indicate that the CameraOutput instance is removed.'); })
-
The following enum in MetadataObjectType is changed:
The enum value name is changed from FACE to FACE_DETECTION.
-
The name of the Camera API is changed to CameraDevice.