Skip to content

Commit

Permalink
Viewer fix (#1953)
Browse files Browse the repository at this point in the history
* Viewer fix

* ICE agent update

* new flag

* stopgathering flag set

* Windows fix
  • Loading branch information
disa6302 authored Mar 20, 2024
1 parent 1eaede8 commit f107343
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ jobs:
- name: Install dependencies
shell: powershell
run: |
choco install gstreamer --version=1.16.2
choco install gstreamer-devel --version=1.16.2
choco install gstreamer --version=1.16.3
choco install gstreamer-devel --version=1.16.3
curl.exe -o C:\tools\pthreads-w32-2-9-1-release.zip ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip
mkdir C:\tools\pthreads-w32-2-9-1-release\
Expand-Archive -Path C:\tools\pthreads-w32-2-9-1-release.zip -DestinationPath C:\tools\pthreads-w32-2-9-1-release
Expand Down
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ include(CheckIncludeFiles)
include(CheckFunctionExists)

# The version MUST be updated before every release
project(KinesisVideoWebRTCClient VERSION 1.10.0 LANGUAGES C)



project(KinesisVideoWebRTCClient VERSION 1.10.1 LANGUAGES C)

# User Flags
option(ADD_MUCLIBC "Add -muclibc c flag" OFF)
Expand Down
25 changes: 15 additions & 10 deletions src/source/Ice/IceAgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ STATUS createIceAgent(PCHAR username, PCHAR password, PIceAgentCallbacks pIceAge

ATOMIC_STORE_BOOL(&pIceAgent->remoteCredentialReceived, FALSE);
ATOMIC_STORE_BOOL(&pIceAgent->agentStartGathering, FALSE);
ATOMIC_STORE_BOOL(&pIceAgent->stopGathering, FALSE);
ATOMIC_STORE_BOOL(&pIceAgent->candidateGatheringFinished, FALSE);
ATOMIC_STORE_BOOL(&pIceAgent->shutdown, FALSE);
ATOMIC_STORE_BOOL(&pIceAgent->restart, FALSE);
ATOMIC_STORE_BOOL(&pIceAgent->processStun, TRUE);
ATOMIC_STORE_BOOL(&pIceAgent->addedRelayCandidate, FALSE);
pIceAgent->isControlling = FALSE;
pIceAgent->tieBreaker = (UINT64) RAND();
pIceAgent->iceTransportPolicy = pRtcConfiguration->iceTransportPolicy;
Expand Down Expand Up @@ -327,7 +329,7 @@ STATUS iceAgentAddConfig(PIceAgent pIceAgent, PIceConfigInfo pIceConfigInfo)
DLOGE("Failed to parse ICE servers");
}
}

ATOMIC_STORE_BOOL(&pIceAgent->addedRelayCandidate, TRUE);
CleanUp:
CHK_LOG_ERR(retStatus);

Expand Down Expand Up @@ -382,7 +384,6 @@ STATUS iceAgentReportNewLocalCandidate(PIceAgent pIceAgent, PIceCandidate pIceCa
UINT32 serializedIceCandidateBufLen = ARRAY_SIZE(serializedIceCandidateBuf);

CHK(pIceAgent != NULL && pIceCandidate != NULL, STATUS_NULL_ARG);

iceAgentLogNewCandidate(pIceCandidate);

CHK_WARN(pIceAgent->iceAgentCallbacks.newLocalCandidateFn != NULL, retStatus, "newLocalCandidateFn callback not implemented");
Expand Down Expand Up @@ -919,7 +920,7 @@ STATUS iceAgentRestart(PIceAgent pIceAgent, PCHAR localIceUfrag, PCHAR localIceP
CHK(pIceAgent != NULL, STATUS_NULL_ARG);
CHK(!ATOMIC_LOAD_BOOL(&pIceAgent->shutdown), STATUS_INVALID_OPERATION);

DLOGD("Restarting ICE");
DLOGI("Restarting ICE");

alreadyRestarting = ATOMIC_EXCHANGE_BOOL(&pIceAgent->restart, TRUE);
CHK(!alreadyRestarting, retStatus);
Expand Down Expand Up @@ -948,6 +949,8 @@ STATUS iceAgentRestart(PIceAgent pIceAgent, PCHAR localIceUfrag, PCHAR localIceP
pIceAgent->iceAgentStatus = STATUS_SUCCESS;
pIceAgent->lastDataReceivedTime = INVALID_TIMESTAMP_VALUE;
pIceAgent->relayCandidateCount = 0;
ATOMIC_STORE_BOOL(&pIceAgent->addedRelayCandidate, FALSE);
ATOMIC_STORE_BOOL(&pIceAgent->stopGathering, FALSE);

CHK_STATUS(doubleListGetHeadNode(pIceAgent->localCandidates, &pCurNode));
while (pCurNode != NULL) {
Expand Down Expand Up @@ -1627,7 +1630,6 @@ STATUS iceAgentGatherCandidateTimerCallback(UINT32 timerId, UINT64 currentTime,

MUTEX_LOCK(pIceAgent->lock);
locked = TRUE;

CHK_STATUS(doubleListGetHeadNode(pIceAgent->localCandidates, &pCurNode));
while (pCurNode != NULL) {
CHK_STATUS(doubleListGetNodeData(pCurNode, &data));
Expand Down Expand Up @@ -1663,10 +1665,14 @@ STATUS iceAgentGatherCandidateTimerCallback(UINT32 timerId, UINT64 currentTime,
if (pendingSrflxCandidateCount > 0) {
CHK_STATUS(iceAgentSendSrflxCandidateRequest(pIceAgent));
}

/* stop scheduling if there is no more pending candidate or if timeout is reached. */
if ((totalCandidateCount > 0 && pendingCandidateCount == 0) || currentTime >= pIceAgent->candidateGatheringEndTime) {
/* 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
* more pending candidate and relay candidates are added or if timeout is reached. */
if (ATOMIC_LOAD_BOOL(&pIceAgent->stopGathering) ||
(totalCandidateCount > 0 && pendingCandidateCount == 0 && ATOMIC_LOAD_BOOL(&pIceAgent->addedRelayCandidate)) ||
currentTime >= pIceAgent->candidateGatheringEndTime) {
DLOGI("Candidate gathering completed.");
PROFILE_WITH_START_END_TIME_OBJ(pIceAgent->candidateGatheringStartTime, pIceAgent->candidateGatheringProcessEndTime,
pIceAgent->iceAgentProfileDiagnostics.candidateGatheringTime, "Candidate gathering time");
stopScheduling = TRUE;
pIceAgent->iceCandidateGatheringTimerTask = MAX_UINT32;
}
Expand All @@ -1682,8 +1688,6 @@ STATUS iceAgentGatherCandidateTimerCallback(UINT32 timerId, UINT64 currentTime,

if (stopScheduling) {
ATOMIC_STORE_BOOL(&pIceAgent->candidateGatheringFinished, TRUE);
PROFILE_WITH_START_END_TIME_OBJ(pIceAgent->candidateGatheringStartTime, pIceAgent->candidateGatheringProcessEndTime,
pIceAgent->iceAgentProfileDiagnostics.candidateGatheringTime, "Candidate gathering time");
/* notify that candidate gathering is finished. */
if (pIceAgent->iceAgentCallbacks.newLocalCandidateFn != NULL) {
pIceAgent->iceAgentCallbacks.newLocalCandidateFn(pIceAgent->iceAgentCallbacks.customData, NULL);
Expand Down Expand Up @@ -2242,6 +2246,8 @@ STATUS iceAgentReadyStateSetup(PIceAgent pIceAgent)
}
CHK(pNominatedAndValidCandidatePair != NULL, STATUS_ICE_NO_NOMINATED_VALID_CANDIDATE_PAIR_AVAILABLE);
pIceAgent->pDataSendingIceCandidatePair = pNominatedAndValidCandidatePair;
// Set to stop gathering
ATOMIC_STORE_BOOL(&pIceAgent->stopGathering, TRUE);
}

CHK_STATUS(getIpAddrStr(&pIceAgent->pDataSendingIceCandidatePair->local->ipAddress, ipAddrStr, ARRAY_SIZE(ipAddrStr)));
Expand All @@ -2252,7 +2258,6 @@ STATUS iceAgentReadyStateSetup(PIceAgent pIceAgent)
iceAgentGetCandidateTypeStr(pIceAgent->pDataSendingIceCandidatePair->remote->iceCandidateType),
pIceAgent->pDataSendingIceCandidatePair->roundTripTime / HUNDREDS_OF_NANOS_IN_A_MILLISECOND,
pIceAgent->pDataSendingIceCandidatePair->local->priority, pIceAgent->pDataSendingIceCandidatePair->priority);

/* no state timeout for ready state */
pIceAgent->stateEndTime = INVALID_TIMESTAMP_VALUE;

Expand Down
2 changes: 2 additions & 0 deletions src/source/Ice/IceAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ struct __IceAgent {
volatile ATOMIC_BOOL shutdown;
volatile ATOMIC_BOOL restart;
volatile ATOMIC_BOOL processStun;
volatile ATOMIC_BOOL addedRelayCandidate;
volatile ATOMIC_BOOL stopGathering;

CHAR localUsername[MAX_ICE_CONFIG_USER_NAME_LEN + 1];
CHAR localPassword[MAX_ICE_CONFIG_CREDENTIAL_LEN + 1];
Expand Down

0 comments on commit f107343

Please sign in to comment.