• 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 "icamera_util.h"
17 #include "camera_error_code.h"
18 #include "camera_util.h"
19 #include "camera_log.h"
20 #include "icamera_service.h"
21 
22 namespace OHOS {
23 namespace CameraStandard {
ServiceToCameraError(int32_t ret)24 int32_t ServiceToCameraError(int32_t ret)
25 {
26     int32_t err = CameraErrorCode::SERVICE_FATL_ERROR;
27     switch (ret) {
28         case CAMERA_OK:
29             err = 0;
30             break;
31         case CAMERA_ALLOC_ERROR:
32             err = CameraErrorCode::SERVICE_FATL_ERROR;
33             break;
34         case CAMERA_INVALID_ARG:
35             err = CameraErrorCode::SERVICE_FATL_ERROR;
36             break;
37         case CAMERA_UNSUPPORTED:
38             err = CameraErrorCode::DEVICE_DISABLED;
39             break;
40         case CAMERA_DEVICE_BUSY:
41             err = CameraErrorCode::CONFLICT_CAMERA;
42             break;
43         case CAMERA_DEVICE_CLOSED:
44             err = CameraErrorCode::DEVICE_DISABLED;
45             break;
46         case CAMERA_DEVICE_REQUEST_TIMEOUT:
47             err = CameraErrorCode::SERVICE_FATL_ERROR;
48             break;
49         case CAMERA_STREAM_BUFFER_LOST:
50             err = CameraErrorCode::SERVICE_FATL_ERROR;
51             break;
52         case CAMERA_INVALID_SESSION_CFG:
53             err = CameraErrorCode::SERVICE_FATL_ERROR;
54             break;
55         case CAMERA_CAPTURE_LIMIT_EXCEED:
56             err = CameraErrorCode::SERVICE_FATL_ERROR;
57             break;
58         case CAMERA_INVALID_STATE:
59             err = CameraErrorCode::SERVICE_FATL_ERROR;
60             break;
61         case CAMERA_UNKNOWN_ERROR:
62             err = CameraErrorCode::SERVICE_FATL_ERROR;
63             break;
64         case CAMERA_DEVICE_PREEMPTED:
65             err = CameraErrorCode::DEVICE_PREEMPTED;
66             break;
67         case CAMERA_OPERATION_NOT_ALLOWED:
68             err = CameraErrorCode::OPERATION_NOT_ALLOWED;
69             break;
70         case CAMERA_DEVICE_ERROR:
71             err = CameraErrorCode::OPERATION_NOT_ALLOWED;
72             break;
73         case CAMERA_NO_PERMISSION:
74             err = CameraErrorCode::OPERATION_NOT_ALLOWED;
75             break;
76         case CAMERA_DEVICE_CONFLICT:
77             err = CameraErrorCode::OPERATION_NOT_ALLOWED;
78             break;
79         case IPC_PROXY_ERR:
80         case IPC_PROXY_DEAD_OBJECT_ERR:
81         case IPC_PROXY_NULL_INVOKER_ERR:
82         case IPC_PROXY_TRANSACTION_ERR:
83         case IPC_PROXY_INVALID_CODE_ERR:
84         case IPC_STUB_ERR:
85         case IPC_STUB_WRITE_PARCEL_ERR:
86         case IPC_STUB_INVOKE_THREAD_ERR:
87         case IPC_STUB_INVALID_DATA_ERR:
88         case IPC_STUB_CURRENT_NULL_ERR:
89         case IPC_STUB_UNKNOW_TRANS_ERR:
90         case IPC_STUB_CREATE_BUS_SERVER_ERR:
91             err = CameraErrorCode::SERVICE_FATL_ERROR;
92             break;
93         case CAMERA_DEVICE_SWITCH_FREQUENT:
94             err = CameraErrorCode::DEVICE_SWITCH_FREQUENT;
95             break;
96         case CAMERA_DEVICE_LENS_RETRACTED:
97             err = CameraErrorCode::CAMERA_LENS_RETRACTED;
98             break;
99         default:
100             MEDIA_ERR_LOG("ServiceToCameraError() error code from service: %{public}d", ret);
101             break;
102     }
103     return err;
104 }
105 
GetIsCameraMutedIpcCode()106 int32_t GetIsCameraMutedIpcCode()
107 {
108     return static_cast<uint32_t>(ICameraServiceIpcCode::COMMAND_IS_CAMERA_MUTED);
109 }
110 } // namespace CameraStandard
111 } // namespace OHOS
112