• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MSG_H
17 #define OHOS_SHARING_WFD_MSG_H
18 
19 #include "common/const_def.h"
20 #include "interaction/ipc_codec/ipc_msg.h"
21 #include "iremote_object.h"
22 
23 namespace OHOS {
24 namespace Sharing {
25 
26 enum WfdMsgId {
27     WFD_COMMON_RSP = SharingMsgId::WFD_MSG_ID_START,
28     WFD_SINK_START_REQ,
29     WFD_SINK_STOP_REQ,
30     WFD_SET_SURFACE_REQ,
31     WFD_ADD_SURFACE_REQ,
32     WFD_DEL_SURFACE_REQ,
33     WFD_SET_MEDIA_FORMAT_REQ,
34     WFD_PLAY_REQ,
35     WFD_PAUSE_REQ,
36     WFD_CLOSE_REQ,
37     WFD_SET_SCENE_TYPE_REQ,
38     WFD_MUTE_REQ,
39     WFD_UNMUTE_REQ,
40     WFD_GET_SINK_CONFIG_REQ,
41     WFD_GET_SINK_CONFIG_RSP,
42     WFD_CONNECTION_CHANGED_MSG,
43     WFD_DECODER_ACCELERATION_DONE,
44     WFD_ERROR_MSG,
45     WFD_INFO_MSG,
46     WFD_SURFACE_FAILURE,
47     WFD_SOURCE_START_DISCOVERY_REQ,
48     WFD_SOURCE_STOP_DISCOVERY_REQ,
49     WFD_SOURCE_DEVICE_FOUND_MSG,
50     WFD_SOURCE_ADD_DEVICE_REQ,
51     WFD_SOURCE_REMOVE_DEVICE_REQ,
52     WFD_SOURCE_DESTROY_SCREEN_CAPTUREREQ_REQ,
53     // domain msg
54 };
55 
56 struct WfdCommonRsp : public BaseMsg {
57     enum { MSG_ID = WfdMsgId::WFD_COMMON_RSP };
58 
GetMsgIdWfdCommonRsp59     int32_t GetMsgId() final { return MSG_ID; }
60     WfdCommonRsp() = default;
WfdCommonRspWfdCommonRsp61     explicit WfdCommonRsp(const WfdCommonRsp &rReq) {};
62     WfdCommonRsp &operator=(const WfdCommonRsp &rReq)
63     {
64         if (this != &rReq) {
65             this->ret = rReq.ret;
66         }
67 
68         return *this;
69     }
70 
71     IPC_BIND_ATTR(ret)
72 
73     int32_t ret = 0;
74 };
75 
76 struct WfdSinkStartReq : public BaseMsg {
77     enum { MSG_ID = WfdMsgId::WFD_SINK_START_REQ };
GetMsgIdWfdSinkStartReq78     int32_t GetMsgId() final { return MSG_ID; }
79 
80     IPC_BIND_ATTR0
81 };
82 
83 struct WfdSinkStopReq : public BaseMsg {
84     enum { MSG_ID = WfdMsgId::WFD_SINK_STOP_REQ };
GetMsgIdWfdSinkStopReq85     int32_t GetMsgId() final { return MSG_ID; }
86 
87     IPC_BIND_ATTR0
88 };
89 
90 struct WfdAppendSurfaceReq : public BaseMsg {
91     enum { MSG_ID = WfdMsgId::WFD_SET_SURFACE_REQ };
92 
GetMsgIdWfdAppendSurfaceReq93     int32_t GetMsgId() final { return MSG_ID; }
94     WfdAppendSurfaceReq() = default;
WfdAppendSurfaceReqWfdAppendSurfaceReq95     explicit WfdAppendSurfaceReq(const WfdAppendSurfaceReq &rReq) {};
96     WfdAppendSurfaceReq &operator=(const WfdAppendSurfaceReq &rReq)
97     {
98         if (this != &rReq) {
99             this->sceneType = rReq.sceneType;
100             this->deviceId = rReq.deviceId;
101             this->surface = rReq.surface;
102         }
103 
104         return *this;
105     }
106 
107     IPC_BIND_ATTR(sceneType, deviceId, surface)
108 
109     uint32_t sceneType = 1;
110 
111     std::string deviceId;
112     sptr<IRemoteObject> surface;
113 };
114 
115 struct WfdRemoveSurfaceReq : public BaseMsg {
116     enum { MSG_ID = WfdMsgId::WFD_DEL_SURFACE_REQ };
117 
GetMsgIdWfdRemoveSurfaceReq118     int32_t GetMsgId() final { return MSG_ID; }
119     WfdRemoveSurfaceReq() = default;
WfdRemoveSurfaceReqWfdRemoveSurfaceReq120     explicit WfdRemoveSurfaceReq(const WfdRemoveSurfaceReq &rReq) {};
121     WfdRemoveSurfaceReq &operator=(const WfdRemoveSurfaceReq &rReq)
122     {
123         if (this != &rReq) {
124             this->surfaceId = rReq.surfaceId;
125             this->deviceId = rReq.deviceId;
126         }
127 
128         return *this;
129     }
130 
131     IPC_BIND_ATTR(surfaceId, deviceId)
132 
133     uint64_t surfaceId;
134     std::string deviceId;
135 };
136 
137 struct CodecAttr {
138     IPC_BIND_ATTR(formatId, codecType)
139 
140     int32_t formatId = -1;
141     int32_t codecType = -1;
142 };
143 
144 struct SetMediaFormatReq : public BaseMsg {
145     enum { MSG_ID = WfdMsgId::WFD_SET_MEDIA_FORMAT_REQ };
146 
GetMsgIdSetMediaFormatReq147     int32_t GetMsgId() final { return MSG_ID; }
148     SetMediaFormatReq() = default;
SetMediaFormatReqSetMediaFormatReq149     explicit SetMediaFormatReq(const SetMediaFormatReq &req) {};
150     SetMediaFormatReq &operator=(const SetMediaFormatReq &rReq)
151     {
152         if (this != &rReq) {
153             this->deviceId = rReq.deviceId;
154             this->videoAttr = rReq.videoAttr;
155             this->audioAttr = rReq.audioAttr;
156         }
157 
158         return *this;
159     }
160 
161     IPC_BIND_ATTR(deviceId, videoAttr, audioAttr)
162 
163     std::string deviceId;
164     CodecAttr videoAttr;
165     CodecAttr audioAttr;
166 };
167 
168 struct WfdPlayReq : public BaseMsg {
169     enum { MSG_ID = WfdMsgId::WFD_PLAY_REQ };
170 
GetMsgIdWfdPlayReq171     int32_t GetMsgId() final { return MSG_ID; }
172     WfdPlayReq() = default;
WfdPlayReqWfdPlayReq173     explicit WfdPlayReq(const WfdPlayReq &rReq) {};
174     WfdPlayReq &operator=(const WfdPlayReq &rReq)
175     {
176         if (this != &rReq) {
177             this->deviceId = rReq.deviceId;
178         }
179 
180         return *this;
181     }
182 
183     IPC_BIND_ATTR(deviceId)
184 
185     std::string deviceId;
186 };
187 
188 struct WfdPauseReq : public BaseMsg {
189     enum { MSG_ID = WfdMsgId::WFD_PAUSE_REQ };
190 
GetMsgIdWfdPauseReq191     int32_t GetMsgId() final { return MSG_ID; }
192     WfdPauseReq() = default;
WfdPauseReqWfdPauseReq193     explicit WfdPauseReq(const WfdPauseReq &rReq) {};
194     WfdPauseReq &operator=(const WfdPauseReq &rReq)
195     {
196         if (this != &rReq) {
197             this->deviceId = rReq.deviceId;
198         }
199 
200         return *this;
201     }
202 
203     IPC_BIND_ATTR(deviceId)
204 
205     std::string deviceId;
206 };
207 
208 struct WfdCloseReq : public BaseMsg {
209     enum { MSG_ID = WfdMsgId::WFD_CLOSE_REQ };
210 
GetMsgIdWfdCloseReq211     int32_t GetMsgId() final { return MSG_ID; }
212     WfdCloseReq() = default;
WfdCloseReqWfdCloseReq213     explicit WfdCloseReq(const WfdCloseReq &rReq) {};
214     WfdCloseReq &operator=(const WfdCloseReq &rReq)
215     {
216         if (this != &rReq) {
217             this->deviceId = rReq.deviceId;
218         }
219 
220         return *this;
221     }
222 
223     IPC_BIND_ATTR(deviceId)
224 
225     std::string deviceId;
226 };
227 
228 struct SetSceneTypeReq : public BaseMsg {
229     enum { MSG_ID = WfdMsgId::WFD_SET_SCENE_TYPE_REQ };
230 
GetMsgIdSetSceneTypeReq231     int32_t GetMsgId() final { return MSG_ID; }
232     SetSceneTypeReq() = default;
SetSceneTypeReqSetSceneTypeReq233     explicit SetSceneTypeReq(const SetSceneTypeReq &rReq) {};
234     SetSceneTypeReq &operator=(const SetSceneTypeReq &rReq)
235     {
236         if (this != &rReq) {
237             this->sceneType = rReq.sceneType;
238             this->surfaceId = rReq.surfaceId;
239             this->deviceId = rReq.deviceId;
240         }
241 
242         return *this;
243     }
244 
245     IPC_BIND_ATTR(sceneType, surfaceId, deviceId)
246 
247     uint32_t sceneType;
248     uint64_t surfaceId;
249 
250     std::string deviceId;
251 };
252 
253 struct MuteReq : public BaseMsg {
254     enum { MSG_ID = WfdMsgId::WFD_MUTE_REQ };
255 
GetMsgIdMuteReq256     int32_t GetMsgId() final { return MSG_ID; }
257     MuteReq() = default;
MuteReqMuteReq258     explicit MuteReq(const MuteReq &rReq) {};
259     MuteReq &operator=(const MuteReq &rReq)
260     {
261         if (this != &rReq) {
262             this->deviceId = rReq.deviceId;
263         }
264 
265         return *this;
266     }
267 
268     IPC_BIND_ATTR(deviceId)
269 
270     std::string deviceId;
271 };
272 
273 struct UnMuteReq : public BaseMsg {
274     enum { MSG_ID = WfdMsgId::WFD_UNMUTE_REQ };
275 
GetMsgIdUnMuteReq276     int32_t GetMsgId() final { return MSG_ID; }
277     UnMuteReq() = default;
UnMuteReqUnMuteReq278     explicit UnMuteReq(const UnMuteReq &rReq) {};
279     UnMuteReq &operator=(const UnMuteReq &rReq)
280     {
281         if (this != &rReq) {
282             this->deviceId = rReq.deviceId;
283         }
284 
285         return *this;
286     }
287 
288     IPC_BIND_ATTR(deviceId)
289 
290     std::string deviceId;
291 };
292 
293 struct GetSinkConfigReq : public BaseMsg {
294     enum { MSG_ID = WfdMsgId::WFD_GET_SINK_CONFIG_REQ };
295 
GetMsgIdGetSinkConfigReq296     int32_t GetMsgId() final { return MSG_ID; }
297 
298     IPC_BIND_ATTR0
299 };
300 
301 struct GetSinkConfigRsp : public BaseMsg {
302     enum { MSG_ID = WfdMsgId::WFD_GET_SINK_CONFIG_RSP };
303 
GetMsgIdGetSinkConfigRsp304     int32_t GetMsgId() final { return MSG_ID; }
305     GetSinkConfigRsp() = default;
GetSinkConfigRspGetSinkConfigRsp306     explicit GetSinkConfigRsp(const GetSinkConfigRsp &rReq) {};
307     GetSinkConfigRsp &operator=(const GetSinkConfigRsp &rRsp)
308     {
309         if (this != &rRsp) {
310             this->surfaceMaximum = rRsp.surfaceMaximum;
311             this->accessDevMaximum = rRsp.accessDevMaximum;
312             this->foregroundMaximum = rRsp.foregroundMaximum;
313         }
314 
315         return *this;
316     }
317 
318     IPC_BIND_ATTR(surfaceMaximum, accessDevMaximum, foregroundMaximum)
319 
320     uint32_t surfaceMaximum;
321     uint32_t accessDevMaximum;
322     uint32_t foregroundMaximum;
323 };
324 
325 struct WfdSourceStartDiscoveryReq : public BaseMsg {
326     enum { MSG_ID = WfdMsgId::WFD_SOURCE_START_DISCOVERY_REQ };
327 
GetMsgIdWfdSourceStartDiscoveryReq328     int32_t GetMsgId() final { return MSG_ID; }
329 
330     IPC_BIND_ATTR0
331 };
332 
333 struct WfdSourceStopDiscoveryReq : public BaseMsg {
334     enum { MSG_ID = WfdMsgId::WFD_SOURCE_STOP_DISCOVERY_REQ };
335 
GetMsgIdWfdSourceStopDiscoveryReq336     int32_t GetMsgId() final { return MSG_ID; }
337 
338     IPC_BIND_ATTR0
339 };
340 
341 struct WfdCastDeviceInfo {
342     IPC_BIND_ATTR(deviceId, ipAddr, deviceName, primaryDeviceType, secondaryDeviceType)
343 
344     std::string deviceId;
345     std::string ipAddr;
346     std::string deviceName;
347     std::string primaryDeviceType;
348     std::string secondaryDeviceType;
349 };
350 
351 struct WfdSourceDeviceFoundMsg : public BaseMsg {
352     enum { MSG_ID = WfdMsgId::WFD_SOURCE_DEVICE_FOUND_MSG };
353 
GetMsgIdWfdSourceDeviceFoundMsg354     int32_t GetMsgId() final { return MSG_ID; }
355 
356     IPC_BIND_ATTR(deviceInfos)
357 
358     std::vector<WfdCastDeviceInfo> deviceInfos;
359 };
360 
361 struct WfdSourceAddDeviceReq : public BaseMsg {
362     enum { MSG_ID = WfdMsgId::WFD_SOURCE_ADD_DEVICE_REQ };
363 
GetMsgIdWfdSourceAddDeviceReq364     int32_t GetMsgId() final { return MSG_ID; }
365 
366     IPC_BIND_ATTR(screenId, deviceId)
367 
368     uint64_t screenId;
369     std::string deviceId;
370 };
371 
372 struct WfdSourceRemoveDeviceReq : public BaseMsg {
373     enum { MSG_ID = WfdMsgId::WFD_SOURCE_REMOVE_DEVICE_REQ };
374 
GetMsgIdWfdSourceRemoveDeviceReq375     int32_t GetMsgId() final { return MSG_ID; }
376 
377     IPC_BIND_ATTR(deviceId)
378 
379     std::string deviceId;
380 };
381 
382 struct DestroyScreenCaptureReq : public BaseMsg {
383     enum { MSG_ID = WfdMsgId::WFD_SOURCE_DESTROY_SCREEN_CAPTUREREQ_REQ };
384 
GetMsgIdDestroyScreenCaptureReq385     int32_t GetMsgId() final { return MSG_ID; }
386 
387     IPC_BIND_ATTR(deviceId)
388 
389     std::string deviceId;
390 };
391 
392 struct WfdErrorMsg : public BaseMsg {
393     enum { MSG_ID = WfdMsgId::WFD_ERROR_MSG };
394 
GetMsgIdWfdErrorMsg395     int32_t GetMsgId() final { return MSG_ID; }
396     WfdErrorMsg() = default;
WfdErrorMsgWfdErrorMsg397     WfdErrorMsg(const WfdErrorMsg &rReq) {};
398     WfdErrorMsg &operator=(const WfdErrorMsg &rReq)
399     {
400         if (this != &rReq) {
401             this->errorCode = rReq.errorCode;
402             this->agentId = rReq.agentId;
403             this->contextId = rReq.contextId;
404             this->message = rReq.message;
405             this->mac = rReq.mac;
406         }
407 
408         return *this;
409     }
410 
411     IPC_BIND_ATTR(errorCode, agentId, contextId, message, mac)
412 
413     int32_t errorCode;
414 
415     uint32_t agentId;
416     uint32_t contextId;
417 
418     std::string message;
419     std::string mac;
420 };
421 
422 struct WfdConnectionChangedMsg : public BaseMsg {
423     enum { MSG_ID = WfdMsgId::WFD_CONNECTION_CHANGED_MSG };
424 
GetMsgIdWfdConnectionChangedMsg425     int32_t GetMsgId() final { return MSG_ID; }
426     WfdConnectionChangedMsg() = default;
WfdConnectionChangedMsgWfdConnectionChangedMsg427     explicit WfdConnectionChangedMsg(const WfdConnectionChangedMsg &rReq) {};
428     WfdConnectionChangedMsg &operator=(const WfdConnectionChangedMsg &rReq)
429     {
430         if (this != &rReq) {
431             this->state = rReq.state;
432             this->surfaceId = rReq.surfaceId;
433             this->ip = rReq.ip;
434             this->mac = rReq.mac;
435             this->deviceName = rReq.deviceName;
436             this->primaryDeviceType = rReq.primaryDeviceType;
437             this->secondaryDeviceType = rReq.secondaryDeviceType;
438         }
439 
440         return *this;
441     }
442 
443     IPC_BIND_ATTR(state, surfaceId, ip, mac, deviceName, primaryDeviceType, secondaryDeviceType)
444 
445     int32_t state;
446     uint64_t surfaceId;
447 
448     std::string ip;
449     std::string mac;
450     std::string deviceName;
451     std::string primaryDeviceType;
452     std::string secondaryDeviceType;
453 };
454 
455 struct WfdDecoderAccelerationDoneMsg : public BaseMsg {
456     enum { MSG_ID = WfdMsgId::WFD_DECODER_ACCELERATION_DONE };
457 
GetMsgIdWfdDecoderAccelerationDoneMsg458     int32_t GetMsgId() final { return MSG_ID; }
459     WfdDecoderAccelerationDoneMsg() = default;
WfdDecoderAccelerationDoneMsgWfdDecoderAccelerationDoneMsg460     explicit WfdDecoderAccelerationDoneMsg(const WfdDecoderAccelerationDoneMsg &rReq) {};
461     WfdDecoderAccelerationDoneMsg &operator=(const WfdDecoderAccelerationDoneMsg &rReq)
462     {
463         if (this != &rReq) {
464             this->surfaceId = rReq.surfaceId;
465         }
466 
467         return *this;
468     }
469 
470     IPC_BIND_ATTR(surfaceId)
471 
472     uint64_t surfaceId;
473 };
474 
475 struct WfdSurfaceFailureMsg : public BaseMsg {
476     enum { MSG_ID = WfdMsgId::WFD_SURFACE_FAILURE };
477 
GetMsgIdWfdSurfaceFailureMsg478     int32_t GetMsgId() final { return MSG_ID; }
479     WfdSurfaceFailureMsg() = default;
WfdSurfaceFailureMsgWfdSurfaceFailureMsg480     explicit WfdSurfaceFailureMsg(const WfdSurfaceFailureMsg &rReq) {};
481     WfdSurfaceFailureMsg &operator=(const WfdSurfaceFailureMsg &rReq)
482     {
483         if (this != &rReq) {
484             this->surfaceId = rReq.surfaceId;
485             this->mac = rReq.mac;
486         }
487 
488         return *this;
489     }
490 
491     IPC_BIND_ATTR(surfaceId, mac)
492 
493     uint64_t surfaceId;
494     std::string mac;
495 };
496 
497 } // namespace Sharing
498 } // namespace OHOS
499 #endif
500