• 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 #include "istream_repeat_callback.h"
20 
21 namespace OHOS {
22 namespace CameraStandard {
HStreamRepeatCallbackProxy(const sptr<IRemoteObject> & impl)23 HStreamRepeatCallbackProxy::HStreamRepeatCallbackProxy(const sptr<IRemoteObject> &impl)
24     : IRemoteProxy<IStreamRepeatCallback>(impl) { }
25 
OnFrameStarted()26 int32_t HStreamRepeatCallbackProxy::OnFrameStarted()
27 {
28     MessageParcel data;
29     MessageParcel reply;
30     MessageOption option;
31     option.SetFlags(option.TF_ASYNC);
32 
33     data.WriteInterfaceToken(GetDescriptor());
34     int error = Remote()->SendRequest(
35         static_cast<uint32_t>(StreamRepeatCallbackInterfaceCode::CAMERA_STREAM_REPEAT_ON_FRAME_STARTED),
36         data, reply, option);
37     CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
38         "HStreamRepeatCallbackProxy OnFrameStarted failed, error: %{public}d", error);
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     option.SetFlags(option.TF_ASYNC);
49 
50     data.WriteInterfaceToken(GetDescriptor());
51     data.WriteInt32(frameCount);
52 
53     int error = Remote()->SendRequest(
54         static_cast<uint32_t>(StreamRepeatCallbackInterfaceCode::CAMERA_STREAM_REPEAT_ON_FRAME_ENDED),
55         data, reply, option);
56     CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
57         "HStreamRepeatCallbackProxy OnFrameEnded failed, error: %{public}d", error);
58 
59     return error;
60 }
61 
OnFrameError(int32_t errorCode)62 int32_t HStreamRepeatCallbackProxy::OnFrameError(int32_t errorCode)
63 {
64     MessageParcel data;
65     MessageParcel reply;
66     MessageOption option;
67     option.SetFlags(option.TF_ASYNC);
68 
69     data.WriteInterfaceToken(GetDescriptor());
70     data.WriteInt32(errorCode);
71 
72     int error = Remote()->SendRequest(
73         static_cast<uint32_t>(StreamRepeatCallbackInterfaceCode::CAMERA_STREAM_REPEAT_ON_ERROR), data, reply, option);
74     CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
75         "HStreamRepeatCallbackProxy OnFrameError failed, error: %{public}d", error);
76 
77     return error;
78 }
79 
OnSketchStatusChanged(SketchStatus status)80 int32_t HStreamRepeatCallbackProxy::OnSketchStatusChanged(SketchStatus status)
81 {
82     MessageParcel data;
83     MessageParcel reply;
84     MessageOption option;
85     option.SetFlags(option.TF_ASYNC);
86     data.WriteInterfaceToken(GetDescriptor());
87     data.WriteInt32(static_cast<int32_t>(status));
88 
89     int error = Remote()->SendRequest(
90         static_cast<uint32_t>(StreamRepeatCallbackInterfaceCode::CAMERA_STREAM_SKETCH_STATUS_ON_CHANGED), data, reply,
91         option);
92     CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
93         "HStreamRepeatCallbackProxy OnSketchStatusChanged failed, error: %{public}d", error);
94     return error;
95 }
96 
OnDeferredVideoEnhancementInfo(CaptureEndedInfoExt captureEndedInfo)97 int32_t HStreamRepeatCallbackProxy::OnDeferredVideoEnhancementInfo(CaptureEndedInfoExt captureEndedInfo)
98 {
99     MessageParcel data;
100     MessageParcel reply;
101     MessageOption option;
102     option.SetFlags(option.TF_ASYNC);
103     data.WriteInterfaceToken(GetDescriptor());
104     data.WriteInt32(captureEndedInfo.streamId);
105     data.WriteInt32(captureEndedInfo.frameCount);
106     data.WriteBool(captureEndedInfo.isDeferredVideoEnhancementAvailable);
107     data.WriteString(captureEndedInfo.videoId);
108     int error = Remote()->SendRequest(
109         static_cast<uint32_t>(StreamRepeatCallbackInterfaceCode::CAMERA_STREAM_REPEAT_VIDEO_DEFERRED_INFO), data, reply,
110         option);
111     CHECK_ERROR_PRINT_LOG(error != ERR_NONE,
112         "HStreamRepeatCallbackProxy OnDeferredVideoEnhancementInfo failed, error: %{public}d", error);
113     return error;
114 }
115 } // namespace CameraStandard
116 } // namespace OHOS
117