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