• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 CAMERA_MANAGER_IMPL_H
17 #define CAMERA_MANAGER_IMPL_H
18 
19 #include "camera_error.h"
20 #include "camera_utils.h"
21 #include "ffi_remote_data.h"
22 #include "input/camera_manager.h"
23 #include "listener_base.h"
24 
25 namespace OHOS {
26 namespace CameraStandard {
27 class CJCameraManagerCallback : public CameraManagerCallback, public ListenerBase<const CameraStatusInfo &> {
28 public:
29     CJCameraManagerCallback() = default;
30     ~CJCameraManagerCallback() = default;
31     void OnCameraStatusChanged(const CameraStatusInfo &cameraStatusInfo) const override;
32     void OnFlashlightStatusChanged(const std::string &cameraID, const FlashStatus flashStatus) const override;
33 };
34 
35 class CJFoldListener : public FoldListener, public ListenerBase<const FoldStatusInfo &> {
36 public:
37     CJFoldListener() = default;
38     ~CJFoldListener() = default;
39     void OnFoldStatusChanged(const FoldStatusInfo &foldStatusInfo) const override;
40 };
41 
42 class CJTorchListener : public TorchListener, public ListenerBase<const TorchStatusInfo &> {
43 public:
44     CJTorchListener() = default;
45     ~CJTorchListener() = default;
46     void OnTorchStatusChange(const TorchStatusInfo &torchStatusInfo) const override;
47 };
48 
49 class CJCameraManager : public OHOS::FFI::FFIData {
50     DECL_TYPE(CJCameraManager, OHOS::FFI::FFIData)
51 public:
52     CJCameraManager();
53     ~CJCameraManager() override;
54     CArrCJCameraDevice GetSupportedCameras(int32_t *errCode);
55     CArrI32 GetSupportedSceneModes(std::string cameraId, int32_t *errCode);
56     sptr<CameraOutputCapability> GetSupportedOutputCapability(sptr<CameraDevice> &camera, int32_t modeType = 0);
57     static bool IsCameraMuted();
58     int64_t CreateCameraInputWithCameraDevice(sptr<CameraDevice> &camera, sptr<CameraInput> *pCameraInput);
59     int64_t CreateCameraInputWithCameraDeviceInfo(CameraPosition position, CameraType cameraType,
60                                                   sptr<CameraInput> *pCameraInput);
61     static sptr<CameraStandard::CaptureSession> CreateSession(int32_t mode);
62     static bool IsTorchSupported();
63     static bool IsTorchModeSupported(int32_t modeType);
64     static int32_t GetTorchMode();
65     static int32_t SetTorchMode(int32_t modeType);
66     void OnCameraStatusChanged(int64_t callbackId);
67     void OffCameraStatusChanged(int64_t callbackId);
68     void OffAllCameraStatusChanged();
69     void OnFoldStatusChanged(int64_t callbackId);
70     void OffFoldStatusChanged(int64_t callbackId);
71     void OffAllFoldStatusChanged();
72     void OnTorchStatusChange(int64_t callbackId);
73     void OffTorchStatusChange(int64_t callbackId);
74     void OffAllTorchStatusChange();
75 
76     sptr<CameraDevice> GetCameraDeviceById(std::string cameraId);
77 
78 private:
79     sptr<CameraManager> cameraManager_;
80     std::shared_ptr<CJCameraManagerCallback> cameraManagerCallback_;
81     std::shared_ptr<CJFoldListener> foldListener_;
82     std::shared_ptr<CJTorchListener> torchListener_;
83 };
84 } // namespace CameraStandard
85 } // namespace OHOS
86 #endif