1 /* 2 * Copyright (c) 2021-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 */ 15 16 #ifndef CLIENT_TRANS_UDP_STREAM_INTERFACE_H_ 17 #define CLIENT_TRANS_UDP_STREAM_INTERFACE_H_ 18 19 #include "softbus_trans_def.h" 20 21 #ifdef __cplusplus 22 #if __cplusplus 23 extern "C" { 24 #endif 25 #endif 26 27 typedef enum { 28 VTP, 29 TCP, 30 } Proto; 31 32 // keep same with the SessionStatus of softbus. 33 typedef enum { 34 STREAM_INIT, 35 STREAM_OPENING, 36 STREAM_OPENED, 37 STREAM_CONNECTING, 38 STREAM_CONNECTED, 39 STREAM_CLOSING, 40 STREAM_CLOSED, 41 } StreamStatus; 42 43 typedef struct { 44 void (*OnStatusChange)(int32_t channelId, int32_t newStatus); 45 void (*OnStreamReceived)(int32_t channelId, const StreamData *data, const StreamData *ext, 46 const StreamFrameInfo *param); 47 void (*OnQosEvent)(int32_t channelId, int32_t eventId, int32_t tvCount, const QosTv *tvList); 48 void (*OnFrameStats)(int32_t channelId, const StreamSendStats *data); 49 void (*OnRippleStats)(int32_t channelId, const TrafficStats *data); 50 } IStreamListener; 51 52 typedef struct { 53 const char *pkgName; 54 char *myIp; 55 char *peerIp; 56 int32_t peerPort; 57 StreamType type; 58 uint8_t *sessionKey; 59 uint32_t keyLen; 60 bool isRawStreamEncrypt; 61 } VtpStreamOpenParam; 62 63 int32_t StartVtpStreamChannelServer(int32_t channelId, const VtpStreamOpenParam *param, 64 const IStreamListener *callback); 65 int32_t StartVtpStreamChannelClient(int32_t channelId, const VtpStreamOpenParam *param, 66 const IStreamListener *callback); 67 int32_t SendVtpStream(int32_t channelId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param); 68 int32_t CloseVtpStreamChannel(int32_t channelId, const char *pkgName); 69 int32_t SetVtpStreamMultiLayerOpt(int32_t channelId, const void *optValue); 70 71 #ifdef __cplusplus 72 #if __cplusplus 73 } 74 #endif /* __cplusplus */ 75 #endif /* __cplusplus */ 76 77 #endif // !defined(CLIENT_TRANS_UDP_STREAM_INTERFACE_H_) 78