openharmony 鸿蒙 changelogs-camera

2023-02-03 浏览 (603)

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

ModuleClassMethod/Attribute/Enumeration/ConstantChange Type
ohos.multimedia.cameraProfilereadonly format:CameraFormat;Added
ohos.multimedia.cameraProfilereadonly size: Size;Added
ohos.multimedia.cameraFrameRateRangereadonly min: number;Added
ohos.multimedia.cameraFrameRateRangereadonly max: number;Added
ohos.multimedia.cameraVideoProfilereadonly frameRateRange: FrameRateRange;Added
ohos.multimedia.cameraCameraOutputCapabilityreadonly previewProfiles: Array;Added
ohos.multimedia.cameraCameraOutputCapabilityreadonly photoProfiles: Array;Added
ohos.multimedia.cameraCameraOutputCapabilityreadonly videoProfiles: Array;Added
ohos.multimedia.cameraCameraOutputCapabilityreadonly supportedMetadataObjectTypes: Array;Added
ohos.multimedia.cameraCameraManagergetSupportedCameras(callback: AsyncCallback<Array>): void;
getSupportedCameras(): Promise<Array>;
Added
ohos.multimedia.cameraCameraManagergetSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void;
getSupportedOutputCapability(camera: CameraDevice): Promise;
Added
ohos.multimedia.cameraCameraManagerisCameraMuted(): boolean;Added
ohos.multimedia.cameraCameraManagerisCameraMuteSupported(): boolean;Added
ohos.multimedia.cameraCameraManagermuteCamera(mute: boolean): void;Added
ohos.multimedia.cameraCameraManagercreateCameraInput(camera: CameraDevice, callback: AsyncCallback): void;
createCameraInput(camera: CameraDevice): Promise;
Added
ohos.multimedia.cameraCameraManagercreatePreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;
createPreviewOutput(profile: Profile, surfaceId: string): Promise;
Added
ohos.multimedia.cameraCameraManagercreatePhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;
createPhotoOutput(profile: Profile, surfaceId: string): Promise;
Added
ohos.multimedia.cameraCameraManagercreateVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void;
createVideoOutput(profile: VideoProfile, surfaceId: string): Promise;
Added
ohos.multimedia.cameraCameraManagercreateMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void;
createMetadataOutput(metadataObjectTypes: Array): Promise;
Added
ohos.multimedia.cameraCameraManagercreateCaptureSession(callback: AsyncCallback): void;
createCaptureSession(): Promise;
Added
ohos.multimedia.cameraCameraManageron(type: 'cameraMute', callback: AsyncCallback): void;Added
ohos.multimedia.cameraCameraManagergetCameras(callback: AsyncCallback<Array>): void;
getCameras(): Promise<Array>;
Deprecated
ohos.multimedia.cameraCameraManagercreateCameraInput(cameraId: string, callback: AsyncCallback): void;
createCameraInput(cameraId: string): Promise;
Deprecated
ohos.multimedia.cameraCameraManagercreateCaptureSession(context: Context, callback: AsyncCallback): void;
createCaptureSession(context: Context): Promise;
Deprecated
ohos.multimedia.cameraCameraManagercreatePreviewOutput(surfaceId: string, callback: AsyncCallback): void;
createPreviewOutput(surfaceId: string): Promise;
Deprecated
ohos.multimedia.cameraCameraManagerCreatePhotoOutput(surfaceId: string, callback: AsyncCallback): void;
CreatePhotoOutput(surfaceId: string): Promise;
Deprecated
ohos.multimedia.cameraCameraManagercreateVideoOutput(surfaceId: string, callback: AsyncCallback): void;
createVideoOutput(surfaceId: string): Promise;
Deprecated
ohos.multimedia.cameraCameraManagercreateMetadataOutput(callback: AsyncCallback): void;
createVideoOutput(): Promise;
Deprecated
ohos.multimedia.cameraCameraStatusInfocamera: CameraDevice;Added
ohos.multimedia.cameraCameraStatusInfocamera: Camera;Deprecated
ohos.multimedia.cameraCameraDeviceinterface CameraDeviceAdded
ohos.multimedia.cameraCamerainterface CameraDeprecated
ohos.multimedia.cameraCameraInputopen(callback: AsyncCallback): void;
open(): Promise;
Added
ohos.multimedia.cameraCameraInputclose(callback: AsyncCallback): void;
close(): Promise;
Added
ohos.multimedia.cameraCameraInputon(type: 'error', camera: CameraDevice, callback: ErrorCallback): void;Added
ohos.multimedia.cameraCameraInputisFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetZoomRatioRange(callback: AsyncCallback<Array>): void;
getZoomRatioRange(): Promise<Array>;
Deprecated
ohos.multimedia.cameraCameraInputgetZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetCameraId(callback: AsyncCallback): void;
getCameraId(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetExposurePoint(callback: AsyncCallback): void;
getExposurePoint(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetExposurePoint(exposurePoint: Point, callback: AsyncCallback): void;
setExposurePoint(exposurePoint: Point): Promise;
Deprecated
ohos.multimedia.cameraCameraInputhasFlash(callback: AsyncCallback): void;
hasFlash(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputisFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void;
isFlashModeSupported(flashMode: FlashMode): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetFlashMode(callback: AsyncCallback): void;
getFlashMode(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetFlashMode(flashMode: FlashMode, callback: AsyncCallback): void;
setFlashMode(flashMode: FlashMode): Promise;
Deprecated
ohos.multimedia.cameraCameraInputisExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void;
isExposureModeSupported(aeMode: ExposureMode): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetExposureMode(callback: AsyncCallback): void;
getExposureMode(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void;
setExposureMode(aeMode: ExposureMode): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetMeteringPoint(callback: AsyncCallback): void;
getMeteringPoint(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetMeteringPoint(point: Point, callback: AsyncCallback): void;
setMeteringPoint(point: Point): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetExposureBiasRange(callback: AsyncCallback<Array>): void;
getExposureBiasRange(): Promise<Array>;
Deprecated
ohos.multimedia.cameraCameraInputsetExposureBias(exposureBias: number, callback: AsyncCallback): void;
setExposureBias(exposureBias: number): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetExposureValue(callback: AsyncCallback): void;
getExposureValue(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputisFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetFocusPoint(point: Point, callback: AsyncCallback): void;
setFocusPoint(point: Point): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetFocusPoint(callback: AsyncCallback): void;
getFocusPoint(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetFocalLength(callback: AsyncCallback): void;
getFocalLength(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputgetZoomRatioRange(callback: AsyncCallback<Array>): void;
getZoomRatioRange(): Promise<Array>;
Deprecated
ohos.multimedia.cameraCameraInputgetZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
Deprecated
ohos.multimedia.cameraCameraInputsetZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise;
Deprecated
ohos.multimedia.cameraCameraInputon(type: 'focusStateChange', callback: AsyncCallback): void;Deprecated
ohos.multimedia.cameraCameraInputon(type: 'exposureStateChange', callback: AsyncCallback): void;Deprecated
ohos.multimedia.cameraCameraInputon(type: 'error', callback: ErrorCallback): void;Deprecated
ohos.multimedia.cameraCameraInputErrorCodeERROR_NO_PERMISSION = 0Added
ohos.multimedia.cameraCameraInputErrorCodeERROR_DEVICE_PREEMPTED = 1Added
ohos.multimedia.cameraCameraInputErrorCodeERROR_DEVICE_DISCONNECTED = 2Added
ohos.multimedia.cameraCameraInputErrorCodeERROR_DEVICE_IN_USE = 3Added
ohos.multimedia.cameraCameraInputErrorCodeERROR_DRIVER_ERROR = 4Added
ohos.multimedia.cameraCameraFormatCAMERA_FORMAT_RGBA_8888 = 3Added
ohos.multimedia.cameraExposureModeEXPOSURE_MODE_AUTO = 1Added
ohos.multimedia.cameraExposureModeEXPOSURE_MODE_CONTINUOUS_AUTO = 2Added
ohos.multimedia.cameraExposureModeEXPOSURE_MODE_AUTODeprecated
ohos.multimedia.cameraExposureModeEXPOSURE_MODE_CONTINUOUS_AUTODeprecated
ohos.multimedia.cameraVideoStabilizationModeLOW = 1Added
ohos.multimedia.cameraVideoStabilizationModeMIDDLE = 2Added
ohos.multimedia.cameraVideoStabilizationModeHIGH = 3Added
ohos.multimedia.cameraVideoStabilizationModeAUTO = 4Added
ohos.multimedia.cameraVideoStabilizationModeLOWDeprecated
ohos.multimedia.cameraVideoStabilizationModeMIDDLEDeprecated
ohos.multimedia.cameraVideoStabilizationModeHIGHDeprecated
ohos.multimedia.cameraVideoStabilizationModeAUTODeprecated
ohos.multimedia.cameraCaptureSessionaddOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
addOutput(cameraOutput: CameraOutput): Promise;
Added
ohos.multimedia.cameraCaptureSessionremoveOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
removeOutput(cameraOutput: CameraOutput): Promise;
Added
ohos.multimedia.cameraCaptureSessionisVideoStabilizationModeSupported(vsMode: VideoStabilizationMode, callback: AsyncCallback): void;
isVideoStabilizationModeSupported(vsMode: VideoStabilizationMode): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetActiveVideoStabilizationMode(callback: AsyncCallback): void;
getActiveVideoStabilizationMode(): Promise;
Added
ohos.multimedia.cameraCaptureSessionsetVideoStabilizationMode(mode: VideoStabilizationMode, callback: AsyncCallback): void;
setVideoStabilizationMode(mode: VideoStabilizationMode): Promise;
Added
ohos.multimedia.cameraCaptureSessionon(type: 'focusStateChange', callback: AsyncCallback): void;Added
ohos.multimedia.cameraCaptureSessionhasFlash(callback: AsyncCallback): void;
hasFlash(): Promise;
Added
ohos.multimedia.cameraCaptureSessionisFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void;
isFlashModeSupported(flashMode: FlashMode): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetFlashMode(callback: AsyncCallback): void;
getFlashMode(): Promise;
Added
ohos.multimedia.cameraCaptureSessionsetFlashMode(flashMode: FlashMode, callback: AsyncCallback): void;
setFlashMode(flashMode: FlashMode): Promise;
Added
ohos.multimedia.cameraCaptureSessionisExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void;
isExposureModeSupported(aeMode: ExposureMode): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetExposureMode(callback: AsyncCallback): void;
getExposureMode(): Promise;
Added
ohos.multimedia.cameraCaptureSessionsetExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void;
setExposureMode(aeMode: ExposureMode): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetMeteringPoint(callback: AsyncCallback): void;
getMeteringPoint(): Promise;
Added
ohos.multimedia.cameraCaptureSessionsetMeteringPoint(point: Point, callback: AsyncCallback): void;
setMeteringPoint(point: Point): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetExposureBiasRange(callback: AsyncCallback<Array>): void;
getExposureBiasRange(): Promise<Array>;
Added
ohos.multimedia.cameraCaptureSessionsetExposureBias(exposureBias: number, callback: AsyncCallback): void;
setExposureBias(exposureBias: number): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetExposureValue(callback: AsyncCallback): void;
getExposureValue(): Promise;
Added
ohos.multimedia.cameraCaptureSessionisFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
Added
ohos.multimedia.cameraCaptureSessionsetFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
Added
ohos.multimedia.cameraCaptureSessionsetFocusPoint(point: Point, callback: AsyncCallback): void;
setFocusPoint(point: Point): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetFocusPoint(callback: AsyncCallback): void;
getFocusPoint(): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetFocalLength(callback: AsyncCallback): void;
getFocalLength(): Promise;
Added
ohos.multimedia.cameraCaptureSessiongetZoomRatioRange(callback: AsyncCallback<Array>): void;
getZoomRatioRange(): Promise<Array>;
Added
ohos.multimedia.cameraCaptureSessiongetZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
Added
ohos.multimedia.cameraCaptureSessionsetZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise;
Added
ohos.multimedia.cameraCaptureSessionaddOutput(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.cameraCaptureSessionremoveOutput(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.cameraCaptureSessionErrorCodeERROR_INSUFFICIENT_RESOURCES = 0Added
ohos.multimedia.cameraCaptureSessionErrorCodeERROR_TIMEOUT = 1Added
ohos.multimedia.cameraCameraOutputrelease(callback: AsyncCallback): void;
release(): Promise;
Added
ohos.multimedia.cameraPreviewOutputstart(callback: AsyncCallback): void;
start(): Promise;
Added
ohos.multimedia.cameraPreviewOutputstop(callback: AsyncCallback): void;
stop(): Promise;
Added
ohos.multimedia.cameraPreviewOutputrelease(callback: AsyncCallback): void;
release(): Promise;
Deprecated
ohos.multimedia.cameraPhotoOutputrelease(callback: AsyncCallback): void;
release(): Promise;
Deprecated
ohos.multimedia.cameraVideoOutputrelease(callback: AsyncCallback): void;
release(): Promise;
Deprecated
ohos.multimedia.cameraPhotoCaptureSettingmirror?: boolean;Added
ohos.multimedia.cameraPhotoOutputErrorCodeERROR_DRIVER_ERROR = 0Added
ohos.multimedia.cameraPhotoOutputErrorCodeERROR_INSUFFICIENT_RESOURCES = 1Added
ohos.multimedia.cameraPhotoOutputErrorCodeERROR_TIMEOUT = 2Added
ohos.multimedia.cameraVideoOutputErrorCodeERROR_DRIVER_ERROR = 0Added
ohos.multimedia.cameraMetadataObjectTypeFACE_DETECTION = 0Added
ohos.multimedia.cameraMetadataObjectTypeFACE = 0Deprecated
ohos.multimedia.cameraMetadataOutputon(type: 'error', callback: ErrorCallback): void;Added
ohos.multimedia.cameraMetadataOutputsetCapturingMetadataObjectTypes(metadataObjectTypes: Array, callback: AsyncCallback): void;
setCapturingMetadataObjectTypes(metadataObjectTypes: Array): Promise;
Deprecated
ohos.multimedia.cameraMetadataOutputgetSupportedMetadataObjectTypes(callback: AsyncCallback<Array>): void;
getSupportedMetadataObjectTypes(): Promise<Array>;
Deprecated
ohos.multimedia.cameraMetadataOutputErrorCodeERROR_UNKNOWN = -1Added
ohos.multimedia.cameraMetadataOutputErrorCodeERROR_INSUFFICIENT_RESOURCES = 0Added
ohos.multimedia.cameraMetadataOutputErrorcode: 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

  2. FrameRateRange API

    Attribute 1: readonly min; type: number

    Attribute 2: readonly max; type: number

  3. VideoProfile API (inherited from Profile)

    Attribute: readonly frameRateRange; type: FrameRateRange

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

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

    The sample code is as follows:

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

    The sample code is as follows:

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

    The sample code is as follows:

    let mute = true;
    cameraManager.muteCamera(mute);
    
  9. 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;
        }
    })
    
  10. 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;

  4. The following APIs in metadataOutput are deprecated:

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

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

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

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

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

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

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

    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}`);
    })
    
  2. 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');
    })
    
  3. 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.');
    })
    
  4. 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.');
    })
    
  5. 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.');
    })
    
  6. 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.');
    })
    
  7. 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.');
    })
    
  8. The type of the camera attribute of the CameraStatusInfo API is changed from Camera to CameraDevice.

  9. 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}`);
    })
    
  10. 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;

  11. 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}`);
    })
    
  12. 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

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

  14. 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.');
    })
    
  15. 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.');
    })
    
  16. The following enumeration in MetadataObjectType is changed:

    The enumeration value name is changed from FACE to FACE_DETECTION.

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

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/fbc0b206e4664074a1192aca50f3baa7