From 4c241029427617d5624e6d8b8f2206a5b9cde199 Mon Sep 17 00:00:00 2001 From: qinliwen Date: Mon, 3 Apr 2023 18:25:13 +0800 Subject: [PATCH] =?UTF-8?q?<=E4=BF=AE=E5=A4=8DcameraVideo=E5=92=8CcameraPr?= =?UTF-8?q?eviewFormat=E5=88=87=E6=8D=A2format=E9=97=AE=E9=A2=98>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qinliwen --- .../ets/pages/Camera/CameraPhotoFormat.ets | 2 +- .../ets/pages/Camera/CameraPreviewFormat.ets | 4 ++-- .../src/main/ets/pages/Camera/CameraVideo.ets | 6 ++--- .../src/main/ets/pages/model/CameraService.ts | 22 ++++++++++++++----- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraPhotoFormat.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraPhotoFormat.ets index 60bb60a03..e2fcf4eed 100644 --- a/validator/acts_validator/src/main/ets/pages/Camera/CameraPhotoFormat.ets +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraPhotoFormat.ets @@ -79,7 +79,7 @@ struct cameraOrientation { async cameraInit(obj?) { CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, obj, this.clickFrequency).then(() => { - this.resolution = CameraService.previewSizeResolution + this.resolution = CameraService.photoResolution this.resolutionSelectVal = String(this.resolution[this.clickFrequency].value) this.cameraListFn() }) diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraPreviewFormat.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraPreviewFormat.ets index ec4358f7a..b9d58b529 100644 --- a/validator/acts_validator/src/main/ets/pages/Camera/CameraPreviewFormat.ets +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraPreviewFormat.ets @@ -63,7 +63,7 @@ struct cameraFormat { } async cameraInit(obj?) { - CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, obj).then(() => { + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, undefined, undefined, obj).then(() => { this.resolution = CameraService.resolution this.resolutionSelectVal = String(this.resolution[this.clickFrequency].value) this.cameraListFn() @@ -170,7 +170,7 @@ struct cameraFormat { "height": objH } } - CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, obj) + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, undefined, undefined, obj) Logger.info(this.tag, `onSelect Rotation index: ${index}, value: ${value}, obj: ${obj}`) }) .backgroundColor(Color.Black) diff --git a/validator/acts_validator/src/main/ets/pages/Camera/CameraVideo.ets b/validator/acts_validator/src/main/ets/pages/Camera/CameraVideo.ets index de603cb92..9e83e564c 100644 --- a/validator/acts_validator/src/main/ets/pages/Camera/CameraVideo.ets +++ b/validator/acts_validator/src/main/ets/pages/Camera/CameraVideo.ets @@ -105,8 +105,8 @@ struct cameraOrientation { } async cameraInit(obj?) { - CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, obj).then(() => { - this.resolution = CameraService.resolution + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex).then(() => { + this.resolution = CameraService.videoResolution this.resolutionSelectVal = String(this.resolution[this.clickFrequency].value) this.cameraListFn() }) @@ -199,7 +199,7 @@ struct cameraOrientation { "height": objH } } - CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex, obj) + CameraService.initCamera(this.surfaceId, this.cameraDeviceIndex) Logger.info(this.tag, `onSelect Rotation index: ${index}, value: ${value}, obj: ${obj}`) }) .backgroundColor(Color.Black) diff --git a/validator/acts_validator/src/main/ets/pages/model/CameraService.ts b/validator/acts_validator/src/main/ets/pages/model/CameraService.ts index bba7d8063..194e5c1a4 100644 --- a/validator/acts_validator/src/main/ets/pages/model/CameraService.ts +++ b/validator/acts_validator/src/main/ets/pages/model/CameraService.ts @@ -77,7 +77,8 @@ class CameraService { } private videoOutputStopBol: boolean = true resolution: any = null - previewSizeResolution: any = null + photoResolution: any = null + videoResolution: any = null constructor() { try { @@ -132,7 +133,7 @@ class CameraService { } } - async initCamera(surfaceId: number, cameraDeviceIndex: number, obj?, photoIndex?) { + async initCamera(surfaceId: number, cameraDeviceIndex: number, obj?, photoIndex?, previewObj?) { try { if (deviceInfo.deviceType === 'default') { this.videoConfig.videoSourceType = 1 @@ -140,12 +141,13 @@ class CameraService { this.videoConfig.videoSourceType = 0 } Logger.info(this.tag, `cameraDeviceIndex success: ${cameraDeviceIndex}`) + previewObj.format = this.cameraOutputCapability.previewProfiles[0].format + Logger.info(this.tag, `previewObj format: ${previewObj.format}`) await this.releaseCamera() await this.getCameraManagerFn() await this.getSupportedCamerasFn() await this.getSupportedOutputCapabilityFn(cameraDeviceIndex) - // await this.createPreviewOutputFn(obj ? obj : this.photoProfileObj, surfaceId) - await this.createPreviewOutputFn(this.cameraOutputCapability.previewProfiles[0], surfaceId) + await this.createPreviewOutputFn(previewObj ? previewObj : this.cameraOutputCapability.previewProfiles[0], surfaceId) // await this.createPhotoOutputFn(this.photoProfileObj) await this.createPhotoOutputFn(obj ? obj : this.cameraOutputCapability.photoProfiles[photoIndex?photoIndex:0]) await this.createCameraInputFn(this.cameras[cameraDeviceIndex]) @@ -441,8 +443,9 @@ class CameraService { this.cameraOutputCapability = this.cameraManager.getSupportedOutputCapability(this.cameras[cameraDeviceIndex]) let previewSize = [] let photoSize = [] + let videoSize = [] this.cameraOutputCapability.previewProfiles.forEach((item, index) => { -// Logger.info(this.tag, `cameraOutputCapability previewProfiles index: ${index}, item:` + JSON.stringify(item)) + Logger.info(this.tag, `cameraOutputCapability previewProfiles index: ${index}, item:` + JSON.stringify(item)) previewSize.push({ value: `${item.size.width}x${item.size.height}` }) @@ -453,12 +456,19 @@ class CameraService { value: `${item.size.width}x${item.size.height}` }) }) + this.cameraOutputCapability.videoProfiles.forEach((item, index) => { + Logger.info(this.tag, `cameraOutputCapability videoProfiles index: ${index}, item:` + JSON.stringify(item)) + videoSize.push({ + value: `${item.size.width}x${item.size.height}` + }) + }) Logger.info(this.tag, `cameraOutputCapability previewProfiles:` + JSON.stringify(this.cameraOutputCapability.previewProfiles)) Logger.info(this.tag, `cameraOutputCapability photoProfiles:` + JSON.stringify(this.cameraOutputCapability.photoProfiles)) Logger.info(this.tag, `cameraOutputCapability videoProfiles:` + JSON.stringify(this.cameraOutputCapability.videoProfiles)) Logger.info(this.tag, `cameraOutputCapability previewProfiles previewSize:` + JSON.stringify(previewSize)) this.resolution = previewSize - this.previewSizeResolution = photoSize + this.photoResolution = photoSize + this.videoResolution = videoSize return previewSize } // 释放会话及其相关参数 -- GitLab