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_wrapper.h"
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 static OHOS::sptr<OHOS::Camera::ICameraDeviceCallback> g_deviceCallback;
22
BindCameraDeviceCallback(const OHOS::sptr<OHOS::Camera::ICameraDeviceCallback> & callback)23 void BindCameraDeviceCallback(const OHOS::sptr<OHOS::Camera::ICameraDeviceCallback>& callback)
24 {
25 g_deviceCallback = callback;
26 }
27
DeviceCBOnError(int type,int errorMsg)28 void DeviceCBOnError(int type, int errorMsg)
29 {
30 if (g_deviceCallback == nullptr) {
31 return;
32 }
33
34 g_deviceCallback->OnError(static_cast<OHOS::Camera::ErrorType>(type), errorMsg);
35
36 return;
37 }
38
DeviceCBOnResult(uint64_t timestamp,CameraResultCIF * result)39 void DeviceCBOnResult(uint64_t timestamp, CameraResultCIF* result)
40 {
41 if (g_deviceCallback == nullptr) {
42 return;
43 }
44
45 std::shared_ptr<CameraMetadata> meta = std::make_shared<CameraMetadata>(0, 0);
46 g_deviceCallback->OnResult(timestamp, meta);
47
48 return;
49 }
50
51 #ifdef __cplusplus
52 }
53 #endif
54