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::PARAMETER_ERROR:
34         case CameraErrorCode::INVALID_ARGUMENT:
35             err = CAMERA_INVALID_ARGUMENT;
36             break;
37         case CameraErrorCode::OPERATION_NOT_ALLOWED:
38             err = CAMERA_OPERATION_NOT_ALLOWED;
39             break;
40         case CameraErrorCode::SESSION_NOT_CONFIG:
41             err = CAMERA_SESSION_NOT_CONFIG;
42             break;
43         case CameraErrorCode::SESSION_NOT_RUNNING:
44             err = CAMERA_SESSION_NOT_RUNNING;
45             break;
46         case CameraErrorCode::SESSION_CONFIG_LOCKED:
47             err = CAMERA_SESSION_CONFIG_LOCKED;
48             break;
49         case CameraErrorCode::DEVICE_SETTING_LOCKED:
50             err = CAMERA_DEVICE_SETTING_LOCKED;
51             break;
52         case CameraErrorCode::CONFLICT_CAMERA:
53             err = CAMERA_CONFLICT_CAMERA;
54             break;
55         case CameraErrorCode::DEVICE_DISABLED:
56             err = CAMERA_DEVICE_DISABLED;
57             break;
58         case CameraErrorCode::DEVICE_PREEMPTED:
59             err = CAMERA_DEVICE_PREEMPTED;
60             break;
61         case CameraErrorCode::SERVICE_FATL_ERROR:
62             err = CAMERA_SERVICE_FATAL_ERROR;
63             break;
64         case CameraErrorCode::UNRESOLVED_CONFLICTS_BETWEEN_STREAMS:
65             err = CAMERA_UNRESOLVED_CONFLICTS_WITH_CURRENT_CONFIGURATIONS;
66             break;
67         default:
68             MEDIA_ERR_LOG("ServiceToCameraError() error code from service: %{public}d", ret);
69             break;
70     }
71     return err;
72 }
73 } // namespace CameraStandard
74 } // namespace OHOS