• 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 #ifndef OHOS_CAMERA_UTIL_H
17 #define OHOS_CAMERA_UTIL_H
18 
19 #include "display_type.h"
20 #include <limits.h>
21 #include "types.h"
22 
23 namespace OHOS {
24 namespace CameraStandard {
25 static const std::int32_t CAMERA_PREVIEW_COLOR_SPACE = 8;
26 static const std::int32_t CAMERA_PREVIEW_STREAM_ID = 1001;
27 
28 static const std::int32_t CAMERA_PHOTO_COLOR_SPACE = 8;
29 static const std::int32_t CAMERA_PHOTO_STREAM_ID = 1002;
30 
31 static const std::int32_t CAMERA_VIDEO_COLOR_SPACE = 8;
32 static const std::int32_t CAMERA_VIDEO_STREAM_ID = 1003;
33 
34 static const std::int32_t CAPTURE_TYPE_COUNT = 3;
35 
36 static const std::int32_t PREVIEW_CAPTURE_ID_START = 1;
37 static const std::int32_t PREVIEW_CAPTURE_ID_END = (INT_MAX / CAPTURE_TYPE_COUNT);
38 
39 static const std::int32_t PHOTO_CAPTURE_ID_START = PREVIEW_CAPTURE_ID_END + 1;
40 static const std::int32_t PHOTO_CAPTURE_ID_END = (2 * (INT_MAX / CAPTURE_TYPE_COUNT));
41 
42 static const std::int32_t VIDEO_CAPTURE_ID_START = PHOTO_CAPTURE_ID_END + 1;
43 static const std::int32_t VIDEO_CAPTURE_ID_END = INT_MAX;
44 
45 enum CamServiceError {
46     CAMERA_OK = 0,
47     CAMERA_ALLOC_ERROR,
48     CAMERA_INVALID_ARG,
49     CAMERA_UNSUPPORTED,
50     CAMERA_DEVICE_BUSY,
51     CAMERA_DEVICE_CLOSED,
52     CAMERA_DEVICE_REQUEST_TIMEOUT,
53     CAMERA_STREAM_BUFFER_LOST,
54     CAMERA_INVALID_SESSION_CFG,
55     CAMERA_CAPTURE_LIMIT_EXCEED,
56     CAMERA_INVALID_STATE,
57     CAMERA_UNKNOWN_ERROR
58 };
59 
60 extern std::unordered_map<int32_t, int32_t> g_cameraToPixelFormat;
61 extern std::map<int, std::string> g_cameraPos;
62 extern std::map<int, std::string> g_cameraType;
63 extern std::map<int, std::string> g_cameraConType;
64 extern std::map<int, std::string> g_cameraFormat;
65 extern std::map<int, std::string> g_cameraFocusMode;
66 extern std::map<int, std::string> g_cameraFlashMode;
67 
68 int32_t HdiToServiceError(Camera::CamRetCode ret);
69 
70 bool IsValidSize(std::shared_ptr<Camera::CameraMetadata> cameraAbility, int32_t format, int32_t width, int32_t height);
71 } // namespace CameraStandard
72 } // namespace OHOS
73 #endif // OHOS_CAMERA_UTIL_H
74