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_repeat_callback_proxy.h"
17 #include "camera_log.h"
18 #include "remote_request_code.h"
19
20 namespace OHOS {
21 namespace CameraStandard {
HStreamRepeatCallbackProxy(const sptr<IRemoteObject> & impl)22 HStreamRepeatCallbackProxy::HStreamRepeatCallbackProxy(const sptr<IRemoteObject> &impl)
23 : IRemoteProxy<IStreamRepeatCallback>(impl) { }
24
OnFrameStarted()25 int32_t HStreamRepeatCallbackProxy::OnFrameStarted()
26 {
27 MessageParcel data;
28 MessageParcel reply;
29 MessageOption option;
30
31 if (!data.WriteInterfaceToken(GetDescriptor())) {
32 MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameStarted Write interface token failed");
33 return IPC_PROXY_ERR;
34 }
35 int error = Remote()->SendRequest(CAMERA_STREAM_REPEAT_ON_FRAME_STARTED, data, reply, option);
36 if (error != ERR_NONE) {
37 MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameStarted failed, error: %{public}d", error);
38 }
39
40 return error;
41 }
42
OnFrameEnded(int32_t frameCount)43 int32_t HStreamRepeatCallbackProxy::OnFrameEnded(int32_t frameCount)
44 {
45 MessageParcel data;
46 MessageParcel reply;
47 MessageOption option;
48
49 if (!data.WriteInterfaceToken(GetDescriptor())) {
50 MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameEnded Write interface token failed");
51 return IPC_PROXY_ERR;
52 }
53 if (!data.WriteInt32(frameCount)) {
54 MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameEnded Write frameCount failed");
55 return IPC_PROXY_ERR;
56 }
57
58 int error = Remote()->SendRequest(CAMERA_STREAM_REPEAT_ON_FRAME_ENDED, data, reply, option);
59 if (error != ERR_NONE) {
60 MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameEnded failed, error: %{public}d", error);
61 }
62
63 return error;
64 }
65
OnFrameError(int32_t errorCode)66 int32_t HStreamRepeatCallbackProxy::OnFrameError(int32_t errorCode)
67 {
68 MessageParcel data;
69 MessageParcel reply;
70 MessageOption option;
71
72 if (!data.WriteInterfaceToken(GetDescriptor())) {
73 MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameError Write interface token failed");
74 return IPC_PROXY_ERR;
75 }
76 if (!data.WriteInt32(errorCode)) {
77 MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameError Write errorType failed");
78 return IPC_PROXY_ERR;
79 }
80
81 int error = Remote()->SendRequest(CAMERA_STREAM_REPEAT_ON_ERROR, data, reply, option);
82 if (error != ERR_NONE) {
83 MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameError failed, error: %{public}d", error);
84 }
85
86 return error;
87 }
88 } // namespace CameraStandard
89 } // namespace OHOS
90