• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "hstream_depth_data_proxy.h"
17 
18 #include "camera_log.h"
19 #include "camera_service_ipc_interface_code.h"
20 
21 namespace OHOS {
22 namespace CameraStandard {
23 
HStreamDepthDataProxy(const sptr<IRemoteObject> & impl)24 HStreamDepthDataProxy::HStreamDepthDataProxy(const sptr<IRemoteObject>& impl) : IRemoteProxy<IStreamDepthData>(impl) {}
25 
~HStreamDepthDataProxy()26 HStreamDepthDataProxy::~HStreamDepthDataProxy()
27 {
28     MEDIA_INFO_LOG("~HStreamDepthDataProxy is called");
29 }
30 
Start()31 int32_t HStreamDepthDataProxy::Start()
32 {
33     MessageParcel data;
34     MessageParcel reply;
35     MessageOption option;
36 
37     data.WriteInterfaceToken(GetDescriptor());
38     int error = Remote()->SendRequest(
39         static_cast<uint32_t>(StreamDepthDataInterfaceCode::CAMERA_STREAM_DEPTH_DATA_START), data, reply, option);
40     CHECK_ERROR_PRINT_LOG(error != ERR_NONE, "HStreamDepthDataProxy Start failed, error: %{public}d", error);
41 
42     return error;
43 }
44 
Stop()45 int32_t HStreamDepthDataProxy::Stop()
46 {
47     MessageParcel data;
48     MessageParcel reply;
49     MessageOption option;
50 
51     data.WriteInterfaceToken(GetDescriptor());
52     int error = Remote()->SendRequest(
53         static_cast<uint32_t>(StreamDepthDataInterfaceCode::CAMERA_STREAM_DEPTH_DATA_STOP), data, reply, option);
54     CHECK_ERROR_PRINT_LOG(error != ERR_NONE, "HStreamDepthDataProxy Stop failed, error: %{public}d", error);
55 
56     return error;
57 }
58 
Release()59 int32_t HStreamDepthDataProxy::Release()
60 {
61     MessageParcel data;
62     MessageParcel reply;
63     MessageOption option;
64 
65     data.WriteInterfaceToken(GetDescriptor());
66     int error = Remote()->SendRequest(
67         static_cast<uint32_t>(StreamDepthDataInterfaceCode::CAMERA_STREAM_DEPTH_DATA_RELEASE), data, reply, option);
68     CHECK_ERROR_PRINT_LOG(error != ERR_NONE, "HStreamDepthDataProxy Stop failed, error: %{public}d", error);
69     return error;
70 }
71 
SetCallback(sptr<IStreamDepthDataCallback> & callback)72 int32_t HStreamDepthDataProxy::SetCallback(sptr<IStreamDepthDataCallback>& callback)
73 {
74     MessageParcel data;
75     MessageParcel reply;
76     MessageOption option;
77 
78     CHECK_ERROR_RETURN_RET_LOG(callback == nullptr, IPC_PROXY_ERR,
79         "HStreamDepthDataProxy SetCallback callback is null");
80 
81     data.WriteInterfaceToken(GetDescriptor());
82     data.WriteRemoteObject(callback->AsObject());
83 
84     int error = Remote()->SendRequest(static_cast<uint32_t>(
85         StreamDepthDataInterfaceCode::CAMERA_STREAM_DEPTH_DATA_SET_CALLBACK), data, reply, option);
86     CHECK_ERROR_PRINT_LOG(error != ERR_NONE, "HStreamDepthDataProxy SetCallback failed, error: %{public}d", error);
87 
88     return error;
89 }
90 
UnSetCallback()91 int32_t HStreamDepthDataProxy::UnSetCallback()
92 {
93     MessageParcel data;
94     MessageParcel reply;
95     MessageOption option;
96     data.WriteInterfaceToken(GetDescriptor());
97     int error = Remote()->SendRequest(
98         static_cast<uint32_t>(StreamDepthDataInterfaceCode::CAMERA_STREAM_DEPTH_DATA_UNSET_CALLBACK), data, reply,
99         option);
100     if (error != ERR_NONE) {
101         MEDIA_ERR_LOG("HStreamDepthDataProxy UnSetCallback failed, error: %{public}d", error);
102     }
103     return error;
104 }
105 
SetDataAccuracy(int32_t dataAccuracy)106 int32_t HStreamDepthDataProxy::SetDataAccuracy(int32_t dataAccuracy)
107 {
108     MessageParcel data;
109     MessageParcel reply;
110     MessageOption option;
111 
112     data.WriteInterfaceToken(GetDescriptor());
113     data.WriteInt32(dataAccuracy);
114 
115     int error = Remote()->SendRequest(static_cast<uint32_t>(
116         StreamDepthDataInterfaceCode::CAMERA_STREAM_DEPTH_DATA_ACCURACY_SET), data, reply, option);
117     CHECK_ERROR_PRINT_LOG(error != ERR_NONE, "HStreamDepthDataProxy SetDataAccuracy failed, error: %{public}d", error);
118     return error;
119 }
120 } // namespace CameraStandard
121 } // namespace OHOS
122