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
16 #include "offline_stream_operator_proxy.h"
17 #include <hdf_base.h>
18 #include <hdf_log.h>
19 #include <message_parcel.h>
20
21 namespace OHOS::Camera {
CancelCapture(int captureId)22 CamRetCode OfflineStreamOperatorProxy::CancelCapture(int captureId)
23 {
24 MessageParcel data;
25 MessageParcel reply;
26 MessageOption option;
27
28 if (!data.WriteInterfaceToken(OfflineStreamOperatorProxy::GetDescriptor()) ||
29 !data.WriteInt32(static_cast<int32_t>(captureId))) {
30 HDF_LOGE("%s: write captureId obj failed!", __func__);
31 return INVALID_ARGUMENT;
32 }
33
34 int32_t ret = Remote()->SendRequest(CMD_OFFLINE_STREAM_OPERATOR_CANCEL_CAPTURE, data, reply, option);
35 if (ret != HDF_SUCCESS) {
36 HDF_LOGE("%{public}s: SendRequest failed, error code is %{public}d", __func__, ret);
37 return INVALID_ARGUMENT;
38 }
39
40 int32_t result = reply.ReadInt32();
41 HDF_LOGE("%s: CameraHostProxy::return entry! result = %d", __func__, result);
42
43 return static_cast<CamRetCode>(result);
44 }
45
ReleaseStreams(const std::vector<int> & streamIds)46 CamRetCode OfflineStreamOperatorProxy::ReleaseStreams(const std::vector<int> &streamIds)
47 {
48 MessageParcel data;
49 MessageParcel reply;
50 MessageOption option;
51
52 std::vector<int32_t> pxyStreamIds = streamIds;
53 if (!data.WriteInterfaceToken(OfflineStreamOperatorProxy::GetDescriptor()) ||
54 !data.WriteInt32Vector(pxyStreamIds)) {
55 HDF_LOGE("%s: write streamIds obj failed!", __func__);
56 return INVALID_ARGUMENT;
57 }
58
59 int32_t ret = Remote()->SendRequest(CMD_OFFLINE_STREAM_OPERATOR_RELEASE_STREAMS, data, reply, option);
60 if (ret != HDF_SUCCESS) {
61 HDF_LOGE("%{public}s: SendRequest failed, error code is %{public}d", __func__, ret);
62 return INVALID_ARGUMENT;
63 }
64
65 int32_t result = reply.ReadInt32();
66 HDF_LOGE("%s: CameraHostProxy::return entry! result = %d", __func__, result);
67
68 return static_cast<CamRetCode>(result);
69 }
70
Release()71 CamRetCode OfflineStreamOperatorProxy::Release()
72 {
73 MessageParcel data;
74 MessageParcel reply;
75 MessageOption option;
76 if (!data.WriteInterfaceToken(OfflineStreamOperatorProxy::GetDescriptor())) {
77 return INVALID_ARGUMENT;
78 }
79 int32_t ret = Remote()->SendRequest(CMD_OFFLINE_STREAM_OPERATOR_RELEASE, data, reply, option);
80 if (ret != HDF_SUCCESS) {
81 HDF_LOGE("%{public}s: SendRequest failed, error code is %{public}d", __func__, ret);
82 return INVALID_ARGUMENT;
83 }
84
85 int32_t result = reply.ReadInt32();
86 HDF_LOGE("%s: CameraHostProxy::return entry! result = %d", __func__, result);
87
88 return static_cast<CamRetCode>(result);
89 }
90 }