• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 CLIENT_TRANS_UDP_MANAGER_H
17 #define CLIENT_TRANS_UDP_MANAGER_H
18 
19 #include <stdint.h>
20 
21 #include "client_trans_session_callback.h"
22 #include "session.h"
23 #include "softbus_def.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 typedef struct {
30     void (*OnStreamReceived)(int32_t channelId, const StreamData *data, const StreamData *ext,
31         const StreamFrameInfo *param);
32     int32_t (*OnFileGetSessionId)(int32_t channelId, int32_t *sessionId);
33     void (*OnMessageReceived)(void);
34     int32_t (*OnUdpChannelOpened)(int32_t channelId);
35     void (*OnUdpChannelClosed)(int32_t channelId, ShutdownReason reason);
36     void (*OnQosEvent)(int channelId, int eventId, int tvCount, const QosTv *tvList);
37     int32_t (*OnIdleTimeoutReset)(int32_t sessionId);
38 } UdpChannelMgrCb;
39 
40 typedef struct {
41     bool isServer;
42     int32_t peerUid;
43     int32_t peerPid;
44     char mySessionName[SESSION_NAME_SIZE_MAX];
45     char peerSessionName[SESSION_NAME_SIZE_MAX];
46     char peerDeviceId[DEVICE_ID_SIZE_MAX];
47     char groupId[GROUP_ID_SIZE_MAX];
48     char myIp[IP_LEN];
49 } sessionNeed;
50 
51 typedef struct {
52     ListNode node;
53     int32_t channelId;
54     int32_t dfileId;
55     int32_t businessType;
56     bool isEnable;
57     sessionNeed info;
58     int32_t routeType;
59 } UdpChannel;
60 
61 int32_t ClientTransUdpMgrInit(IClientSessionCallBack *callback);
62 void ClientTransUdpMgrDeinit(void);
63 
64 int32_t TransOnUdpChannelOpened(const char *sessionName, const ChannelInfo *channel, int32_t *udpPort);
65 int32_t TransOnUdpChannelOpenFailed(int32_t channelId, int32_t errCode);
66 int32_t TransOnUdpChannelClosed(int32_t channelId, ShutdownReason reason);
67 int32_t TransOnUdpChannelQosEvent(int32_t channelId, int32_t eventId, int32_t tvCount, const QosTv *tvList);
68 
69 int32_t ClientTransCloseUdpChannel(int32_t channelId, ShutdownReason reason);
70 
71 int32_t TransUdpChannelSendStream(int32_t channelId, const StreamData *data, const StreamData *ext,
72     const StreamFrameInfo *param);
73 
74 int32_t TransUdpChannelSendFile(int32_t channelId, const char *sFileList[], const char *dFileList[], uint32_t fileCnt);
75 
76 int32_t TransGetUdpChannelByFileId(int32_t dfileId, UdpChannel *udpChannel);
77 
78 int32_t TransGetUdpChannel(int32_t channelId, UdpChannel *udpChannel);
79 
80 void TransUdpDeleteFileListener(const char *sessionName);
81 #ifdef __cplusplus
82 }
83 #endif
84 #endif // CLIENT_TRANS_UDP_MANAGER_H