• 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 "camera_device_callback_stub.h"
17 #include <hdf_log.h>
18 #include <hdf_base.h>
19 #include <hdf_sbuf_ipc.h>
20 #include "camera_device_callback.h"
21 #include "metadata_utils.h"
22 #include "cmd_common.h"
23 
24 namespace OHOS::Camera {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)25 int32_t CameraDeviceCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
26     MessageOption &option)
27 {
28     HDF_LOGE("%s: CameraDeviceCallbackStub::OnRemoteRequest entry!", __func__);
29     switch (code) {
30         case CMD_CAMERA_DEVICE_CALLBACK_ON_ERROR: {
31             if (data.ReadInterfaceToken() != CameraDeviceCallbackStub::GetDescriptor()) {
32                 HDF_LOGE("%{public}s: invalid interface descriptor.", __func__);
33                 return INVALID_ARGUMENT;
34             }
35 
36             ErrorType type = static_cast<ErrorType>(data.ReadUint32());
37             int32_t errorMsg = data.ReadInt32();
38             OnError(type, errorMsg);
39             break;
40         }
41         case CMD_CAMERA_DEVICE_CALLBACK_ON_RESULT: {
42             if (data.ReadInterfaceToken() != CameraDeviceCallbackStub::GetDescriptor()) {
43                 HDF_LOGE("%{public}s: invalid interface descriptor.", __func__);
44                 return INVALID_ARGUMENT;
45             }
46 
47             uint64_t timestamp = data.ReadUint64();
48             std::shared_ptr<CameraMetadata> result = nullptr;
49             MetadataUtils::DecodeCameraMetadata(data, result);
50             OnResult(timestamp, result);
51             break;
52         }
53         default: {
54             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
55         }
56     }
57     return 0;
58 }
59 }
60