• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2023 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 "deferred_photo_processing_session_proxy.h"
17 #include "deferred_processing_service_ipc_interface_code.h"
18 #include "dp_log.h"
19 
20 namespace OHOS {
21 namespace CameraStandard {
22 namespace DeferredProcessing {
DeferredPhotoProcessingSessionProxy(const sptr<IRemoteObject> & impl)23 DeferredPhotoProcessingSessionProxy::DeferredPhotoProcessingSessionProxy(const sptr<IRemoteObject> &impl)
24     : IRemoteProxy<IDeferredPhotoProcessingSession>(impl) { }
25 
BeginSynchronize()26 int32_t DeferredPhotoProcessingSessionProxy::BeginSynchronize()
27 {
28     MessageParcel data;
29     MessageParcel reply;
30     MessageOption option;
31 
32     data.WriteInterfaceToken(GetDescriptor());
33     int error = Remote()->SendRequest(
34         static_cast<uint32_t>(DeferredProcessingServiceInterfaceCode::DPS_BEGIN_SYNCHRONIZE), data, reply, option);
35     if (error != ERR_NONE) {
36         DP_ERR_LOG("DeferredPhotoProcessingSessionProxy::BeginSynchronize failed, error: %{public}d", error);
37     }
38     return error;
39 }
40 
EndSynchronize()41 int32_t DeferredPhotoProcessingSessionProxy::EndSynchronize()
42 {
43     MessageParcel data;
44     MessageParcel reply;
45     MessageOption option;
46 
47     data.WriteInterfaceToken(GetDescriptor());
48     int error = Remote()->SendRequest(
49         static_cast<uint32_t>(DeferredProcessingServiceInterfaceCode::DPS_END_SYNCHRONIZE), data, reply, option);
50     if (error != ERR_NONE) {
51         DP_ERR_LOG("DeferredPhotoProcessingSessionProxy::EndSynchronize failed, error: %{public}d", error);
52     }
53     return error;
54 }
55 
AddImage(const std::string & imageId,DpsMetadata & metadata,const bool discardable)56 int32_t DeferredPhotoProcessingSessionProxy::AddImage(const std::string& imageId,
57     DpsMetadata& metadata, const bool discardable)
58 {
59     MessageParcel data;
60     MessageParcel reply;
61     MessageOption option;
62 
63     data.WriteInterfaceToken(GetDescriptor());
64     data.WriteString(imageId);
65     metadata.WriteToParcel(data);
66     data.WriteBool(discardable);
67 
68     int error = Remote()->SendRequest(
69         static_cast<uint32_t>(DeferredProcessingServiceInterfaceCode::DPS_ADD_IMAGE), data, reply, option);
70     if (error != ERR_NONE) {
71         DP_ERR_LOG("DeferredPhotoProcessingSessionProxy::AddImage failed, error: %{public}d", error);
72     }
73     return error;
74 }
75 
RemoveImage(const std::string & imageId,const bool restorable)76 int32_t DeferredPhotoProcessingSessionProxy::RemoveImage(const std::string& imageId, const bool restorable)
77 {
78     MessageParcel data;
79     MessageParcel reply;
80     MessageOption option;
81 
82     data.WriteInterfaceToken(GetDescriptor());
83     data.WriteString(imageId);
84     data.WriteBool(restorable);
85 
86     int error = Remote()->SendRequest(
87         static_cast<uint32_t>(DeferredProcessingServiceInterfaceCode::DPS_REMOVE_IMAGE), data, reply, option);
88     if (error != ERR_NONE) {
89         DP_ERR_LOG("DeferredPhotoProcessingSessionProxy::RemoveImage failed, error: %{public}d", error);
90     }
91     return error;
92 }
93 
RestoreImage(const std::string & imageId)94 int32_t DeferredPhotoProcessingSessionProxy::RestoreImage(const std::string& imageId)
95 {
96     MessageParcel data;
97     MessageParcel reply;
98     MessageOption option;
99 
100     data.WriteInterfaceToken(GetDescriptor());
101     data.WriteString(imageId);
102 
103     int error = Remote()->SendRequest(
104         static_cast<uint32_t>(DeferredProcessingServiceInterfaceCode::DPS_RESTORE_IMAGE), data, reply, option);
105     if (error != ERR_NONE) {
106         DP_ERR_LOG("DeferredPhotoProcessingSessionProxy::RestoreImage failed, error: %{public}d", error);
107     }
108     return error;
109 }
110 
ProcessImage(const std::string & appName,const std::string & imageId)111 int32_t DeferredPhotoProcessingSessionProxy::ProcessImage(const std::string& appName, const std::string& imageId)
112 {
113     MessageParcel data;
114     MessageParcel reply;
115     MessageOption option;
116 
117     data.WriteInterfaceToken(GetDescriptor());
118     data.WriteString(appName);
119     data.WriteString(imageId);
120 
121     int error = Remote()->SendRequest(
122         static_cast<uint32_t>(DeferredProcessingServiceInterfaceCode::DPS_PROCESS_IMAGE), data, reply, option);
123     if (error != ERR_NONE) {
124         DP_ERR_LOG("DeferredPhotoProcessingSessionProxy::ProcessImage failed, error: %{public}d", error);
125     }
126     return error;
127 }
128 
CancelProcessImage(const std::string & imageId)129 int32_t DeferredPhotoProcessingSessionProxy::CancelProcessImage(const std::string& imageId)
130 {
131     MessageParcel data;
132     MessageParcel reply;
133     MessageOption option;
134 
135     data.WriteInterfaceToken(GetDescriptor());
136     data.WriteString(imageId);
137 
138     int error = Remote()->SendRequest(
139         static_cast<uint32_t>(DeferredProcessingServiceInterfaceCode::DPS_CANCEL_PROCESS_IMAGE), data, reply, option);
140     if (error != ERR_NONE) {
141         DP_ERR_LOG("DeferredPhotoProcessingSessionProxy::CancelProcessImage failed, error: %{public}d", error);
142     }
143     return error;
144 }
145 
146 } // namespace DeferredProcessing
147 } // namespace CameraStandard
148 } // namespace OHOS
149