1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FACEAUTH_SERVICES_INCLUDE_FACE_AUTH_CAMERA_H 17 #define FACEAUTH_SERVICES_INCLUDE_FACE_AUTH_CAMERA_H 18 19 #include <mutex> 20 #include "input/camera_input.h" 21 #include "input/camera_manager.h" 22 #include "system_ability_definition.h" 23 24 namespace OHOS { 25 namespace UserIAM { 26 namespace FaceAuth { 27 class FaceAuthCamera { 28 public: 29 static std::shared_ptr<FaceAuthCamera> GetInstance(); 30 FaceAuthCamera(); 31 virtual ~FaceAuthCamera(); 32 int32_t OpenCamera(sptr<IBufferProducer> producer); 33 void CloseCamera(); 34 void SetZoomRatio(float zoom); 35 void SetFlashMode(camera_flash_mode_enum_t flash); 36 void SetFocusMode(camera_af_mode_t focus); 37 void SetExposureMode(camera_ae_mode_t exposure); 38 39 private: 40 int32_t CreateCamera(sptr<IBufferProducer> producer); 41 int32_t PrepareCamera(sptr<IBufferProducer> producer); 42 int32_t CreateDisplayPreviewOutput(sptr<CameraStandard::CameraManager> &camManagerObj, 43 sptr<IBufferProducer> producer); 44 int32_t Start(); 45 void Stop(); 46 void Release(); 47 sptr<CameraStandard::CaptureOutput> CreatePreviewOutput(sptr<CameraStandard::CameraManager> &camManagerObj); 48 sptr<CameraStandard::CaptureOutput> CreateTempPreviewOutput(sptr<CameraStandard::CameraManager> &camManagerObj); 49 sptr<CameraStandard::CaptureInput> camInput_; 50 sptr<CameraStandard::CaptureSession> capSession_; 51 sptr<CameraStandard::CaptureOutput> previewOutput_; 52 sptr<CameraStandard::CaptureOutput> disPlayPreviewOutput_; 53 static std::mutex mutex_; 54 static std::shared_ptr<FaceAuthCamera> instance_; 55 bool isDisplay_; 56 }; 57 } // namespace FaceAuth 58 } // namespace UserIAM 59 } // namespace OHOS 60 61 #endif // FACEAUTH_SERVICES_INCLUDE_FACE_AUTH_CAMERA_H 62