• 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_repeat_callback_proxy.h"
17 #include "camera_log.h"
18 #include "camera_service_ipc_interface_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(
36         static_cast<uint32_t>(StreamRepeatCallbackInterfaceCode::CAMERA_STREAM_REPEAT_ON_FRAME_STARTED),
37         data, reply, option);
38     if (error != ERR_NONE) {
39         MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameStarted failed, error: %{public}d", error);
40     }
41 
42     return error;
43 }
44 
OnFrameEnded(int32_t frameCount)45 int32_t HStreamRepeatCallbackProxy::OnFrameEnded(int32_t frameCount)
46 {
47     MessageParcel data;
48     MessageParcel reply;
49     MessageOption option;
50 
51     if (!data.WriteInterfaceToken(GetDescriptor())) {
52         MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameEnded Write interface token failed");
53         return IPC_PROXY_ERR;
54     }
55     if (!data.WriteInt32(frameCount)) {
56         MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameEnded Write frameCount failed");
57         return IPC_PROXY_ERR;
58     }
59 
60     int error = Remote()->SendRequest(
61         static_cast<uint32_t>(StreamRepeatCallbackInterfaceCode::CAMERA_STREAM_REPEAT_ON_FRAME_ENDED),
62         data, reply, option);
63     if (error != ERR_NONE) {
64         MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameEnded failed, error: %{public}d", error);
65     }
66 
67     return error;
68 }
69 
OnFrameError(int32_t errorCode)70 int32_t HStreamRepeatCallbackProxy::OnFrameError(int32_t errorCode)
71 {
72     MessageParcel data;
73     MessageParcel reply;
74     MessageOption option;
75 
76     if (!data.WriteInterfaceToken(GetDescriptor())) {
77         MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameError Write interface token failed");
78         return IPC_PROXY_ERR;
79     }
80     if (!data.WriteInt32(errorCode)) {
81         MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameError Write errorType failed");
82         return IPC_PROXY_ERR;
83     }
84 
85     int error = Remote()->SendRequest(
86         static_cast<uint32_t>(StreamRepeatCallbackInterfaceCode::CAMERA_STREAM_REPEAT_ON_ERROR), data, reply, option);
87     if (error != ERR_NONE) {
88         MEDIA_ERR_LOG("HStreamRepeatCallbackProxy OnFrameError failed, error: %{public}d", error);
89     }
90 
91     return error;
92 }
93 } // namespace CameraStandard
94 } // namespace OHOS
95