1 /* 2 * Copyright (c) 2022-2023 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_DSCREEN_CONSTANTS_H 17 #define OHOS_DSCREEN_CONSTANTS_H 18 19 #include <cstdint> 20 #include <string> 21 #include <unistd.h> 22 23 namespace OHOS { 24 namespace DistributedHardware { 25 enum RpcEventType { 26 NOTIFY_SINK_SETUP = 1, 27 NOTIFY_SOURCE_SETUP_RESULT = 2, 28 }; 29 30 enum DScreenState { 31 DISABLED, 32 ENABLED, 33 DISABLING, 34 ENABLING, 35 CONNECTING, 36 CONNECTED, 37 DISCONNECTING, 38 }; 39 40 enum TaskType { 41 TASK_ENABLE, 42 TASK_DISABLE, 43 TASK_CONNECT, 44 TASK_DISCONNECT, 45 }; 46 47 enum CodecType : uint8_t { 48 VIDEO_CODEC_TYPE_VIDEO_H264 = 0, 49 VIDEO_CODEC_TYPE_VIDEO_H265 = 1, 50 VIDEO_CODEC_TYPE_VIDEO_MPEG4 = 2, 51 }; 52 53 enum VideoFormat : uint8_t { 54 VIDEO_DATA_FORMAT_YUVI420 = 0, 55 VIDEO_DATA_FORMAT_NV12 = 1, 56 VIDEO_DATA_FORMAT_NV21 = 2, 57 VIDEO_DATA_FORMAT_RGBA8888 = 3, 58 }; 59 60 enum DataType : uint8_t { 61 VIDEO_FULL_SCREEN_DATA = 0, 62 VIDEO_PART_SCREEN_DATA = 1, 63 }; 64 65 enum DScreenMsgType : uint32_t { 66 START_MIRROR = 0, 67 START_MIRROR_SUCCESS = 1, 68 START_MIRROR_FAIL = 2, 69 STOP_MIRROR = 3, 70 }; 71 72 enum DScreenEventType : uint32_t { 73 ENGINE_ERROR = 0, 74 TRANS_CHANNEL_CLOSED = 1, 75 }; 76 77 /* Screen package name */ 78 const std::string PKG_NAME = "ohos.dhardware.dscreen"; 79 80 /* Screen data session name */ 81 const std::string DATA_SESSION_NAME = "ohos.dhardware.dscreen.data"; 82 const std::string JPEG_SESSION_NAME = "ohos.dhardware.dscreen.jpeg"; 83 /*YUV*/ 84 constexpr int32_t YR_PARAM = 66; 85 constexpr int32_t YG_PARAM = 129; 86 constexpr int32_t YB_PARAM = 25; 87 constexpr int32_t UR_PARAM = 38; 88 constexpr int32_t UG_PARAM = 74; 89 constexpr int32_t UB_PARAM = 112; 90 constexpr int32_t VG_PARAM = 94; 91 constexpr int32_t VB_PARAM = 18; 92 constexpr int32_t YA_PARAM = 16; 93 constexpr int32_t UA_PARAM = 128; 94 constexpr int32_t YUV_PARAM = 255; 95 constexpr int32_t MOVEBITS = 8; 96 97 /* RGBA */ 98 constexpr uint32_t RGBA_CHROMA = 4; 99 constexpr uint32_t RGB_CHROMA = 3; 100 constexpr uint32_t ONE = 1; 101 constexpr uint32_t TWO = 2; 102 constexpr uint32_t THREE = 3; 103 constexpr uint32_t ZERO = 0; 104 constexpr uint32_t ALIGNEDBITS = 32; 105 106 /* Screen session name max len */ 107 constexpr uint32_t DSCREEN_MAX_SESSION_NAME_LEN = 50; 108 109 constexpr uint32_t DSCREEN_MAX_DEVICE_ID_LEN = 100; 110 111 /* Screen data received max length */ 112 constexpr uint32_t DSCREEN_MAX_RECV_DATA_LEN = 104857600; 113 114 /* Screen max video data width */ 115 constexpr uint32_t DSCREEN_MAX_VIDEO_DATA_WIDTH = 2560; 116 117 /* Screen max video data height */ 118 constexpr uint32_t DSCREEN_MAX_VIDEO_DATA_HEIGHT = 2772; 119 120 /* Screen max screen data width */ 121 constexpr uint32_t DSCREEN_MAX_SCREEN_DATA_WIDTH = 2560; 122 123 /* Screen max screen data height */ 124 constexpr uint32_t DSCREEN_MAX_SCREEN_DATA_HEIGHT = 2772; 125 126 /* YUV420 buffer size max size */ 127 constexpr int64_t MAX_YUV420_BUFFER_SIZE = 2560 * 1600 * (3 / 2) * 2; 128 constexpr int32_t DSCREEN_MAX_LEN = 4096; 129 130 constexpr int32_t INVALID_WINDOW_ID = -1; 131 constexpr int32_t STRIDE_ALIGNMENT = 0x8; 132 constexpr int32_t SURFACE_SYNC_FENCE_TIMEOUT = 100; 133 134 const std::string DSCREEN_LOG_TITLE_TAG = "DSCREEN"; 135 const std::string DSCREEN_PREFIX = "DISTRIBUTED_SCREEN"; 136 const std::string SCREEN_PREFIX = "SCREEN"; 137 const std::string DSCREEN_VERSION = "1.0"; 138 const std::string DSCREEN_PROCESS_NAME = "dscreen"; 139 const std::string SEPERATOR = "#"; 140 const std::string KEY_VERSION = "screenVersion"; 141 const std::string KEY_DISPLAY_ID = "displayId"; 142 const std::string KEY_SCREEN_ID = "screenId"; 143 const std::string KEY_DISPLAY_RECT = "displayRect"; 144 const std::string KEY_SCREEN_RECT = "screenRect"; 145 const std::string KEY_POINT_START_X = "startX"; 146 const std::string KEY_POINT_START_Y = "startY"; 147 const std::string KEY_POINT_DIRTY_X = "dirtyX"; 148 const std::string KEY_POINT_DIRTY_Y = "dirtyY"; 149 const std::string KEY_POINT_DIRTY_W = "dirtyW"; 150 const std::string KEY_POINT_DIRTY_H = "dirtyH"; 151 const std::string KEY_POINT_DIRTY_SIZE = "dirtySize"; 152 const std::string KEY_WIDTH = "width"; 153 const std::string KEY_HEIGHT = "height"; 154 const std::string KEY_SCREEN_WIDTH = "screenWidth"; 155 const std::string KEY_SCREEN_HEIGHT = "screenHeight"; 156 const std::string KEY_VIDEO_WIDTH = "videoWidth"; 157 const std::string KEY_VIDEO_HEIGHT = "videoHeight"; 158 const std::string KEY_COLOR_FORMAT = "colorFormat"; 159 const std::string KEY_FPS = "fps"; 160 const std::string KEY_CODECTYPE = "codecType"; 161 const std::string SCREEN_CLIENT_WINDOW = "screenClientWindow"; 162 const std::string KEY_DEV_ID = "devId"; 163 const std::string KEY_DH_ID = "dhId"; 164 const std::string KEY_ERR_CODE = "errCode"; 165 const std::string KEY_ERR_CONTENT = "errContent"; 166 const std::string KEY_VIDEO_PARAM = "videoParam"; 167 const std::string KEY_MAPRELATION = "mapRelation"; 168 const std::string KEY_PARTIALREFREAH = "PartialRefresh"; 169 const std::string CODEC_NAME_H264 = "OMX_hisi_video_encoder_avc"; 170 const std::string CODEC_NAME_H265 = "OMX_hisi_video_encoder_hevc"; 171 const std::string CODEC_NAME_MPEG4 = "avenc_mpeg4"; 172 // Publish massage 173 const std::string SOURCE_WIN_ID = "sourceWinId"; 174 const std::string SOURCE_DEV_ID = "sourceDevId"; 175 const std::string SINK_DEV_ID = "sinkDevId"; 176 const std::string SOURCE_WIN_WIDTH = "sourceWinWidth"; 177 const std::string SOURCE_WIN_HEIGHT = "sourceWinHeight"; 178 const std::string SINK_SHOW_WIN_ID = "sinkShowWinId"; 179 const std::string SINK_PROJ_SHOW_WIDTH = "sinkProjShowWidth"; 180 const std::string SINK_PROJ_SHOW_HEIGHT = "sinkProjShowHeight"; 181 const std::string SINK_WIN_SHOW_X = "sinkWinShowX"; 182 const std::string SINK_WIN_SHOW_Y = "sinkWinShowY"; 183 constexpr const char* PARTIAL_REFRESH_PARAM = "persist.distributedhardware.dscreen.partial.refresh.enable"; 184 185 constexpr int32_t DSCREEN_MIN_VERSION = 1; 186 constexpr int32_t AV_TRANS_SUPPORTED_VERSION = 3; 187 constexpr int32_t PARTIAL_REFRESH_ENABLED_VALUE = 1; 188 constexpr uint32_t MAX_MESSAGES_LEN = 40 * 1024 * 1024; 189 constexpr float DEFAULT_DENSITY = 2.0; 190 constexpr int32_t DEFAULT_SCREEN_FLAGS = 0; 191 constexpr uint32_t DEFAULT_FPS = 60; 192 constexpr int32_t DIRTY_MAX_SIZE = 10; 193 constexpr uint8_t DEFAULT_CODECTYPE = VIDEO_CODEC_TYPE_VIDEO_H264; 194 constexpr uint8_t DEFAULT_VIDEO_FORMAT = VIDEO_DATA_FORMAT_NV12; 195 constexpr int32_t DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID = 4807; 196 constexpr int32_t DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID = 4808; 197 constexpr uint64_t SCREEN_ID_INVALID = -1ULL; 198 constexpr uint64_t SCREEN_ID_DEFAULT = 0; 199 constexpr int32_t SCREEN_LOADSA_TIMEOUT_MS = 10000; 200 constexpr size_t DID_MAX_SIZE = 256; 201 constexpr size_t PARAM_MAX_SIZE = 50 * 1024 * 1024; 202 constexpr uint8_t SESSION_WAIT_SECONDS = 5; 203 constexpr uint8_t DATA_WAIT_SECONDS = 1; 204 constexpr size_t DATA_QUEUE_MAX_SIZE = 1000; 205 constexpr uint32_t DECODE_WAIT_MILLISECONDS = 5000; 206 constexpr size_t DATA_BUFFER_MAX_SIZE = 10 * 1024 * 1024; 207 constexpr uint8_t TASK_WAIT_SECONDS = 1; 208 constexpr int32_t JPEG_QUALITY = 80; 209 constexpr uint32_t BIT_RATE = 12000000; 210 constexpr int32_t WAIT_TIMEOUT_MS = 5000; 211 constexpr uint32_t SYSTEM_PARAM_VALUE_SIZE = 50; 212 } // namespace DistributedHardware 213 } // namespace OHOS 214 #endif