4 #ifndef __KINESIS_VIDEO_WEBRTC_LWS_API_CALLS__
5 #define __KINESIS_VIDEO_WEBRTC_LWS_API_CALLS__
14 #define SIGNALING_SERVICE_API_CALL_CONNECTION_TIMEOUT (2 * HUNDREDS_OF_NANOS_IN_A_SECOND)
15 #define SIGNALING_SERVICE_API_CALL_COMPLETION_TIMEOUT (5 * HUNDREDS_OF_NANOS_IN_A_SECOND)
16 #define SIGNALING_SERVICE_API_CALL_TIMEOUT_IN_SECONDS \
17 ((SIGNALING_SERVICE_API_CALL_CONNECTION_TIMEOUT + SIGNALING_SERVICE_API_CALL_COMPLETION_TIMEOUT) / HUNDREDS_OF_NANOS_IN_A_SECOND)
18 #define SIGNALING_SERVICE_TCP_KEEPALIVE_IN_SECONDS 3
19 #define SIGNALING_SERVICE_TCP_KEEPALIVE_PROBE_COUNT 3
20 #define SIGNALING_SERVICE_TCP_KEEPALIVE_PROBE_INTERVAL_IN_SECONDS 1
21 #define SIGNALING_SERVICE_WSS_PING_PONG_INTERVAL_IN_SECONDS 10
22 #define SIGNALING_SERVICE_WSS_HANGUP_IN_SECONDS 7200
25 #define PROTOCOL_INDEX_HTTPS 0
26 #define PROTOCOL_INDEX_WSS 1
29 #define CREATE_SIGNALING_CHANNEL_API_POSTFIX "/createSignalingChannel"
30 #define DESCRIBE_SIGNALING_CHANNEL_API_POSTFIX "/describeSignalingChannel"
31 #define GET_SIGNALING_CHANNEL_ENDPOINT_API_POSTFIX "/getSignalingChannelEndpoint"
32 #define DELETE_SIGNALING_CHANNEL_API_POSTFIX "/deleteSignalingChannel"
33 #define GET_ICE_CONFIG_API_POSTFIX "/v1/get-ice-server-config"
34 #define JOIN_STORAGE_SESSION_API_POSTFIX "/joinStorageSession"
35 #define DESCRIBE_MEDIA_STORAGE_CONF_API_POSTFIX "/describeMediaStorageConfiguration"
36 #define UPDATE_MEDIA_STORAGE_CONF_API_POSTFIX "/updateMediaStorageConfiguration"
39 #define SIGNALING_CHANNEL_PROTOCOL "\"WSS\", \"HTTPS\""
40 #define SIGNALING_CHANNEL_PROTOCOL_W_MEDIA_STORAGE "\"WSS\", \"HTTPS\", \"WEBRTC\""
43 #define DESCRIBE_CHANNEL_PARAM_JSON_TEMPLATE "{\n\t\"ChannelName\": \"%s\"\n}"
44 #define DESCRIBE_MEDIA_STORAGE_CONF_PARAM_JSON_TEMPLATE "{\n\t\"ChannelARN\": \"%s\"\n}"
47 #define DELETE_CHANNEL_PARAM_JSON_TEMPLATE \
48 "{\n\t\"ChannelARN\": \"%s\"," \
49 "\n\t\"CurrentVersion\": \"%s\"\n}"
52 #define CREATE_CHANNEL_PARAM_JSON_TEMPLATE \
53 "{\n\t\"ChannelName\": \"%s\"," \
54 "\n\t\"ChannelType\": \"%s\"," \
55 "\n\t\"SingleMasterConfiguration\": {" \
56 "\n\t\t\"MessageTtlSeconds\": %" PRIu64 "\n\t}" \
60 #define TAG_PARAM_JSON_OBJ_TEMPLATE "\n\t\t{\"Key\": \"%s\", \"Value\": \"%s\"},"
63 #define TAGS_PARAM_JSON_TEMPLATE ",\n\t\"Tags\": [%s\n\t]"
66 #define GET_CHANNEL_ENDPOINT_PARAM_JSON_TEMPLATE \
67 "{\n\t\"ChannelARN\": \"%s\"," \
68 "\n\t\"SingleMasterChannelEndpointConfiguration\": {" \
69 "\n\t\t\"Protocols\": [%s]," \
70 "\n\t\t\"Role\": \"%s\"" \
74 #define GET_ICE_CONFIG_PARAM_JSON_TEMPLATE \
75 "{\n\t\"ChannelARN\": \"%s\"," \
76 "\n\t\"ClientId\": \"%s\"," \
77 "\n\t\"Service\": \"TURN\"" \
80 #define SIGNALING_JOIN_STORAGE_SESSION_MASTER_PARAM_JSON_TEMPLATE "{\n\t\"channelArn\": \"%s\"\n}"
81 #define SIGNALING_JOIN_STORAGE_SESSION_VIEWER_PARAM_JSON_TEMPLATE \
82 "{\n\t\"channelArn\": \"%s\"," \
83 "\n\t\"clientId\": \"%s\"\n}"
84 #define SIGNALING_UPDATE_STORAGE_CONFIG_PARAM_JSON_TEMPLATE \
85 "{\n\t\"StreamARN\": \"%s\"," \
86 "\n\t\"ChannelARN\": \"%s\"," \
87 "\n\t\"StorageStatus\": \"%s\"" \
91 #define SIGNALING_ROLE_PARAM_NAME "X-Amz-Role"
92 #define SIGNALING_CHANNEL_NAME_PARAM_NAME "X-Amz-ChannelName"
93 #define SIGNALING_CHANNEL_ARN_PARAM_NAME "X-Amz-ChannelARN"
94 #define SIGNALING_CLIENT_ID_PARAM_NAME "X-Amz-ClientId"
97 #define SIGNALING_ENDPOINT_MASTER_URL_WSS_TEMPLATE "%s?%s=%s"
98 #define SIGNALING_ENDPOINT_VIEWER_URL_WSS_TEMPLATE "%s?%s=%s&%s=%s"
100 #define SIGNALING_SDP_TYPE_OFFER "SDP_OFFER"
101 #define SIGNALING_SDP_TYPE_ANSWER "SDP_ANSWER"
102 #define SIGNALING_ICE_CANDIDATE "ICE_CANDIDATE"
103 #define SIGNALING_GO_AWAY "GO_AWAY"
104 #define SIGNALING_RECONNECT_ICE_SERVER "RECONNECT_ICE_SERVER"
105 #define SIGNALING_STATUS_RESPONSE "STATUS_RESPONSE"
106 #define SIGNALING_MESSAGE_UNKNOWN "UNKNOWN"
109 #define MAX_SIGNALING_MESSAGE_TYPE_LEN ARRAY_SIZE(SIGNALING_RECONNECT_ICE_SERVER)
112 #define MAX_SIGNALING_STATUS_MESSAGE_LEN 16
115 #define SIGNALING_SEND_MESSAGE_TEMPLATE \
117 "\t\"action\": \"%s\",\n" \
118 "\t\"RecipientClientId\": \"%.*s\",\n" \
119 "\t\"MessagePayload\": \"%s\"%s\n" \
123 #define SIGNALING_SEND_MESSAGE_TEMPLATE_WITH_CORRELATION_ID \
125 "\t\"action\": \"%s\",\n" \
126 "\t\"RecipientClientId\": \"%.*s\",\n" \
127 "\t\"MessagePayload\": \"%s\",\n" \
128 "\t\"CorrelationId\": \"%.*s\"%s\n" \
131 #define SIGNALING_ICE_SERVER_LIST_TEMPLATE_START \
133 "\t\"IceServerList\": ["
135 #define SIGNALING_ICE_SERVER_LIST_TEMPLATE_END "\n\t]"
137 #define SIGNALING_ICE_SERVER_TEMPLATE \
140 "\t\t\t\"Password\": \"%s\",\n" \
141 "\t\t\t\"Ttl\": %" PRIu64 ",\n" \
142 "\t\t\t\"Uris\": [%s],\n" \
143 "\t\t\t\"Username\": \"%s\"\n" \
147 #define MAX_DATE_HEADER_BUFFER_LENGTH 64
149 #define MIN_CLOCK_SKEW_TIME_TO_CORRECT (5 * HUNDREDS_OF_NANOS_IN_A_MINUTE)
152 #define ICE_SERVER_INFO_TEMPLATE_BLOAT_SIZE 128
155 #define ICE_SERVER_URI_BLOAT_SIZE 10
158 #define MAX_ICE_SERVER_URI_STR_LEN (MAX_ICE_CONFIG_URI_COUNT * (MAX_ICE_CONFIG_URI_LEN + ICE_SERVER_URI_BLOAT_SIZE))
161 #define MAX_ICE_SERVER_INFO_STR_LEN \
162 (MAX_ICE_SERVER_URI_STR_LEN + MAX_ICE_CONFIG_USER_NAME_LEN + MAX_ICE_CONFIG_CREDENTIAL_LEN + ICE_SERVER_INFO_TEMPLATE_BLOAT_SIZE)
165 #define MAX_ICE_SERVER_INFOS_STR_LEN (MAX_ICE_CONFIG_COUNT * MAX_ICE_SERVER_INFO_STR_LEN)
168 #define MAX_ENCODED_ICE_SERVER_INFOS_STR_LEN (MAX_ICE_SERVER_INFOS_STR_LEN + ICE_SERVER_INFO_TEMPLATE_BLOAT_SIZE)
171 #define LWS_SCRATCH_BUFFER_SIZE (MAX_JSON_PARAMETER_STRING_LEN + LWS_PRE)
174 #define LWS_MESSAGE_BUFFER_SIZE (SIZEOF(CHAR) * (MAX_SIGNALING_MESSAGE_LEN + LWS_PRE))
176 #define AWS_SIG_V4_HEADER_HOST (PCHAR) "host"
179 #define BLOCK_ON_CORRELATION_ID FALSE
182 #define LWS_SERVICE_LOOP_ITERATION_WAIT (50 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND)
185 #define CHECK_SIGNALING_CREDENTIALS_EXPIRATION(p) \
187 if (SIGNALING_GET_CURRENT_TIME((p)) >= (p)->pAwsCredentials->expiration) { \
188 ATOMIC_STORE(&(p)->result, (SIZE_T) SERVICE_CALL_NOT_AUTHORIZED); \
189 CHK(FALSE, retStatus); \
198 #define WSS_SIGNALING_PROTOCOL_INDEX 1
INT32 lwsHttpCallbackRoutine(struct lws *, enum lws_callback_reasons, PVOID, PVOID, size_t)
Definition: LwsApiCalls.c:15
STATUS getIceConfigLws(PSignalingClient, UINT64)
Definition: LwsApiCalls.c:1135
PVOID reconnectHandler(PVOID)
Definition: LwsApiCalls.c:1720
STATUS connectSignalingChannelLws(PSignalingClient, UINT64)
Definition: LwsApiCalls.c:1392
STATUS writeLwsData(PSignalingClient, BOOL)
Definition: LwsApiCalls.c:1905
STATUS describeMediaStorageConfLws(PSignalingClient, UINT64)
Definition: LwsApiCalls.c:1562
STATUS deleteChannelLws(PSignalingClient, UINT64)
Definition: LwsApiCalls.c:1268
STATUS terminateConnectionWithStatus(PSignalingClient, SERVICE_CALL_RESULT)
Definition: LwsApiCalls.c:2248
VOID lwsSignalHandler(INT32)
Definition: LwsApiCalls.c:9
STATUS lwsCompleteSync(PLwsCallInfo)
Definition: LwsApiCalls.c:533
STATUS receiveLwsMessage(PSignalingClient, PCHAR, UINT32)
Definition: LwsApiCalls.c:1979
BOOL isCallResultSignatureNotYetCurrent(PCallInfo)
Definition: LwsApiCalls.c:705
PVOID receiveLwsMessageWrapper(PVOID)
Definition: LwsApiCalls.c:2360
STATUS describeChannelLws(PSignalingClient, UINT64)
Definition: LwsApiCalls.c:745
struct SignalingMessageWrapper * PSignalingMessageWrapper
BOOL isCallResultSignatureExpired(PCallInfo)
Definition: LwsApiCalls.c:700
STATUS createChannelLws(PSignalingClient, UINT64)
Definition: LwsApiCalls.c:879
STATUS wakeLwsServiceEventLoop(PSignalingClient, UINT32)
Definition: LwsApiCalls.c:2412
STATUS createLwsCallInfo(PSignalingClient, PRequestInfo, UINT32, PLwsCallInfo *)
Definition: LwsApiCalls.c:1338
PCHAR getMessageTypeInString(SIGNALING_MESSAGE_TYPE)
Definition: LwsApiCalls.c:2318
PVOID lwsListenerHandler(PVOID)
Definition: LwsApiCalls.c:1667
STATUS sendLwsMessage(PSignalingClient, SIGNALING_MESSAGE_TYPE, PCHAR, PCHAR, UINT32, PCHAR, UINT32)
Definition: LwsApiCalls.c:1772
STATUS getMessageTypeFromString(PCHAR, UINT32, SIGNALING_MESSAGE_TYPE *)
Definition: LwsApiCalls.c:2281
#define LWS_SCRATCH_BUFFER_SIZE
Definition: LwsApiCalls.h:171
INT32 lwsWssCallbackRoutine(struct lws *, enum lws_callback_reasons, PVOID, PVOID, size_t)
Definition: LwsApiCalls.c:290
STATUS getChannelEndpointLws(PSignalingClient, UINT64)
Definition: LwsApiCalls.c:986
STATUS joinStorageSessionLws(PSignalingClient, UINT64)
Definition: LwsApiCalls.c:1484
STATUS terminateLwsListenerLoop(PSignalingClient)
Definition: LwsApiCalls.c:2339
#define LWS_MESSAGE_BUFFER_SIZE
Definition: LwsApiCalls.h:174
STATUS freeLwsCallInfo(PLwsCallInfo *)
Definition: LwsApiCalls.c:1368
SIGNALING_MESSAGE_TYPE
Defines different signaling messages.
Definition: Include.h:880
Structure defining the signaling message to be received.
Definition: Include.h:1290
Definition: Signaling.h:225
Definition: LwsApiCalls.h:233
PSignalingClient pSignalingClient
Definition: LwsApiCalls.h:238
ReceivedSignalingMessage receivedSignalingMessage
Definition: LwsApiCalls.h:235
Definition: LwsApiCalls.h:201
UINT32 receiveBufferSize
Definition: LwsApiCalls.h:230
BYTE sendBuffer[(SIZEOF(CHAR) *(MAX_SIGNALING_MESSAGE_LEN+LWS_PRE))]
Definition: LwsApiCalls.h:224
volatile SIZE_T sendOffset
Definition: LwsApiCalls.h:206
volatile ATOMIC_BOOL cancelService
Definition: LwsApiCalls.h:209
UINT32 protocolIndex
Definition: LwsApiCalls.h:212
BYTE receiveBuffer[(SIZEOF(CHAR) *(MAX_SIGNALING_MESSAGE_LEN+LWS_PRE))]
Definition: LwsApiCalls.h:227
CHAR buffer[(MAX_JSON_PARAMETER_STRING_LEN+LWS_PRE)]
Definition: LwsApiCalls.h:221
CallInfo callInfo
Definition: LwsApiCalls.h:215
volatile SIZE_T sendBufferSize
Definition: LwsApiCalls.h:203
PSignalingClient pSignalingClient
Definition: LwsApiCalls.h:218