1 /* 2 * Copyright (c) 2021-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 OHOS_CAMERA_H_CAMERA_DEVICE_H 17 #define OHOS_CAMERA_H_CAMERA_DEVICE_H 18 19 #include "camera_device_callback_stub.h" 20 #include "camera_metadata_info.h" 21 #include "hcamera_device_stub.h" 22 #include "hcamera_host_manager.h" 23 #include "icamera_device.h" 24 #include "icamera_host.h" 25 26 #include <iostream> 27 28 namespace OHOS { 29 namespace CameraStandard { 30 class CameraDeviceCallback; 31 32 class HCameraDevice : public HCameraDeviceStub { 33 public: 34 HCameraDevice(sptr<HCameraHostManager> &cameraHostManager, sptr<CameraDeviceCallback> deviceCallback, 35 std::string cameraID); 36 ~HCameraDevice(); 37 38 int32_t Open() override; 39 int32_t Close() override; 40 int32_t Release() override; 41 int32_t UpdateSetting(const std::shared_ptr<Camera::CameraMetadata> &settings) override; 42 int32_t GetEnabledResults(std::vector<int32_t> &results) override; 43 int32_t EnableResult(std::vector<int32_t> &results) override; 44 int32_t DisableResult(std::vector<int32_t> &results) override; 45 int32_t GetStreamOperator(sptr<Camera::IStreamOperatorCallback> callback, 46 sptr<Camera::IStreamOperator> &streamOperator); 47 sptr<Camera::IStreamOperator> GetStreamOperator(); 48 int32_t SetCallback(sptr<ICameraDeviceServiceCallback> &callback) override; 49 int32_t OnError(const Camera::ErrorType type, const int32_t errorMsg); 50 int32_t OnResult(const uint64_t timestamp, const std::shared_ptr<Camera::CameraMetadata> &result); 51 std::shared_ptr<Camera::CameraMetadata> GetSettings(); 52 std::string GetCameraId(); 53 bool IsReleaseCameraDevice(); 54 int32_t SetReleaseCameraDevice(bool isRelease); 55 56 private: 57 sptr<Camera::ICameraDevice> hdiCameraDevice_; 58 sptr<HCameraHostManager> cameraHostManager_; 59 std::string cameraID_; 60 bool isReleaseCameraDevice_; 61 sptr<ICameraDeviceServiceCallback> deviceSvcCallback_; 62 sptr<CameraDeviceCallback> deviceHDICallback_; 63 std::shared_ptr<Camera::CameraMetadata> updateSettings_; 64 sptr<Camera::IStreamOperator> streamOperator_; 65 }; 66 67 class CameraDeviceCallback : public Camera::CameraDeviceCallbackStub { 68 public: 69 CameraDeviceCallback() = default; 70 CameraDeviceCallback(sptr<HCameraDevice> hCameraDevice); 71 virtual ~CameraDeviceCallback() = default; 72 virtual void OnError(Camera::ErrorType type, int32_t errorMsg) override; 73 virtual void OnResult(const uint64_t timestamp, 74 const std::shared_ptr<Camera::CameraMetadata> &result) override; 75 void SetHCameraDevice(sptr<HCameraDevice> hcameraDevice); 76 77 private: 78 sptr<HCameraDevice> hCameraDevice_; 79 }; 80 } // namespace CameraStandard 81 } // namespace OHOS 82 #endif // OHOS_CAMERA_H_CAMERA_DEVICE_H 83