1 /*
2  * Copyright (c) 2021-2024 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 DISTRIBUTED_CONSTANTS_H
17 #define DISTRIBUTED_CONSTANTS_H
18 
19 #include <string>
20 #include <vector>
21 
22 namespace OHOS {
23 namespace DistributedHardware {
24 const uint32_t YUV_WIDTH_RATIO = 3;
25 const uint32_t YUV_HEIGHT_RATIO = 2;
26 
27 const uint32_t DEVID_MAX_LENGTH = 256;
28 const uint32_t DHID_MAX_LENGTH =  256;
29 const uint32_t CONTAINER_CAPACITY_MAX_SIZE = 50 * 1024 * 1024;
30 const uint32_t METADATA_CAPACITY_MAX_SIZE = 50 * 1024 * 1024;
31 const int32_t STREAM_HEIGHT_MAX_SIZE = 10000;
32 const int32_t STREAM_WIDTH_MAX_SIZE = 10000;
33 const int32_t JPEG_MAX_SIZE = 24 * 1024 * 1024;
34 
35 constexpr size_t DEFAULT_ENTRY_CAPACITY = 100;
36 constexpr size_t DEFAULT_DATA_CAPACITY = 2000;
37 
38 const uint32_t SIZE_FMT_LEN = 2;
39 const uint32_t MAX_SUPPORT_PREVIEW_WIDTH = 1920;
40 const uint32_t MAX_SUPPORT_PREVIEW_HEIGHT = 1080;
41 const uint32_t MAX_SUPPORT_PHOTO_WIDTH = 4096;
42 const uint32_t MAX_SUPPORT_PHOTO_HEIGHT = 3072;
43 const std::string STAR_SEPARATOR = "*";
44 
45 const uint32_t MIN_SUPPORT_DEFAULT_FPS = 15;
46 const uint32_t MAX_SUPPORT_DEFAULT_FPS = 30;
47 
48 const int64_t MAX_FRAME_DURATION = 1000000000LL / 10;
49 
50 const uint32_t BUFFER_QUEUE_SIZE = 8;
51 
52 const uint32_t DEGREE_180 = 180;
53 const uint32_t DEGREE_240 = 240;
54 
55 const uint32_t INGNORE_STR_LEN = 2;
56 
57 const uint32_t WAIT_OPEN_TIMEOUT_SEC = 5;
58 const uint32_t BUFFER_SYNC_FENCE_TIMEOUT = 100;
59 const int32_t GET_FULL_WAIT_SECONDS = 10;
60 
61 const std::string ENCODE_TYPE_STR_H264 = "video/avc";
62 const std::string ENCODE_TYPE_STR_H265 = "video/hevc";
63 const std::string ENCODE_TYPE_STR_JPEG = "jpeg";
64 const std::string ENCODE_TYPE_STR_MPEG4_ES = "video/mp4v-es";
65 const std::string DC_LOG_TITLE_TAG = "DCAMERA";
66 const std::string FULL_DATA_KEY = "ProtocolVer";
67 const std::string META_DATA_KEY = "MetaData";
68 const std::string CAMERA_SUPPORT_MODE = "Mode";
69 constexpr int32_t LOG_MAX_LEN = 4096;
70 constexpr uint64_t SEC_TO_NSEC_TIMES = 1000000000;
71 
72 typedef enum {
73     OHOS_CAMERA_FORMAT_INVALID = 0,
74     OHOS_CAMERA_FORMAT_RGBA_8888,
75     OHOS_CAMERA_FORMAT_YCBCR_420_888,
76     OHOS_CAMERA_FORMAT_YCRCB_420_SP,
77     OHOS_CAMERA_FORMAT_JPEG,
78 } DCameraFormat;
79 
80 typedef enum {
81     DCAMERA_MESSAGE = 0,
82     DCAMERA_OPERATION = 1,
83     DCAMERA_SINK_STOP = 2,
84     DCAMERE_GETFULLCAP = 3,
85 } DCameraEventType;
86 
87 typedef enum {
88     DCAMERA_EVENT_CHANNEL_DISCONNECTED = 0,
89     DCAMERA_EVENT_CHANNEL_CONNECTED = 1,
90     DCAMERA_EVENT_CAMERA_SUCCESS = 2,
91 
92     DCAMERA_EVENT_CAMERA_ERROR = -1,
93     DCAMERA_EVENT_OPEN_CHANNEL_ERROR = -2,
94     DCAMERA_EVENT_CLOSE_CHANNEL_ERROR = -3,
95     DCAMERA_EVENT_CONFIG_STREAMS_ERROR = -4,
96     DCAMERA_EVENT_RELEASE_STREAMS_ERROR = -5,
97     DCAMERA_EVENT_START_CAPTURE_ERROR = -6,
98     DCAMERA_EVENT_STOP_CAPTURE_ERROR = -7,
99     DCAMERA_EVENT_UPDATE_SETTINGS_ERROR = -8,
100     DCAMERA_EVENT_DEVICE_ERROR = -9,
101     DCAMERA_EVENT_DEVICE_PREEMPT = -10,
102     DCAMERA_EVENT_DEVICE_IN_USE = -11,
103     DCAMERA_EVENT_NO_PERMISSION = -12,
104 } DCameraEventResult;
105 
106 enum DCameraBufferUsage : uint64_t {
107     CAMERA_USAGE_SW_READ_OFTEN = (1 << 0),
108     CAMERA_USAGE_SW_WRITE_OFTEN = (1 << 1),
109     CAMERA_USAGE_MEM_DMA = (1 << 2),
110 };
111 
112 using DCSceneType = enum _DCSceneType : int32_t {
113     PREVIEW = 0,
114     VIDEO = 1,
115     PHOTO = 2
116 };
117 
118 using RetCode = uint32_t;
119 enum Ret : uint32_t {
120     RC_OK = 0,
121     RC_ERROR,
122 };
123 
124 struct DCResolution {
125     int32_t width_;
126     int32_t height_;
127 
DCResolutionDCResolution128     DCResolution() : width_(0), height_(0) {}
129 
DCResolutionDCResolution130     DCResolution(int32_t width, int32_t height) : width_(width), height_(height) {}
131 
132     bool operator ==(const DCResolution others) const
133     {
134         return (this->width_ == others.width_) && (this->height_ == others.height_);
135     }
136 
137     bool operator <(const DCResolution others) const
138     {
139         return this->width_ < others.width_ ||
140             (this->width_ == others.width_ && this->height_ < others.height_);
141     }
142 };
143 } // namespace DistributedHardware
144 } // namespace OHOS
145 #endif // DISTRIBUTED_CONSTANTS_H
146