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_HCAMERA_SERVICE_PROXY_H
17 #define OHOS_CAMERA_HCAMERA_SERVICE_PROXY_H
18 
19 #include "icamera_service.h"
20 #include "icamera_service_callback.h"
21 #include "iremote_proxy.h"
22 
23 namespace OHOS {
24 namespace CameraStandard {
25 class HCameraProxy : public IRemoteProxy<ICameraBroker> {
26 public:
27     explicit HCameraProxy(const sptr<IRemoteObject> &impl);
28     ~HCameraProxy() = default;
29 
30     int32_t NotifyCloseCamera(std::string cameraId) override;
31     int32_t NotifyMuteCamera(bool muteMode) override;
32 private:
33     static inline BrokerDelegator<HCameraProxy> delegator_;
34 };
35 
36 class HCameraServiceProxy : public IRemoteProxy<ICameraService> {
37 public:
38     explicit HCameraServiceProxy(const sptr<IRemoteObject> &impl);
39 
40     virtual ~HCameraServiceProxy() = default;
41 
42     int32_t CreateCameraDevice(std::string cameraId, sptr<ICameraDeviceService>& device) override;
43 
44     int32_t SetCameraCallback(sptr<ICameraServiceCallback>& callback) override;
45 
46     int32_t SetMuteCallback(sptr<ICameraMuteServiceCallback>& callback) override;
47 
48     int32_t SetTorchCallback(sptr<ITorchServiceCallback>& callback) override;
49 
50     int32_t SetFoldStatusCallback(sptr<IFoldServiceCallback>& callback, bool isInnerCallback = false) override;
51 
52     int32_t GetCameras(std::vector<std::string> &cameraIds,
53         std::vector<std::shared_ptr<OHOS::Camera::CameraMetadata>> &cameraAbilityList) override;
54 
55     int32_t GetCameraIds(std::vector<std::string>& cameraIds) override;
56 
57     int32_t GetCameraAbility(std::string& cameraId,
58         std::shared_ptr<OHOS::Camera::CameraMetadata>& cameraAbility) override;
59 
60     int32_t CreateCaptureSession(sptr<ICaptureSession>& session, int32_t operationMode = 0) override;
61 
62     int32_t CreateDeferredPhotoProcessingSession(int32_t userId,
63         sptr<DeferredProcessing::IDeferredPhotoProcessingSessionCallback>& callback,
64         sptr<DeferredProcessing::IDeferredPhotoProcessingSession>& session) override;
65 
66     int32_t CreateDeferredVideoProcessingSession(int32_t userId,
67         sptr<DeferredProcessing::IDeferredVideoProcessingSessionCallback>& callback,
68         sptr<DeferredProcessing::IDeferredVideoProcessingSession>& session) override;
69 
70     int32_t CreatePhotoOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
71                               int32_t width, int32_t height, sptr<IStreamCapture> &photoOutput) override;
72 
73     int32_t CreatePreviewOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
74                                 int32_t width, int32_t height, sptr<IStreamRepeat> &previewOutput) override;
75 
76     int32_t CreateDeferredPreviewOutput(int32_t format, int32_t width, int32_t height,
77                                         sptr<IStreamRepeat> &previewOutput) override;
78 
79     int32_t CreateDepthDataOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
80                                   int32_t width, int32_t height, sptr<IStreamDepthData> &depthDataOutput) override;
81 
82     int32_t CreateMetadataOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
83                                  std::vector<int32_t> metadataTypes,
84                                  sptr<IStreamMetadata>& metadataOutput) override;
85 
86     int32_t CreateVideoOutput(const sptr<OHOS::IBufferProducer> &producer, int32_t format,
87                               int32_t width, int32_t height, sptr<IStreamRepeat> &videoOutput) override;
88 
89     int32_t SetListenerObject(const sptr<IRemoteObject> &object) override;
90 
91     int32_t MuteCamera(bool muteMode) override;
92 
93     int32_t MuteCameraPersist(PolicyType policyType, bool isMute) override;
94 
95     int32_t PrelaunchCamera() override;
96 
97     int32_t PreSwitchCamera(const std::string cameraId) override;
98 
99     int32_t SetPrelaunchConfig(std::string cameraId, RestoreParamTypeOhos restoreParamType, int activeTime,
100         EffectParam effectParam) override;
101 
102     int32_t IsCameraMuted(bool &muteMode) override;
103 
104     int32_t SetTorchLevel(float level) override;
105 
106     int32_t AllowOpenByOHSide(std::string cameraId, int32_t state, bool &canOpenCamera) override;
107 
108     int32_t NotifyCameraState(std::string cameraId, int32_t state) override;
109 
110     int32_t SetPeerCallback(sptr<ICameraBroker>& callback) override;
111 
112     int32_t UnsetPeerCallback() override;
113 
114     int32_t DestroyStubObj() override;
115 
116     int32_t ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy) override;
117 
118     int32_t ResetAllFreezeStatus() override;
119 
120     int32_t GetDmDeviceInfo(std::vector<std::string> &deviceInfos) override;
121 
122     int32_t GetCameraOutputStatus(int32_t pid, int32_t &status) override;
123 
124     int32_t RequireMemorySize(int32_t memSize) override;
125 private:
126     static inline BrokerDelegator<HCameraServiceProxy> delegator_;
127 };
128 } // namespace CameraStandard
129 } // namespace OHOS
130 #endif // OHOS_CAMERA_HCAMERA_SERVICE_PROXY_H
131