4 #ifndef __KINESIS_VIDEO_WEBRTC_SIGNALING_CLIENT__
5 #define __KINESIS_VIDEO_WEBRTC_SIGNALING_CLIENT__
14 #define SIGNALING_REQUEST_ID_HEADER_NAME KVS_REQUEST_ID_HEADER_NAME ":"
17 #define SIGNALING_CLIENT_FROM_CUSTOM_DATA(h) ((PSignalingClient) (h))
18 #define CUSTOM_DATA_FROM_SIGNALING_CLIENT(p) ((UINT64) (p))
21 #define ICE_CONFIGURATION_REFRESH_GRACE_PERIOD (30 * HUNDREDS_OF_NANOS_IN_A_SECOND)
24 #define SIGNALING_CLIENT_SHUTDOWN_TIMEOUT ((2 + SIGNALING_SERVICE_API_CALL_TIMEOUT_IN_SECONDS) * HUNDREDS_OF_NANOS_IN_A_SECOND)
27 #define SIGNALING_CLIENT_STATE_UNKNOWN_STR "Unknown"
28 #define SIGNALING_CLIENT_STATE_NEW_STR "New"
29 #define SIGNALING_CLIENT_STATE_GET_CREDENTIALS_STR "Get Security Credentials"
30 #define SIGNALING_CLIENT_STATE_DESCRIBE_STR "Describe Channel"
31 #define SIGNALING_CLIENT_STATE_CREATE_STR "Create Channel"
32 #define SIGNALING_CLIENT_STATE_GET_ENDPOINT_STR "Get Channel Endpoint"
33 #define SIGNALING_CLIENT_STATE_GET_ICE_CONFIG_STR "Get ICE Server Configuration"
34 #define SIGNALING_CLIENT_STATE_READY_STR "Ready"
35 #define SIGNALING_CLIENT_STATE_CONNECTING_STR "Connecting"
36 #define SIGNALING_CLIENT_STATE_CONNECTED_STR "Connected"
37 #define SIGNALING_CLIENT_STATE_DISCONNECTED_STR "Disconnected"
38 #define SIGNALING_CLIENT_STATE_DELETE_STR "Delete"
39 #define SIGNALING_CLIENT_STATE_DELETED_STR "Deleted"
40 #define SIGNALING_CLIENT_STATE_DESCRIBE_MEDIA_STR "Describe Media Storage"
41 #define SIGNALING_CLIENT_STATE_JOIN_SESSION_STR "Join Session"
42 #define SIGNALING_CLIENT_STATE_JOIN_SESSION_WAITING_STR "Join Session Waiting"
43 #define SIGNALING_CLIENT_STATE_JOIN_SESSION_CONNECTED_STR "Join Session Connected"
46 #define SIGNALING_ICE_CONFIG_REFRESH_ERROR_MSG "Failed refreshing ICE server configuration with status code 0x%08x."
49 #define SIGNALING_RECONNECT_ERROR_MSG "Failed to reconnect with status code 0x%08x."
52 #define SIGNALING_MAX_ERROR_MESSAGE_LEN 512
55 #define SIGNALING_ASYNC_ICE_CONFIG_REFRESH_DELAY (50 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND)
58 #define LWS_PROTOCOL_COUNT 2
63 #define SIGNALING_CLOCKSKEW_HASH_TABLE_BUCKET_LENGTH 2
64 #define SIGNALING_CLOCKSKEW_HASH_TABLE_BUCKET_COUNT MIN_HASH_BUCKET_COUNT
67 #define SIGNALING_API_LATENCY_CALCULATION(pClient, time, isCpApi) \
68 MUTEX_LOCK((pClient)->diagnosticsLock); \
70 (pClient)->diagnostics.cpApiLatency = \
71 EMA_ACCUMULATOR_GET_NEXT((pClient)->diagnostics.cpApiLatency, SIGNALING_GET_CURRENT_TIME((pClient)) - (time)); \
73 (pClient)->diagnostics.dpApiLatency = \
74 EMA_ACCUMULATOR_GET_NEXT((pClient)->diagnostics.dpApiLatency, SIGNALING_GET_CURRENT_TIME((pClient)) - (time)); \
76 MUTEX_UNLOCK((pClient)->diagnosticsLock);
78 #define SIGNALING_UPDATE_ERROR_COUNT(pClient, status) \
79 if ((pClient) != NULL && STATUS_FAILED(status)) { \
80 ATOMIC_INCREMENT(&(pClient)->diagnostics.numberOfErrors); \
83 #define IS_CURRENT_TIME_CALLBACK_SET(pClient) ((pClient) != NULL && ((pClient)->signalingClientCallbacks.getCurrentTimeFn != NULL))
85 #define SIGNALING_GET_CURRENT_TIME(pClient) \
86 (IS_CURRENT_TIME_CALLBACK_SET((pClient)) \
87 ? ((pClient)->signalingClientCallbacks.getCurrentTimeFn((pClient)->signalingClientCallbacks.customData)) \
90 #define DEFAULT_CREATE_SIGNALING_CLIENT_RETRY_ATTEMPTS 7
92 #define SIGNALING_STATE_MACHINE_NAME (PCHAR) "SIGNALING"
94 static const ExponentialBackoffRetryStrategyConfig DEFAULT_SIGNALING_STATE_MACHINE_EXPONENTIAL_BACKOFF_RETRY_CONFIGURATION = {
112 KVS_INFINITE_EXPONENTIAL_RETRIES,
115 DEFAULT_KVS_MIN_TIME_TO_RESET_RETRY_STATE_MILLISECONDS,
134 CHAR cacheFilePath[MAX_PATH_LEN + 1];
390 #define TO_SIGNALING_CLIENT_HANDLE(p) ((SIGNALING_CLIENT_HANDLE) (p))
391 #define FROM_SIGNALING_CLIENT_HANDLE(h) (IS_VALID_SIGNALING_CLIENT_HANDLE(h) ? (PSignalingClient) (h) : NULL)
STATUS freeClientRetryStrategy(PSignalingClient)
Definition: Signaling.c:354
STATUS signalingRemoveOngoingMessage(PSignalingClient, PCHAR)
Definition: Signaling.c:801
STATUS signalingSendMessageSync(PSignalingClient, PSignalingMessage)
Definition: Signaling.c:394
STATUS uninitializeThreadTracker(PThreadTracker)
Definition: Signaling.c:914
struct __LwsCallInfo * PLwsCallInfo
Definition: Signaling.h:121
STATUS getIceConfig(PSignalingClient, UINT64)
Definition: Signaling.c:1146
STATUS createSignalingSync(PSignalingClientInfoInternal, PChannelInfo, PSignalingClientCallbacks, PAwsCredentialProvider, PSignalingClient *)
Definition: Signaling.c:7
STATUS configureRetryStrategyForSignalingStateMachine(PSignalingClient)
Definition: Signaling.c:330
STATUS signalingGetIceConfigInfo(PSignalingClient, UINT32, PIceConfigInfo *)
Definition: Signaling.c:455
STATUS describeMediaStorageConf(PSignalingClient, UINT64)
Definition: Signaling.c:1319
struct SignalingDiagnostics PSignalingDiagnostics
STATUS setupDefaultRetryStrategyForSignalingStateMachine(PSignalingClient)
Definition: Signaling.c:310
STATUS signalingDeleteSync(PSignalingClient)
Definition: Signaling.c:578
struct SignalingClientInfoInternal * PSignalingClientInfoInternal
STATUS validateSignalingClientInfo(PSignalingClient, PSignalingClientInfoInternal)
Definition: Signaling.c:626
STATUS describeChannel(PSignalingClient, UINT64)
Definition: Signaling.c:957
STATUS refreshIceConfiguration(PSignalingClient)
Definition: Signaling.c:706
STATUS createChannel(PSignalingClient, UINT64)
Definition: Signaling.c:1021
struct ThreadTracker * PThreadTracker
STATUS validateIceConfiguration(PSignalingClient)
Definition: Signaling.c:674
#define LWS_PROTOCOL_COUNT
Definition: Signaling.h:58
STATUS signalingGetOngoingMessage(PSignalingClient, PCHAR, PCHAR, PSignalingMessage *)
Definition: Signaling.c:845
STATUS signalingDisconnectSync(PSignalingClient)
Definition: Signaling.c:553
STATUS connectSignalingChannel(PSignalingClient, UINT64)
Definition: Signaling.c:1229
STATUS awaitForThreadTermination(PThreadTracker, UINT64)
Definition: Signaling.c:931
STATUS joinStorageSession(PSignalingClient, UINT64)
Definition: Signaling.c:1274
STATUS deleteChannel(PSignalingClient, UINT64)
Definition: Signaling.c:1187
STATUS(* SignalingApiCallHookFunc)(UINT64)
Definition: Signaling.h:124
STATUS signalingFetchSync(PSignalingClient)
Definition: Signaling.c:477
STATUS signalingGetMetrics(PSignalingClient, PSignalingClientMetrics)
Definition: Signaling.c:1387
STATUS signalingConnectSync(PSignalingClient)
Definition: Signaling.c:514
STATUS validateSignalingCallbacks(PSignalingClient, PSignalingClientCallbacks)
Definition: Signaling.c:607
STATUS terminateOngoingOperations(PSignalingClient)
Definition: Signaling.c:373
STATUS freeSignaling(PSignalingClient *)
Definition: Signaling.c:209
STATUS signalingStoreOngoingMessage(PSignalingClient, PSignalingMessage)
Definition: Signaling.c:776
STATUS signalingGetIceConfigInfoCount(PSignalingClient, PUINT32)
Definition: Signaling.c:436
STATUS getChannelEndpoint(PSignalingClient, UINT64)
Definition: Signaling.c:1063
UINT64 signalingGetCurrentTime(UINT64)
Definition: Signaling.c:1381
STATUS initializeThreadTracker(PThreadTracker)
Definition: Signaling.c:895
struct SignalingClient * PSignalingClient
#define MAX_ICE_CONFIG_COUNT
Definition: Include.h:615
#define MAX_SIGNALING_ENDPOINT_URI_LEN
Definition: Include.h:461
Contains all signaling channel related information.
Definition: Include.h:1321
ICE configuration information struct.
Definition: Include.h:1390
Signaling channel description returned from the service.
Definition: Include.h:1474
Register Signaling client callbacks.
Definition: Include.h:1462
Definition: Signaling.h:129
SignalingApiCallHookFunc describePreHookFn
Definition: Signaling.h:147
SignalingApiCallHookFunc connectPostHookFn
Definition: Signaling.h:156
SignalingApiCallHookFunc getEndpointPostHookFn
Definition: Signaling.h:152
SignalingClientInfo signalingClientInfo
Definition: Signaling.h:131
SignalingApiCallHookFunc getIceConfigPreHookFn
Definition: Signaling.h:153
SignalingApiCallHookFunc getIceConfigPostHookFn
Definition: Signaling.h:154
UINT64 hookCustomData
Definition: Signaling.h:144
SignalingApiCallHookFunc deletePreHookFn
Definition: Signaling.h:161
SignalingApiCallHookFunc joinSessionPreHookFn
Definition: Signaling.h:157
KvsRetryStrategy signalingStateMachineRetryStrategy
Definition: Signaling.h:165
SignalingApiCallHookFunc describeMediaStorageConfPostHookFn
Definition: Signaling.h:160
KvsRetryStrategyCallbacks signalingStateMachineRetryStrategyCallbacks
Definition: Signaling.h:166
SignalingApiCallHookFunc describePostHookFn
Definition: Signaling.h:148
SignalingApiCallHookFunc createPreHookFn
Definition: Signaling.h:149
SignalingApiCallHookFunc connectPreHookFn
Definition: Signaling.h:155
SignalingApiCallHookFunc getEndpointPreHookFn
Definition: Signaling.h:151
SignalingApiCallHookFunc deletePostHookFn
Definition: Signaling.h:162
UINT64 connectTimeout
Definition: Signaling.h:141
SignalingApiCallHookFunc describeMediaStorageConfPreHookFn
Definition: Signaling.h:159
SignalingApiCallHookFunc createPostHookFn
Definition: Signaling.h:150
SignalingApiCallHookFunc joinSessionPostHookFn
Definition: Signaling.h:158
Populate Signaling client with client ID and application log level.
Definition: Include.h:1299
SignalingStats Collection of signaling related stats. Can be expanded in the future.
Definition: Include.h:1553
Definition: Signaling.h:225
volatile ATOMIC_BOOL deleted
Definition: Signaling.h:248
MUTEX diagnosticsLock
Definition: Signaling.h:362
PAwsCredentials pAwsCredentials
Definition: Signaling.h:299
SignalingClientInfoInternal clientInfo
Definition: Signaling.h:263
MUTEX sendLock
Definition: Signaling.h:314
UINT64 describeTime
Definition: Signaling.h:368
CVAR connectedCvar
Definition: Signaling.h:311
ServiceCallContext serviceCallContext
Definition: Signaling.h:302
PChannelInfo pChannelInfo
Definition: Signaling.h:272
volatile ATOMIC_BOOL connected
Definition: Signaling.h:242
volatile ATOMIC_BOOL deleting
Definition: Signaling.h:245
CVAR sendCvar
Definition: Signaling.h:317
UINT64 offerReceivedTime
Definition: Signaling.h:376
CVAR jssWaitCvar
Definition: Signaling.h:386
PLwsCallInfo pOngoingCallInfo
Definition: Signaling.h:332
MUTEX connectedLock
Definition: Signaling.h:308
volatile ATOMIC_BOOL offerReceived
Definition: Signaling.h:260
UINT64 offerSentTime
Definition: Signaling.h:377
MUTEX offerSendReceiveTimeLock
Definition: Signaling.h:379
UINT64 connectTime
Definition: Signaling.h:373
UINT32 iceConfigCount
Definition: Signaling.h:290
UINT32 version
Definition: Signaling.h:227
UINT64 deleteTime
Definition: Signaling.h:372
volatile ATOMIC_BOOL refreshIceConfig
Definition: Signaling.h:255
SignalingChannelDescription channelDescription
Definition: Signaling.h:275
UINT64 getIceConfigTime
Definition: Signaling.h:371
volatile ATOMIC_BOOL shutdown
Definition: Signaling.h:239
UINT64 joinSessionTime
Definition: Signaling.h:380
MUTEX receiveLock
Definition: Signaling.h:320
MediaStorageConfig mediaStorageConfig
Definition: Signaling.h:278
MUTEX lwsServiceLock
Definition: Signaling.h:356
UINT64 answerTime
Definition: Signaling.h:375
volatile ATOMIC_BOOL serviceLockContention
Definition: Signaling.h:258
MUTEX jssWaitLock
Definition: Signaling.h:383
UINT64 iceConfigTime
Definition: Signaling.h:326
UINT64 iceConfigExpiration
Definition: Signaling.h:329
CVAR receiveCvar
Definition: Signaling.h:323
MUTEX stateLock
Definition: Signaling.h:305
ThreadTracker reconnecterTracker
Definition: Signaling.h:338
UINT64 getEndpointTime
Definition: Signaling.h:370
SignalingDiagnostics diagnostics
Definition: Signaling.h:365
UINT64 describeMediaTime
Definition: Signaling.h:374
PStateMachine pStateMachine
Definition: Signaling.h:296
ThreadTracker listenerTracker
Definition: Signaling.h:335
struct lws_context * pLwsContext
Definition: Signaling.h:341
PAwsCredentialProvider pCredentialProvider
Definition: Signaling.h:269
volatile ATOMIC_BOOL clientReady
Definition: Signaling.h:236
MUTEX messageQueueLock
Definition: Signaling.h:353
UINT64 createTime
Definition: Signaling.h:369
PStackQueue pMessageQueue
Definition: Signaling.h:350
volatile SIZE_T messageResult
Definition: Signaling.h:233
MUTEX lwsSerializerLock
Definition: Signaling.h:359
SignalingClientCallbacks signalingClientCallbacks
Definition: Signaling.h:266
volatile SIZE_T result
Definition: Signaling.h:230
Definition: Signaling.h:182
UINT64 dpApiLatency
Definition: Signaling.h:204
UINT32 stateMachineRetryCount
Definition: Signaling.h:219
volatile SIZE_T numberOfMessagesReceived
Definition: Signaling.h:184
UINT64 getSignalingChannelEndpointEndTime
Definition: Signaling.h:192
UINT64 offerToAnswerTime
Definition: Signaling.h:215
UINT64 connectTime
Definition: Signaling.h:202
UINT64 fetchClientTime
Definition: Signaling.h:213
UINT64 connectStartTime
Definition: Signaling.h:199
UINT64 joinSessionToOfferRecvTime
Definition: Signaling.h:217
UINT64 connectCallTime
Definition: Signaling.h:211
PHashTable pEndpointToClockSkewHashMap
Definition: Signaling.h:218
volatile SIZE_T numberOfErrors
Definition: Signaling.h:186
UINT64 getIceConfigCallTime
Definition: Signaling.h:210
UINT64 createCallTime
Definition: Signaling.h:208
UINT64 createTime
Definition: Signaling.h:201
volatile SIZE_T iceRefreshCount
Definition: Signaling.h:185
volatile SIZE_T numberOfReconnects
Definition: Signaling.h:188
UINT64 getTokenEndTime
Definition: Signaling.h:196
UINT64 describeCallTime
Definition: Signaling.h:206
UINT64 getTokenStartTime
Definition: Signaling.h:195
UINT64 connectClientTime
Definition: Signaling.h:214
volatile SIZE_T numberOfRuntimeErrors
Definition: Signaling.h:187
UINT64 createClientTime
Definition: Signaling.h:212
UINT64 getSignalingChannelEndpointStartTime
Definition: Signaling.h:191
UINT64 createChannelStartTime
Definition: Signaling.h:197
UINT64 joinSessionCallTime
Definition: Signaling.h:216
UINT64 describeChannelStartTime
Definition: Signaling.h:189
UINT64 getEndpointCallTime
Definition: Signaling.h:209
UINT64 describeChannelEndTime
Definition: Signaling.h:190
UINT64 getTokenCallTime
Definition: Signaling.h:205
UINT64 connectEndTime
Definition: Signaling.h:200
UINT64 describeMediaCallTime
Definition: Signaling.h:207
UINT64 getIceServerConfigStartTime
Definition: Signaling.h:193
UINT64 getIceServerConfigEndTime
Definition: Signaling.h:194
UINT64 createChannelEndTime
Definition: Signaling.h:198
UINT64 cpApiLatency
Definition: Signaling.h:203
volatile SIZE_T numberOfMessagesSent
Definition: Signaling.h:183
Structure defining the basic signaling message.
Definition: Include.h:1268
Definition: Signaling.h:172
TID threadId
Definition: Signaling.h:174
MUTEX lock
Definition: Signaling.h:175
CVAR await
Definition: Signaling.h:176
volatile ATOMIC_BOOL terminated
Definition: Signaling.h:173
Definition: LwsApiCalls.h:201