Amazon Kinesis Webrtc C SDK
 
Loading...
Searching...
No Matches
Include_i.h
Go to the documentation of this file.
1/*******************************************
2Main 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
10extern "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
29#ifdef KVS_USE_OPENSSL
30#include <openssl/bio.h>
31#include <openssl/err.h>
32#include <openssl/hmac.h>
33#include <openssl/md5.h>
34#include <openssl/rand.h>
35#include <openssl/sha.h>
36#include <openssl/ssl.h>
37#elif KVS_USE_MBEDTLS
38#include <mbedtls/ssl.h>
39#include <mbedtls/entropy.h>
40#include <mbedtls/ctr_drbg.h>
41#include <mbedtls/error.h>
42#if MBEDTLS_VERSION_NUMBER < 0x03000000
43#include <mbedtls/certs.h>
44#endif
45#include <mbedtls/sha256.h>
46#include <mbedtls/md5.h>
47#endif
48
49#ifdef USE_LIBSRTP3
50#include <srtp3/srtp.h>
51#else
52#include <srtp2/srtp.h>
53#endif
54
55// INET/INET6 MUST be defined before usrsctp
56// If removed will cause corruption that is hard to determine at runtime
57#define INET 1
58#define INET6 1
59#include <usrsctp.h>
60
61#if !defined __WINDOWS_BUILD__
62#include <signal.h>
63#include <sys/types.h>
64#ifdef HAVE_IFADDRS_H
65#include <ifaddrs.h>
66#endif
67#include <sys/types.h>
68#include <sys/socket.h>
69#include <netdb.h>
70#include <net/if.h>
71#include <arpa/inet.h>
72#include <fcntl.h>
73#include <netinet/tcp.h>
74#ifdef HAVE_POLL_H
75#include <poll.h>
76#endif
77#endif
78
79// Max uFrag and uPwd length as documented in https://tools.ietf.org/html/rfc5245#section-15.4
80#define ICE_MAX_UFRAG_LEN 256
81#define ICE_MAX_UPWD_LEN 256
82
83// Max stun username attribute len: https://tools.ietf.org/html/rfc5389#section-15.3
84#define STUN_MAX_USERNAME_LEN (UINT16) 512
85
86// https://tools.ietf.org/html/rfc5389#section-15.7
87#define STUN_MAX_REALM_LEN (UINT16) 128
88
89// https://tools.ietf.org/html/rfc5389#section-15.8
90#define STUN_MAX_NONCE_LEN (UINT16) 128
91
92// https://tools.ietf.org/html/rfc5389#section-15.6
93#define STUN_MAX_ERROR_PHRASE_LEN (UINT16) 128
94
95// Byte sizes of the IP addresses
96#define IPV6_ADDRESS_LENGTH (UINT16) 16
97#define IPV4_ADDRESS_LENGTH (UINT16) 4
98
99#define CERTIFICATE_FINGERPRINT_LENGTH 160
100
101#define MAX_UDP_PACKET_SIZE 65507
102
103typedef enum {
104 KVS_IP_FAMILY_TYPE_NOT_SET = (UINT16) 0x0000, // Sentinel value for not yet set IP address.
105 KVS_IP_FAMILY_TYPE_IPV4 = (UINT16) 0x0001,
106 KVS_IP_FAMILY_TYPE_IPV6 = (UINT16) 0x0002,
108
109typedef struct {
110 UINT16 family;
111 UINT16 port; // port is stored in network byte order
112 BYTE address[IPV6_ADDRESS_LENGTH]; // address is stored in network byte order
115
116// This structure stores both an IPv4 and IPv6 address (if applicable).
121
122static inline BOOL IS_IPV4_ADDR(const PKvsIpAddress pAddress)
123{
124 return pAddress != NULL && pAddress->family == KVS_IP_FAMILY_TYPE_IPV4;
125}
126
127static inline BOOL IS_IPV6_ADDR(const PKvsIpAddress pAddress)
128{
129 return pAddress != NULL && pAddress->family == KVS_IP_FAMILY_TYPE_IPV6;
130}
131
132// Used for ensuring alignment
133#define ALIGN_UP_TO_MACHINE_WORD(x) ROUND_UP((x), SIZEOF(SIZE_T))
134
135typedef STATUS (*IceServerSetIpFunc)(UINT64, PCHAR, PDualKvsIpAddresses);
136STATUS getIpAddrStr(PKvsIpAddress pKvsIpAddress, PCHAR pBuffer, UINT32 bufferLen);
137
139// Project forward declarations
141struct __TurnConnection;
142struct __SocketConnection;
143STATUS generateJSONSafeString(PCHAR, UINT32);
144
146// Project internal includes
149#include "Crypto/IOBuffer.h"
150#include "Crypto/Crypto.h"
151#include "Crypto/Dtls.h"
152#include "Crypto/Tls.h"
153#include "Ice/Network.h"
154#include "Ice/SocketConnection.h"
156#include "Stun/Stun.h"
157#include "Ice/IceUtils.h"
158#include "Sdp/Sdp.h"
159#include "Ice/IceAgent.h"
160#include "Ice/TurnConnection.h"
164#include "Srtp/SrtpSession.h"
165#include "Sctp/Sctp.h"
166#include "Signaling/FileCache.h"
167#include "Signaling/Signaling.h"
171#include "Rtp/RtpPacket.h"
172#include "Rtcp/RtcpPacket.h"
173#include "Rtcp/RollingBuffer.h"
179#include "PeerConnection/Rtp.h"
180#include "PeerConnection/Rtcp.h"
187#include "Metrics/Metrics.h"
188
190// Project internal defines
192
194// Project internal functions
196
197#define KVS_CONVERT_TIMESCALE(pts, from_timescale, to_timescale) (pts * to_timescale / from_timescale)
198
199#ifdef __cplusplus
200}
201#endif
202#endif /* __KINESIS_VIDEO_WEBRTC_CLIENT_INCLUDE_I__ */
KVS_IP_FAMILY_TYPE
Definition Include_i.h:103
@ KVS_IP_FAMILY_TYPE_IPV4
Definition Include_i.h:105
@ KVS_IP_FAMILY_TYPE_NOT_SET
Definition Include_i.h:104
@ KVS_IP_FAMILY_TYPE_IPV6
Definition Include_i.h:106
#define IPV6_ADDRESS_LENGTH
Definition Include_i.h:96
STATUS generateJSONSafeString(PCHAR, UINT32)
Definition PeerConnection.c:711
struct DualKvsIpAddresses * PDualKvsIpAddresses
struct KvsIpAddress * PKvsIpAddress
STATUS getIpAddrStr(PKvsIpAddress pKvsIpAddress, PCHAR pBuffer, UINT32 bufferLen)
Definition Network.c:636
STATUS(* IceServerSetIpFunc)(UINT64, PCHAR, PDualKvsIpAddresses)
Definition Include_i.h:135
Definition Include_i.h:117
KvsIpAddress ipv4Address
Definition Include_i.h:118
KvsIpAddress ipv6Address
Definition Include_i.h:119
Definition Include_i.h:109
UINT16 port
Definition Include_i.h:111
BOOL isPointToPoint
Definition Include_i.h:113
UINT16 family
Definition Include_i.h:110
Definition SocketConnection.h:25
Definition TurnConnection.h:119