• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024-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  * Description: implement the cast source connect
15  * Author: lijianzhao
16  * Create: 2024-07-28
17  */
18 
19 #ifndef RADAR_CONSTANTS_H
20 #define RADAR_CONSTANTS_H
21 #include <string>
22 
23 namespace OHOS {
24 namespace CastEngine {
25 namespace CastEngineService {
26 
27 struct BasicInfo {
28     std::string func;
29     int32_t bizStage;
30     int32_t stageRes;
31     int32_t bizState;
32     int32_t errorCode = 0;
33 };
34 
35 struct LocalAndPeerDeviceInfo {
36     std::string localUdid;
37     std::string localNetId;
38     std::string localDevType;
39     std::string localWifiMac;
40     std::string localIp;
41     std::string localPort;
42 
43     std::string peerUdid;
44     std::string peerNetId;
45     std::string peerDevType;
46     std::string peerWifiMac;
47     std::string peerIp;
48     std::string peerPort;
49     std::string peerVer;
50     std::string peerDeviceVer;
51     int32_t triggerType;
52 };
53 
54 struct CommonEventForm {
55     BasicInfo basicInfo;
56     LocalAndPeerDeviceInfo deviceInfo;
57 };
58 
59 /*
60  * moduleID range 0~31
61  * 1~6 for HMOS4.x and before
62  * 0,7~9 reserved
63  * 10~18 for cast+
64  * 18~31 for miracast and DLNA
65  */
66 enum class RadarModuleID : int32_t {
67     DISCOVERY = 10,
68     CONNECTION = 11,
69     CAST_SESSION = 12,
70     RTSP = 13,
71     VIDEO = 14,
72     AUDIO = 15,
73     REMOTE_CTRL = 16,
74     STREAM = 17,
75     UICAST = 18,
76     MIRACAST_CONNECTION = 19
77 };
78 
79 /*
80  * 1~99 for castplus
81  * 100~199 for miracast
82  * 200~299 for DLNA
83  */
84 enum class BizScene : int32_t {
85     DISCOVERY_CAST = 1,
86     CONNECTION_CAST_MIRROR = 2,
87     CONNECTION_CAST_STREAM = 3,
88     CONNECTION_COLLABORATION = 4,
89     CONNECTION_CAST_MIRROR_LEAGACY = 5,
90     CONNECTION_CAST_STREAM_LEAGACY = 6,
91     CONNECTION_COLLABORATION_LEAGACY = 7,
92     DISCOVERY_MIRRACAST = 100,
93     CONNECTION_MIRRACAST = 101,
94     DISCOVERY_DLNA = 200,
95     CONNECTION_DLNA = 201,
96 };
97 
98 enum DiscoverStage : int32_t {
99     S1_START_DISCOVERY = 1,
100     S2_DISCOVERYING = 2,
101 };
102 
103 enum ConnectionStage : int32_t {
104     S1_START_CONNECTION = 1,
105     S2_AUTH_CHANEL = 2,
106     S3_SELECT_TRUST = 3,
107     S4_PIN_CODE_BIND = 4,
108     S5_NETWORKING_ONLINE = 5,
109     S6_OPEN_CONSULT_CHANNEL = 6,
110     S7_QUERY_P2P_IP = 7,
111     S8_RSTP_CREATE_PORT = 8,
112     S9_CONSULT_DATA = 9,
113     S10_RTSP_NEGOTIATE = 10,
114     S11_AUDIO_VIDEO_CHANNELS = 11,
115     S12_AVCODEC_INIT = 12,
116     S13_AVCODEC_START = 13,
117     S11_STREAM_CHANNEL = 14,
118 };
119 
120 enum TriggerMode : int32_t {
121     TRIGGER_BT = 1,
122     TRIGGER_WIFI = 2,
123 };
124 
125 static constexpr char DOMAIN_CAST_ENGINE[] = "CAST_ENGINE";
126 static constexpr char DOMAIN_PROJECTION_UE[] = "PROJECTION_UE";  // for UE dfx
127 static const std::string EVENT_NAME = "CAST_PLUS_BEHAVIOR";
128 
129 static const std::string PKG_CAST_ENGINE = "cast_engine_service";
130 static const std::string PKG_DEVICE_MANAGER = "deviceManager";
131 static const std::string PKG_DSOFTBUS = "dsoftbus";
132 static const std::string PKG_COLLABORATION_SERVICE = "collaboration_service";
133 static const std::string PKG_AVSESSION = "av_session";
134 static const std::string PKG_COLLABORATION_FWK = "CollaborationFwk";
135 
136 static const std::string REMOTE_VER_THIRD_PARTY = "third_party";
137 
138 static constexpr uint8_t SUBSYSTEM_CAST_ENGINE = 208;
139 static constexpr uint32_t MASK_SUBSYSTEM = 0xff;
140 static constexpr uint32_t MASK_MODULE_ID = 0x1f;
141 static constexpr uint32_t MASK_ERROR_CODE = 0xffff;
142 static constexpr uint8_t OFFSET_MODULE_ID = 16;
143 static constexpr uint8_t OFFSET_SUBSYSTEM = 21;
144 
145 #define CAST_ENGINE_ERR_CODE(moduleID) \
146     ((SUBSYSTEM_CAST_ENGINE << OFFSET_SUBSYSTEM) | (static_cast<uint32_t>(moduleID) << OFFSET_MODULE_ID))
147 
148 enum RadarErrCode : int32_t {
149     SUCCESS = 0,
150 
151     //@RadarModuleID::DISCOVERY error code, base is 436862976
152     DISCOVERY_BASE = CAST_ENGINE_ERR_CODE(RadarModuleID::DISCOVERY),
153     DISCOVERY_NO_LISTENER = DISCOVERY_BASE + 1,
154     DISCOVERY_NO_HANDLER = DISCOVERY_BASE + 2,
155 
156     //@RadarModuleID::CONNECTION error code, base is 436928512
157     CONNECTION_BASE = CAST_ENGINE_ERR_CODE(RadarModuleID::CONNECTION),
158     CONNECTION_IP_ADDRESS_INVAILD = CONNECTION_BASE + 1,
159     CONNECTION_DEVICE_IS_MISSING = CONNECTION_BASE + 2,
160     CONNECTION_NETWORK_ID_INVAILD = CONNECTION_BASE + 3,
161     CONNECTION_NO_SESSION_KEY = CONNECTION_BASE + 4,
162     CONNECTION_CONSULT_FAIL_FROM_SINK = CONNECTION_BASE + 5,
163     CONNECTION_DEVICE_LOST = CONNECTION_BASE + 6,
164 
165     // error code for meta node
166     CONNECTION_META_UNKNOW_BIND_ACTION = CONNECTION_BASE + 1000,
167     CONNECTION_META_AUTH_INIT_FAIL = CONNECTION_BASE + 1001,
168     CONNECTION_META_GET_AUTH_CHANNEL_FAIL = CONNECTION_BASE + 1002,
169     CONNECTION_META_NO_CONSULT_DATA = CONNECTION_BASE + 1003,
170     CONNECTION_META_NO_AUTH_VERSION = CONNECTION_BASE + 1004,
171     CONNECTION_META_FAIL_FROM_SINK = CONNECTION_BASE + 1005,
172     CONNECTION_META_GET_GM_INSTANCE_FAIL = CONNECTION_BASE + 1006,
173     CONNECTION_META_MEMCPY_FAIL = CONNECTION_BASE + 1007,
174     CONNECTION_META_GET_HICHAIN_INTERFACE_FAIL = CONNECTION_BASE + 1008,
175     CONNECTION_META_GET_HICHAIN_INSTANCE_FAIL = CONNECTION_BASE + 1009,
176     CONNECTION_META_NO_WIFI_BLE_ADDR = CONNECTION_BASE + 1010,
177     CONNECTION_META_DEVICE_IS_BUSY = CONNECTION_BASE + 1011,
178 
179     //@RadarModuleID::CAST_SESSION error code, base is 436994048
180     SESSION_BASE = CAST_ENGINE_ERR_CODE(RadarModuleID::CAST_SESSION),
181     SESSION_DEVICE_IS_MISS = SESSION_BASE + 1,
182     SESSION_RTSP_START_FAIL = SESSION_BASE + 2,
183     SESSION_RTSP_BUILD_REQ_FAIL = SESSION_BASE + 3,
184     SESSION_MEDIA_START_FAIL = SESSION_BASE + 4,
185     SESSION_SETUP_FAIL = SESSION_BASE + 5,
186     SESSION_CONNECT_TIMEOUT = SESSION_BASE + 6,
187     // todo, temp define
188     SESSION_MULTI_CONNECT_FAIL = SESSION_BASE + 100,
189 
190     //@RadarModuleID::RTSP error code, base is 437059584
191     RTSP_BASE = CAST_ENGINE_ERR_CODE(RadarModuleID::RTSP),
192     RTSP_ANNOUNCE_SEND_FAIL = RTSP_BASE + 1,
193     RTSP_ANNOUNCE_REQUEST_FAIL = RTSP_BASE + 2,
194     RTSP_M1_SEND_FAIL = RTSP_BASE + 3,
195     RTSP_M3_SEND_FAIL = RTSP_BASE + 4,
196     RTSP_M3_RECV_FAIL = RTSP_BASE + 5,
197     RTSP_M4_SEND_FAIL = RTSP_BASE + 6,
198     RTSP_M4_RECV_FAIL = RTSP_BASE + 7,
199     RTSP_M5_RECV_FAIL = RTSP_BASE + 8,
200     RTSP_M6_RECV_FAIL = RTSP_BASE + 9,
201     RTSP_RENDER_READY_SEND_FAIL = RTSP_BASE + 10,
202     RTSP_RENDER_READY_RECV_FAIL = RTSP_BASE + 11,
203     RTSP_PAUSE_SEND_FAIL = RTSP_BASE + 12,
204     RTSP_PAUSE_RECV_FAIL = RTSP_BASE + 13,
205     RTSP_PLAY_SEND_FAIL = RTSP_BASE + 14,
206     RTSP_PLAY_REQUEST_FAIL = RTSP_BASE + 15,
207     RTSP_TEARDOWN_SEND_FAIL = RTSP_BASE + 16,
208     RTSP_TEARDOWN_RECV_FAIL = RTSP_BASE + 17,
209 
210     //@RadarModuleID::VIDEO error code, base is 437125120
211     VIDEO_BASE = CAST_ENGINE_ERR_CODE(RadarModuleID::VIDEO),
212     VIDEO_ENCODER_IS_NULL = VIDEO_BASE + 1,
213     VIDEO_ENCODER_START_FAIL = VIDEO_BASE + 2,
214     VIDEO_DEFAULTDISPLAY_IS_NULLPTR = VIDEO_BASE + 3,
215     VIDEO_SET_VIRTUAL_SCREEN_SURFACE_FAIL = VIDEO_BASE + 4,
216     VIDEO_SCREEN_MANAGER_REGISTER_LISTENER_FAIL = VIDEO_BASE + 5,
217 
218     //@RadarModuleID::AUDIO error code, base is 437190656
219     AUDIO_BASE = CAST_ENGINE_ERR_CODE(RadarModuleID::AUDIO),
220     AUDIO_ENCODER_START_FAIL = AUDIO_BASE + 1,
221     AUDIO_CAPTURE_START_FAIL = AUDIO_BASE + 2,
222 
223     //@RadarModuleID::MIRACAST error code, base is 437452800
224     WIFI_DISPLAY_BASE = CAST_ENGINE_ERR_CODE(RadarModuleID::MIRACAST_CONNECTION),
225     WIFI_DISPLAY_GENERAL_ERROR = WIFI_DISPLAY_BASE + 1,
226     WIFI_DISPLAY_BAD_PARAMETER = WIFI_DISPLAY_BASE + 2,
227     WIFI_DISPLAY_P2P_STATE_EXCEPTION = WIFI_DISPLAY_BASE + 3,
228     WIFI_DISPLAY_P2P_CONNECTION_FAILURE = WIFI_DISPLAY_BASE + 4,
229     WIFI_DISPLAY_P2P_CONNECTION_TIMEOUT = WIFI_DISPLAY_BASE + 5,
230     WIFI_DISPLAY_NETWORK_ERROR = WIFI_DISPLAY_BASE + 6,
231     WIFI_DISPLAY_RTSP_KEEPALIVE_TIMEOUT = WIFI_DISPLAY_BASE + 7,
232     WIFI_DISPLAY_RTSP_CONNECTION_TIMEOUT = WIFI_DISPLAY_BASE + 8,
233     WIFI_DISPLAY_RTSP_INTERACTION_TIMEOUT = WIFI_DISPLAY_BASE + 9,
234     WIFI_DISPLAY_RTSP_SOCKET_ERROR = WIFI_DISPLAY_BASE + 10,
235     WIFI_DISPLAY_P2P_OPT_FAILED = WIFI_DISPLAY_BASE + 11,
236     WIFI_DISPLAY_P2P_OPT_NOT_SUPPORTED = WIFI_DISPLAY_BASE + 12,
237     WIFI_DISPLAY_P2P_OPT_INVALID_PARAM = WIFI_DISPLAY_BASE + 13,
238     WIFI_DISPLAY_P2P_OPT_FORBID_AIRPLANE = WIFI_DISPLAY_BASE + 14,
239     WIFI_DISPLAY_P2P_OPT_FORBID_POWSAVING = WIFI_DISPLAY_BASE + 15,
240     WIFI_DISPLAY_P2P_OPT_PERMISSION_DENIED = WIFI_DISPLAY_BASE + 16,
241     WIFI_DISPLAY_P2P_OPT_OPEN_FAIL_WHEN_CLOSING = WIFI_DISPLAY_BASE + 17,
242     WIFI_DISPLAY_P2P_OPT_OPEN_SUCC_WHEN_OPENED = WIFI_DISPLAY_BASE + 18,
243     WIFI_DISPLAY_P2P_OPT_CLOSE_FAIL_WHEN_OPENING = WIFI_DISPLAY_BASE + 19,
244     WIFI_DISPLAY_P2P_OPT_CLOSE_SUCC_WHEN_CLOSED = WIFI_DISPLAY_BASE + 20,
245     WIFI_DISPLAY_P2P_OPT_STA_NOT_OPENED = WIFI_DISPLAY_BASE + 21,
246     WIFI_DISPLAY_P2P_OPT_SCAN_NOT_OPENED = WIFI_DISPLAY_BASE + 22,
247     WIFI_DISPLAY_P2P_OPT_AP_NOT_OPENED = WIFI_DISPLAY_BASE + 23,
248     WIFI_DISPLAY_P2P_OPT_INVALID_CONFIG = WIFI_DISPLAY_BASE + 24,
249     WIFI_DISPLAY_P2P_OPT_P2P_NOT_OPENED = WIFI_DISPLAY_BASE + 25,
250     WIFI_DISPLAY_P2P_OPT_P2P_MAC_NOT_FOUND = WIFI_DISPLAY_BASE + 26,
251     WIFI_DISPLAY_P2P_OPT_P2P_ERR_MAC_FORMAT = WIFI_DISPLAY_BASE + 27,
252     WIFI_DISPLAY_P2P_OPT_P2P_ERR_CONTEN = WIFI_DISPLAY_BASE + 28,
253     WIFI_DISPLAY_P2P_OPT_P2P_ERR_SIZE_NW_NAME = WIFI_DISPLAY_BASE + 29,
254     WIFI_DISPLAY_P2P_OPT_MOVING_FREEZE_CTRL = WIFI_DISPLAY_BASE + 30,
255     WIFI_DISPLAY_P2P_OPT_NON_SYSTEMAPP = WIFI_DISPLAY_BASE + 31,
256     WIFI_DISPLAY_P2P_OPT_ENTERPRISE_DENIED = WIFI_DISPLAY_BASE + 32,
257     WIFI_DISPLAY_P2P_DISCONNECTED_STATE_CLOSED = WIFI_DISPLAY_BASE + 33,
258     WIFI_DISPLAY_P2P_DISCONNECTED_DEVICE_CHANGE = WIFI_DISPLAY_BASE + 34,
259     WIFI_DISPLAY_P2P_DISCONNECTED_CONNECTION_CHANGE = WIFI_DISPLAY_BASE + 35,
260 };
261 
262 }  // namespace CastEngineService
263 }  // namespace CastEngine
264 }  // namespace OHOS
265 
266 #endif
267