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