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 STREAM_COMMON_INNER_H
17 #define STREAM_COMMON_INNER_H
18 
19 #include "stream_common.h"
20 #include "trans_log.h"
21 
22 namespace Communication {
23 namespace SoftBus {
24 enum InnerStreamOptionType {
25     INNER_STREAM_OPTION_TYPE_MIN = 0,
26 
27     // for socket
28     PROTOCOL,
29     LOCAL_IP,
30     LOCAL_PORT,
31     REMOTE_IP,
32     REMOTE_PORT,
33     IP_TYPE,
34     LOCAL_SCOPE_ID,
35     REMOTE_SCOPE_ID,
36     SERVER_FD,
37     FD,
38     SEND_BUF_SIZE,
39     RECV_BUF_SIZE,
40     KEEP_ALIVE_TIMEOUT,
41     TOS,
42     BOUND_INTERFACE_IP,
43     SOFTBUS_SOCKET_ERROR,
44     NON_BLOCK,
45     IS_SERVER,
46     REUSE_ADDR,
47     NO_DELAY,
48 
49     // for RAW Stream
50     SCENE,
51     STREAM_HEADER_SIZE,
52 
53     // for VTP
54     NACK_DELAY,
55     NACK_DELAY_TIMEOUT,
56     PACK_INTERVAL_ENLARGE,
57     REDUNANCY_SWITCH,
58     REDUNANCY_LEVEL,
59     PKT_LOSS,
60     PKT_STATISTICS,
61     SEND_CACHE,
62     RECV_CACHE,
63     PACKET_SIZE,
64     MAX_VTP_SOCKET_NUM,
65     MAX_VTP_CONNECT_NUM,
66 
67     // for link/mac
68     LINK_TYPE,
69     INNER_STREAM_OPTION_TYPE_MAX = 1000,
70 };
71 
72 enum StreamEventType {
73     REPORT_NETWORK_QUALITY,
74     REPORT_DROP_FRAME,
75     REPORT_SCORE,
76 };
77 
78 template<class T> struct StreamEvent {
79     StreamEventType type;
80     T event;
81 };
82 
83 struct HistoryStats {
84     Proto type = VTP;
85     int periodFrameNum;
86     int avgFrameInterval;
87     int minFrameInterval;
88     int maxFrameInterval;
89     int interval = 1000; // ms
90 };
91 
92 extern bool g_logOn;
93 } // namespace SoftBus
94 } // namespace Communication
95 
96 #endif