harmony 鸿蒙ChangeLog of JS API Changes in the Multimedia Subsystem

  • 2023-02-03
  • 浏览 (489)

ChangeLog of JS API Changes in the Multimedia Subsystem

Compared with OpenHarmony 3.2 Beta3, OpenHarmony 3.2 Beta4 has the following changes in APIs of the camera component in the multimedia subsystem.

Camera API Changes

Some functional APIs are added and some others are deprecated to: 1. Improve the usability of camera APIs. 2. Help you quickly understand camera APIs and use them for development. 3. 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 Impacts

JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement functions in the SDK environment of the new version.

Key API/Component Changes

Module Class Method/Attribute/Enumeration/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>): void;
getSupportedCameras(): Promise>;
Added
ohos.multimedia.camera CameraManager getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void;
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): void;
createCameraInput(camera: CameraDevice): Promise;
Added
ohos.multimedia.camera CameraManager createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;
createPreviewOutput(profile: Profile, surfaceId: string): Promise;
Added
ohos.multimedia.camera CameraManager createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;
createPhotoOutput(profile: Profile, surfaceId: string): Promise;
Added
ohos.multimedia.camera CameraManager createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void;
createVideoOutput(profile: VideoProfile, surfaceId: string): Promise;
Added
ohos.multimedia.camera CameraManager createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void;
createMetadataOutput(metadataObjectTypes: Array): Promise;
Added
ohos.multimedia.camera CameraManager createCaptureSession(callback: AsyncCallback): void;
createCaptureSession(): Promise;
Added
ohos.multimedia.camera CameraManager on(type: ‘cameraMute’, callback: AsyncCallback): void; Added
ohos.multimedia.camera CameraManager getCameras(callback: AsyncCallback>): void;
getCameras(): Promise>;
Deprecated
ohos.multimedia.camera CameraManager createCameraInput(cameraId: string, callback: AsyncCallback): void;
createCameraInput(cameraId: string): Promise;
Deprecated
ohos.multimedia.camera CameraManager createCaptureSession(context: Context, callback: AsyncCallback): void;
createCaptureSession(context: Context): Promise;
Deprecated
ohos.multimedia.camera CameraManager createPreviewOutput(surfaceId: string, callback: AsyncCallback): void;
createPreviewOutput(surfaceId: string): Promise;
Deprecated
ohos.multimedia.camera CameraManager CreatePhotoOutput(surfaceId: string, callback: AsyncCallback): void;
CreatePhotoOutput(surfaceId: string): Promise;
Deprecated
ohos.multimedia.camera CameraManager createVideoOutput(surfaceId: string, callback: AsyncCallback): void;
createVideoOutput(surfaceId: string): Promise;
Deprecated
ohos.multimedia.camera CameraManager createMetadataOutput(callback: AsyncCallback): void;
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): void;
open(): Promise;
Added
ohos.multimedia.camera CameraInput close(callback: AsyncCallback): void;
close(): Promise;
Added
ohos.multimedia.camera CameraInput on(type: ‘error’, camera: CameraDevice, callback: ErrorCallback): void; Added
ohos.multimedia.camera CameraInput isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
Deprecated
ohos.multimedia.camera CameraInput getFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
Deprecated
ohos.multimedia.camera CameraInput setFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
Deprecated
ohos.multimedia.camera CameraInput getZoomRatioRange(callback: AsyncCallback>): void;
getZoomRatioRange(): Promise>;
Deprecated
ohos.multimedia.camera CameraInput getZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
Deprecated
ohos.multimedia.camera CameraInput setZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise;
Deprecated
ohos.multimedia.camera CameraInput getCameraId(callback: AsyncCallback): void;
getCameraId(): Promise;
Deprecated
ohos.multimedia.camera CameraInput getExposurePoint(callback: AsyncCallback): void;
getExposurePoint(): Promise;
Deprecated
ohos.multimedia.camera CameraInput setExposurePoint(exposurePoint: Point, callback: AsyncCallback): void;
setExposurePoint(exposurePoint: Point): Promise;
Deprecated
ohos.multimedia.camera CameraInput hasFlash(callback: AsyncCallback): void;
hasFlash(): Promise;
Deprecated
ohos.multimedia.camera CameraInput isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void;
isFlashModeSupported(flashMode: FlashMode): Promise;
Deprecated
ohos.multimedia.camera CameraInput getFlashMode(callback: AsyncCallback): void;
getFlashMode(): Promise;
Deprecated
ohos.multimedia.camera CameraInput setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void;
setFlashMode(flashMode: FlashMode): Promise;
Deprecated
ohos.multimedia.camera CameraInput isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void;
isExposureModeSupported(aeMode: ExposureMode): Promise;
Deprecated
ohos.multimedia.camera CameraInput getExposureMode(callback: AsyncCallback): void;
getExposureMode(): Promise;
Deprecated
ohos.multimedia.camera CameraInput setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void;
setExposureMode(aeMode: ExposureMode): Promise;
Deprecated
ohos.multimedia.camera CameraInput getMeteringPoint(callback: AsyncCallback): void;
getMeteringPoint(): Promise;
Deprecated
ohos.multimedia.camera CameraInput setMeteringPoint(point: Point, callback: AsyncCallback): void;
setMeteringPoint(point: Point): Promise;
Deprecated
ohos.multimedia.camera CameraInput getExposureBiasRange(callback: AsyncCallback>): void;
getExposureBiasRange(): Promise>;
Deprecated
ohos.multimedia.camera CameraInput setExposureBias(exposureBias: number, callback: AsyncCallback): void;
setExposureBias(exposureBias: number): Promise;
Deprecated
ohos.multimedia.camera CameraInput getExposureValue(callback: AsyncCallback): void;
getExposureValue(): Promise;
Deprecated
ohos.multimedia.camera CameraInput isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
Deprecated
ohos.multimedia.camera CameraInput getFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
Deprecated
ohos.multimedia.camera CameraInput setFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
Deprecated
ohos.multimedia.camera CameraInput setFocusPoint(point: Point, callback: AsyncCallback): void;
setFocusPoint(point: Point): Promise;
Deprecated
ohos.multimedia.camera CameraInput getFocusPoint(callback: AsyncCallback): void;
getFocusPoint(): Promise;
Deprecated
ohos.multimedia.camera CameraInput getFocalLength(callback: AsyncCallback): void;
getFocalLength(): Promise;
Deprecated
ohos.multimedia.camera CameraInput getZoomRatioRange(callback: AsyncCallback>): void;
getZoomRatioRange(): Promise>;
Deprecated
ohos.multimedia.camera CameraInput getZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
Deprecated
ohos.multimedia.camera CameraInput setZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise;
Deprecated
ohos.multimedia.camera CameraInput on(type: ‘focusStateChange’, callback: AsyncCallback): void; Deprecated
ohos.multimedia.camera CameraInput on(type: ‘exposureStateChange’, callback: AsyncCallback): void; Deprecated
ohos.multimedia.camera CameraInput on(type: ‘error’, callback: ErrorCallback): void; 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): void;
addOutput(cameraOutput: CameraOutput): Promise;
Added
ohos.multimedia.camera CaptureSession removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
removeOutput(cameraOutput: CameraOutput): Promise;
Added
ohos.multimedia.camera CaptureSession isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback): void;
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise;
Added
ohos.multimedia.camera CaptureSession getActiveVideoStabilizationMode(callback: AsyncCallback): void;
getActiveVideoStabilizationMode(): Promise;
Added
ohos.multimedia.camera CaptureSession setVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void;
setVideoStabilizationMode(mode: VideoStabilizationMode): Promise;
Added
ohos.multimedia.camera CaptureSession on(type: ‘focusStateChange’, callback: AsyncCallback): void; Added
ohos.multimedia.camera CaptureSession hasFlash(callback: AsyncCallback): void;
hasFlash(): Promise;
Added
ohos.multimedia.camera CaptureSession isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void;
isFlashModeSupported(flashMode: FlashMode): Promise;
Added
ohos.multimedia.camera CaptureSession getFlashMode(callback: AsyncCallback): void;
getFlashMode(): Promise;
Added
ohos.multimedia.camera CaptureSession setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void;
setFlashMode(flashMode: FlashMode): Promise;
Added
ohos.multimedia.camera CaptureSession isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void;
isExposureModeSupported(aeMode: ExposureMode): Promise;
Added
ohos.multimedia.camera CaptureSession getExposureMode(callback: AsyncCallback): void;
getExposureMode(): Promise;
Added
ohos.multimedia.camera CaptureSession setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void;
setExposureMode(aeMode: ExposureMode): Promise;
Added
ohos.multimedia.camera CaptureSession getMeteringPoint(callback: AsyncCallback): void;
getMeteringPoint(): Promise;
Added
ohos.multimedia.camera CaptureSession setMeteringPoint(point: Point, callback: AsyncCallback): void;
setMeteringPoint(point: Point): Promise;
Added
ohos.multimedia.camera CaptureSession getExposureBiasRange(callback: AsyncCallback>): void;
getExposureBiasRange(): Promise>;
Added
ohos.multimedia.camera CaptureSession setExposureBias(exposureBias: number, callback: AsyncCallback): void;
setExposureBias(exposureBias: number): Promise;
Added
ohos.multimedia.camera CaptureSession getExposureValue(callback: AsyncCallback): void;
getExposureValue(): Promise;
Added
ohos.multimedia.camera CaptureSession isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
Added
ohos.multimedia.camera CaptureSession getFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
Added
ohos.multimedia.camera CaptureSession setFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
Added
ohos.multimedia.camera CaptureSession setFocusPoint(point: Point, callback: AsyncCallback): void;
setFocusPoint(point: Point): Promise;
Added
ohos.multimedia.camera CaptureSession getFocusPoint(callback: AsyncCallback): void;
getFocusPoint(): Promise;
Added
ohos.multimedia.camera CaptureSession getFocalLength(callback: AsyncCallback): void;
getFocalLength(): Promise;
Added
ohos.multimedia.camera CaptureSession getZoomRatioRange(callback: AsyncCallback>): void;
getZoomRatioRange(): Promise>;
Added
ohos.multimedia.camera CaptureSession getZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
Added
ohos.multimedia.camera CaptureSession setZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise;
Added
ohos.multimedia.camera CaptureSession 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;
Deprecated
ohos.multimedia.camera CaptureSession 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;
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): void;
release(): Promise;
Added
ohos.multimedia.camera PreviewOutput start(callback: AsyncCallback): void;
start(): Promise;
Added
ohos.multimedia.camera PreviewOutput stop(callback: AsyncCallback): void;
stop(): Promise;
Added
ohos.multimedia.camera PreviewOutput release(callback: AsyncCallback): void;
release(): Promise;
Deprecated
ohos.multimedia.camera PhotoOutput release(callback: AsyncCallback): void;
release(): Promise;
Deprecated
ohos.multimedia.camera VideoOutput release(callback: AsyncCallback): void;
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): void; Added
ohos.multimedia.camera MetadataOutput setCapturingMetadataObjectTypes(metadataObjectTypes: Array, callback: AsyncCallback): void;
setCapturingMetadataObjectTypes(metadataObjectTypes: Array): Promise;
Deprecated
ohos.multimedia.camera MetadataOutput getSupportedMetadataObjectTypes(callback: AsyncCallback>): void;
getSupportedMetadataObjectTypes(): Promise>;
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

  1. Profile API

Attribute 1: readonly format; type: CameraFormat

Attribute 2: readonly size; type: Size

  1. FrameRateRange API

Attribute 1: readonly min; type: number

Attribute 2: readonly max; type: number

  1. VideoProfile API (inherited from Profile)

Attribute: readonly frameRateRange; type: FrameRateRange

  1. 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

  1. The following APIs are added to CameraManager:

getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void;

getSupportedOutputCapability(camera: CameraDevice): Promise;

The sample code 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');
       })
   })
  1. The isCameraMuted(): boolean; API is added to CameraManager.

The sample code is as follows:

   let ismuted = cameraManager.isCameraMuted();
  1. The isCameraMuteSupported(): boolean; API is added to CameraManager.

The sample code is as follows:

   let ismutesuppotred = cameraManager.isCameraMuteSupported();
  1. The muteCamera(mute: boolean): void; API is added to CameraManager.

The sample code is as follows:

   let mute = true;
   cameraManager.muteCamera(mute);
  1. The on(type: ‘cameraMute’, callback: AsyncCallback): void; API is added to CameraManager.

The sample code is as follows:

   cameraManager.on('cameraMute', (err, curMuetd) => {
       if (err) {
           console.error(`Failed to get cameraMute callback. ${err.message}`);
           return;
       }
   })
  1. The open(callback: AsyncCallback): void; and open(): Promise; APIs are added to CameraInput.

The sample code 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.');
})
  1. The close(callback: AsyncCallback): void; and close(): Promise; APIs are added to CameraInput.

    The sample code 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.');
    })
    
  2. The following enumerations are added to CameraInputErrorCode:

    Enumeration: ERROR_NO_PERMISSION; value: 0

    Enumeration: ERROR_DEVICE_PREEMPTED; value: 1

    Enumeration: ERROR_DEVICE_DISCONNECTED; value: 2

    Enumeration: ERROR_DEVICE_IN_USE; value: 3

    Enumeration: ERROR_DRIVER_ERROR; value: 4

  3. The following enumeration is added to CameraFormat:

    Enumeration: CAMERA_FORMAT_RGBA_8888; value: 3

  4. The getMeteringPoint(callback: AsyncCallback): void; and getMeteringPoint(): Promise; APIs are added to CaptureSession.

    The sample code 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}`);
    })
    
  5. The setMeteringPoint(point: Point, callback: AsyncCallback): void; and setMeteringPoint(point: Point): Promise; APIs are added to CaptureSession.

    The sample code 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');
    })
    
  6. The following enumerations are added to CaptureSessionErrorCode:

    Enumeration: ERROR_INSUFFICIENT_RESOURCES; value: 0

    Enumeration: ERROR_TIMEOUT; value: 1

  7. 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.');
    })
    
  8. The start(callback: AsyncCallback): void; and start(): Promise; APIs are added to PreviewOutput.

    The sample code 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.');
    })
    
  9. The stop(callback: AsyncCallback): void; and stop(): Promise; APIs are added to PreviewOutput.

    The sample code 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.');
    })
    
  10. PhotoCaptureSetting API

    Attribute 1: mirror?; type: boolean

  11. The following enumerations are added to PhotoOutputErrorCode:

    Enumeration: ERROR_DRIVER_ERROR; value: 0

    Enumeration: ERROR_INSUFFICIENT_RESOURCES; value: 1

    Enumeration: ERROR_TIMEOUT; value: 2

  12. The following enumeration is added to VideoOutputErrorCode:

    Enumeration: ERROR_DRIVER_ERROR; value: 0

  13. The on(type: ‘error’, callback: ErrorCallback): void; API is added to MetadataOutput.

    The sample code is as follows:

    metadataOutput.on('error', (metadataOutputError) => {
        console.log(`Metadata output error code: ${metadataOutputError.code}`);
    })
    
  14. The following enumerations are added to MetadataOutputErrorCode.

    Enumeration: ERROR_UNKNOWN; value: -1

    Enumeration: ERROR_INSUFFICIENT_RESOURCES; value: 0

  15. MetadataOutputError API

    Attribute: code; value: MetadataOutputErrorCode

Deprecated APIs

  1. The on(type: ‘exposureStateChange’, callback: AsyncCallback): void; API in CameraInput is deprecated.

  2. The release(callback: AsyncCallback): void; and release(): Promise; APIs in previewOutput are deprecated.

  3. The following APIs in metadataOutput are deprecated:

setCapturingMetadataObjectTypes(metadataObjectTypes: Array, callback: AsyncCallback): void;
setCapturingMetadataObjectTypes(metadataObjectTypes: Array): Promise;

  1. The following APIs in metadataOutput are deprecated:

getSupportedMetadataObjectTypes(callback: AsyncCallback>): void;
getSupportedMetadataObjectTypes(): Promise>;

  1. The release(callback: AsyncCallback): void; and release(): Promise; APIs in PreviewOutput are deprecated.

  2. The release(callback: AsyncCallback): void; and release(): Promise; APIs in PhotoOutput are deprecated.

  3. The release(callback: AsyncCallback): void; and release(): Promise; APIs in VideoOutput are deprecated.

  4. The getCameraId(callback: AsyncCallback): void; and getCameraId(): Promise; APIs in CameraInput are deprecated.

  5. The getExposurePoint(callback: AsyncCallback): void; and getExposurePoint(): Promise; APIs in CameraInput are deprecated.

  6. The setExposurePoint(exposurePoint: Point, callback: AsyncCallback): void; and setExposurePoint(exposurePoint: Point): Promise; APIs in CameraInput are deprecated.

Changed APIs

  1. 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>): void; and getCameras(): Promise>; APIs are changed to getSupportedCameras(callback: AsyncCallback>): void and getSupportedCameras(): Promise>;.

The sample code 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}`);
   })
  1. 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 sample code 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');
   })
  1. 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 sample code 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.');
   })
  1. 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 sample code 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.');
   })
  1. 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 sample code 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.');
   })
  1. 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): void; and createMetadataOutput(metadataObjectTypes: Array): Promise;.

The sample code 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.');
   })
  1. 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 sample code 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.');
   })
  1. The type of the camera attribute of the CameraStatusInfo API is changed from Camera to CameraDevice.

  2. 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 sample code is as follows:

   let cameraDevice = cameras[0];
   cameraInput.on('error', cameraDevice, (cameraInputError) => {
       console.log(`Camera input error code: ${cameraInputError.code}`);
   })
  1. 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>): void;
    getExposureBiasRange(): Promise>;

    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>): void;
    getZoomRatioRange(): Promise>;

    getZoomRatio(callback: AsyncCallback): void;
    getZoomRatio(): Promise;

    setZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
    setZoomRatio(zoomRatio: number): Promise;

  2. The on(type: ‘focusStateChange’, callback: AsyncCallback): void; API is moved from CameraInput to CaptureSession.

    The sample code is as follows:

    captureSession.on('focusStateChange', (focusState) => {
        console.log(`Focus state  : ${focusState}`);
    })
    
  3. The following enumerations are added to ExposureMode:

    Enumeration: EXPOSURE_MODE_AUTO; initial value: changed from the default value to 1

    Enumeration: EXPOSURE_MODE_CONTINUOUS_AUTO; initial value: changed from the default value to 2

  4. The following enumerations are added to VideoStabilizationMode:

    Enumeration: LOW; initial value: changed from the default value to 1

    Enumeration: MIDDLE; initial value: changed from the default value to 2

    Enumeration: HIGH; initial value: changed from the default value to 3

    Enumeration: AUTO; initial value: changed from the default value to 4

  5. In CaptureSession, the parameter of the addOutput API is changed from the original subclass 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.');
    })
    
  6. In CaptureSession, the parameter of the removeOutput API is changed from the original subclass 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.');
    })
    
  7. The following enumeration in MetadataObjectType is changed:

    The enumeration value name is changed from FACE to FACE_DETECTION.

  8. The name of the Camera API is changed to CameraDevice.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Account Subsystem ChangeLog

harmony 鸿蒙Device Manager ChangeLog

harmony 鸿蒙USB Manager ChangeLog

harmony 鸿蒙DSoftBus Subsystem ChangeLog

harmony 鸿蒙File Management Subsystem ChangeLog

harmony 鸿蒙Globalization Subsystem ChangeLog

harmony 鸿蒙Input Method Framework ChangeLog

harmony 鸿蒙Multimodal Input ChangeLog

harmony 鸿蒙Power Subsystem ChangeLog

harmony 鸿蒙Upload and Download Subsystem ChangeLog

0  赞