diff --git a/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt b/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt index 1f67ea517d..0e1f5a1196 100644 --- a/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt +++ b/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt @@ -6,7 +6,7 @@ include(ExternalProject) ExternalProject_Add(libkvsCommonLws-download GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git - GIT_TAG 9a995a5793b4024f19912be9a319993b1e16005c + GIT_TAG 99c1a8cd8cec88f99c9c4ce3944b53ae341d1491 PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX} diff --git a/samples/Common.c b/samples/Common.c index ae636027da..e5fa72952b 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -697,29 +697,6 @@ STATUS lookForSslCert(PSampleConfiguration* ppSampleConfiguration) return retStatus; } -STATUS setupDefaultSignalingClientRetryStrategy(PSignalingClientInfo pSignalingClientInfo) -{ - ENTERS(); - STATUS retStatus = STATUS_SUCCESS; - PRetryStrategy pRetryStrategy = NULL; - - CHK(pSignalingClientInfo != NULL, STATUS_NULL_ARG); - - pSignalingClientInfo->signalingClientRetryStrategy.retryStrategyType = KVS_RETRY_STRATEGY_EXPONENTIAL_BACKOFF_WAIT; - pSignalingClientInfo->signalingClientRetryStrategy.createRetryStrategyFn = exponentialBackoffRetryStrategyCreate; - pSignalingClientInfo->signalingClientRetryStrategy.freeRetryStrategyFn = exponentialBackoffRetryStrategyFree; - pSignalingClientInfo->signalingClientRetryStrategy.executeRetryStrategyFn = getExponentialBackoffRetryStrategyWaitTime; - - CHK_STATUS(pSignalingClientInfo->signalingClientRetryStrategy.createRetryStrategyFn(NULL /* use default config */, &pRetryStrategy)); - pSignalingClientInfo->signalingClientRetryStrategy.pRetryStrategy = pRetryStrategy; - - pSignalingClientInfo->signalingClientCreationMaxRetryCount = MAX_CREATE_SIGNALING_CLIENT_RETRIES; - -CleanUp: - LEAVES(); - return retStatus; -} - STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE roleType, BOOL trickleIce, BOOL useTurn, PSampleConfiguration* ppSampleConfiguration) { @@ -805,8 +782,6 @@ STATUS createSampleConfiguration(PCHAR channelName, SIGNALING_CHANNEL_ROLE_TYPE pSampleConfiguration->clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; pSampleConfiguration->clientInfo.loggingLevel = logLevel; pSampleConfiguration->clientInfo.cacheFilePath = NULL; // Use the default path - CHK_STATUS(setupDefaultSignalingClientRetryStrategy(&pSampleConfiguration->clientInfo)); - pSampleConfiguration->iceCandidatePairStatsTimerId = MAX_UINT32; pSampleConfiguration->pregenerateCertTimerId = MAX_UINT32; @@ -1088,11 +1063,6 @@ STATUS freeSampleConfiguration(PSampleConfiguration* ppSampleConfiguration) SAFE_MEMFREE(pSampleConfiguration->pVideoFrameBuffer); SAFE_MEMFREE(pSampleConfiguration->pAudioFrameBuffer); - if (pSampleConfiguration->clientInfo.signalingClientRetryStrategy.freeRetryStrategyFn != NULL) { - CHK_STATUS(pSampleConfiguration->clientInfo.signalingClientRetryStrategy.freeRetryStrategyFn( - &(pSampleConfiguration->clientInfo.signalingClientRetryStrategy.pRetryStrategy))); - } - if (IS_VALID_CVAR_VALUE(pSampleConfiguration->cvar) && IS_VALID_MUTEX_VALUE(pSampleConfiguration->sampleConfigurationObjLock)) { CVAR_BROADCAST(pSampleConfiguration->cvar); MUTEX_LOCK(pSampleConfiguration->sampleConfigurationObjLock); diff --git a/samples/Samples.h b/samples/Samples.h index 8e50d295dc..6b721a8d6f 100644 --- a/samples/Samples.h +++ b/samples/Samples.h @@ -39,7 +39,6 @@ extern "C" { #define SAMPLE_HASH_TABLE_BUCKET_COUNT 50 #define SAMPLE_HASH_TABLE_BUCKET_LENGTH 2 -#define MAX_CREATE_SIGNALING_CLIENT_RETRIES 3 #define IOT_CORE_CREDENTIAL_ENDPOINT ((PCHAR) "AWS_IOT_CORE_CREDENTIAL_ENDPOINT") #define IOT_CORE_CERT ((PCHAR) "AWS_IOT_CORE_CERT") diff --git a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h index 2be2eed2ea..88f4f80498 100644 --- a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h +++ b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h @@ -660,9 +660,6 @@ extern "C" { typedef UINT64 SIGNALING_CLIENT_HANDLE; typedef SIGNALING_CLIENT_HANDLE* PSIGNALING_CLIENT_HANDLE; -typedef KvsRetryStrategy SignalingClientRetryStrategy; -typedef PKvsRetryStrategy PSignalingClientRetryStrategy; - /** * @brief This is a sentinel indicating an invalid handle value */ @@ -1180,18 +1177,16 @@ typedef struct { * @brief Populate Signaling client with client ID and application log level */ typedef struct { - UINT32 version; //!< Version of the structure - CHAR clientId[MAX_SIGNALING_CLIENT_ID_LEN + 1]; //!< Client id to use. Defines if the client is a producer/consumer - UINT32 loggingLevel; //!< Verbosity level for the logging. One of LOG_LEVEL_XXX - //!< values or the default verbosity will be assumed. Currently, - //!< default value is LOG_LEVEL_WARNING - PCHAR cacheFilePath; //!< File cache path override. The default - //!< path is "./.SignalingCache_vN" which might not work for - //!< devices which have read only partition where the code is - //!< located. For default value or when file caching is not - //!< being used this value can be NULL or point to an EMPTY_STRING. - SignalingClientRetryStrategy signalingClientRetryStrategy; //!< Retry strategy used while creating signaling client - UINT32 signalingClientCreationMaxRetryCount; //!< Maximum attempts which createSignalingClientSync API will make on failures to create signaling client + UINT32 version; //!< Version of the structure + CHAR clientId[MAX_SIGNALING_CLIENT_ID_LEN + 1]; //!< Client id to use. Defines if the client is a producer/consumer + UINT32 loggingLevel; //!< Verbosity level for the logging. One of LOG_LEVEL_XXX + //!< values or the default verbosity will be assumed. Currently, + //!< default value is LOG_LEVEL_WARNING + PCHAR cacheFilePath; //!< File cache path override. The default + //!< path is "./.SignalingCache_vN" which might not work for + //!< devices which have read only partition where the code is + //!< located. For default value or when file caching is not + //!< being used this value can be NULL or point to an EMPTY_STRING. } SignalingClientInfo, *PSignalingClientInfo; /** diff --git a/src/source/Signaling/Client.c b/src/source/Signaling/Client.c index 870d846eb3..98966bc294 100644 --- a/src/source/Signaling/Client.c +++ b/src/source/Signaling/Client.c @@ -1,37 +1,13 @@ #define LOG_CLASS "SignalingClient" #include "../Include_i.h" -STATUS validateSignalingClientRetryStrategy(PSignalingClientInfo pClientInfo) { - ENTERS(); - STATUS retStatus = STATUS_SUCCESS; - PSignalingClientRetryStrategy pSignalingClientRetryStrategy; - - CHK(pClientInfo != NULL, STATUS_NULL_ARG); - - pSignalingClientRetryStrategy = &(pClientInfo->signalingClientRetryStrategy); - - CHK(pSignalingClientRetryStrategy->retryStrategyType > KVS_RETRY_STRATEGY_DISABLED && - pSignalingClientRetryStrategy->pRetryStrategy != NULL && - pSignalingClientRetryStrategy->executeRetryStrategyFn != NULL, STATUS_NULL_ARG); - - CHK(pClientInfo->signalingClientCreationMaxRetryCount > 0, STATUS_NOT_IMPLEMENTED); - -CleanUp: - - LEAVES(); - return retStatus; -} - STATUS createSignalingClientSync(PSignalingClientInfo pClientInfo, PChannelInfo pChannelInfo, PSignalingClientCallbacks pCallbacks, PAwsCredentialProvider pCredentialProvider, PSIGNALING_CLIENT_HANDLE pSignalingHandle) { ENTERS(); STATUS retStatus = STATUS_SUCCESS; PSignalingClient pSignalingClient = NULL; - PSignalingClientRetryStrategy pSignalingClientRetryStrategy = NULL; SignalingClientInfoInternal signalingClientInfoInternal; - UINT32 signalingClientCreationMaxRetryCount; - UINT64 signalingClientCreationWaitTime; DLOGV("Creating Signaling Client Sync"); CHK(pSignalingHandle != NULL && pClientInfo != NULL, STATUS_NULL_ARG); @@ -40,28 +16,7 @@ STATUS createSignalingClientSync(PSignalingClientInfo pClientInfo, PChannelInfo MEMSET(&signalingClientInfoInternal, 0x00, SIZEOF(signalingClientInfoInternal)); signalingClientInfoInternal.signalingClientInfo = *pClientInfo; - CHK_STATUS(validateSignalingClientRetryStrategy(pClientInfo)); - - signalingClientCreationMaxRetryCount = pClientInfo->signalingClientCreationMaxRetryCount; - pSignalingClientRetryStrategy = &(pClientInfo->signalingClientRetryStrategy); - - while (signalingClientCreationMaxRetryCount > 0) { - // Wait before cresting signaling client to ensure the first call from a large - // client fleet will be spread across the wait time window. - CHK_STATUS(pSignalingClientRetryStrategy->executeRetryStrategyFn(pSignalingClientRetryStrategy->pRetryStrategy, &signalingClientCreationWaitTime)); - DLOGV("Attempting to back off for [%lf] milliseconds before creating signaling client. Signaling client creation retry count [%d]", - signalingClientCreationWaitTime/1000.0, signalingClientCreationMaxRetryCount); - THREAD_SLEEP(signalingClientCreationWaitTime); - - retStatus = createSignalingSync(&signalingClientInfoInternal, pChannelInfo, pCallbacks, pCredentialProvider, &pSignalingClient); - if (retStatus == STATUS_SUCCESS) { - break; - } - signalingClientCreationMaxRetryCount--; - } - - DLOGV("Create signaling client returned [%" PRId64 "].", retStatus); - CHK_STATUS(retStatus); + CHK_STATUS(createSignalingSync(&signalingClientInfoInternal, pChannelInfo, pCallbacks, pCredentialProvider, &pSignalingClient)); *pSignalingHandle = TO_SIGNALING_CLIENT_HANDLE(pSignalingClient); diff --git a/src/source/Signaling/Signaling.c b/src/source/Signaling/Signaling.c index 21f1d7d804..8cf2786b0e 100644 --- a/src/source/Signaling/Signaling.c +++ b/src/source/Signaling/Signaling.c @@ -37,8 +37,9 @@ STATUS createSignalingSync(PSignalingClientInfoInternal pClientInfo, PChannelInf CHK_STATUS(validateSignalingCallbacks(pSignalingClient, pCallbacks)); CHK_STATUS(validateSignalingClientInfo(pSignalingClient, pClientInfo)); - // Set invalid call times pSignalingClient->version = SIGNALING_CLIENT_CURRENT_VERSION; + + // Set invalid call times pSignalingClient->describeTime = INVALID_TIMESTAMP_VALUE; pSignalingClient->createTime = INVALID_TIMESTAMP_VALUE; pSignalingClient->getEndpointTime = INVALID_TIMESTAMP_VALUE; @@ -73,9 +74,6 @@ STATUS createSignalingSync(PSignalingClientInfoInternal pClientInfo, PChannelInf // Store the credential provider pSignalingClient->pCredentialProvider = pCredentialProvider; - // Configure retry strategy for retries on error within signaling state machine - CHK_STATUS(configureRetryStrategyForSignalingStateMachine(pSignalingClient)); - // Create the state machine CHK_STATUS(createStateMachine(SIGNALING_STATE_MACHINE_STATES, SIGNALING_STATE_MACHINE_STATE_COUNT, CUSTOM_DATA_FROM_SIGNALING_CLIENT(pSignalingClient), signalingGetCurrentTime, @@ -207,8 +205,6 @@ STATUS freeSignaling(PSignalingClient* ppSignalingClient) MUTEX_UNLOCK(pSignalingClient->lwsServiceLock); } - freeClientRetryStrategy(pSignalingClient); - freeStateMachine(pSignalingClient->pStateMachine); freeChannelInfo(&pSignalingClient->pChannelInfo); @@ -520,52 +516,6 @@ STATUS validateSignalingClientInfo(PSignalingClient pSignalingClient, PSignaling return retStatus; } -STATUS configureRetryStrategyForSignalingStateMachine(PSignalingClient pSignalingClient) { - ENTERS(); - PRetryStrategy pRetryStrategy = NULL; - STATUS retStatus = STATUS_SUCCESS; - KVS_RETRY_STRATEGY_TYPE defaultKvsRetryStrategyType = KVS_RETRY_STRATEGY_EXPONENTIAL_BACKOFF_WAIT; - - CHK(pSignalingClient != NULL, STATUS_NULL_ARG); - pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.retryStrategyType = KVS_RETRY_STRATEGY_EXPONENTIAL_BACKOFF_WAIT; - pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.createRetryStrategyFn = exponentialBackoffRetryStrategyCreate; - pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.freeRetryStrategyFn = exponentialBackoffRetryStrategyFree; - pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.executeRetryStrategyFn = getExponentialBackoffRetryStrategyWaitTime; - - CHK_STATUS(pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.createRetryStrategyFn( - NULL, &pRetryStrategy)); - - if (pRetryStrategy == NULL) { - DLOGD("Unable to create exponential backoff retry strategy. This should not happen."); - } - - CHK(pRetryStrategy != NULL, STATUS_INTERNAL_ERROR); - pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.pRetryStrategy = pRetryStrategy; - - CleanUp: - - LEAVES(); - return retStatus; -} - -STATUS freeClientRetryStrategy(PSignalingClient pSignalingClient) { - ENTERS(); - STATUS retStatus = STATUS_SUCCESS; - - CHK(pSignalingClient != NULL && - pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.freeRetryStrategyFn != NULL, STATUS_SUCCESS); - - CHK_STATUS(pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.freeRetryStrategyFn( - &(pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.pRetryStrategy))); - - pSignalingClient->clientInfo.signalingStateMachineRetryStrategy.pRetryStrategy = NULL; - - CleanUp: - - LEAVES(); - return retStatus; -} - STATUS validateIceConfiguration(PSignalingClient pSignalingClient) { ENTERS(); diff --git a/src/source/Signaling/Signaling.h b/src/source/Signaling/Signaling.h index c3957f81ff..b404d36687 100644 --- a/src/source/Signaling/Signaling.h +++ b/src/source/Signaling/Signaling.h @@ -107,9 +107,6 @@ typedef struct { SignalingApiCallHookFunc connectPostHookFn; SignalingApiCallHookFunc deletePreHookFn; SignalingApiCallHookFunc deletePostHookFn; - - // Retry strategy for signaling state machine - KvsRetryStrategy signalingStateMachineRetryStrategy; } SignalingClientInfoInternal, *PSignalingClientInfoInternal; /** @@ -284,14 +281,6 @@ typedef struct { UINT64 connectTime; } SignalingClient, *PSignalingClient; -static const ExponentialBackoffRetryStrategyConfig DEFAULT_SIGNALING_STATE_MACHINE_EXPONENTIAL_RETRY_CONFIG = { - KVS_INFINITE_EXPONENTIAL_RETRIES, /* max retry count */ - 10000, /* max retry wait time milliseconds */ - 300, /* retry factor (base retry wait time milliseconds) */ - 25000, /* minimum time in milliseconds to reset retry state */ - 300 /* jitter factor milliseconds (jitter will be unused for FULL_JITTER variant of exponential backoff algorithm) */ -}; - // Public handle to and from object converters #define TO_SIGNALING_CLIENT_HANDLE(p) ((SIGNALING_CLIENT_HANDLE) (p)) #define FROM_SIGNALING_CLIENT_HANDLE(h) (IS_VALID_SIGNALING_CLIENT_HANDLE(h) ? (PSignalingClient) (h) : NULL) @@ -310,10 +299,6 @@ STATUS validateSignalingCallbacks(PSignalingClient, PSignalingClientCallbacks); STATUS validateSignalingClientInfo(PSignalingClient, PSignalingClientInfoInternal); STATUS validateIceConfiguration(PSignalingClient); -STATUS configureRetryStrategyForSignalingStateMachine(PSignalingClient); -STATUS setupDefaultKvsRetryStrategy(PSignalingClient); -STATUS freeClientRetryStrategy(PSignalingClient); - STATUS signalingStoreOngoingMessage(PSignalingClient, PSignalingMessage); STATUS signalingRemoveOngoingMessage(PSignalingClient, PCHAR); STATUS signalingGetOngoingMessage(PSignalingClient, PCHAR, PCHAR, PSignalingMessage*); diff --git a/src/source/Signaling/StateMachine.c b/src/source/Signaling/StateMachine.c index ad2d8cb95d..29f14e9864 100644 --- a/src/source/Signaling/StateMachine.c +++ b/src/source/Signaling/StateMachine.c @@ -7,157 +7,47 @@ /** * Static definitions of the states */ -// /Users/akatey/kvs_git_workspace/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/include/com/amazonaws/kinesis/video/state/Include.h StateMachineState SIGNALING_STATE_MACHINE_STATES[] = { - { - SIGNALING_STATE_NEW, SIGNALING_STATE_NONE | SIGNALING_STATE_NEW, - fromNewSignalingState, - executeNewSignalingState, - defaultSignalingStateTransitionHook, - INFINITE_RETRY_COUNT_SENTINEL, - STATUS_SIGNALING_INVALID_READY_STATE - }, - { - SIGNALING_STATE_GET_TOKEN, - SIGNALING_STATE_NEW | SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CREATE | SIGNALING_STATE_GET_ENDPOINT | SIGNALING_STATE_GET_ICE_CONFIG | - SIGNALING_STATE_READY | SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_DELETE | SIGNALING_STATE_GET_TOKEN, - fromGetTokenSignalingState, - executeGetTokenSignalingState, - defaultSignalingStateTransitionHook, - SIGNALING_STATES_DEFAULT_RETRY_COUNT, - STATUS_SIGNALING_GET_TOKEN_CALL_FAILED - }, - { - SIGNALING_STATE_DESCRIBE, - SIGNALING_STATE_GET_TOKEN | SIGNALING_STATE_CREATE | SIGNALING_STATE_GET_ENDPOINT | SIGNALING_STATE_GET_ICE_CONFIG | SIGNALING_STATE_CONNECT | - SIGNALING_STATE_CONNECTED | SIGNALING_STATE_DELETE | SIGNALING_STATE_DESCRIBE, - fromDescribeSignalingState, - executeDescribeSignalingState, - defaultSignalingStateTransitionHook, - SIGNALING_STATES_DEFAULT_RETRY_COUNT, - STATUS_SIGNALING_DESCRIBE_CALL_FAILED - }, - { - SIGNALING_STATE_CREATE, - SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CREATE, - fromCreateSignalingState, - executeCreateSignalingState, - defaultSignalingStateTransitionHook, - SIGNALING_STATES_DEFAULT_RETRY_COUNT, - STATUS_SIGNALING_CREATE_CALL_FAILED - }, - { - SIGNALING_STATE_GET_ENDPOINT, - SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CREATE | SIGNALING_STATE_GET_TOKEN | SIGNALING_STATE_READY | SIGNALING_STATE_CONNECT | - SIGNALING_STATE_CONNECTED | SIGNALING_STATE_GET_ENDPOINT, - fromGetEndpointSignalingState, - executeGetEndpointSignalingState, - defaultSignalingStateTransitionHook, - SIGNALING_STATES_DEFAULT_RETRY_COUNT, - STATUS_SIGNALING_GET_ENDPOINT_CALL_FAILED - }, - { - SIGNALING_STATE_GET_ICE_CONFIG, - SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_GET_ENDPOINT | SIGNALING_STATE_READY | - SIGNALING_STATE_GET_ICE_CONFIG, - fromGetIceConfigSignalingState, - executeGetIceConfigSignalingState, - defaultSignalingStateTransitionHook, - SIGNALING_STATES_DEFAULT_RETRY_COUNT, - STATUS_SIGNALING_GET_ICE_CONFIG_CALL_FAILED - }, - { - SIGNALING_STATE_READY, - SIGNALING_STATE_GET_ICE_CONFIG | SIGNALING_STATE_DISCONNECTED | SIGNALING_STATE_READY, - fromReadySignalingState, - executeReadySignalingState, - defaultSignalingStateTransitionHook, - INFINITE_RETRY_COUNT_SENTINEL, STATUS_SIGNALING_READY_CALLBACK_FAILED - }, - { - SIGNALING_STATE_CONNECT, - SIGNALING_STATE_READY | SIGNALING_STATE_DISCONNECTED | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_CONNECT, - fromConnectSignalingState, - executeConnectSignalingState, - defaultSignalingStateTransitionHook, - INFINITE_RETRY_COUNT_SENTINEL, - STATUS_SIGNALING_CONNECT_CALL_FAILED - }, - { - SIGNALING_STATE_CONNECTED, - SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED, - fromConnectedSignalingState, - executeConnectedSignalingState, - defaultSignalingStateTransitionHook, - INFINITE_RETRY_COUNT_SENTINEL, - STATUS_SIGNALING_CONNECTED_CALLBACK_FAILED - }, - { - SIGNALING_STATE_DISCONNECTED, - SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED, - fromDisconnectedSignalingState, - executeDisconnectedSignalingState, - defaultSignalingStateTransitionHook, - SIGNALING_STATES_DEFAULT_RETRY_COUNT, - STATUS_SIGNALING_DISCONNECTED_CALLBACK_FAILED - }, - { - SIGNALING_STATE_DELETE, - SIGNALING_STATE_GET_TOKEN | SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CREATE | SIGNALING_STATE_GET_ENDPOINT | SIGNALING_STATE_GET_ICE_CONFIG | - SIGNALING_STATE_READY | SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_DISCONNECTED | SIGNALING_STATE_DELETE, - fromDeleteSignalingState, - executeDeleteSignalingState, - defaultSignalingStateTransitionHook, - SIGNALING_STATES_DEFAULT_RETRY_COUNT, - STATUS_SIGNALING_DELETE_CALL_FAILED - }, - { - SIGNALING_STATE_DELETED, - SIGNALING_STATE_DELETE | SIGNALING_STATE_DELETED, - fromDeletedSignalingState, - executeDeletedSignalingState, - defaultSignalingStateTransitionHook, - INFINITE_RETRY_COUNT_SENTINEL, - STATUS_SIGNALING_DELETE_CALL_FAILED - }, + {SIGNALING_STATE_NEW, SIGNALING_STATE_NONE | SIGNALING_STATE_NEW, fromNewSignalingState, executeNewSignalingState, INFINITE_RETRY_COUNT_SENTINEL, + STATUS_SIGNALING_INVALID_READY_STATE}, + {SIGNALING_STATE_GET_TOKEN, + SIGNALING_STATE_NEW | SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CREATE | SIGNALING_STATE_GET_ENDPOINT | SIGNALING_STATE_GET_ICE_CONFIG | + SIGNALING_STATE_READY | SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_DELETE | SIGNALING_STATE_GET_TOKEN, + fromGetTokenSignalingState, executeGetTokenSignalingState, SIGNALING_STATES_DEFAULT_RETRY_COUNT, STATUS_SIGNALING_GET_TOKEN_CALL_FAILED}, + {SIGNALING_STATE_DESCRIBE, + SIGNALING_STATE_GET_TOKEN | SIGNALING_STATE_CREATE | SIGNALING_STATE_GET_ENDPOINT | SIGNALING_STATE_GET_ICE_CONFIG | SIGNALING_STATE_CONNECT | + SIGNALING_STATE_CONNECTED | SIGNALING_STATE_DELETE | SIGNALING_STATE_DESCRIBE, + fromDescribeSignalingState, executeDescribeSignalingState, SIGNALING_STATES_DEFAULT_RETRY_COUNT, STATUS_SIGNALING_DESCRIBE_CALL_FAILED}, + {SIGNALING_STATE_CREATE, SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CREATE, fromCreateSignalingState, executeCreateSignalingState, + SIGNALING_STATES_DEFAULT_RETRY_COUNT, STATUS_SIGNALING_CREATE_CALL_FAILED}, + {SIGNALING_STATE_GET_ENDPOINT, + SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CREATE | SIGNALING_STATE_GET_TOKEN | SIGNALING_STATE_READY | SIGNALING_STATE_CONNECT | + SIGNALING_STATE_CONNECTED | SIGNALING_STATE_GET_ENDPOINT, + fromGetEndpointSignalingState, executeGetEndpointSignalingState, SIGNALING_STATES_DEFAULT_RETRY_COUNT, + STATUS_SIGNALING_GET_ENDPOINT_CALL_FAILED}, + {SIGNALING_STATE_GET_ICE_CONFIG, + SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_GET_ENDPOINT | SIGNALING_STATE_READY | + SIGNALING_STATE_GET_ICE_CONFIG, + fromGetIceConfigSignalingState, executeGetIceConfigSignalingState, SIGNALING_STATES_DEFAULT_RETRY_COUNT, + STATUS_SIGNALING_GET_ICE_CONFIG_CALL_FAILED}, + {SIGNALING_STATE_READY, SIGNALING_STATE_GET_ICE_CONFIG | SIGNALING_STATE_DISCONNECTED | SIGNALING_STATE_READY, fromReadySignalingState, + executeReadySignalingState, INFINITE_RETRY_COUNT_SENTINEL, STATUS_SIGNALING_READY_CALLBACK_FAILED}, + {SIGNALING_STATE_CONNECT, SIGNALING_STATE_READY | SIGNALING_STATE_DISCONNECTED | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_CONNECT, + fromConnectSignalingState, executeConnectSignalingState, INFINITE_RETRY_COUNT_SENTINEL, STATUS_SIGNALING_CONNECT_CALL_FAILED}, + {SIGNALING_STATE_CONNECTED, SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED, fromConnectedSignalingState, executeConnectedSignalingState, + INFINITE_RETRY_COUNT_SENTINEL, STATUS_SIGNALING_CONNECTED_CALLBACK_FAILED}, + {SIGNALING_STATE_DISCONNECTED, SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED, fromDisconnectedSignalingState, + executeDisconnectedSignalingState, SIGNALING_STATES_DEFAULT_RETRY_COUNT, STATUS_SIGNALING_DISCONNECTED_CALLBACK_FAILED}, + {SIGNALING_STATE_DELETE, + SIGNALING_STATE_GET_TOKEN | SIGNALING_STATE_DESCRIBE | SIGNALING_STATE_CREATE | SIGNALING_STATE_GET_ENDPOINT | SIGNALING_STATE_GET_ICE_CONFIG | + SIGNALING_STATE_READY | SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_DISCONNECTED | SIGNALING_STATE_DELETE, + fromDeleteSignalingState, executeDeleteSignalingState, SIGNALING_STATES_DEFAULT_RETRY_COUNT, STATUS_SIGNALING_DELETE_CALL_FAILED}, + {SIGNALING_STATE_DELETED, SIGNALING_STATE_DELETE | SIGNALING_STATE_DELETED, fromDeletedSignalingState, executeDeletedSignalingState, + INFINITE_RETRY_COUNT_SENTINEL, STATUS_SIGNALING_DELETE_CALL_FAILED}, }; UINT32 SIGNALING_STATE_MACHINE_STATE_COUNT = ARRAY_SIZE(SIGNALING_STATE_MACHINE_STATES); -STATUS defaultSignalingStateTransitionHook( - UINT64 customData /* customData should be PSignalingClient */, - PUINT64 stateTransitionWaitTime) { - ENTERS(); - STATUS retStatus = STATUS_SUCCESS; - PSignalingClient pSignalingClient = NULL; - PKvsRetryStrategy pKvsRetryStrategy = NULL; - UINT64 retryWaitTime = 0; - - pSignalingClient = SIGNALING_CLIENT_FROM_CUSTOM_DATA(customData); - CHK(pSignalingClient != NULL && stateTransitionWaitTime != NULL, STATUS_NULL_ARG); - - pKvsRetryStrategy = &(pSignalingClient->clientInfo.signalingStateMachineRetryStrategy); - - // result > SERVICE_CALL_RESULT_OK covers case for - - // result != SERVICE_CALL_RESULT_NOT_SET and != SERVICE_CALL_RESULT_OK - // If we support any other 2xx service call results, the condition - // should change to (pSignalingClient->result > 299 && ...) - CHK(pSignalingClient->result > SERVICE_CALL_RESULT_OK && - pKvsRetryStrategy != NULL && - pKvsRetryStrategy->pRetryStrategy != NULL && - pKvsRetryStrategy->executeRetryStrategyFn != NULL, STATUS_SUCCESS); - - DLOGD("Signaling Client base result is [%u]. Executing KVS retry handler of retry strategy type [%u]", - pSignalingClient->result, pKvsRetryStrategy->retryStrategyType); - pKvsRetryStrategy->executeRetryStrategyFn(pKvsRetryStrategy->pRetryStrategy, &retryWaitTime); - *stateTransitionWaitTime = retryWaitTime; - - CleanUp: - - LEAVES(); - return retStatus; -} - STATUS signalingStateMachineIterator(PSignalingClient pSignalingClient, UINT64 expiration, UINT64 finalState) { ENTERS(); diff --git a/src/source/Signaling/StateMachine.h b/src/source/Signaling/StateMachine.h index e0b68eeaa6..fea8300e66 100644 --- a/src/source/Signaling/StateMachine.h +++ b/src/source/Signaling/StateMachine.h @@ -13,19 +13,19 @@ extern "C" { /** * Signaling states definitions */ -#define SIGNALING_STATE_NONE ((UINT64) 0x00) -#define SIGNALING_STATE_NEW ((UINT64) 0x01) -#define SIGNALING_STATE_GET_TOKEN ((UINT64) 0x02) -#define SIGNALING_STATE_DESCRIBE ((UINT64) 0x03) -#define SIGNALING_STATE_CREATE ((UINT64) 0x04) -#define SIGNALING_STATE_GET_ENDPOINT ((UINT64) 0x05) -#define SIGNALING_STATE_GET_ICE_CONFIG ((UINT64) 0x06) -#define SIGNALING_STATE_READY ((UINT64) 0x07) -#define SIGNALING_STATE_CONNECT ((UINT64) 0x11) -#define SIGNALING_STATE_CONNECTED ((UINT64) 0x12) -#define SIGNALING_STATE_DISCONNECTED ((UINT64) 0x13) -#define SIGNALING_STATE_DELETE ((UINT64) 0x14) -#define SIGNALING_STATE_DELETED ((UINT64) 0x15) +#define SIGNALING_STATE_NONE ((UINT64) 0) +#define SIGNALING_STATE_NEW ((UINT64) (1 << 0)) +#define SIGNALING_STATE_GET_TOKEN ((UINT64) (1 << 1)) +#define SIGNALING_STATE_DESCRIBE ((UINT64) (1 << 2)) +#define SIGNALING_STATE_CREATE ((UINT64) (1 << 3)) +#define SIGNALING_STATE_GET_ENDPOINT ((UINT64) (1 << 4)) +#define SIGNALING_STATE_GET_ICE_CONFIG ((UINT64) (1 << 5)) +#define SIGNALING_STATE_READY ((UINT64) (1 << 6)) +#define SIGNALING_STATE_CONNECT ((UINT64) (1 << 7)) +#define SIGNALING_STATE_CONNECTED ((UINT64) (1 << 8)) +#define SIGNALING_STATE_DISCONNECTED ((UINT64) (1 << 9)) +#define SIGNALING_STATE_DELETE ((UINT64) (1 << 10)) +#define SIGNALING_STATE_DELETED ((UINT64) (1 << 11)) // Indicates infinite retries #define INFINITE_RETRY_COUNT_SENTINEL 0 @@ -64,8 +64,6 @@ STATUS executeDeleteSignalingState(UINT64, UINT64); STATUS fromDeletedSignalingState(UINT64, PUINT64); STATUS executeDeletedSignalingState(UINT64, UINT64); -STATUS defaultSignalingStateTransitionHook(UINT64, PUINT64); - #ifdef __cplusplus } #endif diff --git a/tst/SignalingApiFunctionalityTest.cpp b/tst/SignalingApiFunctionalityTest.cpp index 26f00d149e..fe5d4b3fa1 100644 --- a/tst/SignalingApiFunctionalityTest.cpp +++ b/tst/SignalingApiFunctionalityTest.cpp @@ -213,7 +213,6 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateConnectFree) clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); - EXPECT_EQ(STATUS_SUCCESS, setupTestSignalingClientRetryStrategy(clientInfo)); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); channelInfo.version = CHANNEL_INFO_CURRENT_VERSION; @@ -238,7 +237,6 @@ TEST_F(SignalingApiFunctionalityTest, basicCreateConnectFree) deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); - EXPECT_EQ(STATUS_SUCCESS, freeTestSignalingClientRetryStrategy(clientInfo)); EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&signalingHandle)); } @@ -272,7 +270,6 @@ TEST_F(SignalingApiFunctionalityTest, mockMaster) clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); - EXPECT_EQ(STATUS_SUCCESS, setupTestSignalingClientRetryStrategy(clientInfo)); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); channelInfo.version = CHANNEL_INFO_CURRENT_VERSION; @@ -408,7 +405,6 @@ TEST_F(SignalingApiFunctionalityTest, mockViewer) clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; STRCPY(clientInfo.clientId, TEST_SIGNALING_VIEWER_CLIENT_ID); - EXPECT_EQ(STATUS_SUCCESS, setupTestSignalingClientRetryStrategy(clientInfo)); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); channelInfo.version = CHANNEL_INFO_CURRENT_VERSION; @@ -508,7 +504,6 @@ TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; - EXPECT_EQ(STATUS_SUCCESS, setupTestSignalingClientRetryStrategy(clientInfo)); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); channelInfo.version = CHANNEL_INFO_CURRENT_VERSION; @@ -714,7 +709,6 @@ TEST_F(SignalingApiFunctionalityTest, invalidChannelInfoInput) clientInfo.version = SIGNALING_CLIENT_INFO_CURRENT_VERSION; clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; STRCPY(clientInfo.clientId, TEST_SIGNALING_VIEWER_CLIENT_ID); - EXPECT_EQ(STATUS_SUCCESS, setupTestSignalingClientRetryStrategy(clientInfo)); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); channelInfo.version = CHANNEL_INFO_CURRENT_VERSION; @@ -2326,7 +2320,6 @@ TEST_F(SignalingApiFunctionalityTest, goAwayEmulation) clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); - EXPECT_EQ(STATUS_SUCCESS, setupTestSignalingClientRetryStrategy(clientInfo)); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); channelInfo.version = CHANNEL_INFO_CURRENT_VERSION; @@ -2410,7 +2403,6 @@ TEST_F(SignalingApiFunctionalityTest, unknownMessageTypeEmulation) clientInfo.loggingLevel = LOG_LEVEL_VERBOSE; clientInfo.cacheFilePath = NULL; STRCPY(clientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); - EXPECT_EQ(STATUS_SUCCESS, setupTestSignalingClientRetryStrategy(clientInfo)); MEMSET(&channelInfo, 0x00, SIZEOF(ChannelInfo)); channelInfo.version = CHANNEL_INFO_CURRENT_VERSION; @@ -2999,8 +2991,6 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) SignalingClientInfoInternal clientInfoInternal; PSignalingClient pSignalingClient; SIGNALING_CLIENT_HANDLE signalingHandle; - PKvsRetryStrategy pKvsRetryStrategy; - PExponentialBackoffRetryStrategyState pExponentialBackoffRetryStrategyState; signalingClientCallbacks.version = SIGNALING_CLIENT_CALLBACKS_CURRENT_VERSION; signalingClientCallbacks.customData = (UINT64) this; @@ -3052,10 +3042,6 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) pActiveClient = pSignalingClient; - pKvsRetryStrategy = (PKvsRetryStrategy)&(pSignalingClient->clientInfo.signalingStateMachineRetryStrategy); - CHECK(pKvsRetryStrategy != NULL); - EXPECT_EQ(KVS_RETRY_STRATEGY_EXPONENTIAL_BACKOFF_WAIT, pKvsRetryStrategy->retryStrategyType); - // Check the states first EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_NEW]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_CREDENTIALS]); @@ -3120,9 +3106,6 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) EXPECT_EQ(4, describeCount); EXPECT_EQ(3, getEndpointCount); - pExponentialBackoffRetryStrategyState = TO_EXPONENTIAL_BACKOFF_STATE(pKvsRetryStrategy->pRetryStrategy); - EXPECT_EQ(79, pExponentialBackoffRetryStrategyState->currentRetryCount); - EXPECT_EQ(STATUS_SUCCESS, signalingClientDisconnectSync(signalingHandle)); deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(signalingHandle), 0); diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index 4109db2089..b92bb11208 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -85,10 +85,8 @@ class WebRtcClientTestBase : public ::testing::Test { mClientInfo.loggingLevel = LOG_LEVEL_VERBOSE; mClientInfo.cacheFilePath = NULL; // Use the default path STRCPY(mClientInfo.clientId, TEST_SIGNALING_MASTER_CLIENT_ID); - setupTestSignalingClientRetryStrategy(mClientInfo); MEMSET(&mChannelInfo, 0x00, SIZEOF(mChannelInfo)); - setupTestSignalingClientRetryStrategy(mClientInfo); mChannelInfo.version = CHANNEL_INFO_CURRENT_VERSION; mChannelInfo.pChannelName = mChannelName; mChannelInfo.pKmsKeyId = NULL; @@ -107,37 +105,6 @@ class WebRtcClientTestBase : public ::testing::Test { } } - STATUS setupTestSignalingClientRetryStrategy(SignalingClientInfo& mClientInfo) { - STATUS retStatus; - - mClientInfo.signalingClientCreationMaxRetryCount = 1; - mClientInfo.signalingClientRetryStrategy.retryStrategyType = KVS_RETRY_STRATEGY_EXPONENTIAL_BACKOFF_WAIT; - mClientInfo.signalingClientRetryStrategy.createRetryStrategyFn = exponentialBackoffRetryStrategyCreate; - mClientInfo.signalingClientRetryStrategy.freeRetryStrategyFn = exponentialBackoffRetryStrategyFree; - mClientInfo.signalingClientRetryStrategy.executeRetryStrategyFn = getExponentialBackoffRetryStrategyWaitTime; - - PRetryStrategy pRetryStrategy = NULL; - retStatus = mClientInfo.signalingClientRetryStrategy.createRetryStrategyFn(NULL, &pRetryStrategy); - if (retStatus != STATUS_SUCCESS) { - return retStatus; - } - - mClientInfo.signalingClientRetryStrategy.pRetryStrategy = pRetryStrategy; - PExponentialBackoffRetryStrategyState pExponentialBackoffRetryStrategyState = TO_EXPONENTIAL_BACKOFF_STATE(pRetryStrategy); - // Change retry wait time factor time from default to 20ms - pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.retryFactorTime = HUNDREDS_OF_NANOS_IN_A_MILLISECOND * 20; - // Change max retry wait time from default to 100ms - pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.maxRetryWaitTime = HUNDREDS_OF_NANOS_IN_A_MILLISECOND * 100; - // Change default jitter from default to 2 - pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.jitterFactor = 2; - - return STATUS_SUCCESS; - } - - STATUS freeTestSignalingClientRetryStrategy(SignalingClientInfo& mClientInfo) { - return mClientInfo.signalingClientRetryStrategy.freeRetryStrategyFn(&(mClientInfo.signalingClientRetryStrategy.pRetryStrategy)); - } - STATUS initializeSignalingClient(PAwsCredentialProvider pCredentialProvider = NULL) { STATUS retStatus; @@ -163,7 +130,7 @@ class WebRtcClientTestBase : public ::testing::Test { if (mAccessKeyIdSet) { deleteChannelLws(FROM_SIGNALING_CLIENT_HANDLE(mSignalingClientHandle), 0); } - EXPECT_EQ(STATUS_SUCCESS, freeTestSignalingClientRetryStrategy(mClientInfo)); + EXPECT_EQ(STATUS_SUCCESS, freeSignalingClient(&mSignalingClientHandle)); return STATUS_SUCCESS;