@@ -43,10 +43,12 @@ STATUS createIceAgent(PCHAR username, PCHAR password, PIceAgentCallbacks pIceAge
43
43
44
44
ATOMIC_STORE_BOOL (& pIceAgent -> remoteCredentialReceived , FALSE);
45
45
ATOMIC_STORE_BOOL (& pIceAgent -> agentStartGathering , FALSE);
46
+ ATOMIC_STORE_BOOL (& pIceAgent -> stopGathering , FALSE);
46
47
ATOMIC_STORE_BOOL (& pIceAgent -> candidateGatheringFinished , FALSE);
47
48
ATOMIC_STORE_BOOL (& pIceAgent -> shutdown , FALSE);
48
49
ATOMIC_STORE_BOOL (& pIceAgent -> restart , FALSE);
49
50
ATOMIC_STORE_BOOL (& pIceAgent -> processStun , TRUE);
51
+ ATOMIC_STORE_BOOL (& pIceAgent -> addedRelayCandidate , FALSE);
50
52
pIceAgent -> isControlling = FALSE;
51
53
pIceAgent -> tieBreaker = (UINT64 ) RAND ();
52
54
pIceAgent -> iceTransportPolicy = pRtcConfiguration -> iceTransportPolicy ;
@@ -327,7 +329,7 @@ STATUS iceAgentAddConfig(PIceAgent pIceAgent, PIceConfigInfo pIceConfigInfo)
327
329
DLOGE ("Failed to parse ICE servers" );
328
330
}
329
331
}
330
-
332
+ ATOMIC_STORE_BOOL ( & pIceAgent -> addedRelayCandidate , TRUE);
331
333
CleanUp :
332
334
CHK_LOG_ERR (retStatus );
333
335
@@ -382,7 +384,6 @@ STATUS iceAgentReportNewLocalCandidate(PIceAgent pIceAgent, PIceCandidate pIceCa
382
384
UINT32 serializedIceCandidateBufLen = ARRAY_SIZE (serializedIceCandidateBuf );
383
385
384
386
CHK (pIceAgent != NULL && pIceCandidate != NULL , STATUS_NULL_ARG );
385
-
386
387
iceAgentLogNewCandidate (pIceCandidate );
387
388
388
389
CHK_WARN (pIceAgent -> iceAgentCallbacks .newLocalCandidateFn != NULL , retStatus , "newLocalCandidateFn callback not implemented" );
@@ -919,7 +920,7 @@ STATUS iceAgentRestart(PIceAgent pIceAgent, PCHAR localIceUfrag, PCHAR localIceP
919
920
CHK (pIceAgent != NULL , STATUS_NULL_ARG );
920
921
CHK (!ATOMIC_LOAD_BOOL (& pIceAgent -> shutdown ), STATUS_INVALID_OPERATION );
921
922
922
- DLOGD ("Restarting ICE" );
923
+ DLOGI ("Restarting ICE" );
923
924
924
925
alreadyRestarting = ATOMIC_EXCHANGE_BOOL (& pIceAgent -> restart , TRUE);
925
926
CHK (!alreadyRestarting , retStatus );
@@ -948,6 +949,8 @@ STATUS iceAgentRestart(PIceAgent pIceAgent, PCHAR localIceUfrag, PCHAR localIceP
948
949
pIceAgent -> iceAgentStatus = STATUS_SUCCESS ;
949
950
pIceAgent -> lastDataReceivedTime = INVALID_TIMESTAMP_VALUE ;
950
951
pIceAgent -> relayCandidateCount = 0 ;
952
+ ATOMIC_STORE_BOOL (& pIceAgent -> addedRelayCandidate , FALSE);
953
+ ATOMIC_STORE_BOOL (& pIceAgent -> stopGathering , FALSE);
951
954
952
955
CHK_STATUS (doubleListGetHeadNode (pIceAgent -> localCandidates , & pCurNode ));
953
956
while (pCurNode != NULL ) {
@@ -1627,7 +1630,6 @@ STATUS iceAgentGatherCandidateTimerCallback(UINT32 timerId, UINT64 currentTime,
1627
1630
1628
1631
MUTEX_LOCK (pIceAgent -> lock );
1629
1632
locked = TRUE;
1630
-
1631
1633
CHK_STATUS (doubleListGetHeadNode (pIceAgent -> localCandidates , & pCurNode ));
1632
1634
while (pCurNode != NULL ) {
1633
1635
CHK_STATUS (doubleListGetNodeData (pCurNode , & data ));
@@ -1663,10 +1665,14 @@ STATUS iceAgentGatherCandidateTimerCallback(UINT32 timerId, UINT64 currentTime,
1663
1665
if (pendingSrflxCandidateCount > 0 ) {
1664
1666
CHK_STATUS (iceAgentSendSrflxCandidateRequest (pIceAgent ));
1665
1667
}
1666
-
1667
- /* stop scheduling if there is no more pending candidate or if timeout is reached. */
1668
- if ((totalCandidateCount > 0 && pendingCandidateCount == 0 ) || currentTime >= pIceAgent -> candidateGatheringEndTime ) {
1668
+ /* stop scheduling if there is a nominated candidate pair (in cases where the pair does not have relay, which is set via stopGathering flag), no
1669
+ * more pending candidate and relay candidates are added or if timeout is reached. */
1670
+ if (ATOMIC_LOAD_BOOL (& pIceAgent -> stopGathering ) ||
1671
+ (totalCandidateCount > 0 && pendingCandidateCount == 0 && ATOMIC_LOAD_BOOL (& pIceAgent -> addedRelayCandidate )) ||
1672
+ currentTime >= pIceAgent -> candidateGatheringEndTime ) {
1669
1673
DLOGI ("Candidate gathering completed." );
1674
+ PROFILE_WITH_START_END_TIME_OBJ (pIceAgent -> candidateGatheringStartTime , pIceAgent -> candidateGatheringProcessEndTime ,
1675
+ pIceAgent -> iceAgentProfileDiagnostics .candidateGatheringTime , "Candidate gathering time" );
1670
1676
stopScheduling = TRUE;
1671
1677
pIceAgent -> iceCandidateGatheringTimerTask = MAX_UINT32 ;
1672
1678
}
@@ -1682,8 +1688,6 @@ STATUS iceAgentGatherCandidateTimerCallback(UINT32 timerId, UINT64 currentTime,
1682
1688
1683
1689
if (stopScheduling ) {
1684
1690
ATOMIC_STORE_BOOL (& pIceAgent -> candidateGatheringFinished , TRUE);
1685
- PROFILE_WITH_START_END_TIME_OBJ (pIceAgent -> candidateGatheringStartTime , pIceAgent -> candidateGatheringProcessEndTime ,
1686
- pIceAgent -> iceAgentProfileDiagnostics .candidateGatheringTime , "Candidate gathering time" );
1687
1691
/* notify that candidate gathering is finished. */
1688
1692
if (pIceAgent -> iceAgentCallbacks .newLocalCandidateFn != NULL ) {
1689
1693
pIceAgent -> iceAgentCallbacks .newLocalCandidateFn (pIceAgent -> iceAgentCallbacks .customData , NULL );
@@ -2242,6 +2246,8 @@ STATUS iceAgentReadyStateSetup(PIceAgent pIceAgent)
2242
2246
}
2243
2247
CHK (pNominatedAndValidCandidatePair != NULL , STATUS_ICE_NO_NOMINATED_VALID_CANDIDATE_PAIR_AVAILABLE );
2244
2248
pIceAgent -> pDataSendingIceCandidatePair = pNominatedAndValidCandidatePair ;
2249
+ // Set to stop gathering
2250
+ ATOMIC_STORE_BOOL (& pIceAgent -> stopGathering , TRUE);
2245
2251
}
2246
2252
2247
2253
CHK_STATUS (getIpAddrStr (& pIceAgent -> pDataSendingIceCandidatePair -> local -> ipAddress , ipAddrStr , ARRAY_SIZE (ipAddrStr )));
@@ -2252,7 +2258,6 @@ STATUS iceAgentReadyStateSetup(PIceAgent pIceAgent)
2252
2258
iceAgentGetCandidateTypeStr (pIceAgent -> pDataSendingIceCandidatePair -> remote -> iceCandidateType ),
2253
2259
pIceAgent -> pDataSendingIceCandidatePair -> roundTripTime / HUNDREDS_OF_NANOS_IN_A_MILLISECOND ,
2254
2260
pIceAgent -> pDataSendingIceCandidatePair -> local -> priority , pIceAgent -> pDataSendingIceCandidatePair -> priority );
2255
-
2256
2261
/* no state timeout for ready state */
2257
2262
pIceAgent -> stateEndTime = INVALID_TIMESTAMP_VALUE ;
2258
2263
0 commit comments