1 /*
2  * Copyright (c) 2021 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 #ifndef OHOS_DISTRIBUTED_CAMERA_SOURCE_PROXY_H
16 #define OHOS_DISTRIBUTED_CAMERA_SOURCE_PROXY_H
17 
18 #include <cstdint>
19 
20 #include "iremote_proxy.h"
21 #include "iremote_broker.h"
22 #include "refbase.h"
23 #include "idistributed_camera_source.h"
24 #include "idistributed_hardware_source.h"
25 namespace OHOS { class IRemoteObject; }
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 class DistributedCameraSourceProxy : public IRemoteProxy<IDistributedCameraSource> {
30 public:
DistributedCameraSourceProxy(const sptr<IRemoteObject> & impl)31     explicit DistributedCameraSourceProxy(const sptr<IRemoteObject>& impl)
32         : IRemoteProxy<IDistributedCameraSource>(impl)
33     {
34     }
35 
~DistributedCameraSourceProxy()36     ~DistributedCameraSourceProxy() {}
37     int32_t InitSource(const std::string& params, const sptr<IDCameraSourceCallback>& callback) override;
38     int32_t ReleaseSource() override;
39     int32_t RegisterDistributedHardware(const std::string& devId, const std::string& dhId,
40         const std::string& reqId, const EnableParam& param) override;
41     int32_t UnregisterDistributedHardware(const std::string& devId, const std::string& dhId,
42         const std::string& reqId) override;
43     int32_t DCameraNotify(const std::string& devId, const std::string& dhId, std::string& events) override;
44 
45 private:
46     bool CheckRegParams(const std::string& devId, const std::string& dhId,
47         const std::string& reqId, const EnableParam& param);
48     bool CheckUnregParams(const std::string& devId, const std::string& dhId, const std::string& reqId);
49     bool CheckNotifyParams(const std::string& devId, const std::string& dhId, std::string& events);
50 
51     static inline BrokerDelegator<DistributedCameraSourceProxy> delegator_;
52     const size_t PARAM_MAX_SIZE = 50 * 1024 * 1024;
53     const size_t DID_MAX_SIZE = 256;
54 };
55 } // namespace DistributedHardware
56 } // namespace OHOS
57 #endif // OHOS_DISTRIBUTED_CAMERA_SOURCE_PROXY_H
58