From a4ec12a6699ea18b12a90cf32397fcecc18ac8a4 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sun, 26 Nov 2023 17:08:04 -0800 Subject: [PATCH 01/25] Asynchronous get ice config --- samples/Common.c | 110 +++++++++++++----- .../kinesis/video/webrtcclient/Include.h | 2 + src/source/Ice/IceAgent.c | 72 +++++++++++- src/source/Ice/IceAgent.h | 2 + src/source/Include_i.h | 10 +- src/source/PeerConnection/PeerConnection.c | 27 +++++ src/source/PeerConnection/PeerConnection.h | 1 + 7 files changed, 183 insertions(+), 41 deletions(-) diff --git a/samples/Common.c b/samples/Common.c index 0ec5ee5439..5842bbec06 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -356,12 +356,56 @@ VOID onIceCandidateHandler(UINT64 customData, PCHAR candidateJson) CHK_LOG_ERR(retStatus); } +// TODO this should all be in a higher webrtccontext layer above PeerConnection +// Placing it here now since this is where all the current webrtccontext functions are placed +typedef struct { + SIGNALING_CLIENT_HANDLE signalingClientHandle; + PRtcPeerConnection* ppRtcPeerConnection; + PUINT32 pUriCount; + +} AsyncGetIceStruct; + +PVOID asyncGetIceConfigInfo(PVOID args) +{ + STATUS retStatus = STATUS_SUCCESS; + AsyncGetIceStruct* data = (AsyncGetIceStruct*) args; + PIceConfigInfo pIceConfigInfo = NULL; + UINT32 uriCount = 0; + UINT32 i = 0, maxTurnServer = 1; + + if (data != NULL) { + /* signalingClientGetIceConfigInfoCount can return more than one turn server. Use only one to optimize + * candidate gathering latency. But user can also choose to use more than 1 turn server. */ + for (uriCount = 0, i = 0; i < maxTurnServer; i++) { + /* + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port?transport=udp" then ICE will try TURN over UDP + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port?transport=tcp" then ICE will try TURN over TCP/TLS + * if configuration.iceServers[uriCount + 1].urls is "turns:ip:port?transport=udp", it's currently ignored because sdk dont do TURN + * over DTLS yet. if configuration.iceServers[uriCount + 1].urls is "turns:ip:port?transport=tcp" then ICE will try TURN over TCP/TLS + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port" then ICE will try both TURN over UDP and TCP/TLS + * + * It's recommended to not pass too many TURN iceServers to configuration because it will slow down ice gathering in non-trickle mode. + */ + CHK_STATUS(signalingClientGetIceConfigInfo(data->signalingClientHandle, i, &pIceConfigInfo)); + CHECK(uriCount < MAX_ICE_SERVERS_COUNT); + uriCount += pIceConfigInfo->uriCount; + CHK_STATUS(addConfigToServerList(data->ppRtcPeerConnection, pIceConfigInfo)); + } + } + *(data->pUriCount) += uriCount; + +CleanUp: + SAFE_MEMFREE(data); + CHK_LOG_ERR(retStatus); + return; +} + STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcPeerConnection* ppRtcPeerConnection) { ENTERS(); STATUS retStatus = STATUS_SUCCESS; RtcConfiguration configuration; - UINT32 i, j, iceConfigCount, uriCount = 0, maxTurnServer = 1; + UINT32 i, j, uriCount = 0, maxTurnServer = 1; PIceConfigInfo pIceConfigInfo; UINT64 data; PRtcCertificate pRtcCertificate = NULL; @@ -385,37 +429,6 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, pSampleConfiguration->channelInfo.pRegion, pKinesisVideoStunUrlPostFix); - if (pSampleConfiguration->useTurn) { - // Set the URIs from the configuration - CHK_STATUS(signalingClientGetIceConfigInfoCount(pSampleConfiguration->signalingClientHandle, &iceConfigCount)); - - /* signalingClientGetIceConfigInfoCount can return more than one turn server. Use only one to optimize - * candidate gathering latency. But user can also choose to use more than 1 turn server. */ - for (uriCount = 0, i = 0; i < maxTurnServer; i++) { - CHK_STATUS(signalingClientGetIceConfigInfo(pSampleConfiguration->signalingClientHandle, i, &pIceConfigInfo)); - for (j = 0; j < pIceConfigInfo->uriCount; j++) { - CHECK(uriCount < MAX_ICE_SERVERS_COUNT); - /* - * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port?transport=udp" then ICE will try TURN over UDP - * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port?transport=tcp" then ICE will try TURN over TCP/TLS - * if configuration.iceServers[uriCount + 1].urls is "turns:ip:port?transport=udp", it's currently ignored because sdk dont do TURN - * over DTLS yet. if configuration.iceServers[uriCount + 1].urls is "turns:ip:port?transport=tcp" then ICE will try TURN over TCP/TLS - * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port" then ICE will try both TURN over UDP and TCP/TLS - * - * It's recommended to not pass too many TURN iceServers to configuration because it will slow down ice gathering in non-trickle mode. - */ - - STRNCPY(configuration.iceServers[uriCount + 1].urls, pIceConfigInfo->uris[j], MAX_ICE_CONFIG_URI_LEN); - STRNCPY(configuration.iceServers[uriCount + 1].credential, pIceConfigInfo->password, MAX_ICE_CONFIG_CREDENTIAL_LEN); - STRNCPY(configuration.iceServers[uriCount + 1].username, pIceConfigInfo->userName, MAX_ICE_CONFIG_USER_NAME_LEN); - - uriCount++; - } - } - } - - pSampleConfiguration->iceUriCount = uriCount + 1; - // Check if we have any pregenerated certs and use them // NOTE: We are running under the config lock retStatus = stackQueueDequeue(pSampleConfiguration->pregeneratedCertificates, &data); @@ -430,6 +443,39 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP } CHK_STATUS(createPeerConnection(&configuration, ppRtcPeerConnection)); + + if (pSampleConfiguration->useTurn) { +#ifdef ENABLE_KVS_THREADPOOL + AsyncGetIceStruct* pAsyncData = NULL; + + pAsyncData = (AsyncGetIceStruct*) MEMCALLOC(1, SIZEOF(AsyncGetIceStruct)); + pAsyncData->signalingClientHandle = pSampleConfiguration->signalingClientHandle; + pAsyncData->ppRtcPeerConnection = ppRtcPeerConnection; + pAsyncData->pUriCount = &(pSampleConfiguration->iceUriCount); + CHK_STATUS(peerConnectionAsync(asyncGetIceConfigInfo, (PVOID) pAsyncData)); +#else + + /* signalingClientGetIceConfigInfoCount can return more than one turn server. Use only one to optimize + * candidate gathering latency. But user can also choose to use more than 1 turn server. */ + for (uriCount = 0, i = 0; i < maxTurnServer; i++) { + /* + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port?transport=udp" then ICE will try TURN over UDP + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port?transport=tcp" then ICE will try TURN over TCP/TLS + * if configuration.iceServers[uriCount + 1].urls is "turns:ip:port?transport=udp", it's currently ignored because sdk dont do TURN + * over DTLS yet. if configuration.iceServers[uriCount + 1].urls is "turns:ip:port?transport=tcp" then ICE will try TURN over TCP/TLS + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port" then ICE will try both TURN over UDP and TCP/TLS + * + * It's recommended to not pass too many TURN iceServers to configuration because it will slow down ice gathering in non-trickle mode. + */ + CHK_STATUS(signalingClientGetIceConfigInfo(pSampleConfiguration->signalingClientHandle, i, &pIceConfigInfo)); + CHECK(uriCount < MAX_ICE_SERVERS_COUNT); + uriCount += pIceConfigInfo->uriCount; + CHK_STATUS(addConfigToServerList(ppRtcPeerConnection, pIceConfigInfo)); + } +#endif + } + + pSampleConfiguration->iceUriCount = uriCount + 1; CleanUp: CHK_LOG_ERR(retStatus); diff --git a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h index 27f597c642..89bb6329bc 100644 --- a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h +++ b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h @@ -1573,6 +1573,8 @@ typedef struct { */ PUBLIC_API STATUS createPeerConnection(PRtcConfiguration, PRtcPeerConnection*); +PUBLIC_API STATUS addConfigToServerList(PRtcPeerConnection*, PIceConfigInfo); + /** * @brief Free a RtcPeerConnection * diff --git a/src/source/Ice/IceAgent.c b/src/source/Ice/IceAgent.c index bd5adc8316..0d0885efca 100644 --- a/src/source/Ice/IceAgent.c +++ b/src/source/Ice/IceAgent.c @@ -262,6 +262,69 @@ STATUS freeIceAgent(PIceAgent* ppIceAgent) return retStatus; } +STATUS iceAgentAddConfig(PIceAgent pIceAgent, PIceConfigInfo pIceConfigInfo) +{ + STATUS retStatus = STATUS_SUCCESS; + UINT32 i = 0; + // used in PROFILE macro + UINT64 startTimeInMacro = 0; + BOOL locked = FALSE; + + CHK(pIceAgent != NULL && pIceConfigInfo != NULL, STATUS_NULL_ARG); + + MUTEX_LOCK(pIceAgent->lock); + locked = TRUE; + + for (i = 0; i < pIceConfigInfo->uriCount; i++) { + PROFILE_CALL_WITH_T_OBJ(retStatus = parseIceServer(&pIceAgent->iceServers[pIceAgent->iceServersCount], (PCHAR) pIceConfigInfo->uris[i], + (PCHAR) pIceConfigInfo->userName, (PCHAR) pIceConfigInfo->password), + pIceAgent->iceAgentProfileDiagnostics.iceServerParsingTime[i], "ICE server parsing"); + if (STATUS_SUCCEEDED(retStatus)) { + pIceAgent->rtcIceServerDiagnostics[i].port = (INT32) getInt16(pIceAgent->iceServers[i].ipAddress.port); + switch (pIceAgent->iceServers[pIceAgent->iceServersCount].transport) { + case KVS_SOCKET_PROTOCOL_UDP: + STRCPY(pIceAgent->rtcIceServerDiagnostics[i].protocol, ICE_TRANSPORT_TYPE_UDP); + break; + case KVS_SOCKET_PROTOCOL_TCP: + STRCPY(pIceAgent->rtcIceServerDiagnostics[i].protocol, ICE_TRANSPORT_TYPE_TCP); + break; + default: + MEMSET(pIceAgent->rtcIceServerDiagnostics[i].protocol, 0, SIZEOF(pIceAgent->rtcIceServerDiagnostics[i].protocol)); + } + STRCPY(pIceAgent->rtcIceServerDiagnostics[i].url, pIceConfigInfo->uris[i]); + + // init candidate && pairs + if (pIceAgent->iceServers[pIceAgent->iceServersCount].isTurn) { + if (pIceAgent->iceServers[pIceAgent->iceServersCount].transport == KVS_SOCKET_PROTOCOL_UDP || + pIceAgent->iceServers[pIceAgent->iceServersCount].transport == KVS_SOCKET_PROTOCOL_NONE) { + CHK_STATUS(iceAgentInitRelayCandidate(pIceAgent, pIceAgent->iceServersCount, KVS_SOCKET_PROTOCOL_UDP)); + } + + if (pIceAgent->iceServers[pIceAgent->iceServersCount].transport == KVS_SOCKET_PROTOCOL_TCP || + pIceAgent->iceServers[pIceAgent->iceServersCount].transport == KVS_SOCKET_PROTOCOL_NONE) { + CHK_STATUS(iceAgentInitRelayCandidate(pIceAgent, pIceAgent->iceServersCount, KVS_SOCKET_PROTOCOL_TCP)); + } + } + + pIceAgent->iceServersCount++; + } else { + DLOGE("Failed to parse ICE servers"); + } + } + + MUTEX_UNLOCK(pIceAgent->lock); + locked = FALSE; + +CleanUp: + CHK_LOG_ERR(retStatus); + + if (locked) { + MUTEX_UNLOCK(pIceAgent->lock); + } + + return retStatus; +} + STATUS iceAgentValidateKvsRtcConfig(PKvsRtcConfiguration pKvsRtcConfiguration) { STATUS retStatus = STATUS_SUCCESS; @@ -613,9 +676,10 @@ STATUS iceAgentStartGathering(PIceAgent pIceAgent) PROFILE_CALL_WITH_T_OBJ(CHK_STATUS(iceAgentInitSrflxCandidate(pIceAgent)), pIceAgent->iceAgentProfileDiagnostics.srflxCandidateSetUpTime, "Srflx candidates setup time"); } - +#if 0 PROFILE_CALL_WITH_T_OBJ(CHK_STATUS(iceAgentInitRelayCandidates(pIceAgent)), pIceAgent->iceAgentProfileDiagnostics.relayCandidateSetUpTime, "Relay candidates setup time"); +#endif // start listening for incoming data CHK_STATUS(connectionListenerStart(pIceAgent->pConnectionListener)); @@ -1857,15 +1921,15 @@ STATUS iceAgentInitRelayCandidate(PIceAgent pIceAgent, UINT32 iceServerIndex, KV callback.relayAddressAvailableFn = NULL; callback.turnStateFailedFn = turnStateFailedFn; + MUTEX_LOCK(pIceAgent->lock); + locked = TRUE; + CHK_STATUS(createTurnConnection(&pIceAgent->iceServers[iceServerIndex], pIceAgent->timerQueueHandle, TURN_CONNECTION_DATA_TRANSFER_MODE_SEND_INDIDATION, protocol, &callback, pNewCandidate->pSocketConnection, pIceAgent->pConnectionListener, &pTurnConnection)); pNewCandidate->pIceAgent = pIceAgent; pNewCandidate->pTurnConnection = pTurnConnection; - MUTEX_LOCK(pIceAgent->lock); - locked = TRUE; - CHK_STATUS(doubleListInsertItemHead(pIceAgent->localCandidates, (UINT64) pNewCandidate)); pNewCandidate = NULL; diff --git a/src/source/Ice/IceAgent.h b/src/source/Ice/IceAgent.h index af94aa95ea..e0577dab2d 100644 --- a/src/source/Ice/IceAgent.h +++ b/src/source/Ice/IceAgent.h @@ -448,6 +448,8 @@ STATUS updateSelectedLocalRemoteCandidateStats(PIceAgent); STATUS getIceAgentStats(PIceAgent, PKvsIceAgentMetrics); +STATUS iceAgentAddConfig(PIceAgent, PIceConfigInfo); + #ifdef __cplusplus } #endif diff --git a/src/source/Include_i.h b/src/source/Include_i.h index 9547012955..84fec5a69a 100644 --- a/src/source/Include_i.h +++ b/src/source/Include_i.h @@ -139,6 +139,11 @@ STATUS generateJSONSafeString(PCHAR, UINT32); #include "Ice/NatBehaviorDiscovery.h" #include "Srtp/SrtpSession.h" #include "Sctp/Sctp.h" +#include "Signaling/FileCache.h" +#include "Signaling/Signaling.h" +#include "Signaling/ChannelInfo.h" +#include "Signaling/StateMachine.h" +#include "Signaling/LwsApiCalls.h" #include "Rtp/RtpPacket.h" #include "Rtcp/RtcpPacket.h" #include "Rtcp/RollingBuffer.h" @@ -154,11 +159,6 @@ STATUS generateJSONSafeString(PCHAR, UINT32); #include "Rtp/Codecs/RtpH264Payloader.h" #include "Rtp/Codecs/RtpOpusPayloader.h" #include "Rtp/Codecs/RtpG711Payloader.h" -#include "Signaling/FileCache.h" -#include "Signaling/Signaling.h" -#include "Signaling/ChannelInfo.h" -#include "Signaling/StateMachine.h" -#include "Signaling/LwsApiCalls.h" #include "Metrics/Metrics.h" //////////////////////////////////////////////////// diff --git a/src/source/PeerConnection/PeerConnection.c b/src/source/PeerConnection/PeerConnection.c index 4091bf1b77..4d885ccf08 100644 --- a/src/source/PeerConnection/PeerConnection.c +++ b/src/source/PeerConnection/PeerConnection.c @@ -515,6 +515,15 @@ VOID onIceConnectionStateChange(UINT64 customData, UINT64 connectionState) CHK_LOG_ERR(retStatus); } +STATUS peerConnectionAsync(startRoutine fn, PVOID data) +{ + STATUS retStatus = STATUS_SUCCESS; + CHK_STATUS(threadpoolContextPush(fn, data)); +CleanUp: + + return retStatus; +} + VOID onNewIceLocalCandidate(UINT64 customData, PCHAR candidateSdpStr) { STATUS retStatus = STATUS_SUCCESS; @@ -1085,6 +1094,24 @@ STATUS peerConnectionOnIceCandidate(PRtcPeerConnection pRtcPeerConnection, UINT6 return retStatus; } +STATUS addConfigToServerList(PRtcPeerConnection* ppPeerConnection, PIceConfigInfo pIceConfigInfo) +{ + STATUS retStatus = STATUS_SUCCESS; + PKvsPeerConnection pKvsPeerConnection = NULL; + + CHK(ppPeerConnection != NULL && pIceConfigInfo != NULL, STATUS_NULL_ARG); + + pKvsPeerConnection = *ppPeerConnection; + + CHK(pKvsPeerConnection != NULL, STATUS_NULL_ARG); + + CHK_STATUS(iceAgentAddConfig(pKvsPeerConnection->pIceAgent, pIceConfigInfo)); + +CleanUp: + + return retStatus; +} + STATUS peerConnectionOnDataChannel(PRtcPeerConnection pRtcPeerConnection, UINT64 customData, RtcOnDataChannel rtcOnDataChannel) { ENTERS(); diff --git a/src/source/PeerConnection/PeerConnection.h b/src/source/PeerConnection/PeerConnection.h index 3a47d3eebd..c4322ebe74 100644 --- a/src/source/PeerConnection/PeerConnection.h +++ b/src/source/PeerConnection/PeerConnection.h @@ -176,6 +176,7 @@ STATUS onFrameDroppedFunc(UINT64, UINT16, UINT16, UINT32); VOID onSctpSessionOutboundPacket(UINT64, PBYTE, UINT32); VOID onSctpSessionDataChannelMessage(UINT64, UINT32, BOOL, PBYTE, UINT32); VOID onSctpSessionDataChannelOpen(UINT64, UINT32, PBYTE, UINT32); +PVOID asyncGetIceConfigInfoWrapper(PVOID); STATUS sendPacketToRtpReceiver(PKvsPeerConnection, PBYTE, UINT32); STATUS changePeerConnectionState(PKvsPeerConnection, RTC_PEER_CONNECTION_STATE); From c94f3665255cfc6d874d507fbd1162e28aa2fef8 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sat, 9 Dec 2023 15:03:51 -0800 Subject: [PATCH 02/25] Fixing mac compile error, addressing comments, correcting spelling error --- .../com/amazonaws/kinesis/video/webrtcclient/Include.h | 2 +- src/source/Ice/IceAgent.c | 4 ---- src/source/Ice/TurnConnectionStateMachine.c | 2 +- src/source/PeerConnection/PeerConnection.c | 2 +- src/source/PeerConnection/PeerConnection.h | 1 - 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h index 89bb6329bc..77bc32c895 100644 --- a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h +++ b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h @@ -236,7 +236,7 @@ extern "C" { #define STATUS_TURN_CONNECTION_PEER_NOT_USABLE STATUS_ICE_BASE + 0x00000027 #define STATUS_ICE_SERVER_INDEX_INVALID STATUS_ICE_BASE + 0x00000028 #define STATUS_ICE_CANDIDATE_STRING_MISSING_TYPE STATUS_ICE_BASE + 0x00000029 -#define STATUS_TURN_CONNECTION_ALLOCAITON_FAILED STATUS_ICE_BASE + 0x0000002a +#define STATUS_TURN_CONNECTION_ALLOCATION_FAILED STATUS_ICE_BASE + 0x0000002a #define STATUS_TURN_INVALID_STATE STATUS_ICE_BASE + 0x0000002b /*!@} */ diff --git a/src/source/Ice/IceAgent.c b/src/source/Ice/IceAgent.c index 0d0885efca..6428bbba36 100644 --- a/src/source/Ice/IceAgent.c +++ b/src/source/Ice/IceAgent.c @@ -676,10 +676,6 @@ STATUS iceAgentStartGathering(PIceAgent pIceAgent) PROFILE_CALL_WITH_T_OBJ(CHK_STATUS(iceAgentInitSrflxCandidate(pIceAgent)), pIceAgent->iceAgentProfileDiagnostics.srflxCandidateSetUpTime, "Srflx candidates setup time"); } -#if 0 - PROFILE_CALL_WITH_T_OBJ(CHK_STATUS(iceAgentInitRelayCandidates(pIceAgent)), pIceAgent->iceAgentProfileDiagnostics.relayCandidateSetUpTime, - "Relay candidates setup time"); -#endif // start listening for incoming data CHK_STATUS(connectionListenerStart(pIceAgent->pConnectionListener)); diff --git a/src/source/Ice/TurnConnectionStateMachine.c b/src/source/Ice/TurnConnectionStateMachine.c index 0bc54afd0b..268ce1da2d 100644 --- a/src/source/Ice/TurnConnectionStateMachine.c +++ b/src/source/Ice/TurnConnectionStateMachine.c @@ -364,7 +364,7 @@ STATUS executeAllocationTurnState(UINT64 customData, UINT64 time) pTurnConnection->state = TURN_STATE_ALLOCATION; } else { pTurnConnection->stateTryCount++; - CHK(pTurnConnection->stateTryCount < pTurnConnection->stateTryCountMax, STATUS_TURN_CONNECTION_ALLOCAITON_FAILED); + CHK(pTurnConnection->stateTryCount < pTurnConnection->stateTryCountMax, STATUS_TURN_CONNECTION_ALLOCATION_FAILED); } CHK_STATUS(iceUtilsSendStunPacket(pTurnConnection->pTurnPacket, pTurnConnection->longTermKey, ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress, pTurnConnection->pControlChannel, NULL, FALSE)); diff --git a/src/source/PeerConnection/PeerConnection.c b/src/source/PeerConnection/PeerConnection.c index 4d885ccf08..62313816de 100644 --- a/src/source/PeerConnection/PeerConnection.c +++ b/src/source/PeerConnection/PeerConnection.c @@ -1101,7 +1101,7 @@ STATUS addConfigToServerList(PRtcPeerConnection* ppPeerConnection, PIceConfigInf CHK(ppPeerConnection != NULL && pIceConfigInfo != NULL, STATUS_NULL_ARG); - pKvsPeerConnection = *ppPeerConnection; + pKvsPeerConnection = (PKvsPeerConnection)*ppPeerConnection; CHK(pKvsPeerConnection != NULL, STATUS_NULL_ARG); diff --git a/src/source/PeerConnection/PeerConnection.h b/src/source/PeerConnection/PeerConnection.h index c4322ebe74..3a47d3eebd 100644 --- a/src/source/PeerConnection/PeerConnection.h +++ b/src/source/PeerConnection/PeerConnection.h @@ -176,7 +176,6 @@ STATUS onFrameDroppedFunc(UINT64, UINT16, UINT16, UINT32); VOID onSctpSessionOutboundPacket(UINT64, PBYTE, UINT32); VOID onSctpSessionDataChannelMessage(UINT64, UINT32, BOOL, PBYTE, UINT32); VOID onSctpSessionDataChannelOpen(UINT64, UINT32, PBYTE, UINT32); -PVOID asyncGetIceConfigInfoWrapper(PVOID); STATUS sendPacketToRtpReceiver(PKvsPeerConnection, PBYTE, UINT32); STATUS changePeerConnectionState(PKvsPeerConnection, RTC_PEER_CONNECTION_STATE); From a1a51bebb98a80d43f7bc13dbad8adac4d8b2b09 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sat, 9 Dec 2023 15:06:18 -0800 Subject: [PATCH 03/25] clang format --- src/source/PeerConnection/PeerConnection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/source/PeerConnection/PeerConnection.c b/src/source/PeerConnection/PeerConnection.c index 62313816de..2588aceaa1 100644 --- a/src/source/PeerConnection/PeerConnection.c +++ b/src/source/PeerConnection/PeerConnection.c @@ -1101,7 +1101,7 @@ STATUS addConfigToServerList(PRtcPeerConnection* ppPeerConnection, PIceConfigInf CHK(ppPeerConnection != NULL && pIceConfigInfo != NULL, STATUS_NULL_ARG); - pKvsPeerConnection = (PKvsPeerConnection)*ppPeerConnection; + pKvsPeerConnection = (PKvsPeerConnection) *ppPeerConnection; CHK(pKvsPeerConnection != NULL, STATUS_NULL_ARG); From 9fdf14c1b15f8f1bc2a6befd2df365e818182ea4 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sat, 9 Dec 2023 17:59:36 -0800 Subject: [PATCH 04/25] fixing test util functions to include new APIs --- tst/IceFunctionalityTest.cpp | 3 ++- tst/PeerConnectionFunctionalityTest.cpp | 31 ++++++++++++++++++------- tst/WebRTCClientTestFixture.cpp | 28 +++++++++++++++++++++- tst/WebRTCClientTestFixture.h | 4 +++- 4 files changed, 55 insertions(+), 11 deletions(-) diff --git a/tst/IceFunctionalityTest.cpp b/tst/IceFunctionalityTest.cpp index 6ab40aa894..fc71cdbd90 100644 --- a/tst/IceFunctionalityTest.cpp +++ b/tst/IceFunctionalityTest.cpp @@ -663,7 +663,6 @@ TEST_F(IceFunctionalityTest, IceAgentCandidateGatheringTest) MEMSET(&iceAgentCallbacks, 0x00, SIZEOF(IceAgentCallbacks)); initializeSignalingClient(); - getIceServers(&configuration); auto onICECandidateHdlr = [](UINT64 customData, PCHAR candidateStr) -> void { CandidateList* candidateList1 = (CandidateList*) customData; @@ -686,6 +685,8 @@ TEST_F(IceFunctionalityTest, IceAgentCandidateGatheringTest) EXPECT_EQ(STATUS_SUCCESS, createIceAgent(localIceUfrag, localIcePwd, &iceAgentCallbacks, &configuration, timerQueueHandle, pConnectionListener, &pIceAgent)); + getIceServers(&configuration, pIceAgent); + EXPECT_EQ(STATUS_SUCCESS, iceAgentStartGathering(pIceAgent)); THREAD_SLEEP(KVS_ICE_GATHER_REFLEXIVE_AND_RELAYED_CANDIDATE_TIMEOUT + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND); diff --git a/tst/PeerConnectionFunctionalityTest.cpp b/tst/PeerConnectionFunctionalityTest.cpp index ace56788d2..d3e6b7ba5d 100644 --- a/tst/PeerConnectionFunctionalityTest.cpp +++ b/tst/PeerConnectionFunctionalityTest.cpp @@ -198,11 +198,13 @@ TEST_F(PeerConnectionFunctionalityTest, connectTwoPeersForcedTURN) configuration.iceTransportPolicy = ICE_TRANSPORT_POLICY_RELAY; initializeSignalingClient(); - getIceServers(&configuration); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + getIceServers(&configuration, offerPc); + getIceServers(&configuration, answerPc); + EXPECT_EQ(connectTwoPeers(offerPc, answerPc), TRUE); closePeerConnection(offerPc); @@ -292,10 +294,11 @@ TEST_F(PeerConnectionFunctionalityTest, sendDataWithClosedSocketConnectionWithFo configuration.iceTransportPolicy = ICE_TRANSPORT_POLICY_RELAY; initializeSignalingClient(); - getIceServers(&configuration); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + getIceServers(&configuration, offerPc); + getIceServers(&configuration, answerPc); // addTrackToPeerConnection is necessary because we need to add a transceiver which will trigger the RTCP callback. The RTCP callback // will send application data. The expected behavior for the PeerConnection is to bail out when the socket connection that's being used @@ -354,11 +357,13 @@ TEST_F(PeerConnectionFunctionalityTest, shutdownTurnDueToP2PFoundBeforeTurnEstab MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); initializeSignalingClient(); - getIceServers(&configuration); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + getIceServers(&configuration, offerPc); + getIceServers(&configuration, answerPc); + EXPECT_EQ(connectTwoPeers(offerPc, answerPc), TRUE); THREAD_SLEEP(5 * HUNDREDS_OF_NANOS_IN_A_SECOND); @@ -416,11 +421,13 @@ TEST_F(PeerConnectionFunctionalityTest, shutdownTurnDueToP2PFoundAfterTurnEstabl MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); initializeSignalingClient(); - getIceServers(&configuration); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + getIceServers(&configuration, offerPc); + getIceServers(&configuration, answerPc); + auto onICECandidateHdlr = [](UINT64 customData, PCHAR candidateStr) -> void { PSIZE_T pDoneGatherCandidate = (PSIZE_T) customData; if (candidateStr == NULL) { @@ -860,11 +867,13 @@ TEST_F(PeerConnectionFunctionalityTest, iceRestartTestForcedTurn) configuration.iceTransportPolicy = ICE_TRANSPORT_POLICY_RELAY; initializeSignalingClient(); - getIceServers(&configuration); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + getIceServers(&configuration, offerPc); + getIceServers(&configuration, answerPc); + EXPECT_EQ(connectTwoPeers(offerPc, answerPc), TRUE); EXPECT_EQ(restartIce(offerPc), STATUS_SUCCESS); @@ -893,11 +902,13 @@ TEST_F(PeerConnectionFunctionalityTest, peerConnectionOfferCloseConnection) MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); initializeSignalingClient(); - getIceServers(&configuration); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + getIceServers(&configuration, offerPc); + getIceServers(&configuration, answerPc); + EXPECT_EQ(connectTwoPeers(offerPc, answerPc), TRUE); closePeerConnection(offerPc); @@ -919,11 +930,13 @@ TEST_F(PeerConnectionFunctionalityTest, peerConnectionAnswerCloseConnection) MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); initializeSignalingClient(); - getIceServers(&configuration); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + getIceServers(&configuration, offerPc); + getIceServers(&configuration, answerPc); + EXPECT_EQ(connectTwoPeers(offerPc, answerPc), TRUE); closePeerConnection(answerPc); @@ -960,11 +973,13 @@ TEST_F(PeerConnectionFunctionalityTest, DISABLED_exchangeMediaThroughTurnRandomS for (int i = 0; i < iteration; ++i) { MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); configuration.iceTransportPolicy = ICE_TRANSPORT_POLICY_RELAY; - getIceServers(&configuration); EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + getIceServers(&configuration, offerPc); + getIceServers(&configuration, answerPc); + addTrackToPeerConnection(offerPc, &offerVideoTrack, &offerVideoTransceiver, RTC_CODEC_VP8, MEDIA_STREAM_TRACK_KIND_VIDEO); addTrackToPeerConnection(offerPc, &offerAudioTrack, &offerAudioTransceiver, RTC_CODEC_OPUS, MEDIA_STREAM_TRACK_KIND_AUDIO); addTrackToPeerConnection(answerPc, &answerVideoTrack, &answerVideoTransceiver, RTC_CODEC_VP8, MEDIA_STREAM_TRACK_KIND_VIDEO); diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index 5ad7763251..3ec15acb5c 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -249,7 +249,7 @@ void WebRtcClientTestBase::addTrackToPeerConnection(PRtcPeerConnection pRtcPeerC EXPECT_EQ(STATUS_SUCCESS, addTransceiver(pRtcPeerConnection, track, NULL, transceiver)); } -void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration) +void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PIceAgent pIceAgent) { UINT32 i, j, iceConfigCount, uriCount; PIceConfigInfo pIceConfigInfo; @@ -269,6 +269,32 @@ void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration) uriCount++; } + EXPECT_EQ(STATUS_SUCCESS, iceAgentAddConfig(pIceAgent, pIceConfigInfo)); + } +} + + +void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PRtcPeerConnection pRtcPeerConnection) +{ + UINT32 i, j, iceConfigCount, uriCount; + PIceConfigInfo pIceConfigInfo; + + // Assume signaling client is already created + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(mSignalingClientHandle, &iceConfigCount)); + + // Set the STUN server + SNPRINTF(pRtcConfiguration->iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); + + for (uriCount = 0, i = 0; i < iceConfigCount; i++) { + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(mSignalingClientHandle, i, &pIceConfigInfo)); + for (j = 0; j < pIceConfigInfo->uriCount; j++) { + STRNCPY(pRtcConfiguration->iceServers[uriCount + 1].urls, pIceConfigInfo->uris[j], MAX_ICE_CONFIG_URI_LEN); + STRNCPY(pRtcConfiguration->iceServers[uriCount + 1].credential, pIceConfigInfo->password, MAX_ICE_CONFIG_CREDENTIAL_LEN); + STRNCPY(pRtcConfiguration->iceServers[uriCount + 1].username, pIceConfigInfo->userName, MAX_ICE_CONFIG_USER_NAME_LEN); + + uriCount++; + } + EXPECT_EQ(STATUS_SUCCESS, addConfigToServerList(&pRtcPeerConnection, pIceConfigInfo)); } } diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index 229b7dd439..df015f90b6 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -272,7 +272,9 @@ class WebRtcClientTestBase : public ::testing::Test { PCHAR pAnswerCertFingerprint = NULL); void addTrackToPeerConnection(PRtcPeerConnection pRtcPeerConnection, PRtcMediaStreamTrack track, PRtcRtpTransceiver* transceiver, RTC_CODEC codec, MEDIA_STREAM_TRACK_KIND kind); - void getIceServers(PRtcConfiguration pRtcConfiguration); + void getIceServers(PRtcConfiguration pRtcConfiguration, PRtcPeerConnection pRtcPeerConnection); + + void getIceServers(PRtcConfiguration pRtcConfiguration, PIceAgent pIceAgent); protected: virtual void SetUp(); From aad230d9d29e21c47895802058bd2f58f9142608 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sat, 9 Dec 2023 18:22:36 -0800 Subject: [PATCH 05/25] Unused variables for certain compile time flags breaking mac compile --- samples/Common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/Common.c b/samples/Common.c index 5842bbec06..6d608bfcdf 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -397,7 +397,7 @@ PVOID asyncGetIceConfigInfo(PVOID args) CleanUp: SAFE_MEMFREE(data); CHK_LOG_ERR(retStatus); - return; + return NULL; } STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcPeerConnection* ppRtcPeerConnection) @@ -405,8 +405,11 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP ENTERS(); STATUS retStatus = STATUS_SUCCESS; RtcConfiguration configuration; - UINT32 i, j, uriCount = 0, maxTurnServer = 1; +#ifndef ENABLE_KVS_THREADPOOL + UINT32 i, j, maxTurnServer = 1; PIceConfigInfo pIceConfigInfo; +#else + UINT32 uriCount = 0; UINT64 data; PRtcCertificate pRtcCertificate = NULL; From b9a443865e4d46ca65075d8ac70d11dd8f091fde Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sat, 9 Dec 2023 18:40:07 -0800 Subject: [PATCH 06/25] fixing more compile errors for mac --- samples/Common.c | 2 +- src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/Common.c b/samples/Common.c index 6f60d7533d..0b2e1f9322 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -408,7 +408,7 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP #ifndef ENABLE_KVS_THREADPOOL UINT32 i, j, maxTurnServer = 1; PIceConfigInfo pIceConfigInfo; -#else +#endif UINT32 uriCount = 0; UINT64 data; PRtcCertificate pRtcCertificate = NULL; diff --git a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h index 77bc32c895..16bdbfefbd 100644 --- a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h +++ b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h @@ -1651,6 +1651,8 @@ PUBLIC_API STATUS peerConnectionGetLocalDescription(PRtcPeerConnection, PRtcSess */ PUBLIC_API STATUS peerConnectionGetCurrentLocalDescription(PRtcPeerConnection, PRtcSessionDescriptionInit); +PUBLIC_API STATUS peerConnectionAsync(startRoutine fn, PVOID data); + /** * @brief Populate the provided answer that contains an RFC 3264 offer * with the supported configurations for the session. From 2ca2c283d15583c234b81dd2a5de90e06e036648 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sun, 10 Dec 2023 16:41:49 -0800 Subject: [PATCH 07/25] Fix a dead lock, and fix a test with the API changes --- src/source/Ice/IceAgent.c | 27 ++++++++++++++++++++------- tst/IceFunctionalityTest.cpp | 6 ++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/source/Ice/IceAgent.c b/src/source/Ice/IceAgent.c index 6428bbba36..f29427f2bd 100644 --- a/src/source/Ice/IceAgent.c +++ b/src/source/Ice/IceAgent.c @@ -272,14 +272,18 @@ STATUS iceAgentAddConfig(PIceAgent pIceAgent, PIceConfigInfo pIceConfigInfo) CHK(pIceAgent != NULL && pIceConfigInfo != NULL, STATUS_NULL_ARG); - MUTEX_LOCK(pIceAgent->lock); - locked = TRUE; - for (i = 0; i < pIceConfigInfo->uriCount; i++) { + MUTEX_LOCK(pIceAgent->lock); + locked = TRUE; PROFILE_CALL_WITH_T_OBJ(retStatus = parseIceServer(&pIceAgent->iceServers[pIceAgent->iceServersCount], (PCHAR) pIceConfigInfo->uris[i], (PCHAR) pIceConfigInfo->userName, (PCHAR) pIceConfigInfo->password), pIceAgent->iceAgentProfileDiagnostics.iceServerParsingTime[i], "ICE server parsing"); + MUTEX_UNLOCK(pIceAgent->lock); + locked = FALSE; + if (STATUS_SUCCEEDED(retStatus)) { + MUTEX_LOCK(pIceAgent->lock); + locked = TRUE; pIceAgent->rtcIceServerDiagnostics[i].port = (INT32) getInt16(pIceAgent->iceServers[i].ipAddress.port); switch (pIceAgent->iceServers[pIceAgent->iceServersCount].transport) { case KVS_SOCKET_PROTOCOL_UDP: @@ -293,7 +297,12 @@ STATUS iceAgentAddConfig(PIceAgent pIceAgent, PIceConfigInfo pIceConfigInfo) } STRCPY(pIceAgent->rtcIceServerDiagnostics[i].url, pIceConfigInfo->uris[i]); - // init candidate && pairs + MUTEX_UNLOCK(pIceAgent->lock); + locked = FALSE; + + // important to unlock iceAgent lock before calling init relay candidate, since iceAgent APIs are thread safe + // if you don't unlock this can lead to a deadlock with the timerqueue. + // init candidate && pairs if (pIceAgent->iceServers[pIceAgent->iceServersCount].isTurn) { if (pIceAgent->iceServers[pIceAgent->iceServersCount].transport == KVS_SOCKET_PROTOCOL_UDP || pIceAgent->iceServers[pIceAgent->iceServersCount].transport == KVS_SOCKET_PROTOCOL_NONE) { @@ -306,15 +315,19 @@ STATUS iceAgentAddConfig(PIceAgent pIceAgent, PIceConfigInfo pIceConfigInfo) } } + MUTEX_LOCK(pIceAgent->lock); + locked = TRUE; + pIceAgent->iceServersCount++; + + MUTEX_UNLOCK(pIceAgent->lock); + locked = FALSE; + } else { DLOGE("Failed to parse ICE servers"); } } - MUTEX_UNLOCK(pIceAgent->lock); - locked = FALSE; - CleanUp: CHK_LOG_ERR(retStatus); diff --git a/tst/IceFunctionalityTest.cpp b/tst/IceFunctionalityTest.cpp index fc71cdbd90..7095771aac 100644 --- a/tst/IceFunctionalityTest.cpp +++ b/tst/IceFunctionalityTest.cpp @@ -678,6 +678,9 @@ TEST_F(IceFunctionalityTest, IceAgentCandidateGatheringTest) iceAgentCallbacks.customData = (UINT64) &candidateList; iceAgentCallbacks.newLocalCandidateFn = onICECandidateHdlr; + // Set the STUN server + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); + EXPECT_EQ(STATUS_SUCCESS, generateJSONSafeString(localIceUfrag, LOCAL_ICE_UFRAG_LEN)); EXPECT_EQ(STATUS_SUCCESS, generateJSONSafeString(localIcePwd, LOCAL_ICE_PWD_LEN)); EXPECT_EQ(STATUS_SUCCESS, createConnectionListener(&pConnectionListener)); @@ -685,9 +688,8 @@ TEST_F(IceFunctionalityTest, IceAgentCandidateGatheringTest) EXPECT_EQ(STATUS_SUCCESS, createIceAgent(localIceUfrag, localIcePwd, &iceAgentCallbacks, &configuration, timerQueueHandle, pConnectionListener, &pIceAgent)); - getIceServers(&configuration, pIceAgent); - EXPECT_EQ(STATUS_SUCCESS, iceAgentStartGathering(pIceAgent)); + getIceServers(&configuration, pIceAgent); THREAD_SLEEP(KVS_ICE_GATHER_REFLEXIVE_AND_RELAYED_CANDIDATE_TIMEOUT + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND); From 6cd49bb98cd6389fc6e5e51931a53732f9e7fd65 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sun, 10 Dec 2023 18:40:46 -0800 Subject: [PATCH 08/25] iceAgentRestart does not remove the IceServers since the old design required them to be supplied at object creation. Initialize relay candidates at end of iceAgentRestart. --- src/source/Ice/IceAgent.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/source/Ice/IceAgent.c b/src/source/Ice/IceAgent.c index f29427f2bd..78d0c4a85a 100644 --- a/src/source/Ice/IceAgent.c +++ b/src/source/Ice/IceAgent.c @@ -1029,6 +1029,8 @@ STATUS iceAgentRestart(PIceAgent pIceAgent, PCHAR localIceUfrag, PCHAR localIceP CHK_STATUS(setStateMachineCurrentState(pIceAgent->pStateMachine, ICE_AGENT_STATE_NEW)); ATOMIC_STORE_BOOL(&pIceAgent->processStun, TRUE); + // this API does not reset servers, so re-initialize relay candidates now. + CHK_STATUS(iceAgentInitRelayCandidates(pIceAgent)); CleanUp: From a32a892c5d658d67610e8fa863486439bba61cca Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Mon, 11 Dec 2023 10:02:20 -0800 Subject: [PATCH 09/25] Update PIC build in an attempt to fix static build on Mac --- CMake/Dependencies/libkvsCommonLws-CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt b/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt index 12e513ca05..e8c265a23b 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 develop + GIT_TAG faea26ad80232f1549250c04cf45669a51e49af8 PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX} From 8ed07cef1482b1ad002e87a126748d604e0f91a4 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Mon, 11 Dec 2023 10:18:21 -0800 Subject: [PATCH 10/25] Moving git tag back to develop, since develop has been updated --- CMake/Dependencies/libkvsCommonLws-CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt b/CMake/Dependencies/libkvsCommonLws-CMakeLists.txt index e8c265a23b..12e513ca05 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 faea26ad80232f1549250c04cf45669a51e49af8 + GIT_TAG develop PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX} From 210267ce367edd154b01e7df2aa846a7d4bbe4eb Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Sun, 26 Nov 2023 11:29:54 -0800 Subject: [PATCH 11/25] remove geticeconfig from standard connect state machine flow --- src/source/Signaling/StateMachine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/source/Signaling/StateMachine.c b/src/source/Signaling/StateMachine.c index 44462f2af7..c8542751e4 100644 --- a/src/source/Signaling/StateMachine.c +++ b/src/source/Signaling/StateMachine.c @@ -34,7 +34,7 @@ StateMachineState SIGNALING_STATE_MACHINE_STATES[] = { 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, + {SIGNALING_STATE_CONNECT, SIGNALING_STATE_READY | SIGNALING_STATE_DISCONNECTED | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_CONNECT | SIGNALING_STATE_GET_ENDPOINT, fromConnectSignalingState, executeConnectSignalingState, defaultSignalingStateTransitionHook, INFINITE_RETRY_COUNT_SENTINEL, STATUS_SIGNALING_CONNECT_CALL_FAILED}, {SIGNALING_STATE_CONNECTED, SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED, fromConnectedSignalingState, executeConnectedSignalingState, @@ -486,7 +486,7 @@ STATUS fromGetEndpointSignalingState(UINT64 customData, PUINT64 pState) result = ATOMIC_LOAD(&pSignalingClient->result); switch (result) { case SERVICE_CALL_RESULT_OK: - state = SIGNALING_STATE_GET_ICE_CONFIG; + state = SIGNALING_STATE_CONNECT; break; case SERVICE_CALL_FORBIDDEN: From a2bffb16c3f70a43b543b8eefbe67478083aa2d2 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Mon, 11 Dec 2023 15:09:15 -0800 Subject: [PATCH 12/25] Async test, and moving geticeserverconfig out of the standard signaling state machine flow --- src/source/Signaling/StateMachine.c | 3 +- tst/PeerConnectionApiTest.cpp | 21 ++++++ tst/PeerConnectionFunctionalityTest.cpp | 26 +++++++ tst/WebRTCClientTestFixture.cpp | 91 +++++++++++++++++++++++++ tst/WebRTCClientTestFixture.h | 24 +++++++ 5 files changed, 164 insertions(+), 1 deletion(-) diff --git a/src/source/Signaling/StateMachine.c b/src/source/Signaling/StateMachine.c index c8542751e4..ff80c19a3a 100644 --- a/src/source/Signaling/StateMachine.c +++ b/src/source/Signaling/StateMachine.c @@ -34,7 +34,8 @@ StateMachineState SIGNALING_STATE_MACHINE_STATES[] = { 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 | SIGNALING_STATE_GET_ENDPOINT, + {SIGNALING_STATE_CONNECT, + SIGNALING_STATE_READY | SIGNALING_STATE_DISCONNECTED | SIGNALING_STATE_CONNECTED | SIGNALING_STATE_CONNECT | SIGNALING_STATE_GET_ENDPOINT, fromConnectSignalingState, executeConnectSignalingState, defaultSignalingStateTransitionHook, INFINITE_RETRY_COUNT_SENTINEL, STATUS_SIGNALING_CONNECT_CALL_FAILED}, {SIGNALING_STATE_CONNECTED, SIGNALING_STATE_CONNECT | SIGNALING_STATE_CONNECTED, fromConnectedSignalingState, executeConnectedSignalingState, diff --git a/tst/PeerConnectionApiTest.cpp b/tst/PeerConnectionApiTest.cpp index 180933a8c9..c80f9497b2 100644 --- a/tst/PeerConnectionApiTest.cpp +++ b/tst/PeerConnectionApiTest.cpp @@ -198,6 +198,27 @@ TEST_F(PeerConnectionApiTest, connectionState) freePeerConnection(&pc); } +TEST_F(PeerConnectionApiTest, peerConnectionAsyncUnitTest) +{ + PRtcPeerConnection pc = nullptr; + RtcConfiguration config{}; + EXPECT_EQ(STATUS_SUCCESS, createPeerConnection(&config, &pc)); + + closePeerConnection(pc); + freePeerConnection(&pc); +} + +TEST_F(PeerConnectionApiTest, addConfigToServerListUnitTest) +{ + PRtcPeerConnection pc = nullptr; + PIceConfigInfo pIceConfigInfo = nullptr; + RtcConfiguration config{}; + EXPECT_EQ(STATUS_SUCCESS, createPeerConnection(&config, &pc)); + + closePeerConnection(pc); + freePeerConnection(&pc); +} + } // namespace webrtcclient } // namespace video } // namespace kinesis diff --git a/tst/PeerConnectionFunctionalityTest.cpp b/tst/PeerConnectionFunctionalityTest.cpp index d3e6b7ba5d..38ce5ebd36 100644 --- a/tst/PeerConnectionFunctionalityTest.cpp +++ b/tst/PeerConnectionFunctionalityTest.cpp @@ -29,6 +29,32 @@ TEST_F(PeerConnectionFunctionalityTest, connectTwoPeers) freePeerConnection(&answerPc); } +TEST_F(PeerConnectionFunctionalityTest, connectTwoPeersWithAsyncGetIceConfigForceTurn) +{ + RtcConfiguration configuration; + PRtcPeerConnection offerPc = NULL, answerPc = NULL; + RtcSessionDescriptionInit sdp; + + MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); + configuration.iceTransportPolicy = ICE_TRANSPORT_POLICY_RELAY; + + initializeSignalingClient(); + + EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); + EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); + + EXPECT_EQ(connectTwoPeersAsyncIce(offerPc, answerPc), TRUE); + + closePeerConnection(offerPc); + closePeerConnection(answerPc); + + freePeerConnection(&offerPc); + freePeerConnection(&answerPc); + + deinitializeSignalingClient(); +} + + TEST_F(PeerConnectionFunctionalityTest, connectTwoPeersWithDelay) { RtcConfiguration configuration; diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index 3ec15acb5c..e6ed01c8a5 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -33,6 +33,41 @@ STATUS createRtpPacketWithSeqNum(UINT16 seqNum, PRtpPacket *ppRtpPacket) { return retStatus; } +PVOID asyncGetIceConfigInfo(PVOID args) +{ + STATUS retStatus = STATUS_SUCCESS; + AsyncGetIceStruct* data = (AsyncGetIceStruct*) args; + PIceConfigInfo pIceConfigInfo = NULL; + UINT32 uriCount = 0; + UINT32 i = 0, maxTurnServer = 1; + + if (data != NULL) { + /* signalingClientGetIceConfigInfoCount can return more than one turn server. Use only one to optimize + * candidate gathering latency. But user can also choose to use more than 1 turn server. */ + for (uriCount = 0, i = 0; i < maxTurnServer; i++) { + /* + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port?transport=udp" then ICE will try TURN over UDP + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port?transport=tcp" then ICE will try TURN over TCP/TLS + * if configuration.iceServers[uriCount + 1].urls is "turns:ip:port?transport=udp", it's currently ignored because sdk dont do TURN + * over DTLS yet. if configuration.iceServers[uriCount + 1].urls is "turns:ip:port?transport=tcp" then ICE will try TURN over TCP/TLS + * if configuration.iceServers[uriCount + 1].urls is "turn:ip:port" then ICE will try both TURN over UDP and TCP/TLS + * + * It's recommended to not pass too many TURN iceServers to configuration because it will slow down ice gathering in non-trickle mode. + */ + CHK_STATUS(signalingClientGetIceConfigInfo(data->signalingClientHandle, i, &pIceConfigInfo)); + CHECK(uriCount < MAX_ICE_SERVERS_COUNT); + uriCount += pIceConfigInfo->uriCount; + CHK_STATUS(addConfigToServerList(data->ppRtcPeerConnection, pIceConfigInfo)); + } + } + *(data->pUriCount) += uriCount; + +CleanUp: + SAFE_MEMFREE(data); + CHK_LOG_ERR(retStatus); + return NULL; +} + WebRtcClientTestBase::WebRtcClientTestBase() : mSignalingClientHandle(INVALID_SIGNALING_CLIENT_HANDLE_VALUE), mAccessKey(NULL), @@ -233,6 +268,62 @@ bool WebRtcClientTestBase::connectTwoPeers(PRtcPeerConnection offerPc, PRtcPeerC return ATOMIC_LOAD(&this->stateChangeCount[RTC_PEER_CONNECTION_STATE_CONNECTED]) == 2; } +bool WebRtcClientTestBase::connectTwoPeersAsyncIce(PRtcPeerConnection offerPc, PRtcPeerConnection answerPc, PCHAR pOfferCertFingerprint, + PCHAR pAnswerCertFingerprint) +{ + AsyncGetIceStruct* pAsyncData = NULL; + RtcSessionDescriptionInit sdp; + + auto onICECandidateHdlr = [](UINT64 customData, PCHAR candidateStr) -> void { + if (candidateStr != NULL) { + std::thread( + [customData](std::string candidate) { + RtcIceCandidateInit iceCandidate; + EXPECT_EQ(STATUS_SUCCESS, deserializeRtcIceCandidateInit((PCHAR) candidate.c_str(), STRLEN(candidate.c_str()), &iceCandidate)); + EXPECT_EQ(STATUS_SUCCESS, addIceCandidate((PRtcPeerConnection) customData, iceCandidate.candidate)); + }, + std::string(candidateStr)) + .detach(); + } + }; + + EXPECT_EQ(STATUS_SUCCESS, peerConnectionOnIceCandidate(offerPc, (UINT64) answerPc, onICECandidateHdlr)); + EXPECT_EQ(STATUS_SUCCESS, peerConnectionOnIceCandidate(answerPc, (UINT64) offerPc, onICECandidateHdlr)); + + auto onICEConnectionStateChangeHdlr = [](UINT64 customData, RTC_PEER_CONNECTION_STATE newState) -> void { + ATOMIC_INCREMENT((PSIZE_T) customData + newState); + }; + + EXPECT_EQ(STATUS_SUCCESS, peerConnectionOnConnectionStateChange(offerPc, (UINT64) this->stateChangeCount, onICEConnectionStateChangeHdlr)); + EXPECT_EQ(STATUS_SUCCESS, peerConnectionOnConnectionStateChange(answerPc, (UINT64) this->stateChangeCount, onICEConnectionStateChangeHdlr)); + + EXPECT_EQ(STATUS_SUCCESS, createOffer(offerPc, &sdp)); + EXPECT_EQ(STATUS_SUCCESS, setLocalDescription(offerPc, &sdp)); + EXPECT_EQ(STATUS_SUCCESS, setRemoteDescription(answerPc, &sdp)); + + // Validate the cert fingerprint if we are asked to do so + if (pOfferCertFingerprint != NULL) { + EXPECT_NE((PCHAR) NULL, STRSTR(sdp.sdp, pOfferCertFingerprint)); + } + + EXPECT_EQ(STATUS_SUCCESS, createAnswer(answerPc, &sdp)); + EXPECT_EQ(STATUS_SUCCESS, setLocalDescription(answerPc, &sdp)); + EXPECT_EQ(STATUS_SUCCESS, setRemoteDescription(offerPc, &sdp)); + + asyncGetIceConfig(answerPc); + asyncGetIceConfig(offerPc); + + if (pAnswerCertFingerprint != NULL) { + EXPECT_NE((PCHAR) NULL, STRSTR(sdp.sdp, pAnswerCertFingerprint)); + } + + for (auto i = 0; i <= 100 && ATOMIC_LOAD(&this->stateChangeCount[RTC_PEER_CONNECTION_STATE_CONNECTED]) != 2; i++) { + THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND); + } + + return ATOMIC_LOAD(&this->stateChangeCount[RTC_PEER_CONNECTION_STATE_CONNECTED]) == 2; +} + // Create track and transceiver and adds to PeerConnection void WebRtcClientTestBase::addTrackToPeerConnection(PRtcPeerConnection pRtcPeerConnection, PRtcMediaStreamTrack track, PRtcRtpTransceiver* transceiver, RTC_CODEC codec, MEDIA_STREAM_TRACK_KIND kind) diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index df015f90b6..3e56309fd2 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -36,8 +36,18 @@ typedef struct { PAwsCredentials pAwsCredentials; } StaticCredentialProvider, *PStaticCredentialProvider; +typedef struct { + SIGNALING_CLIENT_HANDLE signalingClientHandle; + PRtcPeerConnection* ppRtcPeerConnection; + PUINT32 pUriCount; + +} AsyncGetIceStruct; + + STATUS createRtpPacketWithSeqNum(UINT16 seqNum, PRtpPacket* ppRtpPacket); +PVOID asyncGetIceConfigInfo(PVOID args); + class WebRtcClientTestBase : public ::testing::Test { public: PUINT32 mExpectedFrameSizeArr; @@ -47,6 +57,7 @@ class WebRtcClientTestBase : public ::testing::Test { UINT32 mExpectedDroppedFrameCount; PRtpPacket* mPRtpPackets; UINT32 mRtpPacketCount; + UINT32 mUriCount = 0; SIGNALING_CLIENT_HANDLE mSignalingClientHandle; WebRtcClientTestBase(); @@ -149,6 +160,17 @@ class WebRtcClientTestBase : public ::testing::Test { return STATUS_SUCCESS; } + STATUS asyncGetIceConfig(PRtcPeerConnection pRtcPeerConnection) + { + AsyncGetIceStruct* pAsyncData = NULL; + pAsyncData = (AsyncGetIceStruct*) MEMCALLOC(1, SIZEOF(AsyncGetIceStruct)); + pAsyncData->signalingClientHandle = mSignalingClientHandle; + pAsyncData->ppRtcPeerConnection = &pRtcPeerConnection; + pAsyncData->pUriCount = &(this->mUriCount); + EXPECT_EQ(STATUS_SUCCESS, peerConnectionAsync(asyncGetIceConfigInfo, (PVOID) pAsyncData)); + return STATUS_SUCCESS; + } + static STATUS testFrameReadyFunc(UINT64 customData, UINT16 startIndex, UINT16 endIndex, UINT32 frameSize) { WebRtcClientTestBase* base = (WebRtcClientTestBase*) customData; @@ -270,6 +292,8 @@ class WebRtcClientTestBase : public ::testing::Test { bool connectTwoPeers(PRtcPeerConnection offerPc, PRtcPeerConnection answerPc, PCHAR pOfferCertFingerprint = NULL, PCHAR pAnswerCertFingerprint = NULL); + bool connectTwoPeersAsyncIce(PRtcPeerConnection offerPc, PRtcPeerConnection answerPc, PCHAR pOfferCertFingerprint = NULL, + PCHAR pAnswerCertFingerprint = NULL); void addTrackToPeerConnection(PRtcPeerConnection pRtcPeerConnection, PRtcMediaStreamTrack track, PRtcRtpTransceiver* transceiver, RTC_CODEC codec, MEDIA_STREAM_TRACK_KIND kind); void getIceServers(PRtcConfiguration pRtcConfiguration, PRtcPeerConnection pRtcPeerConnection); From 7abe36bd53ea6c2d6b3990f4578bc6f10188fe3b Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Mon, 11 Dec 2023 15:23:38 -0800 Subject: [PATCH 13/25] clang format --- tst/IceFunctionalityTest.cpp | 15 ++-- tst/PeerConnectionApiTest.cpp | 3 +- tst/PeerConnectionFunctionalityTest.cpp | 91 ++++++++++++------------- tst/WebRTCClientTestFixture.cpp | 28 ++++---- tst/WebRTCClientTestFixture.h | 3 +- 5 files changed, 65 insertions(+), 75 deletions(-) diff --git a/tst/IceFunctionalityTest.cpp b/tst/IceFunctionalityTest.cpp index 7095771aac..aa1b697081 100644 --- a/tst/IceFunctionalityTest.cpp +++ b/tst/IceFunctionalityTest.cpp @@ -6,8 +6,7 @@ namespace kinesis { namespace video { namespace webrtcclient { -class IceFunctionalityTest : public WebRtcClientTestBase { -}; +class IceFunctionalityTest : public WebRtcClientTestBase {}; // check if iceCandidatePairs is in descending order BOOL candidatePairsInOrder(PDoubleList iceCandidatePairs) @@ -135,7 +134,7 @@ PVOID connectionListenAddConnectionRoutine(PVOID arg) } for (i = 0; i < pCustomData->connectionToAdd; ++i) { - randomDelay = (UINT64)(RAND() % 300) * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; + randomDelay = (UINT64) (RAND() % 300) * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; THREAD_SLEEP(randomDelay); CHECK(STATUS_SUCCEEDED(createSocketConnection((KVS_IP_FAMILY_TYPE) localhost.family, KVS_SOCKET_PROTOCOL_UDP, &localhost, NULL, 0, NULL, 0, &pSocketConnection))); @@ -151,7 +150,7 @@ TEST_F(IceFunctionalityTest, connectionListenerFunctionalityTest) PConnectionListener pConnectionListener; ConnectionListenerTestCustomData routine1CustomData, routine2CustomData; TID routine1, routine2; - UINT32 connectionCount , newConnectionCount, i; + UINT32 connectionCount, newConnectionCount, i; PSocketConnection pSocketConnection = NULL; KvsIpAddress localhost; TID threadId; @@ -203,7 +202,7 @@ TEST_F(IceFunctionalityTest, connectionListenerFunctionalityTest) MUTEX_LOCK(pConnectionListener->lock); threadId = pConnectionListener->receiveDataRoutine; MUTEX_UNLOCK(pConnectionListener->lock); - EXPECT_TRUE( IS_VALID_TID_VALUE(threadId)); + EXPECT_TRUE(IS_VALID_TID_VALUE(threadId)); ATOMIC_STORE_BOOL(&pConnectionListener->terminate, TRUE); THREAD_JOIN(threadId, NULL); @@ -359,7 +358,7 @@ TEST_F(IceFunctionalityTest, IceAgentAddRemoteCandidateUnitTest) EXPECT_EQ(STATUS_SUCCESS, doubleListGetHeadNode(iceAgent.remoteCandidates, &pCurNode)); // parsing candidate priority correctly - EXPECT_EQ(2122260223, ((PIceCandidate)pCurNode->data)->priority); + EXPECT_EQ(2122260223, ((PIceCandidate) pCurNode->data)->priority); // candidate pair formed EXPECT_EQ(STATUS_SUCCESS, doubleListGetNodeCount(iceAgent.iceCandidatePairs, &iceCandidateCount)); @@ -378,7 +377,7 @@ TEST_F(IceFunctionalityTest, IceAgentAddRemoteCandidateUnitTest) // parsing candidate priority correctly EXPECT_EQ(STATUS_SUCCESS, doubleListGetHeadNode(iceAgent.remoteCandidates, &pCurNode)); - EXPECT_EQ(2122262783, ((PIceCandidate)pCurNode->data)->priority); + EXPECT_EQ(2122262783, ((PIceCandidate) pCurNode->data)->priority); iceAgent.iceAgentState = ICE_AGENT_STATE_CHECK_CONNECTION; EXPECT_EQ(STATUS_SUCCESS, iceAgentAddRemoteCandidate(&iceAgent, relayCandidateStr)); @@ -390,7 +389,7 @@ TEST_F(IceFunctionalityTest, IceAgentAddRemoteCandidateUnitTest) EXPECT_EQ(STATUS_SUCCESS, doubleListGetHeadNode(iceAgent.remoteCandidates, &pCurNode)); // parsing candidate priority correctly - EXPECT_EQ(41885439, ((PIceCandidate)pCurNode->data)->priority); + EXPECT_EQ(41885439, ((PIceCandidate) pCurNode->data)->priority); MUTEX_FREE(iceAgent.lock); EXPECT_EQ(STATUS_SUCCESS, doubleListGetHeadNode(iceAgent.iceCandidatePairs, &pCurNode)); diff --git a/tst/PeerConnectionApiTest.cpp b/tst/PeerConnectionApiTest.cpp index c80f9497b2..926534308d 100644 --- a/tst/PeerConnectionApiTest.cpp +++ b/tst/PeerConnectionApiTest.cpp @@ -6,8 +6,7 @@ namespace kinesis { namespace video { namespace webrtcclient { -class PeerConnectionApiTest : public WebRtcClientTestBase { -}; +class PeerConnectionApiTest : public WebRtcClientTestBase {}; TEST_F(PeerConnectionApiTest, deserializeRtcIceCandidateInit) { diff --git a/tst/PeerConnectionFunctionalityTest.cpp b/tst/PeerConnectionFunctionalityTest.cpp index 38ce5ebd36..fe261f2f04 100644 --- a/tst/PeerConnectionFunctionalityTest.cpp +++ b/tst/PeerConnectionFunctionalityTest.cpp @@ -6,8 +6,7 @@ namespace kinesis { namespace video { namespace webrtcclient { -class PeerConnectionFunctionalityTest : public WebRtcClientTestBase { -}; +class PeerConnectionFunctionalityTest : public WebRtcClientTestBase {}; // Assert that two PeerConnections can connect to each other and go to connected TEST_F(PeerConnectionFunctionalityTest, connectTwoPeers) @@ -54,7 +53,6 @@ TEST_F(PeerConnectionFunctionalityTest, connectTwoPeersWithAsyncGetIceConfigForc deinitializeSignalingClient(); } - TEST_F(PeerConnectionFunctionalityTest, connectTwoPeersWithDelay) { RtcConfiguration configuration; @@ -1021,7 +1019,7 @@ TEST_F(PeerConnectionFunctionalityTest, DISABLED_exchangeMediaThroughTurnRandomS MEMSET(stateChangeCount, 0x00, SIZEOF(stateChangeCount)); EXPECT_EQ(connectTwoPeers(offerPc, answerPc), TRUE); - streamingTimeMs = (UINT64)(RAND() % (maxStreamingDurationMs - minStreamingDurationMs)) + minStreamingDurationMs; + streamingTimeMs = (UINT64) (RAND() % (maxStreamingDurationMs - minStreamingDurationMs)) + minStreamingDurationMs; DLOGI("Stop streaming after %u milliseconds.", streamingTimeMs); auto sendVideoWorker = [](PRtcRtpTransceiver pRtcRtpTransceiver, Frame frame, PSIZE_T pTerminationFlag) -> void { @@ -1063,17 +1061,17 @@ TEST_F(PeerConnectionFunctionalityTest, DISABLED_exchangeMediaThroughTurnRandomS deinitializeSignalingClient(); } -//Check that even when multiple successful candidate pairs are found, only one dtls negotiation takes place -//and that it is on the same candidate throughout the connection. +// Check that even when multiple successful candidate pairs are found, only one dtls negotiation takes place +// and that it is on the same candidate throughout the connection. TEST_F(PeerConnectionFunctionalityTest, multipleCandidateSuccessOneDTLSCheck) { RtcConfiguration configuration; PRtcPeerConnection offerPc = NULL, answerPc = NULL; - //This test can succeed if the highest priority candidate pair happens to be the first one - //to be nominated, even if the DTLS is broken. To be sure that this issue is fixed we want to - //run the test 10 times and have it never break once in that cycle. - for(auto i = 0; i < 10; i++) { + // This test can succeed if the highest priority candidate pair happens to be the first one + // to be nominated, even if the DTLS is broken. To be sure that this issue is fixed we want to + // run the test 10 times and have it never break once in that cycle. + for (auto i = 0; i < 10; i++) { offerPc = NULL; answerPc = NULL; MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); @@ -1081,23 +1079,23 @@ TEST_F(PeerConnectionFunctionalityTest, multipleCandidateSuccessOneDTLSCheck) EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); - //create a callback that can check values at every state of the ice agent state machine + // create a callback that can check values at every state of the ice agent state machine auto masterOnIceConnectionStateChangeTest = [](UINT64 customData, UINT64 connectionState) -> void { static PIceCandidatePair pSendingPair; PKvsPeerConnection pKvsPeerConnection = (PKvsPeerConnection) customData; - //still use normal callback + // still use normal callback onIceConnectionStateChange(customData, connectionState); - switch(connectionState) { + switch (connectionState) { case ICE_AGENT_STATE_CHECK_CONNECTION: - //sleep(1); + // sleep(1); break; case ICE_AGENT_STATE_CONNECTED: - if(pKvsPeerConnection->pIceAgent->pDataSendingIceCandidatePair != NULL) { + if (pKvsPeerConnection->pIceAgent->pDataSendingIceCandidatePair != NULL) { pSendingPair = pKvsPeerConnection->pIceAgent->pDataSendingIceCandidatePair; } break; case ICE_AGENT_STATE_READY: - if(pSendingPair != NULL) { + if (pSendingPair != NULL) { EXPECT_EQ(pSendingPair, pKvsPeerConnection->pIceAgent->pDataSendingIceCandidatePair); pSendingPair = NULL; } @@ -1113,11 +1111,11 @@ TEST_F(PeerConnectionFunctionalityTest, multipleCandidateSuccessOneDTLSCheck) PDoubleListNode pCurNode = NULL; PIceCandidatePair pIceCandidatePair; BOOL locked = FALSE; - //still use normal callback + // still use normal callback onIceConnectionStateChange(customData, connectionState); - switch(connectionState) { + switch (connectionState) { case ICE_AGENT_STATE_CONNECTED: - //send 'USE_CANDIDATE' for every ice candidate pair + // send 'USE_CANDIDATE' for every ice candidate pair MUTEX_LOCK(pIceAgent->lock); locked = TRUE; doubleListGetHeadNode(pIceAgent->iceCandidatePairs, &pCurNode); @@ -1137,9 +1135,9 @@ TEST_F(PeerConnectionFunctionalityTest, multipleCandidateSuccessOneDTLSCheck) } }; - //overwrite normal callback - ((PKvsPeerConnection)answerPc)->pIceAgent->iceAgentCallbacks.connectionStateChangedFn = masterOnIceConnectionStateChangeTest; - ((PKvsPeerConnection)offerPc)->pIceAgent->iceAgentCallbacks.connectionStateChangedFn = viewerOnIceConnectionStateChangeTest; + // overwrite normal callback + ((PKvsPeerConnection) answerPc)->pIceAgent->iceAgentCallbacks.connectionStateChangedFn = masterOnIceConnectionStateChangeTest; + ((PKvsPeerConnection) offerPc)->pIceAgent->iceAgentCallbacks.connectionStateChangedFn = viewerOnIceConnectionStateChangeTest; EXPECT_EQ(connectTwoPeers(offerPc, answerPc), TRUE); @@ -1148,25 +1146,25 @@ TEST_F(PeerConnectionFunctionalityTest, multipleCandidateSuccessOneDTLSCheck) freePeerConnection(&offerPc); freePeerConnection(&answerPc); - MEMSET(this->stateChangeCount, 0, SIZEOF(SIZE_T)*RTC_PEER_CONNECTION_TOTAL_STATE_COUNT); - if(::testing::Test::HasFailure()) { + MEMSET(this->stateChangeCount, 0, SIZEOF(SIZE_T) * RTC_PEER_CONNECTION_TOTAL_STATE_COUNT); + if (::testing::Test::HasFailure()) { break; } } } -//Check that even when multiple successful candidate pairs are found, only one dtls negotiation takes place -//and that it is on the same candidate throughout the connection. This time setting the viewer to use -//aggressive nomination +// Check that even when multiple successful candidate pairs are found, only one dtls negotiation takes place +// and that it is on the same candidate throughout the connection. This time setting the viewer to use +// aggressive nomination TEST_F(PeerConnectionFunctionalityTest, aggressiveNominationDTLSRaceConditionCheck) { RtcConfiguration configuration; PRtcPeerConnection offerPc = NULL, answerPc = NULL; - //This test can succeed if the highest priority candidate pair happens to be the first one - //to be nominated, even if the DTLS is broken. To be sure that this issue is fixed we want to - //run the test 10 times and have it never break once in that cycle. - for(auto i = 0; i < 10; i++) { + // This test can succeed if the highest priority candidate pair happens to be the first one + // to be nominated, even if the DTLS is broken. To be sure that this issue is fixed we want to + // run the test 10 times and have it never break once in that cycle. + for (auto i = 0; i < 10; i++) { offerPc = NULL; answerPc = NULL; MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); @@ -1174,23 +1172,23 @@ TEST_F(PeerConnectionFunctionalityTest, aggressiveNominationDTLSRaceConditionChe EXPECT_EQ(createPeerConnection(&configuration, &offerPc), STATUS_SUCCESS); EXPECT_EQ(createPeerConnection(&configuration, &answerPc), STATUS_SUCCESS); - //create a callback that can check values at every state of the ice agent state machine + // create a callback that can check values at every state of the ice agent state machine auto masterOnIceConnectionStateChangeTest = [](UINT64 customData, UINT64 connectionState) -> void { static PIceCandidatePair pSendingPair; PKvsPeerConnection pKvsPeerConnection = (PKvsPeerConnection) customData; - //still use normal callback + // still use normal callback onIceConnectionStateChange(customData, connectionState); - switch(connectionState) { + switch (connectionState) { case ICE_AGENT_STATE_CHECK_CONNECTION: - //sleep(1); + // sleep(1); break; case ICE_AGENT_STATE_CONNECTED: - if(pKvsPeerConnection->pIceAgent->pDataSendingIceCandidatePair != NULL) { + if (pKvsPeerConnection->pIceAgent->pDataSendingIceCandidatePair != NULL) { pSendingPair = pKvsPeerConnection->pIceAgent->pDataSendingIceCandidatePair; } break; case ICE_AGENT_STATE_READY: - if(pSendingPair != NULL) { + if (pSendingPair != NULL) { EXPECT_EQ(pSendingPair, pKvsPeerConnection->pIceAgent->pDataSendingIceCandidatePair); pSendingPair = NULL; } @@ -1207,13 +1205,13 @@ TEST_F(PeerConnectionFunctionalityTest, aggressiveNominationDTLSRaceConditionChe PDoubleListNode pCurNode = NULL; PIceCandidatePair pIceCandidatePair; BOOL locked = FALSE; - //still use normal callback + // still use normal callback onIceConnectionStateChange(customData, connectionState); - switch(connectionState) { + switch (connectionState) { case ICE_AGENT_STATE_CHECK_CONNECTION: MUTEX_LOCK(pIceAgent->lock); locked = TRUE; - if(!setUseCandidate) { + if (!setUseCandidate) { setUseCandidate = TRUE; appendStunFlagAttribute(pIceAgent->pBindingRequest, STUN_ATTRIBUTE_TYPE_USE_CANDIDATE); } @@ -1230,7 +1228,7 @@ TEST_F(PeerConnectionFunctionalityTest, aggressiveNominationDTLSRaceConditionChe } break; case ICE_AGENT_STATE_CONNECTED: - //send 'USE_CANDIDATE' for every ice candidate pair + // send 'USE_CANDIDATE' for every ice candidate pair setUseCandidate = FALSE; MUTEX_LOCK(pIceAgent->lock); locked = TRUE; @@ -1251,9 +1249,9 @@ TEST_F(PeerConnectionFunctionalityTest, aggressiveNominationDTLSRaceConditionChe } }; - //overwrite normal callback - ((PKvsPeerConnection)answerPc)->pIceAgent->iceAgentCallbacks.connectionStateChangedFn = masterOnIceConnectionStateChangeTest; - ((PKvsPeerConnection)offerPc)->pIceAgent->iceAgentCallbacks.connectionStateChangedFn = viewerOnIceConnectionStateChangeTest; + // overwrite normal callback + ((PKvsPeerConnection) answerPc)->pIceAgent->iceAgentCallbacks.connectionStateChangedFn = masterOnIceConnectionStateChangeTest; + ((PKvsPeerConnection) offerPc)->pIceAgent->iceAgentCallbacks.connectionStateChangedFn = viewerOnIceConnectionStateChangeTest; EXPECT_EQ(connectTwoPeers(offerPc, answerPc), TRUE); @@ -1262,14 +1260,13 @@ TEST_F(PeerConnectionFunctionalityTest, aggressiveNominationDTLSRaceConditionChe freePeerConnection(&offerPc); freePeerConnection(&answerPc); - MEMSET(this->stateChangeCount, 0, SIZEOF(SIZE_T)*RTC_PEER_CONNECTION_TOTAL_STATE_COUNT); - if(::testing::Test::HasFailure()) { + MEMSET(this->stateChangeCount, 0, SIZEOF(SIZE_T) * RTC_PEER_CONNECTION_TOTAL_STATE_COUNT); + if (::testing::Test::HasFailure()) { break; } } } - } // namespace webrtcclient } // namespace video } // namespace kinesis diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index e6ed01c8a5..db4e32504e 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -16,20 +16,20 @@ UINT64 gTotalWebRtcClientMemoryUsage = 0; // MUTEX gTotalWebRtcClientMemoryMutex; -STATUS createRtpPacketWithSeqNum(UINT16 seqNum, PRtpPacket *ppRtpPacket) { +STATUS createRtpPacketWithSeqNum(UINT16 seqNum, PRtpPacket* ppRtpPacket) +{ STATUS retStatus = STATUS_SUCCESS; BYTE payload[10]; PRtpPacket pRtpPacket = NULL; - CHK_STATUS(createRtpPacket(2, FALSE, FALSE, 0, FALSE, - 96, seqNum, 100, 0x1234ABCD, NULL, 0, 0, NULL, payload, 10, &pRtpPacket)); + CHK_STATUS(createRtpPacket(2, FALSE, FALSE, 0, FALSE, 96, seqNum, 100, 0x1234ABCD, NULL, 0, 0, NULL, payload, 10, &pRtpPacket)); *ppRtpPacket = pRtpPacket; CHK_STATUS(createBytesFromRtpPacket(pRtpPacket, NULL, &pRtpPacket->rawPacketLength)); CHK(NULL != (pRtpPacket->pRawPacket = (PBYTE) MEMALLOC(pRtpPacket->rawPacketLength)), STATUS_NOT_ENOUGH_MEMORY); CHK_STATUS(createBytesFromRtpPacket(pRtpPacket, pRtpPacket->pRawPacket, &pRtpPacket->rawPacketLength)); - CleanUp: +CleanUp: return retStatus; } @@ -68,14 +68,9 @@ PVOID asyncGetIceConfigInfo(PVOID args) return NULL; } -WebRtcClientTestBase::WebRtcClientTestBase() : - mSignalingClientHandle(INVALID_SIGNALING_CLIENT_HANDLE_VALUE), - mAccessKey(NULL), - mSecretKey(NULL), - mSessionToken(NULL), - mRegion(NULL), - mCaCertPath(NULL), - mAccessKeyIdSet(FALSE) +WebRtcClientTestBase::WebRtcClientTestBase() + : mSignalingClientHandle(INVALID_SIGNALING_CLIENT_HANDLE_VALUE), mAccessKey(NULL), mSecretKey(NULL), mSessionToken(NULL), mRegion(NULL), + mCaCertPath(NULL), mAccessKeyIdSet(FALSE) { // Initialize the endianness of the library initializeEndianness(); @@ -269,7 +264,7 @@ bool WebRtcClientTestBase::connectTwoPeers(PRtcPeerConnection offerPc, PRtcPeerC } bool WebRtcClientTestBase::connectTwoPeersAsyncIce(PRtcPeerConnection offerPc, PRtcPeerConnection answerPc, PCHAR pOfferCertFingerprint, - PCHAR pAnswerCertFingerprint) + PCHAR pAnswerCertFingerprint) { AsyncGetIceStruct* pAsyncData = NULL; RtcSessionDescriptionInit sdp; @@ -349,7 +344,8 @@ void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PI EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(mSignalingClientHandle, &iceConfigCount)); // Set the STUN server - SNPRINTF(pRtcConfiguration->iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); + SNPRINTF(pRtcConfiguration->iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, + TEST_DEFAULT_STUN_URL_POSTFIX); for (uriCount = 0, i = 0; i < iceConfigCount; i++) { EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(mSignalingClientHandle, i, &pIceConfigInfo)); @@ -364,7 +360,6 @@ void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PI } } - void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PRtcPeerConnection pRtcPeerConnection) { UINT32 i, j, iceConfigCount, uriCount; @@ -374,7 +369,8 @@ void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PR EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(mSignalingClientHandle, &iceConfigCount)); // Set the STUN server - SNPRINTF(pRtcConfiguration->iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, TEST_DEFAULT_STUN_URL_POSTFIX); + SNPRINTF(pRtcConfiguration->iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, + TEST_DEFAULT_STUN_URL_POSTFIX); for (uriCount = 0, i = 0; i < iceConfigCount; i++) { EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(mSignalingClientHandle, i, &pIceConfigInfo)); diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index 3e56309fd2..205c303c4f 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -43,7 +43,6 @@ typedef struct { } AsyncGetIceStruct; - STATUS createRtpPacketWithSeqNum(UINT16 seqNum, PRtpPacket* ppRtpPacket); PVOID asyncGetIceConfigInfo(PVOID args); @@ -293,7 +292,7 @@ class WebRtcClientTestBase : public ::testing::Test { bool connectTwoPeers(PRtcPeerConnection offerPc, PRtcPeerConnection answerPc, PCHAR pOfferCertFingerprint = NULL, PCHAR pAnswerCertFingerprint = NULL); bool connectTwoPeersAsyncIce(PRtcPeerConnection offerPc, PRtcPeerConnection answerPc, PCHAR pOfferCertFingerprint = NULL, - PCHAR pAnswerCertFingerprint = NULL); + PCHAR pAnswerCertFingerprint = NULL); void addTrackToPeerConnection(PRtcPeerConnection pRtcPeerConnection, PRtcMediaStreamTrack track, PRtcRtpTransceiver* transceiver, RTC_CODEC codec, MEDIA_STREAM_TRACK_KIND kind); void getIceServers(PRtcConfiguration pRtcConfiguration, PRtcPeerConnection pRtcPeerConnection); From 59001a9fc825c777164fb9b5650c4d190d036a6c Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 01:37:52 -0800 Subject: [PATCH 14/25] Incorrect state transition --- src/source/Signaling/StateMachine.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/source/Signaling/StateMachine.c b/src/source/Signaling/StateMachine.c index ff80c19a3a..5ac5046ee5 100644 --- a/src/source/Signaling/StateMachine.c +++ b/src/source/Signaling/StateMachine.c @@ -32,10 +32,10 @@ StateMachineState SIGNALING_STATE_MACHINE_STATES[] = { 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 | SIGNALING_STATE_GET_ENDPOINT, + {SIGNALING_STATE_READY, SIGNALING_STATE_GET_ENDPOINT | 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, @@ -487,7 +487,7 @@ STATUS fromGetEndpointSignalingState(UINT64 customData, PUINT64 pState) result = ATOMIC_LOAD(&pSignalingClient->result); switch (result) { case SERVICE_CALL_RESULT_OK: - state = SIGNALING_STATE_CONNECT; + state = SIGNALING_STATE_READY; break; case SERVICE_CALL_FORBIDDEN: From 59085eb3e9fdec48498eaa3c6987feef9c81e149 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 02:05:52 -0800 Subject: [PATCH 15/25] fixing async test --- tst/PeerConnectionFunctionalityTest.cpp | 2 ++ tst/WebRTCClientTestFixture.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/tst/PeerConnectionFunctionalityTest.cpp b/tst/PeerConnectionFunctionalityTest.cpp index fe261f2f04..a5196e39ad 100644 --- a/tst/PeerConnectionFunctionalityTest.cpp +++ b/tst/PeerConnectionFunctionalityTest.cpp @@ -35,6 +35,8 @@ TEST_F(PeerConnectionFunctionalityTest, connectTwoPeersWithAsyncGetIceConfigForc RtcSessionDescriptionInit sdp; MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, + TEST_DEFAULT_STUN_URL_POSTFIX); configuration.iceTransportPolicy = ICE_TRANSPORT_POLICY_RELAY; initializeSignalingClient(); diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index db4e32504e..a7bcc5a56d 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -306,6 +306,10 @@ bool WebRtcClientTestBase::connectTwoPeersAsyncIce(PRtcPeerConnection offerPc, P EXPECT_EQ(STATUS_SUCCESS, setRemoteDescription(offerPc, &sdp)); asyncGetIceConfig(answerPc); + //lazy sleep added to this test that's needed because both peer connections are on the + //same device and we're not sending the remote candidates over the signaling client like + //we normally would. This results in a weird race condition + THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND); asyncGetIceConfig(offerPc); if (pAnswerCertFingerprint != NULL) { From 592ed6c77cb6d1c81fd7afc0c6c6fb180686903b Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 02:21:26 -0800 Subject: [PATCH 16/25] Up the sleep time --- tst/WebRTCClientTestFixture.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index a7bcc5a56d..b4214d4d10 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -306,10 +306,11 @@ bool WebRtcClientTestBase::connectTwoPeersAsyncIce(PRtcPeerConnection offerPc, P EXPECT_EQ(STATUS_SUCCESS, setRemoteDescription(offerPc, &sdp)); asyncGetIceConfig(answerPc); + //lazy sleep added to this test that's needed because both peer connections are on the //same device and we're not sending the remote candidates over the signaling client like //we normally would. This results in a weird race condition - THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND); + THREAD_SLEEP(3*HUNDREDS_OF_NANOS_IN_A_SECOND); asyncGetIceConfig(offerPc); if (pAnswerCertFingerprint != NULL) { From 7688f7f7a56ce51652a2fef5049533df65750fde Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 03:05:04 -0800 Subject: [PATCH 17/25] change async func for test to handle answer and offer --- tst/WebRTCClientTestFixture.cpp | 11 +++-------- tst/WebRTCClientTestFixture.h | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index b4214d4d10..8de5417373 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -57,7 +57,8 @@ PVOID asyncGetIceConfigInfo(PVOID args) CHK_STATUS(signalingClientGetIceConfigInfo(data->signalingClientHandle, i, &pIceConfigInfo)); CHECK(uriCount < MAX_ICE_SERVERS_COUNT); uriCount += pIceConfigInfo->uriCount; - CHK_STATUS(addConfigToServerList(data->ppRtcPeerConnection, pIceConfigInfo)); + CHK_STATUS(addConfigToServerList(data->ppAnswer, pIceConfigInfo)); + CHK_STATUS(addConfigToServerList(data->ppOffer, pIceConfigInfo)); } } *(data->pUriCount) += uriCount; @@ -305,13 +306,7 @@ bool WebRtcClientTestBase::connectTwoPeersAsyncIce(PRtcPeerConnection offerPc, P EXPECT_EQ(STATUS_SUCCESS, setLocalDescription(answerPc, &sdp)); EXPECT_EQ(STATUS_SUCCESS, setRemoteDescription(offerPc, &sdp)); - asyncGetIceConfig(answerPc); - - //lazy sleep added to this test that's needed because both peer connections are on the - //same device and we're not sending the remote candidates over the signaling client like - //we normally would. This results in a weird race condition - THREAD_SLEEP(3*HUNDREDS_OF_NANOS_IN_A_SECOND); - asyncGetIceConfig(offerPc); + asyncGetIceConfig(offerPc, answerPc); if (pAnswerCertFingerprint != NULL) { EXPECT_NE((PCHAR) NULL, STRSTR(sdp.sdp, pAnswerCertFingerprint)); diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index 205c303c4f..24b46c5043 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -23,6 +23,13 @@ #define MAX_TEST_AWAIT_DURATION (2 * HUNDREDS_OF_NANOS_IN_A_SECOND) #define TEST_CACHE_FILE_PATH (PCHAR) "./.TestSignalingCache_v0" +typedef struct { + SIGNALING_CLIENT_HANDLE signalingClientHandle; + PRtcPeerConnection* ppOffer; + PRtcPeerConnection* ppAnswer; + PUINT32 pUriCount; +} AsyncGetIceStruct; + namespace com { namespace amazonaws { namespace kinesis { @@ -36,13 +43,6 @@ typedef struct { PAwsCredentials pAwsCredentials; } StaticCredentialProvider, *PStaticCredentialProvider; -typedef struct { - SIGNALING_CLIENT_HANDLE signalingClientHandle; - PRtcPeerConnection* ppRtcPeerConnection; - PUINT32 pUriCount; - -} AsyncGetIceStruct; - STATUS createRtpPacketWithSeqNum(UINT16 seqNum, PRtpPacket* ppRtpPacket); PVOID asyncGetIceConfigInfo(PVOID args); @@ -159,12 +159,13 @@ class WebRtcClientTestBase : public ::testing::Test { return STATUS_SUCCESS; } - STATUS asyncGetIceConfig(PRtcPeerConnection pRtcPeerConnection) + STATUS asyncGetIceConfig(PRtcPeerConnection pOffer, PRtcPeerConnection pAnswer) { AsyncGetIceStruct* pAsyncData = NULL; pAsyncData = (AsyncGetIceStruct*) MEMCALLOC(1, SIZEOF(AsyncGetIceStruct)); pAsyncData->signalingClientHandle = mSignalingClientHandle; - pAsyncData->ppRtcPeerConnection = &pRtcPeerConnection; + pAsyncData->ppAnswer = &pAnswer; + pAsyncData->ppOffer = &pOffer; pAsyncData->pUriCount = &(this->mUriCount); EXPECT_EQ(STATUS_SUCCESS, peerConnectionAsync(asyncGetIceConfigInfo, (PVOID) pAsyncData)); return STATUS_SUCCESS; From 7fb4483a37f4e076ba3568e1ae6ad119c721e9a4 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 03:29:03 -0800 Subject: [PATCH 18/25] change location of creating pointer pointer --- tst/WebRTCClientTestFixture.cpp | 5 ++--- tst/WebRTCClientTestFixture.h | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index 8de5417373..3d3ecf9430 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -57,8 +57,8 @@ PVOID asyncGetIceConfigInfo(PVOID args) CHK_STATUS(signalingClientGetIceConfigInfo(data->signalingClientHandle, i, &pIceConfigInfo)); CHECK(uriCount < MAX_ICE_SERVERS_COUNT); uriCount += pIceConfigInfo->uriCount; - CHK_STATUS(addConfigToServerList(data->ppAnswer, pIceConfigInfo)); - CHK_STATUS(addConfigToServerList(data->ppOffer, pIceConfigInfo)); + CHK_STATUS(addConfigToServerList(&(data->pAnswer), pIceConfigInfo)); + CHK_STATUS(addConfigToServerList(&(data->pOffer), pIceConfigInfo)); } } *(data->pUriCount) += uriCount; @@ -267,7 +267,6 @@ bool WebRtcClientTestBase::connectTwoPeers(PRtcPeerConnection offerPc, PRtcPeerC bool WebRtcClientTestBase::connectTwoPeersAsyncIce(PRtcPeerConnection offerPc, PRtcPeerConnection answerPc, PCHAR pOfferCertFingerprint, PCHAR pAnswerCertFingerprint) { - AsyncGetIceStruct* pAsyncData = NULL; RtcSessionDescriptionInit sdp; auto onICECandidateHdlr = [](UINT64 customData, PCHAR candidateStr) -> void { diff --git a/tst/WebRTCClientTestFixture.h b/tst/WebRTCClientTestFixture.h index 24b46c5043..d774e97b07 100644 --- a/tst/WebRTCClientTestFixture.h +++ b/tst/WebRTCClientTestFixture.h @@ -25,8 +25,8 @@ typedef struct { SIGNALING_CLIENT_HANDLE signalingClientHandle; - PRtcPeerConnection* ppOffer; - PRtcPeerConnection* ppAnswer; + PRtcPeerConnection pOffer; + PRtcPeerConnection pAnswer; PUINT32 pUriCount; } AsyncGetIceStruct; @@ -164,8 +164,8 @@ class WebRtcClientTestBase : public ::testing::Test { AsyncGetIceStruct* pAsyncData = NULL; pAsyncData = (AsyncGetIceStruct*) MEMCALLOC(1, SIZEOF(AsyncGetIceStruct)); pAsyncData->signalingClientHandle = mSignalingClientHandle; - pAsyncData->ppAnswer = &pAnswer; - pAsyncData->ppOffer = &pOffer; + pAsyncData->pAnswer = pAnswer; + pAsyncData->pOffer = pOffer; pAsyncData->pUriCount = &(this->mUriCount); EXPECT_EQ(STATUS_SUCCESS, peerConnectionAsync(asyncGetIceConfigInfo, (PVOID) pAsyncData)); return STATUS_SUCCESS; From 216465b641354f5de0ec5bbebc23b8a239c34268 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 13:30:47 -0800 Subject: [PATCH 19/25] Fixing tests --- tst/IceFunctionalityTest.cpp | 3 + tst/SignalingApiFunctionalityTest.cpp | 191 ++++++++++++++++---------- tst/SignalingApiTest.cpp | 28 +++- 3 files changed, 147 insertions(+), 75 deletions(-) diff --git a/tst/IceFunctionalityTest.cpp b/tst/IceFunctionalityTest.cpp index aa1b697081..d72543a1b2 100644 --- a/tst/IceFunctionalityTest.cpp +++ b/tst/IceFunctionalityTest.cpp @@ -663,6 +663,9 @@ TEST_F(IceFunctionalityTest, IceAgentCandidateGatheringTest) initializeSignalingClient(); + SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, + TEST_DEFAULT_STUN_URL_POSTFIX); + auto onICECandidateHdlr = [](UINT64 customData, PCHAR candidateStr) -> void { CandidateList* candidateList1 = (CandidateList*) customData; candidateList1->lock.lock(); diff --git a/tst/SignalingApiFunctionalityTest.cpp b/tst/SignalingApiFunctionalityTest.cpp index 9990f5a361..f84302acd3 100644 --- a/tst/SignalingApiFunctionalityTest.cpp +++ b/tst/SignalingApiFunctionalityTest.cpp @@ -973,14 +973,14 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); - // The ICE api should have been called - EXPECT_EQ(1, getIceConfigCount); + // The ICE api shouldn't have been called + EXPECT_EQ(0, getIceConfigCount); // Ensure we can get the ICE configurations EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); @@ -988,7 +988,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio for (i = 0; i < iceCount; i++) { EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, i, &pIceConfigInfo)); } - // Make sure no APIs have been called + // Make sure APIs have been called EXPECT_EQ(1, getIceConfigCount); // Other state transacted @@ -998,7 +998,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1035,7 +1035,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1071,7 +1071,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1108,7 +1108,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1143,7 +1143,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedVariatio EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(6, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1237,14 +1237,14 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); - // The ICE api should have been called - EXPECT_EQ(1, getIceConfigCount); + // The ICE api shouldn't have been called + EXPECT_EQ(0, getIceConfigCount); // Ensure we can get the ICE configurations EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); @@ -1263,9 +1263,9 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1300,9 +1300,9 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1336,9 +1336,9 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); - EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); - EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1373,9 +1373,9 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); - EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); - EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); // @@ -1408,9 +1408,9 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedVariations) EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); - EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); - EXPECT_EQ(5, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(6, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(6, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(6, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); // @@ -1488,12 +1488,30 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpi EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); + //get config + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); + EXPECT_NE(0, iceCount); + EXPECT_NE((UINT64) NULL, (UINT64) pIceConfigInfo); + + // Check the states first + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_NEW]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_CREDENTIALS]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); + // Make sure the credentials expire THREAD_SLEEP(7 * HUNDREDS_OF_NANOS_IN_A_SECOND); @@ -1520,7 +1538,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpi EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1537,7 +1555,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedAuthExpi EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1612,12 +1630,31 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpirat EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); + //get config before credentials expire + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); + EXPECT_NE(0, iceCount); + EXPECT_NE((UINT64) NULL, (UINT64) pIceConfigInfo); + + // Check the states first + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_NEW]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_CREDENTIALS]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); + + // Make sure the credentials expire THREAD_SLEEP(7 * HUNDREDS_OF_NANOS_IN_A_SECOND); @@ -1644,9 +1681,9 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpirat EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); // Attempt to retrieve the ice configuration should succeed @@ -1661,9 +1698,9 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedAuthExpirat EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); // We should have already been connected. This should be a No-op @@ -1737,7 +1774,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -1756,7 +1793,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -1769,7 +1806,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -1852,7 +1889,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -1867,14 +1904,13 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); // Trigger the ICE refresh on the next call - pSignalingClient->iceConfigCount = 0; EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); EXPECT_NE(0, iceCount); @@ -1886,7 +1922,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -1961,6 +1997,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul EXPECT_TRUE(IS_VALID_SIGNALING_CLIENT_HANDLE(signalingHandle)); EXPECT_EQ(STATUS_SUCCESS,signalingClientFetchSync(signalingHandle)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); pActiveClient = pSignalingClient; // Check the states first @@ -1970,7 +2008,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -1987,7 +2025,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_LT(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -2000,7 +2038,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithFaul EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_LT(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -2075,6 +2113,8 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn EXPECT_EQ(STATUS_SUCCESS,signalingClientFetchSync(signalingHandle)); pActiveClient = pSignalingClient; + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); // Connect first EXPECT_EQ(STATUS_SUCCESS, signalingClientConnectSync(signalingHandle)); @@ -2086,7 +2126,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -2103,7 +2143,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_LT(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -2116,7 +2156,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithFaultIn EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_LT(4, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -2183,6 +2223,10 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadA EXPECT_TRUE(IS_VALID_SIGNALING_CLIENT_HANDLE(signalingHandle)); EXPECT_EQ(STATUS_SUCCESS,signalingClientFetchSync(signalingHandle)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); + + pActiveClient = pSignalingClient; // Check the states first @@ -2192,7 +2236,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadA EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -2217,7 +2261,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadA EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_LT(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -2610,7 +2654,7 @@ TEST_F(SignalingApiFunctionalityTest, connectTimeoutEmulation) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -2632,7 +2676,7 @@ TEST_F(SignalingApiFunctionalityTest, connectTimeoutEmulation) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_LE(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -2728,7 +2772,7 @@ TEST_F(SignalingApiFunctionalityTest, channelInfoArnSkipDescribe) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -2781,7 +2825,7 @@ TEST_F(SignalingApiFunctionalityTest, channelInfoArnSkipDescribe) EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -2860,7 +2904,7 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedWithArn) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -2913,7 +2957,7 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedWithArn) EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -2994,7 +3038,7 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -3012,7 +3056,7 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -3032,7 +3076,7 @@ TEST_F(SignalingApiFunctionalityTest, deleteChannelCreatedAuthExpiration) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -3165,7 +3209,7 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) // Account for 1 time failure EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -3187,7 +3231,7 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_LE(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -3209,7 +3253,7 @@ TEST_F(SignalingApiFunctionalityTest, cachingWithFaultInjection) EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_LE(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_LE(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -3544,12 +3588,17 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer) EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); + EXPECT_NE(0, iceCount); + EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + // Ensure the ICE is not refreshed as we already have a current non-expired set EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); @@ -3733,12 +3782,17 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_SlowClockSkew) EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); + EXPECT_NE(0, iceCount); + EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + // Ensure the ICE is not refreshed as we already have a current non-expired set EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); @@ -3923,13 +3977,12 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew) EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); - // Ensure the ICE is not refreshed as we already have a current non-expired set EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(signalingHandle, &iceCount)); EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfo(signalingHandle, 0, &pIceConfigInfo)); EXPECT_NE(0, iceCount); @@ -4115,7 +4168,7 @@ TEST_F(SignalingApiFunctionalityTest, receivingIceConfigOffer_FastClockSkew_Veri EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); diff --git a/tst/SignalingApiTest.cpp b/tst/SignalingApiTest.cpp index affcc3b5b1..7564b6ff7b 100644 --- a/tst/SignalingApiTest.cpp +++ b/tst/SignalingApiTest.cpp @@ -319,11 +319,11 @@ TEST_F(SignalingApiTest, signalingClientGetMetrics) EXPECT_EQ(0, metrics.signalingClientStats.numberOfMessagesReceived); EXPECT_EQ(0, metrics.signalingClientStats.numberOfErrors); EXPECT_EQ(0, metrics.signalingClientStats.numberOfRuntimeErrors); - EXPECT_EQ(1, metrics.signalingClientStats.iceRefreshCount); + EXPECT_EQ(0, metrics.signalingClientStats.iceRefreshCount); EXPECT_NE(0, metrics.signalingClientStats.signalingClientUptime); EXPECT_EQ(0, metrics.signalingClientStats.connectionDuration); EXPECT_NE(0, metrics.signalingClientStats.cpApiCallLatency); - EXPECT_NE(0, metrics.signalingClientStats.dpApiCallLatency); + EXPECT_EQ(0, metrics.signalingClientStats.dpApiCallLatency); // Connect and get metrics EXPECT_EQ(STATUS_SUCCESS, signalingClientConnectSync(mSignalingClientHandle)); @@ -337,11 +337,11 @@ TEST_F(SignalingApiTest, signalingClientGetMetrics) EXPECT_EQ(0, metrics.signalingClientStats.numberOfMessagesReceived); EXPECT_EQ(0, metrics.signalingClientStats.numberOfErrors); EXPECT_EQ(0, metrics.signalingClientStats.numberOfRuntimeErrors); - EXPECT_EQ(1, metrics.signalingClientStats.iceRefreshCount); + EXPECT_EQ(0, metrics.signalingClientStats.iceRefreshCount); EXPECT_NE(0, metrics.signalingClientStats.signalingClientUptime); EXPECT_NE(0, metrics.signalingClientStats.connectionDuration); EXPECT_NE(0, metrics.signalingClientStats.cpApiCallLatency); - EXPECT_NE(0, metrics.signalingClientStats.dpApiCallLatency); + EXPECT_EQ(0, metrics.signalingClientStats.dpApiCallLatency); // Send a message and get metrics signalingMessage.version = SIGNALING_MESSAGE_CURRENT_VERSION; @@ -359,11 +359,11 @@ TEST_F(SignalingApiTest, signalingClientGetMetrics) EXPECT_EQ(0, metrics.signalingClientStats.numberOfMessagesReceived); EXPECT_EQ(0, metrics.signalingClientStats.numberOfErrors); EXPECT_EQ(0, metrics.signalingClientStats.numberOfRuntimeErrors); - EXPECT_EQ(1, metrics.signalingClientStats.iceRefreshCount); + EXPECT_EQ(0, metrics.signalingClientStats.iceRefreshCount); EXPECT_NE(0, metrics.signalingClientStats.signalingClientUptime); EXPECT_NE(0, metrics.signalingClientStats.connectionDuration); EXPECT_NE(0, metrics.signalingClientStats.cpApiCallLatency); - EXPECT_NE(0, metrics.signalingClientStats.dpApiCallLatency); + EXPECT_EQ(0, metrics.signalingClientStats.dpApiCallLatency); // Make a couple of bad API invocations EXPECT_NE(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(mSignalingClientHandle, NULL)); @@ -372,6 +372,22 @@ TEST_F(SignalingApiTest, signalingClientGetMetrics) EXPECT_NE(STATUS_SUCCESS, signalingClientGetMetrics(mSignalingClientHandle, NULL)); EXPECT_NE(STATUS_SUCCESS, signalingClientSendMessageSync(mSignalingClientHandle, NULL)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetMetrics(mSignalingClientHandle, &metrics)); + EXPECT_EQ(0, metrics.signalingClientStats.numberOfReconnects); + EXPECT_EQ(1, metrics.signalingClientStats.numberOfMessagesSent); + EXPECT_EQ(0, metrics.signalingClientStats.numberOfMessagesReceived); + EXPECT_EQ(5, metrics.signalingClientStats.numberOfErrors); + EXPECT_EQ(0, metrics.signalingClientStats.numberOfRuntimeErrors); + EXPECT_EQ(0, metrics.signalingClientStats.iceRefreshCount); + EXPECT_NE(0, metrics.signalingClientStats.signalingClientUptime); + EXPECT_NE(0, metrics.signalingClientStats.connectionDuration); + EXPECT_NE(0, metrics.signalingClientStats.cpApiCallLatency); + EXPECT_EQ(0, metrics.signalingClientStats.dpApiCallLatency); + + UINT32 iceCount = 0; + //Get ice config + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetIceConfigInfoCount(mSignalingClientHandle, &iceCount)); + EXPECT_EQ(STATUS_SUCCESS, signalingClientGetMetrics(mSignalingClientHandle, &metrics)); EXPECT_EQ(0, metrics.signalingClientStats.numberOfReconnects); EXPECT_EQ(1, metrics.signalingClientStats.numberOfMessagesSent); From 7b332bb683ea8062d117671073e5e3381babf015 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 14:11:41 -0800 Subject: [PATCH 20/25] Fix gathering to allow reporting relay candidates even after all srflx candidates have been recieved --- src/source/Ice/IceAgent.c | 3 +-- tst/IceFunctionalityTest.cpp | 2 -- tst/WebRTCClientTestFixture.cpp | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/source/Ice/IceAgent.c b/src/source/Ice/IceAgent.c index 78d0c4a85a..6d1a9ab0cf 100644 --- a/src/source/Ice/IceAgent.c +++ b/src/source/Ice/IceAgent.c @@ -386,8 +386,6 @@ STATUS iceAgentReportNewLocalCandidate(PIceAgent pIceAgent, PIceCandidate pIceCa iceAgentLogNewCandidate(pIceCandidate); CHK_WARN(pIceAgent->iceAgentCallbacks.newLocalCandidateFn != NULL, retStatus, "newLocalCandidateFn callback not implemented"); - CHK_WARN(!ATOMIC_LOAD_BOOL(&pIceAgent->candidateGatheringFinished), retStatus, - "Cannot report new ice candidate because candidate gathering is already finished"); CHK_STATUS(iceCandidateSerialize(pIceCandidate, serializedIceCandidateBuf, &serializedIceCandidateBufLen)); pIceAgent->iceAgentCallbacks.newLocalCandidateFn(pIceAgent->iceAgentCallbacks.customData, serializedIceCandidateBuf); @@ -1942,6 +1940,7 @@ STATUS iceAgentInitRelayCandidate(PIceAgent pIceAgent, UINT32 iceServerIndex, KV pNewCandidate->pTurnConnection = pTurnConnection; CHK_STATUS(doubleListInsertItemHead(pIceAgent->localCandidates, (UINT64) pNewCandidate)); + CHK_STATUS(iceAgentReportNewLocalCandidate(pIceAgent, pNewCandidate)); pNewCandidate = NULL; /* add existing remote candidates to turn. Need to acquire lock because remoteCandidates can be mutated by diff --git a/tst/IceFunctionalityTest.cpp b/tst/IceFunctionalityTest.cpp index d72543a1b2..8693f8711c 100644 --- a/tst/IceFunctionalityTest.cpp +++ b/tst/IceFunctionalityTest.cpp @@ -695,9 +695,7 @@ TEST_F(IceFunctionalityTest, IceAgentCandidateGatheringTest) THREAD_SLEEP(KVS_ICE_GATHER_REFLEXIVE_AND_RELAYED_CANDIDATE_TIMEOUT + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND); - // newLocalCandidateFn should've returned null in its last invocation, which was converted to empty string candidateList.lock.lock(); - EXPECT_TRUE(candidateList.list[candidateList.list.size() - 1].empty()); for (std::vector::iterator it = candidateList.list.begin(); it != candidateList.list.end(); ++it) { std::string candidateStr = *it; diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index 3d3ecf9430..80aa4eacbe 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -336,7 +336,7 @@ void WebRtcClientTestBase::addTrackToPeerConnection(PRtcPeerConnection pRtcPeerC void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PIceAgent pIceAgent) { - UINT32 i, j, iceConfigCount, uriCount; + UINT32 i, j, iceConfigCount = 0, uriCount; PIceConfigInfo pIceConfigInfo; // Assume signaling client is already created @@ -361,7 +361,7 @@ void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PI void WebRtcClientTestBase::getIceServers(PRtcConfiguration pRtcConfiguration, PRtcPeerConnection pRtcPeerConnection) { - UINT32 i, j, iceConfigCount, uriCount; + UINT32 i, j, iceConfigCount = 0, uriCount; PIceConfigInfo pIceConfigInfo; // Assume signaling client is already created From f598f6b957884de206fd23af3b1c054bdf9b4264 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 14:36:10 -0800 Subject: [PATCH 21/25] unit test, longer sleep on teardown of threadpool --- tst/PeerConnectionApiTest.cpp | 13 +++---------- tst/WebRTCClientTestFixture.cpp | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tst/PeerConnectionApiTest.cpp b/tst/PeerConnectionApiTest.cpp index 926534308d..7b3478f680 100644 --- a/tst/PeerConnectionApiTest.cpp +++ b/tst/PeerConnectionApiTest.cpp @@ -197,23 +197,16 @@ TEST_F(PeerConnectionApiTest, connectionState) freePeerConnection(&pc); } -TEST_F(PeerConnectionApiTest, peerConnectionAsyncUnitTest) -{ - PRtcPeerConnection pc = nullptr; - RtcConfiguration config{}; - EXPECT_EQ(STATUS_SUCCESS, createPeerConnection(&config, &pc)); - - closePeerConnection(pc); - freePeerConnection(&pc); -} - TEST_F(PeerConnectionApiTest, addConfigToServerListUnitTest) { PRtcPeerConnection pc = nullptr; PIceConfigInfo pIceConfigInfo = nullptr; RtcConfiguration config{}; + EXPECT_NE(STATUS_SUCCESS, addConfigToServerList(pc, pIceConfigInfo)); EXPECT_EQ(STATUS_SUCCESS, createPeerConnection(&config, &pc)); + EXPECT_NE(STATUS_SUCCESS, addConfigToServerList(pc, pIceConfigInfo)); + closePeerConnection(pc); freePeerConnection(&pc); } diff --git a/tst/WebRTCClientTestFixture.cpp b/tst/WebRTCClientTestFixture.cpp index 80aa4eacbe..af8ccd234b 100644 --- a/tst/WebRTCClientTestFixture.cpp +++ b/tst/WebRTCClientTestFixture.cpp @@ -145,7 +145,7 @@ void WebRtcClientTestBase::TearDown() deinitKvsWebRtc(); // Need this sleep for threads in threadpool to close - THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); + THREAD_SLEEP(400 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); freeStaticCredentialProvider(&mTestCredentialProvider); From 47477d629e0ef0ce1194f430d2f87727b53f22ef Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 15:14:43 -0800 Subject: [PATCH 22/25] Fixing tests --- tst/PeerConnectionApiTest.cpp | 4 ++-- tst/SignalingApiFunctionalityTest.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tst/PeerConnectionApiTest.cpp b/tst/PeerConnectionApiTest.cpp index 7b3478f680..d2cd4be672 100644 --- a/tst/PeerConnectionApiTest.cpp +++ b/tst/PeerConnectionApiTest.cpp @@ -202,10 +202,10 @@ TEST_F(PeerConnectionApiTest, addConfigToServerListUnitTest) PRtcPeerConnection pc = nullptr; PIceConfigInfo pIceConfigInfo = nullptr; RtcConfiguration config{}; - EXPECT_NE(STATUS_SUCCESS, addConfigToServerList(pc, pIceConfigInfo)); + EXPECT_NE(STATUS_SUCCESS, addConfigToServerList(&pc, pIceConfigInfo)); EXPECT_EQ(STATUS_SUCCESS, createPeerConnection(&config, &pc)); - EXPECT_NE(STATUS_SUCCESS, addConfigToServerList(pc, pIceConfigInfo)); + EXPECT_NE(STATUS_SUCCESS, addConfigToServerList(&pc, pIceConfigInfo)); closePeerConnection(pc); freePeerConnection(&pc); diff --git a/tst/SignalingApiFunctionalityTest.cpp b/tst/SignalingApiFunctionalityTest.cpp index f84302acd3..9d5ed74219 100644 --- a/tst/SignalingApiFunctionalityTest.cpp +++ b/tst/SignalingApiFunctionalityTest.cpp @@ -2279,7 +2279,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshNotConnectedWithBadA EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); EXPECT_LT(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); - EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); + EXPECT_EQ(3, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_DISCONNECTED]); @@ -2358,7 +2358,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithBadAuth EXPECT_EQ(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_EQ(0, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); @@ -2383,7 +2383,7 @@ TEST_F(SignalingApiFunctionalityTest, iceServerConfigRefreshConnectedWithBadAuth EXPECT_LT(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_DESCRIBE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CREATE]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ENDPOINT]); - EXPECT_LT(2, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); + EXPECT_LT(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_GET_ICE_CONFIG]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_READY]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTING]); EXPECT_EQ(1, signalingStatesCounts[SIGNALING_CLIENT_STATE_CONNECTED]); From c2d8a8ac3a59e8ffca4aa5a8a458d919ec4d6402 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 15:30:08 -0800 Subject: [PATCH 23/25] Update samples based off feedback, fix clang compile error in test --- samples/Common.c | 13 ++----------- samples/Samples.h | 9 +++++++++ tst/PeerConnectionFunctionalityTest.cpp | 1 - 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/samples/Common.c b/samples/Common.c index 0b2e1f9322..2f9d992627 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -356,15 +356,6 @@ VOID onIceCandidateHandler(UINT64 customData, PCHAR candidateJson) CHK_LOG_ERR(retStatus); } -// TODO this should all be in a higher webrtccontext layer above PeerConnection -// Placing it here now since this is where all the current webrtccontext functions are placed -typedef struct { - SIGNALING_CLIENT_HANDLE signalingClientHandle; - PRtcPeerConnection* ppRtcPeerConnection; - PUINT32 pUriCount; - -} AsyncGetIceStruct; - PVOID asyncGetIceConfigInfo(PVOID args) { STATUS retStatus = STATUS_SUCCESS; @@ -389,7 +380,7 @@ PVOID asyncGetIceConfigInfo(PVOID args) CHK_STATUS(signalingClientGetIceConfigInfo(data->signalingClientHandle, i, &pIceConfigInfo)); CHECK(uriCount < MAX_ICE_SERVERS_COUNT); uriCount += pIceConfigInfo->uriCount; - CHK_STATUS(addConfigToServerList(data->ppRtcPeerConnection, pIceConfigInfo)); + CHK_STATUS(addConfigToServerList(&(data->pRtcPeerConnection), pIceConfigInfo)); } } *(data->pUriCount) += uriCount; @@ -453,7 +444,7 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP pAsyncData = (AsyncGetIceStruct*) MEMCALLOC(1, SIZEOF(AsyncGetIceStruct)); pAsyncData->signalingClientHandle = pSampleConfiguration->signalingClientHandle; - pAsyncData->ppRtcPeerConnection = ppRtcPeerConnection; + pAsyncData->pRtcPeerConnection = *ppRtcPeerConnection; pAsyncData->pUriCount = &(pSampleConfiguration->iceUriCount); CHK_STATUS(peerConnectionAsync(asyncGetIceConfigInfo, (PVOID) pAsyncData)); #else diff --git a/samples/Samples.h b/samples/Samples.h index 1bb705b800..01109e8a5d 100644 --- a/samples/Samples.h +++ b/samples/Samples.h @@ -166,6 +166,15 @@ struct __SampleStreamingSession { KvsIceAgentMetrics iceMetrics; }; +// TODO this should all be in a higher webrtccontext layer above PeerConnection +// Placing it here now since this is where all the current webrtccontext functions are placed +typedef struct { + SIGNALING_CLIENT_HANDLE signalingClientHandle; + PRtcPeerConnection pRtcPeerConnection; + PUINT32 pUriCount; + +} AsyncGetIceStruct; + VOID sigintHandler(INT32); STATUS readFrameFromDisk(PBYTE, PUINT32, PCHAR); PVOID sendVideoPackets(PVOID); diff --git a/tst/PeerConnectionFunctionalityTest.cpp b/tst/PeerConnectionFunctionalityTest.cpp index a5196e39ad..ec74af611d 100644 --- a/tst/PeerConnectionFunctionalityTest.cpp +++ b/tst/PeerConnectionFunctionalityTest.cpp @@ -32,7 +32,6 @@ TEST_F(PeerConnectionFunctionalityTest, connectTwoPeersWithAsyncGetIceConfigForc { RtcConfiguration configuration; PRtcPeerConnection offerPc = NULL, answerPc = NULL; - RtcSessionDescriptionInit sdp; MEMSET(&configuration, 0x00, SIZEOF(RtcConfiguration)); SNPRINTF(configuration.iceServers[0].urls, MAX_ICE_CONFIG_URI_LEN, KINESIS_VIDEO_STUN_URL, TEST_DEFAULT_REGION, From 4d431cc07216fe2b84fa55c93d49fd8119265738 Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 16:46:46 -0800 Subject: [PATCH 24/25] Moved iceUriCount increment, added comments to public API --- samples/Common.c | 3 ++- .../kinesis/video/webrtcclient/Include.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/samples/Common.c b/samples/Common.c index 2f9d992627..6a20183bc4 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -440,6 +440,7 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP if (pSampleConfiguration->useTurn) { #ifdef ENABLE_KVS_THREADPOOL + pSampleConfiguration->iceUriCount = 1; AsyncGetIceStruct* pAsyncData = NULL; pAsyncData = (AsyncGetIceStruct*) MEMCALLOC(1, SIZEOF(AsyncGetIceStruct)); @@ -466,10 +467,10 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP uriCount += pIceConfigInfo->uriCount; CHK_STATUS(addConfigToServerList(ppRtcPeerConnection, pIceConfigInfo)); } + pSampleConfiguration->iceUriCount = uriCount + 1; #endif } - pSampleConfiguration->iceUriCount = uriCount + 1; CleanUp: CHK_LOG_ERR(retStatus); diff --git a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h index 16bdbfefbd..080696fd59 100644 --- a/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h +++ b/src/include/com/amazonaws/kinesis/video/webrtcclient/Include.h @@ -1573,6 +1573,14 @@ typedef struct { */ PUBLIC_API STATUS createPeerConnection(PRtcConfiguration, PRtcPeerConnection*); +/** + * @brief Give peer connection an ice config to add to its server list + * + * @param[in] PRtcPeerConnection* initialized RtcPeerConnection + * @param[in] PIceConfigInfo Ice config info to add to this peer connection + * + * @return STATUS code of the execution. STATUS_SUCCESS on success + */ PUBLIC_API STATUS addConfigToServerList(PRtcPeerConnection*, PIceConfigInfo); /** @@ -1651,6 +1659,14 @@ PUBLIC_API STATUS peerConnectionGetLocalDescription(PRtcPeerConnection, PRtcSess */ PUBLIC_API STATUS peerConnectionGetCurrentLocalDescription(PRtcPeerConnection, PRtcSessionDescriptionInit); +/** + * Allows use of internal threadpool + * + * @param[in] startRoutine function pointer to execute in threadpool + * @param[in] PVOID void pointer to pass to function pointer + * + * @return STATUS code of the execution. STATUS_SUCCESS on success + */ PUBLIC_API STATUS peerConnectionAsync(startRoutine fn, PVOID data); /** From e9da5b59e991cf067cbf5b313b858307254b943b Mon Sep 17 00:00:00 2001 From: James Delaplane Date: Tue, 12 Dec 2023 17:03:04 -0800 Subject: [PATCH 25/25] fix mac compile error from unused variable for specific ifdef --- samples/Common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Common.c b/samples/Common.c index 6a20183bc4..e86ca6519a 100644 --- a/samples/Common.c +++ b/samples/Common.c @@ -399,8 +399,8 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP #ifndef ENABLE_KVS_THREADPOOL UINT32 i, j, maxTurnServer = 1; PIceConfigInfo pIceConfigInfo; -#endif UINT32 uriCount = 0; +#endif UINT64 data; PRtcCertificate pRtcCertificate = NULL;