• 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_host_callback_proxy.h"
17 #include <hdf_base.h>
18 #include <message_parcel.h>
19 
20 namespace OHOS::Camera {
OnCameraStatus(const std::string & cameraId,CameraStatus status)21 void CameraHostCallbackProxy::OnCameraStatus(const std::string &cameraId, CameraStatus status)
22 {
23     MessageParcel data;
24     MessageParcel reply;
25     MessageOption option;
26 
27     if (!data.WriteString(cameraId)) {
28         HDF_LOGE("%{public}s: write cameraId failed.", __func__);
29         return;
30     }
31 
32     if (!data.WriteInt32(status)) {
33         HDF_LOGE("%{public}s: write status failed.", __func__);
34         return;
35     }
36 
37     int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_CALLBACK_REMOTE_ON_STATUS, data, reply, option);
38     if (ret != HDF_SUCCESS) {
39         HDF_LOGE("%{public}s: SendRequest failed, error code is %{public}d", __func__, ret);
40         return;
41     }
42 }
43 
OnFlashlightStatus(const std::string & cameraId,FlashlightStatus status)44 void CameraHostCallbackProxy::OnFlashlightStatus(const std::string &cameraId, FlashlightStatus status)
45 {
46     MessageParcel data;
47     MessageParcel reply;
48     MessageOption option;
49 
50     if (!data.WriteString(cameraId)) {
51         HDF_LOGE("%{public}s: write cameraId failed.", __func__);
52         return;
53     }
54 
55     if (!data.WriteInt32(status)) {
56         HDF_LOGE("%{public}s: write status failed.", __func__);
57         return;
58     }
59 
60     int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_CALLBACK__REMOTE_ON_FLASHLIGHT_STATUS, data, reply, option);
61     if (ret != HDF_SUCCESS) {
62         HDF_LOGE("%{public}s: SendRequest failed, error code is %{public}d", __func__, ret);
63         return;
64     }
65 }
66 }