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 "kits/native/include/camera/camera.h"
17 #include "camera_log.h"
18 #include "camera_error_code.h"
19 #include "camera_util.h"
20 
21 namespace OHOS {
22 namespace CameraStandard {
FrameworkToNdkCameraError(int32_t ret)23 Camera_ErrorCode FrameworkToNdkCameraError(int32_t ret)
24 {
25     Camera_ErrorCode err = CAMERA_OK;
26     switch (ret) {
27         case CameraErrorCode::SUCCESS:
28             err = CAMERA_OK;
29             break;
30         case CameraErrorCode::NO_SYSTEM_APP_PERMISSION:
31             err = CAMERA_OPERATION_NOT_ALLOWED;
32             break;
33         case CameraErrorCode::INVALID_ARGUMENT:
34             err = CAMERA_INVALID_ARGUMENT;
35             break;
36         case CameraErrorCode::OPERATION_NOT_ALLOWED:
37             err = CAMERA_OPERATION_NOT_ALLOWED;
38             break;
39         case CameraErrorCode::SESSION_NOT_CONFIG:
40             err = CAMERA_SESSION_NOT_CONFIG;
41             break;
42         case CameraErrorCode::SESSION_NOT_RUNNING:
43             err = CAMERA_SESSION_NOT_RUNNING;
44             break;
45         case CameraErrorCode::SESSION_CONFIG_LOCKED:
46             err = CAMERA_SESSION_CONFIG_LOCKED;
47             break;
48         case CameraErrorCode::DEVICE_SETTING_LOCKED:
49             err = CAMERA_DEVICE_SETTING_LOCKED;
50             break;
51         case CameraErrorCode::CONFLICT_CAMERA:
52             err = CAMERA_CONFLICT_CAMERA;
53             break;
54         case CameraErrorCode::DEVICE_DISABLED:
55             err = CAMERA_DEVICE_DISABLED;
56             break;
57         case CameraErrorCode::DEVICE_PREEMPTED:
58             err = CAMERA_DEVICE_PREEMPTED;
59             break;
60         case CameraErrorCode::SERVICE_FATL_ERROR:
61             err = CAMERA_SERVICE_FATAL_ERROR;
62             break;
63         case CameraErrorCode::UNRESOLVED_CONFLICTS_BETWEEN_STREAMS:
64             err = CAMERA_UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS;
65             break;
66         default:
67             MEDIA_ERR_LOG("ServiceToCameraError() error code from service: %{public}d", ret);
68             break;
69     }
70     return err;
71 }
72 } // namespace CameraStandard
73 } // namespace OHOS