1 /*
2 * Copyright (c) 2023-2023 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 "deferred_video_processing_session_callback_stub.h"
17
18 namespace OHOS {
19 namespace CameraStandard {
20 namespace DeferredProcessing {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)21 int32_t DeferredVideoProcessingSessionCallbackStub::OnRemoteRequest(
22 uint32_t code,
23 MessageParcel& data,
24 MessageParcel& reply,
25 MessageOption& option)
26 {
27 std::u16string localDescriptor = GetDescriptor();
28 std::u16string remoteDescriptor = data.ReadInterfaceToken();
29 if (localDescriptor != remoteDescriptor) {
30 return ERR_TRANSACTION_FAILED;
31 }
32 switch (code) {
33 case COMMAND_ON_PROCESS_VIDEO_DONE: {
34 std::string videoId = Str16ToStr8(data.ReadString16());
35 sptr<IPCFileDescriptor> fd(data.ReadParcelable<IPCFileDescriptor>());
36 ErrCode errCode = OnProcessVideoDone(videoId, fd);
37 if (!reply.WriteInt32(errCode)) {
38 return ERR_INVALID_VALUE;
39 }
40 return ERR_NONE;
41 }
42 case COMMAND_ON_ERROR: {
43 std::string videoId = Str16ToStr8(data.ReadString16());
44 int32_t errorCode = data.ReadInt32();
45 ErrCode errCode = OnError(videoId, errorCode);
46 if (!reply.WriteInt32(errCode)) {
47 return ERR_INVALID_VALUE;
48 }
49 return ERR_NONE;
50 }
51 case COMMAND_ON_STATE_CHANGED: {
52 int32_t status = data.ReadInt32();
53 ErrCode errCode = OnStateChanged(status);
54 if (!reply.WriteInt32(errCode)) {
55 return ERR_INVALID_VALUE;
56 }
57 return ERR_NONE;
58 }
59 default:
60 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
61 }
62
63 return ERR_TRANSACTION_FAILED;
64 }
65 } // namespace DeferredProcessing
66 } // namespace CameraStandard
67 } // namespace OHOS
68