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 void (*OnUdpChannelOpened)(int32_t channelId); 35 void (*OnUdpChannelClosed)(int32_t channelId); 36 void (*OnQosEvent)(int channelId, int eventId, int tvCount, const QosTv *tvList); 37 } UdpChannelMgrCb; 38 39 typedef struct { 40 bool isServer; 41 int32_t peerUid; 42 int32_t peerPid; 43 char mySessionName[SESSION_NAME_SIZE_MAX]; 44 char peerSessionName[SESSION_NAME_SIZE_MAX]; 45 char peerDeviceId[DEVICE_ID_SIZE_MAX]; 46 char groupId[GROUP_ID_SIZE_MAX]; 47 } sessionNeed; 48 49 typedef struct { 50 ListNode node; 51 int32_t channelId; 52 int32_t dfileId; 53 int32_t businessType; 54 bool isEnable; 55 sessionNeed info; 56 int32_t routeType; 57 } UdpChannel; 58 59 int32_t ClientTransUdpMgrInit(IClientSessionCallBack *callback); 60 void ClientTransUdpMgrDeinit(void); 61 62 int32_t TransOnUdpChannelOpened(const char *sessionName, const ChannelInfo *channel, int32_t *udpPort); 63 int32_t TransOnUdpChannelOpenFailed(int32_t channelId, int32_t errCode); 64 int32_t TransOnUdpChannelClosed(int32_t channelId); 65 int32_t TransOnUdpChannelQosEvent(int32_t channelId, int32_t eventId, int32_t tvCount, const QosTv *tvList); 66 67 int32_t ClientTransCloseUdpChannel(int32_t channelId); 68 69 int32_t TransUdpChannelSendStream(int32_t channelId, const StreamData *data, const StreamData *ext, 70 const StreamFrameInfo *param); 71 72 int32_t TransUdpChannelSendFile(int32_t channelId, const char *sFileList[], const char *dFileList[], uint32_t fileCnt); 73 74 int32_t TransGetUdpChannelByFileId(int32_t dfileId, UdpChannel *udpChannel); 75 76 void TransUdpDeleteFileListener(const char *sessionName); 77 #ifdef __cplusplus 78 } 79 #endif 80 #endif // CLIENT_TRANS_UDP_MANAGER_H