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 SOFTBUS_TRANS_DEF_H
17 #define SOFTBUS_TRANS_DEF_H
18 
19 #include <stdbool.h>
20 #include "session.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif // __cplusplus
25 
26 #define DISABLE_FD (-1)
27 
28 #define MSG_FLAG_REQUEST 0
29 #define MES_FLAG_REPLY 1
30 #define TRAFFIC_LEN 32
31 #define UNKNOW_OS_TYPE 1 /* peer osType unknow */
32 
33 typedef struct {
34     const char *sessionName;
35     const char *peerSessionName;
36     const char *peerDeviceId;
37     const char *groupId;
38     const SessionAttribute *attr;
39     QosTV qos[QOS_TYPE_BUTT];
40     uint32_t qosCount;
41     int32_t sessionId;
42     bool isQosLane;
43     bool isAsync;
44     uint32_t actionId;
45 } SessionParam;
46 
47 typedef struct {
48     int32_t channelId;
49     int32_t channelType;
50     int32_t eventId;
51     int32_t tvCount;
52     int32_t pid;
53     const QosTv *tvList;
54 } QosParam;
55 
56 typedef struct {
57     int32_t channelId;
58     int32_t channelType;
59 } TransInfo;
60 
61 typedef struct {
62     TransInfo transInfo;
63     int32_t ret;
64 } TransSerializer;
65 
66 typedef enum {
67     FRAME_COST_LT10MS = 0,
68     FRAME_COST_LT30MS,
69     FRAME_COST_LT50MS,
70     FRAME_COST_LT75MS,
71     FRAME_COST_LT100MS,
72     FRAME_COST_LT120MS,
73     FRAME_COST_GE120MS,
74     FRAME_COST_BUTT,
75 } StreamFrameCost;
76 
77 typedef enum {
78     FRAME_BIT_RATE_LT3M = 0,
79     FRAME_BIT_RATE_LT6M,
80     FRAME_BIT_RATE_LT10M,
81     FRAME_BIT_RATE_LT20M,
82     FRAME_BIT_RATE_LT30M,
83     FRAME_BIT_RATE_GE30M,
84     FRAME_BIT_RATE_BUTT,
85 } StreamFrameBitRate;
86 
87 typedef struct {
88     uint32_t costTimeStatsCnt[FRAME_COST_BUTT];
89     uint32_t sendBitRateStatsCnt[FRAME_BIT_RATE_BUTT];
90 } StreamSendStats;
91 
92 typedef struct {
93     unsigned char stats[TRAFFIC_LEN];
94 } TrafficStats;
95 
96 typedef struct TransReceiveData {
97     void *data;
98     uint32_t dataLen;
99     int32_t dataType;
100 } TransReceiveData;
101 #ifdef __cplusplus
102 }
103 #endif // __cplusplus
104 #endif // SOFTBUS_TRANS_DEF_H
105