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