1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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_SHARING_WFD_SESSION_DEF_H
17 #define OHOS_SHARING_WFD_SESSION_DEF_H
18 
19 #include "common/event_comm.h"
20 
21 namespace OHOS {
22 namespace Sharing {
23 
24 constexpr uint16_t MAX_RTSP_TIMEOUT_COUNTS = 3;
25 
26 constexpr uint32_t WFD_SEC_TO_MSEC = 1000;
27 constexpr uint32_t P2P_CONNECT_TIMEOUT = 60;
28 constexpr uint32_t P2P_DISCONNECT_TIMEOUT = 3;
29 constexpr uint32_t RTSP_SESSION_TIMEOUT = 30;
30 constexpr uint32_t RTSP_INTERACTION_TIMEOUT = 10;
31 constexpr uint32_t RTSP_TCP_CONNECT_TIMEOUT = 5;
32 constexpr uint32_t MINIMAL_VIDEO_FORMAT_SIZE = 54;
33 
34 const std::string RTSP_METHOD_WFD = "org.wfa.wfd1.0";
35 const std::string WFD_PARAM_3D_FORMATS = "wfd_3d_formats";
36 const std::string WFD_PARAM_TRIGGER = "wfd_trigger_method";
37 const std::string WFD_PARAM_IDR_REQUEST = "wfd_idr_request";
38 const std::string WFD_PARAM_DISPLAY_EDID = "wfd_display_edid";
39 const std::string WFD_PARAM_COUPLED_SINK = "wfd_coupled_sink";
40 const std::string WFD_PARAM_AUDIO_CODECS = "wfd_audio_codecs";
41 const std::string WFD_PARAM_RTP_PORTS = "wfd_client_rtp_ports";
42 const std::string WFD_PARAM_VIDEO_FORMATS = "wfd_video_formats";
43 const std::string WFD_PARAM_TRIGGER_METHOD = "wfd_trigger_method";
44 const std::string WFD_RTSP_URL_DEFAULT = "rtsp://localhost/wfd1.0";
45 const std::string WFD_PARAM_UIBC_CAPABILITY = "wfd_uibc_capability";
46 const std::string WFD_PARAM_PRESENTATION_URL = "wfd_presentation_URL";
47 const std::string WFD_PARAM_CONTENT_PROTECTION = "wfd_content_protection";
48 const std::string WFD_PARAM_STANDBY_RESUME = "wfd_standby_resume_capability";
49 
50 struct WfdSceneEventMsg : public InteractionEventMsg {
51     using Ptr = std::shared_ptr<WfdSceneEventMsg>;
52 
53     std::string mac;
54 };
55 
56 struct WfdSinkSessionEventMsg : public SessionEventMsg {
57     using Ptr = std::shared_ptr<WfdSinkSessionEventMsg>;
58 
59     uint16_t localPort = 0;
60     uint16_t remotePort = 0;
61 
62     std::string ip;
63     std::string mac;
64 
65     AudioFormat audioFormat = AUDIO_48000_16_2;
66     VideoFormat videoFormat = VIDEO_1920X1080_30;
67 };
68 
69 struct WfdSourceSessionEventMsg : public SessionEventMsg {
70     using Ptr = std::shared_ptr<WfdSourceSessionEventMsg>;
71 
72     uint32_t sinkAgentId;
73     uint16_t localPort = 0;
74     uint16_t remotePort = 0;
75 
76     std::string ip;
77     std::string mac;
78 
79     AudioFormat audioFormat = AUDIO_48000_16_2;
80     VideoFormat videoFormat = VIDEO_1920X1080_30;
81 };
82 
83 // Table 34. Supported CEA Resolution/Refresh Rates
84 enum WfdCeaResolution {
85     CEA_640_480_P60 = 0,
86     CEA_720_480_P60,
87     CEA_720_480_I60,
88     CEA_720_576_P50,
89     CEA_720_576_I50,
90     CEA_1280_720_P30 = 5,
91     CEA_1280_720_P60,
92     CEA_1920_1080_P30 = 7,
93     CEA_1920_1080_P60,
94     CEA_1920_1080_I60,
95     CEA_1280_720_P25 = 10,
96     CEA_1280_720_P50,
97     CEA_1920_1080_P25 = 12,
98     CEA_1920_1080_P50,
99     CEA_1920_1080_I50,
100     CEA_1280_720_P24 = 15,
101     CEA_1920_1080_P24 = 16
102 };
103 
104 // Table 35. Supported VESA Resolution/Refresh Rates
105 enum WfdVesaResolution {
106     VESA_800_600_P30 = 0,
107     VESA_800_600_P60,
108     VESA_1366_768_P30 = 12,
109     VESA_1366_768_P60,
110     VESA_1280_1024_P30,
111     VESA_1280_1024_P60 = 15,
112     VESA_1920_1200_P30 = 28
113 };
114 
115 // Table 36. Supported HH Resolutions/Refresh Rates
116 enum WfdHhResolution {
117     HH_800_480_P30 = 0,
118     HH_800_480_P60 = 1,
119     HH_960_540_P30 = 8,
120     HH_960_540_P60,
121     HH_848_480_P60 = 11
122 };
123 
124 // Table 37. Display Native Resolution Refresh Rate
125 enum class WfdResolutionType : uint8_t {
126     RESOLUTION_CEA,  // 0b000
127     RESOLUTION_VESA, // 0b001
128     RESOLUTION_HH    // 0b010
129 };
130 
131 // Table 38. Profiles Bitmap
132 enum class WfdH264Profile {
133     PROFILE_CBP = 0, // 0 0b0: CBP not supported; 0b1: CBP supported;
134     PROFILE_CHP      // 1 0b0: CHP not supported; 0b1: CHP supported;
135 };
136 
137 // Table 39. Maximum H.264 Level Supported
138 enum class WfdH264Level {
139     LEVEL_31 = 0,
140     LEVEL_32,
141     LEVEL_40,
142     LEVEL_41,
143     LEVEL_42,
144 };
145 
146 } // namespace Sharing
147 } // namespace OHOS
148 #endif
149