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