142365ec6Sopenharmony_ci/* 242365ec6Sopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 342365ec6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 442365ec6Sopenharmony_ci * you may not use this file except in compliance with the License. 542365ec6Sopenharmony_ci * You may obtain a copy of the License at 642365ec6Sopenharmony_ci * 742365ec6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 842365ec6Sopenharmony_ci * 942365ec6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1042365ec6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1142365ec6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1242365ec6Sopenharmony_ci * See the License for the specific language governing permissions and 1342365ec6Sopenharmony_ci * limitations under the License. 1442365ec6Sopenharmony_ci */ 1542365ec6Sopenharmony_ci 1642365ec6Sopenharmony_ciimport { Action } from '../redux/actions/Action'; 1742365ec6Sopenharmony_ciimport { CameraId } from '../setting/settingitem/CameraId'; 1842365ec6Sopenharmony_ciimport { CameraPlatformCapability } from '../camera/CameraPlatformCapability'; 1942365ec6Sopenharmony_ciimport { Log } from '../utils/Log'; 2042365ec6Sopenharmony_ciimport { CameraStatus } from '../utils/Constants'; 2142365ec6Sopenharmony_ciimport { BaseFunction } from './BaseFunction'; 2242365ec6Sopenharmony_ciimport { FunctionCallBack } from '../camera/CameraService'; 2342365ec6Sopenharmony_ciimport ReportUtil from '../utils/ReportUtil'; 2442365ec6Sopenharmony_ciimport { GlobalContext } from '../utils/GlobalContext'; 2542365ec6Sopenharmony_ci 2642365ec6Sopenharmony_ciexport class CameraBasicFunction extends BaseFunction { 2742365ec6Sopenharmony_ci private TAG = '[CameraBasicFunction]:'; 2842365ec6Sopenharmony_ci private mCameraId: string = CameraId.BACK; 2942365ec6Sopenharmony_ci private mSurfaceId: string = ''; 3042365ec6Sopenharmony_ci private mCurrentMode: string = ''; 3142365ec6Sopenharmony_ci private mSessionList: string[] = []; 3242365ec6Sopenharmony_ci private isSessionReleasing: boolean = false 3342365ec6Sopenharmony_ci private initDataCache: any = null 3442365ec6Sopenharmony_ci public startIdentification: boolean = false 3542365ec6Sopenharmony_ci 3642365ec6Sopenharmony_ci private functionBackImpl: FunctionCallBack = { 3742365ec6Sopenharmony_ci onCapturePhotoOutput: (): void => { 3842365ec6Sopenharmony_ci Log.info(`${this.TAG} functionBackImpl onCapturePhotoOutput`) 3942365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.capturePhotoOutput()) 4042365ec6Sopenharmony_ci }, 4142365ec6Sopenharmony_ci onCaptureSuccess: (thumbnail: any, resourceUri: any): void => { 4242365ec6Sopenharmony_ci Log.info(`${this.TAG} functionBackImpl onCaptureSuccess ${thumbnail}`) 4342365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.updateThumbnail(thumbnail, resourceUri)) 4442365ec6Sopenharmony_ci }, 4542365ec6Sopenharmony_ci onCaptureFailure: (): void => { 4642365ec6Sopenharmony_ci Log.info(`${this.TAG} functionBackImpl onCaptureFailure`) 4742365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.captureError()) 4842365ec6Sopenharmony_ci }, 4942365ec6Sopenharmony_ci onRecordSuccess: (thumbnail: any): void => { 5042365ec6Sopenharmony_ci Log.info(`${this.TAG} functionBackImpl onRecordSuccess ${thumbnail}`) 5142365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.recordDone(thumbnail)) 5242365ec6Sopenharmony_ci }, 5342365ec6Sopenharmony_ci onRecordFailure: (): void => { 5442365ec6Sopenharmony_ci Log.info(`${this.TAG} functionBackImpl onRecordFailure`) 5542365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.recordError()) 5642365ec6Sopenharmony_ci }, 5742365ec6Sopenharmony_ci thumbnail: (thumbnail: any): void => { 5842365ec6Sopenharmony_ci Log.info(`${this.TAG} functionBackImpl thumbnail ${thumbnail}`) 5942365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.loadThumbnail(thumbnail)) 6042365ec6Sopenharmony_ci } 6142365ec6Sopenharmony_ci } 6242365ec6Sopenharmony_ci 6342365ec6Sopenharmony_ci public async initCamera(data, callType?: string) { 6442365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_BEGIN_INIT); 6542365ec6Sopenharmony_ci Log.info(`${this.TAG} initCamera this.startIdentification:${JSON.stringify(this.startIdentification)} `); 6642365ec6Sopenharmony_ci if (this.startIdentification) { 6742365ec6Sopenharmony_ci const platformCapability = CameraPlatformCapability.getInstance(); 6842365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.initCameraDone(platformCapability)); 6942365ec6Sopenharmony_ci return; 7042365ec6Sopenharmony_ci } 7142365ec6Sopenharmony_ci if (callType) this.startIdentification = true 7242365ec6Sopenharmony_ci Log.start(`${this.TAG} initCamera`) 7342365ec6Sopenharmony_ci this.mSessionList.push('CREATE') 7442365ec6Sopenharmony_ci let curStorageCameraId = AppStorage.Get<string>('storageCameraId') 7542365ec6Sopenharmony_ci if (curStorageCameraId) { 7642365ec6Sopenharmony_ci data.cameraId = curStorageCameraId 7742365ec6Sopenharmony_ci } 7842365ec6Sopenharmony_ci Log.info(`${this.TAG} initData:${JSON.stringify(data)} `) 7942365ec6Sopenharmony_ci this.initDataCache = data 8042365ec6Sopenharmony_ci if (GlobalContext.get().getT<boolean>('isSessionCreating') || this.isSessionReleasing) { 8142365ec6Sopenharmony_ci Log.info(`${this.TAG} initCamera isSessionCreating or isSessionReleasing return`) 8242365ec6Sopenharmony_ci return 8342365ec6Sopenharmony_ci } 8442365ec6Sopenharmony_ci this.mCameraId = data.cameraId 8542365ec6Sopenharmony_ci this.mCurrentMode = data.mode 8642365ec6Sopenharmony_ci let mCameraCount = await this.mCameraService.initCamera(this.mCameraId) 8742365ec6Sopenharmony_ci const platformCapability = CameraPlatformCapability.getInstance() 8842365ec6Sopenharmony_ci await platformCapability.init(mCameraCount) 8942365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.initCameraDone(platformCapability)) 9042365ec6Sopenharmony_ci this.mCameraService.getThumbnail(this.functionBackImpl) 9142365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_INIT_FINISHED); 9242365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.updateCameraStatus()) 9342365ec6Sopenharmony_ci Log.end(`${this.TAG} initCamera`) 9442365ec6Sopenharmony_ci } 9542365ec6Sopenharmony_ci 9642365ec6Sopenharmony_ci private async imageSize(data) { 9742365ec6Sopenharmony_ci Log.info(`${this.TAG} imageSize ${JSON.stringify(data)} E`) 9842365ec6Sopenharmony_ci this.mCameraService.mImageSize.imageWidth = data.imageSize.width 9942365ec6Sopenharmony_ci this.mCameraService.mImageSize.imageHeight = data.imageSize.height 10042365ec6Sopenharmony_ci Log.info(`${this.TAG} imageSize X`) 10142365ec6Sopenharmony_ci } 10242365ec6Sopenharmony_ci 10342365ec6Sopenharmony_ci private async videoSize(data) { 10442365ec6Sopenharmony_ci Log.info(`${this.TAG} videoSize ${JSON.stringify(data)} E`) 10542365ec6Sopenharmony_ci this.mCameraService.mVideoFrameSize.frameWidth = data.videoSize.width 10642365ec6Sopenharmony_ci this.mCameraService.mVideoFrameSize.frameHeight = data.videoSize.height 10742365ec6Sopenharmony_ci Log.info(`${this.TAG} videoSize X`) 10842365ec6Sopenharmony_ci } 10942365ec6Sopenharmony_ci 11042365ec6Sopenharmony_ci private async onSurfacePrepare(data) { 11142365ec6Sopenharmony_ci Log.info(`${this.TAG} onSurfacePrepare ${JSON.stringify(data)} E`) 11242365ec6Sopenharmony_ci this.mSurfaceId = data.surfaceId 11342365ec6Sopenharmony_ci Log.info(`${this.TAG} onSurfacePrepare X`) 11442365ec6Sopenharmony_ci } 11542365ec6Sopenharmony_ci 11642365ec6Sopenharmony_ci private async startPreview(data?) { 11742365ec6Sopenharmony_ci Log.start(`${this.TAG} startPreview`) 11842365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_BEGIN_PREVIEW); 11942365ec6Sopenharmony_ci if (!this.mSurfaceId) { 12042365ec6Sopenharmony_ci Log.info(`${this.TAG} startPreview error mSurfaceId is null`) 12142365ec6Sopenharmony_ci this.enableUi() 12242365ec6Sopenharmony_ci return 12342365ec6Sopenharmony_ci } 12442365ec6Sopenharmony_ci await this.mCameraService.createPreviewOutput(this.mSurfaceId, this.mCurrentMode) 12542365ec6Sopenharmony_ci if (await this.isVideoMode()) { 12642365ec6Sopenharmony_ci // await this.mCameraService.createVideoOutput(this.functionBackImpl) 12742365ec6Sopenharmony_ci } else { 12842365ec6Sopenharmony_ci await this.mCameraService.createPhotoOutput(this.functionBackImpl) 12942365ec6Sopenharmony_ci } 13042365ec6Sopenharmony_ci await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) 13142365ec6Sopenharmony_ci if ([...this.mSessionList].pop() === 'RELEASE') { 13242365ec6Sopenharmony_ci await this.close() 13342365ec6Sopenharmony_ci } 13442365ec6Sopenharmony_ci if (data && data?.zoomRatio && data.zoomRatio !== 1) { 13542365ec6Sopenharmony_ci await this.mCameraService.setZoomRatio(data.zoomRatio) 13642365ec6Sopenharmony_ci } 13742365ec6Sopenharmony_ci this.mSessionList = [] 13842365ec6Sopenharmony_ci this.enableUi() 13942365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_PREVIEW_FINISHED); 14042365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.updateCameraStatus()) 14142365ec6Sopenharmony_ci Log.end(`${this.TAG} startPreview`) 14242365ec6Sopenharmony_ci } 14342365ec6Sopenharmony_ci 14442365ec6Sopenharmony_ci private async reStartPreview(data) { 14542365ec6Sopenharmony_ci Log.start(`${this.TAG} reStartPreview`) 14642365ec6Sopenharmony_ci if (!this.mSurfaceId) { 14742365ec6Sopenharmony_ci Log.info(`${this.TAG} reStartPreview error mSurfaceId is null`) 14842365ec6Sopenharmony_ci this.enableUi() 14942365ec6Sopenharmony_ci return 15042365ec6Sopenharmony_ci } 15142365ec6Sopenharmony_ci this.mCameraService.setCameraId(this.mCameraId) 15242365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_RELEASING); 15342365ec6Sopenharmony_ci await this.mCameraService.releaseCamera() 15442365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_RELEASE_FINISHED); 15542365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_BEGIN_PREVIEW); 15642365ec6Sopenharmony_ci await this.mCameraService.createCameraInput(this.mCameraId) 15742365ec6Sopenharmony_ci await this.mCameraService.createPreviewOutput(this.mSurfaceId, this.mCurrentMode) 15842365ec6Sopenharmony_ci if (await this.isVideoMode()) { 15942365ec6Sopenharmony_ci // await this.mCameraService.createVideoOutput(this.functionBackImpl) 16042365ec6Sopenharmony_ci } else { 16142365ec6Sopenharmony_ci await this.mCameraService.createPhotoOutput(this.functionBackImpl) 16242365ec6Sopenharmony_ci } 16342365ec6Sopenharmony_ci await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) 16442365ec6Sopenharmony_ci if ([...this.mSessionList].pop() === 'RELEASE') { 16542365ec6Sopenharmony_ci await this.close() 16642365ec6Sopenharmony_ci } 16742365ec6Sopenharmony_ci if (data && data?.zoomRatio && data.zoomRatio !== 1) { 16842365ec6Sopenharmony_ci await this.mCameraService.setZoomRatio(data.zoomRatio) 16942365ec6Sopenharmony_ci } 17042365ec6Sopenharmony_ci this.mSessionList = [] 17142365ec6Sopenharmony_ci this.enableUi() 17242365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_PREVIEW_FINISHED); 17342365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.updateCameraStatus()) 17442365ec6Sopenharmony_ci Log.end(`${this.TAG} reStartPreview`) 17542365ec6Sopenharmony_ci } 17642365ec6Sopenharmony_ci 17742365ec6Sopenharmony_ci private async changeMode(data) { 17842365ec6Sopenharmony_ci Log.start(`${this.TAG} changeMode`) 17942365ec6Sopenharmony_ci ReportUtil.write(ReportUtil.SWITCH_MODE) 18042365ec6Sopenharmony_ci this.mCurrentMode = data.mode 18142365ec6Sopenharmony_ci this.mCameraId = this.mCameraId.split('_').pop() as string; 18242365ec6Sopenharmony_ci Log.info(`${this.TAG} this.mCurrentMode = ${this.mCurrentMode}`) 18342365ec6Sopenharmony_ci await this.mCameraService.releaseCamera() 18442365ec6Sopenharmony_ci await this.mCameraService.createCameraInput(this.mCameraId, 'modeChange') 18542365ec6Sopenharmony_ci await this.mCameraService.createPreviewOutput(this.mSurfaceId, this.mCurrentMode) 18642365ec6Sopenharmony_ci if (await this.isVideoMode()) { 18742365ec6Sopenharmony_ci // await this.mCameraService.createVideoOutput(this.functionBackImpl) 18842365ec6Sopenharmony_ci } else { 18942365ec6Sopenharmony_ci await this.mCameraService.createPhotoOutput(this.functionBackImpl) 19042365ec6Sopenharmony_ci } 19142365ec6Sopenharmony_ci await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) 19242365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.onModeChanged(this.mCurrentMode)) 19342365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.swipeModeChangeDone(false)) 19442365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_PREVIEW_FINISHED); 19542365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.updateCameraStatus()) 19642365ec6Sopenharmony_ci this.enableUi() 19742365ec6Sopenharmony_ci Log.end(`${this.TAG} changeMode`) 19842365ec6Sopenharmony_ci } 19942365ec6Sopenharmony_ci 20042365ec6Sopenharmony_ci private async switchCamera(data) { 20142365ec6Sopenharmony_ci Log.start(`${this.TAG} switchCamera`) 20242365ec6Sopenharmony_ci ReportUtil.write(ReportUtil.SWITCH_CAMERA) 20342365ec6Sopenharmony_ci this.mCameraId = data.cameraId 20442365ec6Sopenharmony_ci this.mCameraService.setCameraId(this.mCameraId) 20542365ec6Sopenharmony_ci await this.mCameraService.releaseCamera() 20642365ec6Sopenharmony_ci await this.mCameraService.createCameraInput(this.mCameraId) 20742365ec6Sopenharmony_ci if (data?.curMode && data.curMode !== undefined && data.curMode !== this.mCurrentMode) { 20842365ec6Sopenharmony_ci this.mCurrentMode = data.curMode 20942365ec6Sopenharmony_ci } 21042365ec6Sopenharmony_ci await this.mCameraService.createPreviewOutput(this.mSurfaceId, this.mCurrentMode) 21142365ec6Sopenharmony_ci if (await this.isVideoMode()) { 21242365ec6Sopenharmony_ci // await this.mCameraService.createVideoOutput(this.functionBackImpl) 21342365ec6Sopenharmony_ci } else { 21442365ec6Sopenharmony_ci await this.mCameraService.createPhotoOutput(this.functionBackImpl) 21542365ec6Sopenharmony_ci } 21642365ec6Sopenharmony_ci await this.mCameraService.createSession(this.mSurfaceId, await this.isVideoMode()) 21742365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_PREVIEW_FINISHED); 21842365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.updateCameraStatus()) 21942365ec6Sopenharmony_ci if (new Date().getTime() - GlobalContext.get().getT<number>('switchCameraTime') > 2000) { 22042365ec6Sopenharmony_ci ReportUtil.write(ReportUtil.SWITCH_TIMEOUT) 22142365ec6Sopenharmony_ci } 22242365ec6Sopenharmony_ci this.enableUi() 22342365ec6Sopenharmony_ci Log.end(`${this.TAG} switchCamera`) 22442365ec6Sopenharmony_ci } 22542365ec6Sopenharmony_ci 22642365ec6Sopenharmony_ci private async close() { 22742365ec6Sopenharmony_ci Log.start(`${this.TAG} close`) 22842365ec6Sopenharmony_ci this.mSessionList.push('RELEASE') 22942365ec6Sopenharmony_ci if (GlobalContext.get().getT<boolean>('isSessionCreating') || this.isSessionReleasing) { 23042365ec6Sopenharmony_ci Log.info(`${this.TAG} isSessionCreating or isSessionReleasing return`) 23142365ec6Sopenharmony_ci return 23242365ec6Sopenharmony_ci } 23342365ec6Sopenharmony_ci this.isSessionReleasing = true 23442365ec6Sopenharmony_ci await this.mCameraService.releaseCamera() 23542365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_RELEASE_FINISHED); 23642365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.updateCameraStatus()) 23742365ec6Sopenharmony_ci this.startIdentification = false 23842365ec6Sopenharmony_ci this.isSessionReleasing = false 23942365ec6Sopenharmony_ci if ([...this.mSessionList].pop() === 'CREATE') { 24042365ec6Sopenharmony_ci await this.initCamera(this.initDataCache) 24142365ec6Sopenharmony_ci GlobalContext.get().setObject('cameraStatus', CameraStatus.CAMERA_INIT_FINISHED); 24242365ec6Sopenharmony_ci this.mWorkerManager.postMessage(Action.updateCameraStatus()) 24342365ec6Sopenharmony_ci } 24442365ec6Sopenharmony_ci this.mSessionList = [] 24542365ec6Sopenharmony_ci Log.end(`${this.TAG} close`) 24642365ec6Sopenharmony_ci } 24742365ec6Sopenharmony_ci 24842365ec6Sopenharmony_ci private async isVideoMode(): Promise<boolean> { 24942365ec6Sopenharmony_ci Log.info(`${this.TAG} isVideoMode ${this.mCurrentMode} ${this.mCurrentMode === 'VIDEO'}`) 25042365ec6Sopenharmony_ci return this.mCurrentMode === 'VIDEO' 25142365ec6Sopenharmony_ci } 25242365ec6Sopenharmony_ci 25342365ec6Sopenharmony_ci private async reloadThumbnail(data) { 25442365ec6Sopenharmony_ci Log.info(`${this.TAG} loadThumbnail E`) 25542365ec6Sopenharmony_ci this.mCameraService.getThumbnail(this.functionBackImpl) 25642365ec6Sopenharmony_ci Log.info(`${this.TAG} loadThumbnail X`) 25742365ec6Sopenharmony_ci } 25842365ec6Sopenharmony_ci 25942365ec6Sopenharmony_ci static getInstance() { 26042365ec6Sopenharmony_ci if (!globalThis?.cameraBasicMethod) { 26142365ec6Sopenharmony_ci globalThis.cameraBasicMethod = new CameraBasicFunction() 26242365ec6Sopenharmony_ci } 26342365ec6Sopenharmony_ci return globalThis.cameraBasicMethod 26442365ec6Sopenharmony_ci } 26542365ec6Sopenharmony_ci 26642365ec6Sopenharmony_ci load(): void { 26742365ec6Sopenharmony_ci Log.info(`${this.TAG} load E`) 26842365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_INIT, this.initCamera.bind(this)) 26942365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_CHANGE_IMAGE_SIZE, this.imageSize.bind(this)) 27042365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_CHANGE_VIDEO_SIZE, this.videoSize.bind(this)) 27142365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_PREPARE_SURFACE, this.onSurfacePrepare.bind(this)) 27242365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_START_PREVIEW, this.startPreview.bind(this)) 27342365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_RESTART_PREVIEW, this.reStartPreview.bind(this)) 27442365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_CHANGE_MODE, this.changeMode.bind(this)) 27542365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) 27642365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_CLOSE_CAMERA, this.close.bind(this)) 27742365ec6Sopenharmony_ci this.mEventBus.on(Action.ACTION_RELOAD_THUMBNAIL, this.reloadThumbnail.bind(this)) 27842365ec6Sopenharmony_ci Log.info(`${this.TAG} load X`) 27942365ec6Sopenharmony_ci } 28042365ec6Sopenharmony_ci 28142365ec6Sopenharmony_ci unload(): void { 28242365ec6Sopenharmony_ci Log.info(`${this.TAG} unload E`) 28342365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_INIT, this.initCamera.bind(this)) 28442365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_CHANGE_IMAGE_SIZE, this.imageSize.bind(this)) 28542365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_CHANGE_VIDEO_SIZE, this.videoSize.bind(this)) 28642365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_PREPARE_SURFACE, this.onSurfacePrepare.bind(this)) 28742365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_START_PREVIEW, this.startPreview.bind(this)) 28842365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_RESTART_PREVIEW, this.reStartPreview.bind(this)) 28942365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_CHANGE_MODE, this.changeMode.bind(this)) 29042365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_SWITCH_CAMERA, this.switchCamera.bind(this)) 29142365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_CLOSE_CAMERA, this.close.bind(this)) 29242365ec6Sopenharmony_ci this.mEventBus.off(Action.ACTION_RELOAD_THUMBNAIL, this.reloadThumbnail.bind(this)) 29342365ec6Sopenharmony_ci Log.info(`${this.TAG} unload X`) 29442365ec6Sopenharmony_ci } 29542365ec6Sopenharmony_ci}