From 1f57986fadb93b15aa1c73f7d0373a4933ab59e7 Mon Sep 17 00:00:00 2001 From: mali Date: Tue, 20 Dec 2022 10:28:26 +0800 Subject: [PATCH] Improve the description of interface change of beta3 to beta4 cameras-03 Signed-off-by: mali --- .../OpenHarmony_3.2.8.1/changelogs-camera.md | 778 +++++++++--------- 1 file changed, 388 insertions(+), 390 deletions(-) diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.8.1/changelogs-camera.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.8.1/changelogs-camera.md index 7e31752b7a..08900aa351 100644 --- a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.8.1/changelogs-camera.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.8.1/changelogs-camera.md @@ -158,627 +158,625 @@ OpenHarmony3.2 Beta4版本相较于OpenHarmony3.2 Beta3版本,媒体子系统c 除新增接口,和废弃接口之外,开发者需要关注变更的接口的适配: -**接口变更** - 从Beta4版本开始,对以下接口进行调整: -1. CameraManager中接口getCameras返回值由Array变更为Array,因此旧接口getCameras(callback: AsyncCallback>): void;以及getCameras(): Promise>;变更为getSupportedCameras(callback: AsyncCallback>): void和getSupportedCameras(): Promise>; +**新增接口** - 参考代码如下: +1. Profile接口 - ``` - 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}`); - }) - ``` + 属性1:readonly format,类型:CameraFormat; - ``` - cameraManager.getSupportedCameras().then((cameras) => { - console.log(`Promise returned with an array of supported cameras: ${cameras.length}`); - }) - ``` + 属性2:readonly size,类型:Size; -2. CameraManager中接口createCameraInput传递参数由原来cameraId: string变更为camera: CameraDevice,因此旧接口createCameraInput(cameraId: string, callback: AsyncCallback): void;以及createCameraInput(cameraId: string): Promise;变更为createCameraInput(camera: CameraDevice, callback: AsyncCallback): void;和createCameraInput(camera: CameraDevice): Promise; +2. FrameRateRange接口 - 参考代码如下: + 属性1:readonly min,类型:number; - ``` - 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.'); - }) - ``` + 属性2:readonly max,类型:number; - ``` - let cameraDevice = cameras[0]; - cameraManager.createCameraInput(cameraDevice).then((cameraInput) => { - console.log('Promise returned with the CameraInput instance'); - }) - ``` +3. VideoProfile接口,继承自Profile -3. CameraManager中接口createPreviewOutput新增传递参数profile: Profile,因此旧接口createPreviewOutput(surfaceId: string, callback: AsyncCallback): void;以及createPreviewOutput(surfaceId: string): Promise;变更为createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;createPreviewOutput(profile: Profile, surfaceId: string): Promise; + 属性:readonly frameRateRange,类型:FrameRateRange; - 参考代码如下: +4. CameraOutputCapability接口 - ``` - 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.'); - }) - ``` + 属性1:readonly previewProfiles,类型:Array; - ``` - let profile = cameraoutputcapability.previewProfiles[0]; - cameraManager.createPreviewOutput(profile, surfaceId).then((previewOutput) => { - console.log('Promise returned with previewOutput created.'); - }) - ``` + 属性2:readonly photoProfiles,类型:Array; -4. CameraManager中接口createPhotoOutput新增传递参数profile: Profile,因此旧接口CreatePhotoOutput(surfaceId: string, callback: AsyncCallback): void;以及CreatePhotoOutput(surfaceId: string): Promise;变更为createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;和createPhotoOutput(profile: Profile, surfaceId: string): Promise; + 属性3:readonly videoProfiles,类型:Array; - 参考代码如下: + 属性4:readonly supportedMetadataObjectTypes,类型:Array; - ``` - 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.'); - }) - ``` +5. CameraManager中新增 - ``` - let profile = cameraoutputcapability.photoProfiles[0]; - cameraManager.createPhotoOutput(profile, surfaceId).then((photoOutput) => { - console.log('Promise returned with photoOutput created.'); - }) - ``` + getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void; -5. CameraManager中接口createVideoOutput新增传递参数profile: Profile,因此旧接口createVideoOutput(surfaceId: string, callback: AsyncCallback): void;以及createVideoOutput(surfaceId: string): Promise;变更为createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void;和createVideoOutput(profile: VideoProfile, surfaceId: string): Promise; + getSupportedOutputCapability(camera: CameraDevice): Promise; 参考代码如下: ``` - 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' ); + 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'); + }) }) ``` ``` - let profile = cameraoutputcapability.videoProfiles[0]; - cameraManager.createVideoOutput(profile, surfaceId).then((videoOutput) => { - console.log('Promise returned with videoOutput created.'); + cameraManager.getSupportedCameras().then((cameras) => { + let cameraDevice = cameras[0]; + cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => { + console.log('Promise returned with an array of supported outputCapability'); + }) }) ``` -6. CameraManager中接口createMetadataOutput新增传递参数metadataObjectTypes: Array,因此旧接口createMetadataOutput(callback: AsyncCallback): void;以及createVideoOutput(): Promise;变更为createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void;和createMetadataOutput(metadataObjectTypes: Array): Promise; +6. CameraManager中新增isCameraMuted(): boolean; 参考代码如下: ``` - 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 ismuted = cameraManager.isCameraMuted(); ``` - ``` - let metadataObjectTypes = cameraoutputcapability.supportedMetadataObjectTypes; - cameraManager.createMetadataOutput(metadataObjectTypes).then((metadataOutput) => { - console.log('Promise returned with metadataOutput created.'); - }) - ``` - -7. CameraManager中createCaptureSession不需要考虑context属性,因此旧接口createCaptureSession(context: Context, callback: AsyncCallback): void;以及createCaptureSession(context: Context): Promise;改为createCaptureSession(callback: AsyncCallback): void;和createCaptureSession(): Promise; +7. CameraManager中新增isCameraMuteSupported(): boolean; 参考代码如下: - ```typescript - cameraManager.createCaptureSession((err, captureSession) => { - if (err) { - console.error(`Failed to create captureSession. ${err.message}`); - return; - } - console.log('Callback returned with captureSession created.'); - }) ``` + let ismutesuppotred = cameraManager.isCameraMuteSupported(); + ``` + +8. CameraManager中新增muteCamera(mute: boolean): void; + + 参考代码如下: ``` - cameraManager.createCaptureSession().then((captureSession) => { - console.log('Promise returned with captureSession created.'); - }) + let mute = true; + cameraManager.muteCamera(mute); ``` -8. CameraStatusInfo接口下属性camera类型由Camera变更为CameraDevice - -9. CameraInput中接口on(type: 'error')新增传递参数camera: CameraDevice,因此旧接口on(type: 'error', callback: ErrorCallback): void;变更为on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; +9. CameraManager中新增on(type: 'cameraMute', callback: AsyncCallback): void; 参考代码如下: ``` - let cameraDevice = cameras[0]; - cameraInput.on('error', cameraDevice, (cameraInputError) => { - console.log(`Camera input error code: ${cameraInputError.code}`); + cameraManager.on('cameraMute', (err, curMuetd) => { + if (err) { + console.error(`Failed to get cameraMute callback. ${err.message}`); + return; + } }) ``` - -10. CameraInput中以下接口调整到CaptureSession中 - hasFlash(callback: AsyncCallback): void;
hasFlash(): Promise;
+10. CameraInput中新增open(callback: AsyncCallback): void;以及open(): Promise; - isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void;
isFlashModeSupported(flashMode: FlashMode): Promise;
+参考代码如下: - getFlashMode(callback: AsyncCallback): void;
getFlashMode(): Promise;
+``` +cameraInput.open((err) => { + if (err) { + console.error(`Failed to open the camera. ${err.message}`); + return; + } + console.log('Callback returned with camera opened.'); +}) +``` - setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void;
setFlashMode(flashMode: FlashMode): Promise;
+``` +cameraInput.open().then(() => { + console.log('Promise returned with camera opened.'); +}) +``` - isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void;
isExposureModeSupported(aeMode: ExposureMode): Promise;
+11. CameraInput中新增close(callback: AsyncCallback): void;以及close(): Promise; - getExposureMode(callback: AsyncCallback): void;
getExposureMode(): Promise;
+ 参考代码如下: - setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void;
setExposureMode(aeMode: ExposureMode): Promise;
+ ``` + cameraInput.close((err) => { + if (err) { + console.error(`Failed to close the cameras. ${err.message}`); + return; + } + console.log('Callback returned with camera closed.'); + }) + ``` - getMeteringPoint(callback: AsyncCallback): void;
getMeteringPoint(): Promise;
+ ``` + cameraInput.close().then(() => { + console.log('Promise returned with camera closed.'); + }) + ``` - setMeteringPoint(point: Point, callback: AsyncCallback): void;
setMeteringPoint(point: Point): Promise;
+12. 枚举CameraInputErrorCode中新增 - getExposureBiasRange(callback: AsyncCallback>): void;
getExposureBiasRange(): Promise>;
+ 枚举值名称:ERROR_NO_PERMISSION,值:0; - setExposureBias(exposureBias: number, callback: AsyncCallback): void;
setExposureBias(exposureBias: number): Promise;
+ 枚举值名称:ERROR_DEVICE_PREEMPTED,值:1; - getExposureValue(callback: AsyncCallback): void;
getExposureValue(): Promise;
+ 枚举值名称:ERROR_DEVICE_DISCONNECTED,值:2; - isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
+ 枚举值名称:ERROR_DEVICE_IN_USE,值:3; - getFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
+ 枚举值名称:ERROR_DRIVER_ERROR,值:4; - setFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
+13. 枚举CameraFormat中新增 - setFocusPoint(point: Point, callback: AsyncCallback): void;
setFocusPoint(point: Point): Promise;
+ 枚举值名称:CAMERA_FORMAT_RGBA_8888,值:3; - getFocusPoint(callback: AsyncCallback): void;
getFocusPoint(): Promise;
+14. CaptureSession中新增getMeteringPoint(callback: AsyncCallback): void;以及getMeteringPoint(): Promise; - getFocalLength(callback: AsyncCallback): void;
getFocalLength(): Promise;
+ 参考代码如下: - getZoomRatioRange(callback: AsyncCallback>): void;
getZoomRatioRange(): Promise>;
+ ``` + 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}`); + }) + ``` - getZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
+ ``` + captureSession.getMeteringPoint().then((exposurePoint) => { + console.log(`Promise returned with current exposure point : ${exposurePoint}`); + }) + ``` - setZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise; - -11. CameraInput中接口on(type: 'focusStateChange', callback: AsyncCallback): void;调整到CaptureSession中,对应接口on(type: 'focusStateChange', callback: AsyncCallback): void; +15. CaptureSession中新增setMeteringPoint(point: Point, callback: AsyncCallback): void;以及setMeteringPoint(point: Point): Promise; 参考代码如下: ``` - captureSession.on('focusStateChange', (focusState) => { - console.log(`Focus state : ${focusState}`); + 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'); }) ``` -12. 枚举ExposureMode中 + ``` + const Point2 = {x: 2, y: 2}; + + captureSession.setMeteringPoint(Point2).then(() => { + console.log('Promise returned with the successful execution of setMeteringPoint'); + }) + ``` - 枚举值名称:EXPOSURE_MODE_AUTO,初值由默认变更为1; +16. 枚举CaptureSessionErrorCode中新增 - 枚举值名称:EXPOSURE_MODE_CONTINUOUS_AUTO,初值由默认变更为2; + 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:0; -13. 枚举VideoStabilizationMode中 + 枚举值名称:ERROR_TIMEOUT,值:1; - 枚举值名称:LOW,初值由默认变更为1; +17. 新增接口CameraOutput,接口下有release(callback: AsyncCallback): void;以及release(): Promise;方法 - 枚举值名称:MIDDLE,初值由默认变更为2; + 参考代码如下:用previewOutput做示例 - 枚举值名称:HIGH,初值由默认变更为3; + ``` + 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.'); + }); + ``` - 枚举值名称:AUTO,初值由默认变更为4; + ``` + previewOutput.release().then(() => { + console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); + }) + ``` -14. CaptureSession中接口addOutput参数由原来子类类型(PreviewOutput,PhotoOutput,VideoOutput,MetadataOutput)统一修改为基类类型(CameraOutput),由原来8个接口改变之后只有2个接口 +18. PreviewOutput中新增start(callback: AsyncCallback): void;以及start(): Promise; - 改变前接口为: + 参考代码如下 - 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; + ``` + 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.'); + }) + ``` - addOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
addOutput(cameraOutput: CameraOutput): Promise; +19. PreviewOutput中新增stop(callback: AsyncCallback): void;以及stop(): Promise; - 参考代码如下:以PreviewOutput为例 + 参考代码如下 ``` - captureSession.addOutput(previewOutput, (err) => { + previewOutput.stop((err) => { if (err) { - console.error(`Failed to add output. ${err.message}`); + console.error(`Failed to stop the previewOutput. ${err.message}`); return; } - console.log('Callback returned with output added.'); + console.log('Callback returned with previewOutput stopped.'); }) ``` ``` - captureSession.addOutput(previewOutput).then(() => { - console.log('Promise returned with cameraOutput added.'); + previewOutput.stop().then(() => { + console.log('Callback returned with previewOutput stopped.'); }) ``` -15. CaptureSession中接口removeOutput参数由原来子类类型(PreviewOutput,PhotoOutput,VideoOutput,MetadataOutput)统一修改为基类类型(CameraOutput),由原来8个接口改变之后只有2个接口 +20. PhotoCaptureSetting接口 - 改变前接口为: + 属性1:mirror?,类型:boolean; - 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; +21. 枚举PhotoOutputErrorCode中新增 - 改变后接口为: + 枚举值名称:ERROR_DRIVER_ERROR,值:0; - removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
removeOutput(cameraOutput: CameraOutput): Promise; + 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:1; - 参考代码如下:以PreviewOutput为例 + 枚举值名称:ERROR_TIMEOUT,值:2; - ``` - 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.'); - }); - ``` +22. 枚举VideoOutputErrorCode中新增 + + 枚举值名称:ERROR_DRIVER_ERROR,值:0; + +23. MetadataOutput中新增on(type: 'error', callback: ErrorCallback): void; + + 参考代码如下 ``` - captureSession.removeOutput(previewOutput).then(() => { - console.log('Promise returned to indicate that the CameraOutput instance is removed.'); + metadataOutput.on('error', (metadataOutputError) => { + console.log(`Metadata output error code: ${metadataOutputError.code}`); }) ``` -16. 枚举MetadataObjectType中 +24. MetadataOutputErrorCode枚举 - 枚举值名称由FACE变更为FACE_DETECTION; + 枚举值名称:ERROR_UNKNOWN,值:-1; -17. 接口Camera名称更改为CameraDevice + 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:0; -**新增接口** +25. MetadataOutputError接口 -1. Profile接口 + 属性名称:code,值:MetadataOutputErrorCode - 属性1:readonly format,类型:CameraFormat; +**废弃接口** - 属性2:readonly size,类型:Size; +1. CameraInput中废弃接口on(type: 'exposureStateChange', callback: AsyncCallback): void; -2. FrameRateRange接口 +2. previewOutput中废弃接口release(callback: AsyncCallback): void;以及release(): Promise; - 属性1:readonly min,类型:number; +3. metadataOutput中废弃接口 - 属性2:readonly max,类型:number; + setCapturingMetadataObjectTypes(metadataObjectTypes: Array, callback: AsyncCallback): void;
setCapturingMetadataObjectTypes(metadataObjectTypes: Array): Promise; -3. VideoProfile接口,继承自Profile +4. metadataOutput中废弃接口 - 属性:readonly frameRateRange,类型:FrameRateRange; + getSupportedMetadataObjectTypes(callback: AsyncCallback>): void;
getSupportedMetadataObjectTypes(): Promise>; -4. CameraOutputCapability接口 +5. PreviewOutput中废弃接口release(callback: AsyncCallback): void;以及release(): Promise; - 属性1:readonly previewProfiles,类型:Array; +6. PhotoOutput中废弃接口release(callback: AsyncCallback): void;以及release(): Promise; - 属性2:readonly photoProfiles,类型:Array; +7. VideoOutput中废弃接口release(callback: AsyncCallback): void;以及release(): Promise; - 属性3:readonly videoProfiles,类型:Array; +8. CameraInput中废弃接口getCameraId(callback: AsyncCallback): void;以及getCameraId(): Promise; - 属性4:readonly supportedMetadataObjectTypes,类型:Array; +9. CameraInput中废弃接口getExposurePoint(callback: AsyncCallback): void;以及getExposurePoint(): Promise; -5. CameraManager中新增 +10. CameraInput中废弃接口setExposurePoint(exposurePoint: Point, callback: AsyncCallback): void;以及setExposurePoint(exposurePoint: Point): Promise; - getSupportedOutputCapability(camera: CameraDevice, callback: AsyncCallback): void; +**接口变更** - getSupportedOutputCapability(camera: CameraDevice): Promise; +1. CameraManager中接口getCameras返回值由Array变更为Array,接口名由getCameras 更换为 getSupportedCameras,因此旧接口getCameras(callback: AsyncCallback>): void;以及getCameras(): Promise>;变更为getSupportedCameras(callback: AsyncCallback>): void和getSupportedCameras(): Promise>; 参考代码如下: ``` - 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((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) => { - let cameraDevice = cameras[0]; - cameraManager.getSupportedOutputCapability(cameraDevice).then((cameraoutputcapability) => { - console.log('Promise returned with an array of supported outputCapability'); - }) + console.log(`Promise returned with an array of supported cameras: ${cameras.length}`); }) ``` -6. CameraManager中新增isCameraMuted(): boolean; +2. CameraManager中接口createCameraInput传递参数由原来cameraId: string变更为camera: CameraDevice,因此旧接口createCameraInput(cameraId: string, callback: AsyncCallback): void;以及createCameraInput(cameraId: string): Promise;变更为createCameraInput(camera: CameraDevice, callback: AsyncCallback): void;和createCameraInput(camera: CameraDevice): Promise; 参考代码如下: ``` - let ismuted = cameraManager.isCameraMuted(); + 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.'); + }) ``` -7. CameraManager中新增isCameraMuteSupported(): boolean; + ``` + let cameraDevice = cameras[0]; + cameraManager.createCameraInput(cameraDevice).then((cameraInput) => { + console.log('Promise returned with the CameraInput instance'); + }) + ``` + +3. CameraManager中接口createPreviewOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口createPreviewOutput(surfaceId: string, callback: AsyncCallback): void;以及createPreviewOutput(surfaceId: string): Promise;变更为createPreviewOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;createPreviewOutput(profile: Profile, surfaceId: string): Promise; 参考代码如下: ``` - let ismutesuppotred = cameraManager.isCameraMuteSupported(); + 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.'); + }) ``` -8. CameraManager中新增muteCamera(mute: boolean): void; + ``` + let profile = cameraoutputcapability.previewProfiles[0]; + cameraManager.createPreviewOutput(profile, surfaceId).then((previewOutput) => { + console.log('Promise returned with previewOutput created.'); + }) + ``` + +4. CameraManager中接口createPhotoOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口CreatePhotoOutput(surfaceId: string, callback: AsyncCallback): void;以及CreatePhotoOutput(surfaceId: string): Promise;变更为createPhotoOutput(profile: Profile, surfaceId: string, callback: AsyncCallback): void;和createPhotoOutput(profile: Profile, surfaceId: string): Promise; + + 参考代码如下: + + ``` + 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. CameraManager中接口createVideoOutput新增传递参数profile: Profile,profile参数由getSupportedOutputCapability接口获取,因此旧接口createVideoOutput(surfaceId: string, callback: AsyncCallback): void;以及createVideoOutput(surfaceId: string): Promise;变更为createVideoOutput(profile: VideoProfile, surfaceId: string, callback: AsyncCallback): void;和createVideoOutput(profile: VideoProfile, surfaceId: string): Promise; + + 参考代码如下: + + ``` + 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. CameraManager中接口createMetadataOutput新增传递参数metadataObjectTypes: Array,metadataObjectTypes参数由getSupportedOutputCapability接口获取,因此旧接口function createMetadataOutput(callback: AsyncCallback): void;以及function createMetadataOutput(): Promise;变更为createMetadataOutput(metadataObjectTypes: Array, callback: AsyncCallback): void;和createMetadataOutput(metadataObjectTypes: Array): Promise; + + 参考代码如下: + + ``` + 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. CameraManager中createCaptureSession不需要考虑context属性,因此旧接口createCaptureSession(context: Context, callback: AsyncCallback): void;以及createCaptureSession(context: Context): Promise;改为createCaptureSession(callback: AsyncCallback): void;和createCaptureSession(): Promise; 参考代码如下: + ```typescript + cameraManager.createCaptureSession((err, captureSession) => { + if (err) { + console.error(`Failed to create captureSession. ${err.message}`); + return; + } + console.log('Callback returned with captureSession created.'); + }) ``` - let mute = true; - cameraManager.muteCamera(mute); + + ``` + cameraManager.createCaptureSession().then((captureSession) => { + console.log('Promise returned with captureSession created.'); + }) ``` -9. CameraManager中新增on(type: 'cameraMute', callback: AsyncCallback): void; +8. CameraStatusInfo接口下属性camera类型由Camera变更为CameraDevice + +9. CameraInput中接口on(type: 'error')新增传递参数camera: CameraDevice,因此旧接口on(type: 'error', callback: ErrorCallback): void;变更为on(type: 'error', camera: CameraDevice, callback: ErrorCallback): void; 参考代码如下: ``` - cameraManager.on('cameraMute', (err, curMuetd) => { - if (err) { - console.error(`Failed to get cameraMute callback. ${err.message}`); - return; - } + let cameraDevice = cameras[0]; + cameraInput.on('error', cameraDevice, (cameraInputError) => { + console.log(`Camera input error code: ${cameraInputError.code}`); }) ``` + +10. CameraInput中以下接口调整到CaptureSession中 -10. CameraInput中新增open(callback: AsyncCallback): void;以及open(): Promise; - -参考代码如下: + hasFlash(callback: AsyncCallback): void;
hasFlash(): Promise;
-``` -cameraInput.open((err) => { - if (err) { - console.error(`Failed to open the camera. ${err.message}`); - return; - } - console.log('Callback returned with camera opened.'); -}) -``` + isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void;
isFlashModeSupported(flashMode: FlashMode): Promise;
-``` -cameraInput.open().then(() => { - console.log('Promise returned with camera opened.'); -}) -``` + getFlashMode(callback: AsyncCallback): void;
getFlashMode(): Promise;
+ setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void;
setFlashMode(flashMode: FlashMode): Promise;
-11. CameraInput中新增close(callback: AsyncCallback): void;以及close(): Promise; + isExposureModeSupported(aeMode: ExposureMode, callback: AsyncCallback): void;
isExposureModeSupported(aeMode: ExposureMode): Promise;
- 参考代码如下: + getExposureMode(callback: AsyncCallback): void;
getExposureMode(): Promise;
- ``` - cameraInput.close((err) => { - if (err) { - console.error(`Failed to close the cameras. ${err.message}`); - return; - } - console.log('Callback returned with camera closed.'); - }) - ``` + setExposureMode(aeMode: ExposureMode, callback: AsyncCallback): void;
setExposureMode(aeMode: ExposureMode): Promise;
- ``` - cameraInput.close().then(() => { - console.log('Promise returned with camera closed.'); - }) - ``` + getMeteringPoint(callback: AsyncCallback): void;
getMeteringPoint(): Promise;
-12. 枚举CameraInputErrorCode中新增 + setMeteringPoint(point: Point, callback: AsyncCallback): void;
setMeteringPoint(point: Point): Promise;
- 枚举值名称:ERROR_NO_PERMISSION,值:0; + getExposureBiasRange(callback: AsyncCallback>): void;
getExposureBiasRange(): Promise>;
- 枚举值名称:ERROR_DEVICE_PREEMPTED,值:1; + setExposureBias(exposureBias: number, callback: AsyncCallback): void;
setExposureBias(exposureBias: number): Promise;
- 枚举值名称:ERROR_DEVICE_DISCONNECTED,值:2; + getExposureValue(callback: AsyncCallback): void;
getExposureValue(): Promise;
- 枚举值名称:ERROR_DEVICE_IN_USE,值:3; + isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void;
isFocusModeSupported(afMode: FocusMode): Promise;
- 枚举值名称:ERROR_DRIVER_ERROR,值:4; + getFocusMode(callback: AsyncCallback): void;
getFocusMode(): Promise;
-13. 枚举CameraFormat中新增 + setFocusMode(afMode: FocusMode, callback: AsyncCallback): void;
setFocusMode(afMode: FocusMode): Promise;
- 枚举值名称:CAMERA_FORMAT_RGBA_8888,值:3; + setFocusPoint(point: Point, callback: AsyncCallback): void;
setFocusPoint(point: Point): Promise;
-14. CaptureSession中新增getMeteringPoint(callback: AsyncCallback): void;以及getMeteringPoint(): Promise; + getFocusPoint(callback: AsyncCallback): void;
getFocusPoint(): Promise;
- 参考代码如下: + getFocalLength(callback: AsyncCallback): void;
getFocalLength(): Promise;
- ``` - 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}`); - }) - ``` + getZoomRatioRange(callback: AsyncCallback>): void;
getZoomRatioRange(): Promise>;
- ``` - captureSession.getMeteringPoint().then((exposurePoint) => { - console.log(`Promise returned with current exposure point : ${exposurePoint}`); - }) - ``` + getZoomRatio(callback: AsyncCallback): void;
getZoomRatio(): Promise;
-15. CaptureSession中新增setMeteringPoint(point: Point, callback: AsyncCallback): void;以及setMeteringPoint(point: Point): Promise; + setZoomRatio(zoomRatio: number, callback: AsyncCallback): void;
setZoomRatio(zoomRatio: number): Promise; + +11. CameraInput中接口on(type: 'focusStateChange', callback: AsyncCallback): void;调整到CaptureSession中,对应接口on(type: 'focusStateChange', callback: AsyncCallback): void; 参考代码如下: ``` - 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'); + captureSession.on('focusStateChange', (focusState) => { + console.log(`Focus state : ${focusState}`); }) ``` - ``` - const Point2 = {x: 2, y: 2}; - - captureSession.setMeteringPoint(Point2).then(() => { - console.log('Promise returned with the successful execution of setMeteringPoint'); - }) - ``` +12. 枚举ExposureMode中 -16. 枚举CaptureSessionErrorCode中新增 + 枚举值名称:EXPOSURE_MODE_AUTO,初值由默认变更为1; - 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:0; + 枚举值名称:EXPOSURE_MODE_CONTINUOUS_AUTO,初值由默认变更为2; - 枚举值名称:ERROR_TIMEOUT,值:1; +13. 枚举VideoStabilizationMode中 -17. 新增接口CameraOutput,接口下有release(callback: AsyncCallback): void;以及release(): Promise;方法 + 枚举值名称:LOW,初值由默认变更为1; - 参考代码如下:用previewOutput做示例 + 枚举值名称:MIDDLE,初值由默认变更为2; - ``` - 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.'); - }); - ``` + 枚举值名称:HIGH,初值由默认变更为3; - ``` - previewOutput.release().then(() => { - console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.'); - }) - ``` + 枚举值名称:AUTO,初值由默认变更为4; -18. PreviewOutput中新增start(callback: AsyncCallback): void;以及start(): Promise; +14. CaptureSession中接口addOutput参数由原来子类类型(PreviewOutput,PhotoOutput,VideoOutput,MetadataOutput)统一修改为基类类型(CameraOutput),由原来8个接口改变之后只有2个接口 - 参考代码如下 + 改变前接口为: - ``` - previewOutput.start((err) => { - if (err) { - console.error(`Failed to start the previewOutput. ${err.message}`); - return; - } - console.log('Callback returned with previewOutput started.'); - }) - ``` + 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; - ``` - previewOutput.start().then(() => { - console.log('Promise returned with previewOutput started.'); - }) - ``` + 改变后接口为: -19. PreviewOutput中新增stop(callback: AsyncCallback): void;以及stop(): Promise; + addOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
addOutput(cameraOutput: CameraOutput): Promise; - 参考代码如下 + 参考代码如下:以PreviewOutput为例 ``` - previewOutput.stop((err) => { + captureSession.addOutput(previewOutput, (err) => { if (err) { - console.error(`Failed to stop the previewOutput. ${err.message}`); + console.error(`Failed to add output. ${err.message}`); return; } - console.log('Callback returned with previewOutput stopped.'); + console.log('Callback returned with output added.'); }) ``` ``` - previewOutput.stop().then(() => { - console.log('Callback returned with previewOutput stopped.'); + captureSession.addOutput(previewOutput).then(() => { + console.log('Promise returned with cameraOutput added.'); }) ``` -20. PhotoCaptureSetting接口 - - 属性1:mirror?,类型:boolean; - -21. 枚举PhotoOutputErrorCode中新增 - - 枚举值名称:ERROR_DRIVER_ERROR,值:0; +15. CaptureSession中接口removeOutput参数由原来子类类型(PreviewOutput,PhotoOutput,VideoOutput,MetadataOutput)统一修改为基类类型(CameraOutput),由原来8个接口改变之后只有2个接口 - 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:1; + 改变前接口为: - 枚举值名称:ERROR_TIMEOUT,值:2; + 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; -22. 枚举VideoOutputErrorCode中新增 + 改变后接口为: - 枚举值名称:ERROR_DRIVER_ERROR,值:0; + removeOutput(cameraOutput: CameraOutput, callback: AsyncCallback): void;
removeOutput(cameraOutput: CameraOutput): Promise; -23. MetadataOutput中新增on(type: 'error', callback: ErrorCallback): void; + 参考代码如下:以PreviewOutput为例 - 参考代码如下 + ``` + 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.'); + }); + ``` ``` - metadataOutput.on('error', (metadataOutputError) => { - console.log(`Metadata output error code: ${metadataOutputError.code}`); + captureSession.removeOutput(previewOutput).then(() => { + console.log('Promise returned to indicate that the CameraOutput instance is removed.'); }) ``` -24. MetadataOutputErrorCode枚举 - - 枚举值名称:ERROR_UNKNOWN,值:-1; - - 枚举值名称:ERROR_INSUFFICIENT_RESOURCES,值:0; - -25. MetadataOutputError接口 - - 属性名称:code,值:MetadataOutputErrorCode - - -**接口废弃** - -1. CameraInput中废弃接口on(type: 'exposureStateChange', callback: AsyncCallback): void; - -2. previewOutput中废弃接口release(callback: AsyncCallback): void;以及release(): Promise; - -3. metadataOutput中废弃接口 - - setCapturingMetadataObjectTypes(metadataObjectTypes: Array, callback: AsyncCallback): void;
setCapturingMetadataObjectTypes(metadataObjectTypes: Array): Promise; - -4. metadataOutput中废弃接口 - - getSupportedMetadataObjectTypes(callback: AsyncCallback>): void;
getSupportedMetadataObjectTypes(): Promise>; - -5. PreviewOutput中废弃接口release(callback: AsyncCallback): void;以及release(): Promise; - -6. PhotoOutput中废弃接口release(callback: AsyncCallback): void;以及release(): Promise; - -7. VideoOutput中废弃接口release(callback: AsyncCallback): void;以及release(): Promise; - -8. CameraInput中废弃接口getCameraId(callback: AsyncCallback): void;以及getCameraId(): Promise; +16. 枚举MetadataObjectType中 -9. CameraInput中废弃接口getExposurePoint(callback: AsyncCallback): void;以及getExposurePoint(): Promise; + 枚举值名称由FACE变更为FACE_DETECTION; -10. CameraInput中废弃接口setExposurePoint(exposurePoint: Point, callback: AsyncCallback): void;以及setExposurePoint(exposurePoint: Point): Promise; +17. 接口Camera名称更改为CameraDevice -- GitLab