-
Notifications
You must be signed in to change notification settings - Fork 334
/
Copy pathInclude_i.h
184 lines (153 loc) · 5.26 KB
/
Include_i.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*******************************************
Main internal include file
*******************************************/
#ifndef __KINESIS_VIDEO_WEBRTC_CLIENT_INCLUDE_I__
#define __KINESIS_VIDEO_WEBRTC_CLIENT_INCLUDE_I__
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <iphlpapi.h>
#include <ws2tcpip.h>
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
#endif
////////////////////////////////////////////////////
// Project include files
////////////////////////////////////////////////////
#include <com/amazonaws/kinesis/video/webrtcclient/Include.h>
#include "kvssdp/sdp_data_types.h"
#include "kvsstun/stun_data_types.h"
#ifdef KVS_USE_OPENSSL
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/hmac.h>
#include <openssl/md5.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
#include <openssl/ssl.h>
#elif KVS_USE_MBEDTLS
#include <mbedtls/ssl.h>
#include <mbedtls/entropy.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/error.h>
#include <mbedtls/certs.h>
#include <mbedtls/sha256.h>
#include <mbedtls/md5.h>
#endif
#include <srtp2/srtp.h>
// INET/INET6 MUST be defined before usrsctp
// If removed will cause corruption that is hard to determine at runtime
#define INET 1
#define INET6 1
#include <usrsctp.h>
#include <libwebsockets.h>
#if !defined __WINDOWS_BUILD__
#include <signal.h>
#include <sys/types.h>
#include <ifaddrs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#endif
// Max uFrag and uPwd length as documented in https://tools.ietf.org/html/rfc5245#section-15.4
#define ICE_MAX_UFRAG_LEN 256
#define ICE_MAX_UPWD_LEN 256
// Max stun username attribute len: https://tools.ietf.org/html/rfc5389#section-15.3
#define STUN_MAX_USERNAME_LEN (UINT16) 512
// https://tools.ietf.org/html/rfc5389#section-15.7
#define STUN_MAX_REALM_LEN (UINT16) 128
// https://tools.ietf.org/html/rfc5389#section-15.8
#define STUN_MAX_NONCE_LEN (UINT16) 128
// https://tools.ietf.org/html/rfc5389#section-15.6
#define STUN_MAX_ERROR_PHRASE_LEN (UINT16) 128
// Byte sizes of the IP addresses
#define IPV6_ADDRESS_LENGTH (UINT16) 16
#define IPV4_ADDRESS_LENGTH (UINT16) 4
#define CERTIFICATE_FINGERPRINT_LENGTH 160
#define MAX_UDP_PACKET_SIZE 65507
typedef enum {
KVS_IP_FAMILY_TYPE_IPV4 = (UINT16) 0x0001,
KVS_IP_FAMILY_TYPE_IPV6 = (UINT16) 0x0002,
} KVS_IP_FAMILY_TYPE;
typedef struct {
UINT16 family;
UINT16 port; // port is stored in network byte order
BYTE address[IPV6_ADDRESS_LENGTH]; // address is stored in network byte order
BOOL isPointToPoint;
} KvsIpAddress, *PKvsIpAddress;
#define IS_IPV4_ADDR(pAddress) ((pAddress)->family == KVS_IP_FAMILY_TYPE_IPV4)
// Used for ensuring alignment
#define ALIGN_UP_TO_MACHINE_WORD(x) ROUND_UP((x), SIZEOF(SIZE_T))
typedef STATUS (*IceServerSetIpFunc)(UINT64, PCHAR, PKvsIpAddress);
STATUS getIpAddrStr(PKvsIpAddress pKvsIpAddress, PCHAR pBuffer, UINT32 bufferLen);
////////////////////////////////////////////////////
// Project forward declarations
////////////////////////////////////////////////////
struct __TurnConnection;
struct __SocketConnection;
STATUS generateJSONSafeString(PCHAR, UINT32);
////////////////////////////////////////////////////
// Project internal includes
////////////////////////////////////////////////////
#include "Threadpool/ThreadpoolContext.h"
#include "Crypto/IOBuffer.h"
#include "Crypto/Crypto.h"
#include "Crypto/Dtls.h"
#include "Crypto/Tls.h"
#include "Ice/Network.h"
#include "Ice/SocketConnection.h"
#include "Ice/ConnectionListener.h"
#include "Stun/Stun.h"
#include "Ice/IceUtils.h"
#include "Sdp/Sdp.h"
#include "Ice/IceAgent.h"
#include "Ice/TurnConnection.h"
#include "Ice/IceAgentStateMachine.h"
#include "Ice/TurnConnectionStateMachine.h"
#include "Ice/NatBehaviorDiscovery.h"
#include "Srtp/SrtpSession.h"
#include "Sctp/Sctp.h"
#include "Signaling/FileCache.h"
#include "Signaling/Signaling.h"
#include "Signaling/ChannelInfo.h"
#include "Signaling/StateMachine.h"
#include "Signaling/LwsApiCalls.h"
#include "Rtp/RtpPacket.h"
#include "Rtcp/RtcpPacket.h"
#include "Rtcp/RollingBuffer.h"
#include "Rtcp/RtpRollingBuffer.h"
#include "PeerConnection/JitterBuffer.h"
#include "PeerConnection/PeerConnection.h"
#include "PeerConnection/Retransmitter.h"
#include "PeerConnection/SessionDescription.h"
#include "PeerConnection/Rtp.h"
#include "PeerConnection/Rtcp.h"
#include "PeerConnection/DataChannel.h"
#include "Rtp/Codecs/RtpVP8Payloader.h"
#include "Rtp/Codecs/RtpH264Payloader.h"
#include "Rtp/Codecs/RtpH265Payloader.h"
#include "Rtp/Codecs/RtpOpusPayloader.h"
#include "Rtp/Codecs/RtpAacPayloader.h"
#include "Rtp/Codecs/RtpG711Payloader.h"
#include "Metrics/Metrics.h"
////////////////////////////////////////////////////
// Project internal defines
////////////////////////////////////////////////////
////////////////////////////////////////////////////
// Project internal functions
////////////////////////////////////////////////////
#define KVS_CONVERT_TIMESCALE(pts, from_timescale, to_timescale) (pts * to_timescale / from_timescale)
STATUS convertSdpErrorCode(SdpResult_t sdpResult);
STATUS convertStunErrorCode(StunResult_t sdpResult);
#ifdef __cplusplus
}
#endif
#endif /* __KINESIS_VIDEO_WEBRTC_CLIENT_INCLUDE_I__ */