Skip to content

Commit

Permalink
Log ice candidate protocol appropriately (#1230)
Browse files Browse the repository at this point in the history
* Log ice candidate protocol appropriately

* Add develop to travis CI

* Address comments
  • Loading branch information
disa6302 authored Aug 18, 2021
1 parent 07deb17 commit 00e00b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sudo: true
branches:
only:
- master
- develop

cache:
- directories:
Expand Down
41 changes: 21 additions & 20 deletions src/source/Ice/IceAgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
PDoubleListNode pCurNode = NULL;
SDP_ICE_CANDIDATE_PARSER_STATE state;
ICE_CANDIDATE_TYPE iceCandidateType = ICE_CANDIDATE_TYPE_HOST;
CHAR remoteProtocol[MAX_PROTOCOL_LENGTH] = {'\0'};

CHK(pIceAgent != NULL && pIceCandidateString != NULL, STATUS_NULL_ARG);
CHK(!IS_EMPTY_STRING(pIceCandidateString), STATUS_INVALID_ARG);
Expand Down Expand Up @@ -354,6 +355,9 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
STRTOUI32(curr, next, 10, &priority);
break;
case SDP_ICE_CANDIDATE_PARSER_STATE_PROTOCOL:
if(tokenLen < MAX_PROTOCOL_LENGTH) {
STRNCPY(remoteProtocol, curr, tokenLen);
}
CHK(STRNCMPI("tcp", curr, tokenLen) != 0, STATUS_ICE_CANDIDATE_STRING_IS_TCP);
break;
case SDP_ICE_CANDIDATE_PARSER_STATE_IP:
Expand Down Expand Up @@ -411,11 +415,12 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
pIceCandidate->state = ICE_CANDIDATE_STATE_VALID;
pIceCandidate->priority = priority;
pIceCandidate->iceCandidateType = iceCandidateType;
STRNCPY(pIceCandidate->remoteProtocol, remoteProtocol, SIZEOF(remoteProtocol));

CHK_STATUS(doubleListInsertItemHead(pIceAgent->remoteCandidates, (UINT64) pIceCandidate));
freeIceCandidateIfFail = FALSE;

CHK_STATUS(createIceCandidatePairs(pIceAgent, pIceCandidate, TRUE));

iceAgentLogNewCandidate(pIceCandidate);

/* pass remote candidate to each turnConnection */
Expand All @@ -430,7 +435,6 @@ STATUS iceAgentAddRemoteCandidate(PIceAgent pIceAgent, PCHAR pIceCandidateString
}

CleanUp:

if (locked) {
MUTEX_UNLOCK(pIceAgent->lock);
}
Expand Down Expand Up @@ -2631,27 +2635,24 @@ VOID iceAgentLogNewCandidate(PIceCandidate pIceCandidate)
{
CHAR ipAddr[KVS_IP_ADDRESS_STRING_BUFFER_LEN];
PCHAR protocol = "UNKNOWN";

if (pIceCandidate != NULL) {
getIpAddrStr(&pIceCandidate->ipAddress, ipAddr, ARRAY_SIZE(ipAddr));
if (pIceCandidate->iceCandidateType == ICE_CANDIDATE_TYPE_RELAYED) {
if (pIceCandidate->pTurnConnection == NULL) {
protocol = "NA";
} else {
switch (pIceCandidate->pTurnConnection->protocol) {
case KVS_SOCKET_PROTOCOL_TCP:
protocol = "TCP";
break;
case KVS_SOCKET_PROTOCOL_UDP:
protocol = "UDP";
break;
case KVS_SOCKET_PROTOCOL_NONE:
protocol = "NONE";
break;
default:
break;
}
if (!pIceCandidate->isRemote && pIceCandidate->pSocketConnection != NULL) {
switch (pIceCandidate->pSocketConnection->protocol) {
case KVS_SOCKET_PROTOCOL_TCP:
protocol = "tcp";
break;
case KVS_SOCKET_PROTOCOL_UDP:
protocol = "udp";
break;
case KVS_SOCKET_PROTOCOL_NONE:
protocol = "none";
break;
default:
break;
}
} else {
protocol = pIceCandidate->remoteProtocol;
}

DLOGD("New %s ice candidate discovered. Id: %s. Ip: %s:%u. Type: %s. Protocol: %s.", pIceCandidate->isRemote ? "remote" : "local",
Expand Down
1 change: 1 addition & 0 deletions src/source/Ice/IceAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ typedef struct {
* has been reported through IceNewLocalCandidateFunc */
BOOL reported;
CHAR id[ICE_CANDIDATE_ID_LEN + 1];
CHAR remoteProtocol[MAX_PROTOCOL_LENGTH];
} IceCandidate, *PIceCandidate;

typedef struct {
Expand Down

0 comments on commit 00e00b2

Please sign in to comment.