Skip to content

Commit

Permalink
Debug 1
Browse files Browse the repository at this point in the history
  • Loading branch information
disa6302 committed Mar 7, 2024
1 parent bf9a2ee commit ad7d02f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
26 changes: 13 additions & 13 deletions samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,21 @@ STATUS logSelectedIceCandidatesInformation(PSampleStreamingSession pSampleStream
CHK(pSampleStreamingSession != NULL, STATUS_NULL_ARG);
rtcMetrics.requestedTypeOfStats = RTC_STATS_TYPE_LOCAL_CANDIDATE;
CHK_STATUS(rtcPeerConnectionGetMetrics(pSampleStreamingSession->pPeerConnection, NULL, &rtcMetrics));
DLOGD("Local Candidate IP Address: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.address);
DLOGD("Local Candidate type: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.candidateType);
DLOGD("Local Candidate port: %d", rtcMetrics.rtcStatsObject.localIceCandidateStats.port);
DLOGD("Local Candidate priority: %d", rtcMetrics.rtcStatsObject.localIceCandidateStats.priority);
DLOGD("Local Candidate transport protocol: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.protocol);
DLOGD("Local Candidate relay protocol: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.relayProtocol);
DLOGD("Local Candidate Ice server source: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.url);
DLOGI("Local Candidate IP Address: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.address);
DLOGI("Local Candidate type: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.candidateType);
DLOGI("Local Candidate port: %d", rtcMetrics.rtcStatsObject.localIceCandidateStats.port);
DLOGI("Local Candidate priority: %d", rtcMetrics.rtcStatsObject.localIceCandidateStats.priority);
DLOGI("Local Candidate transport protocol: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.protocol);
DLOGI("Local Candidate relay protocol: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.relayProtocol);
DLOGI("Local Candidate Ice server source: %s", rtcMetrics.rtcStatsObject.localIceCandidateStats.url);

rtcMetrics.requestedTypeOfStats = RTC_STATS_TYPE_REMOTE_CANDIDATE;
CHK_STATUS(rtcPeerConnectionGetMetrics(pSampleStreamingSession->pPeerConnection, NULL, &rtcMetrics));
DLOGD("Remote Candidate IP Address: %s", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.address);
DLOGD("Remote Candidate type: %s", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.candidateType);
DLOGD("Remote Candidate port: %d", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.port);
DLOGD("Remote Candidate priority: %d", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.priority);
DLOGD("Remote Candidate transport protocol: %s", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.protocol);
DLOGI("Remote Candidate IP Address: %s", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.address);
DLOGI("Remote Candidate type: %s", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.candidateType);
DLOGI("Remote Candidate port: %d", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.port);
DLOGI("Remote Candidate priority: %d", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.priority);
DLOGI("Remote Candidate transport protocol: %s", rtcMetrics.rtcStatsObject.remoteIceCandidateStats.protocol);
CleanUp:
LEAVES();
return retStatus;
Expand Down Expand Up @@ -397,8 +397,8 @@ STATUS initializePeerConnection(PSampleConfiguration pSampleConfiguration, PRtcP

// Set the ICE mode explicitly
configuration.iceTransportPolicy = ICE_TRANSPORT_POLICY_ALL;
configuration.kvsRtcConfiguration.enableIceStats = FALSE;

configuration.kvsRtcConfiguration.enableIceStats = TRUE;
// Set the STUN server
PCHAR pKinesisVideoStunUrlPostFix = KINESIS_VIDEO_STUN_URL_POSTFIX;
// If region is in CN, add CN region uri postfix
Expand Down
13 changes: 6 additions & 7 deletions src/source/Ice/IceAgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ STATUS freeIceAgent(PIceAgent* ppIceAgent)

pIceAgent = *ppIceAgent;

hashTableFree(pIceAgent->requestTimestampDiagnostics);

if (pIceAgent->localCandidates != NULL) {
CHK_STATUS(doubleListGetHeadNode(pIceAgent->localCandidates, &pCurNode));
while (pCurNode != NULL) {
Expand Down Expand Up @@ -276,6 +274,7 @@ STATUS freeIceAgent(PIceAgent* ppIceAgent)
for (int i = 0; i < MAX_ICE_SERVERS_COUNT; i++) {
SAFE_MEMFREE(pIceAgent->pRtcIceServerDiagnostics[i]);
}
hashTableFree(pIceAgent->requestTimestampDiagnostics);

MEMFREE(pIceAgent);

Expand Down Expand Up @@ -2084,7 +2083,6 @@ STATUS updateCandidateStats(PIceAgent pIceAgent, BOOL isRemote)
STATUS retStatus = STATUS_SUCCESS;
CHK(pIceAgent != NULL && pIceAgent->pDataSendingIceCandidatePair != NULL, STATUS_NULL_ARG);
PIceCandidate pIceCandidate = pIceAgent->pDataSendingIceCandidatePair->remote;

PRtcIceCandidateDiagnostics pRtcIceCandidateDiagnostics = pIceAgent->pRtcSelectedRemoteIceCandidateDiagnostics;
CHK(pRtcIceCandidateDiagnostics != NULL, STATUS_SUCCESS);
if (!isRemote) {
Expand Down Expand Up @@ -2179,16 +2177,17 @@ STATUS iceAgentConnectedStateSetup(PIceAgent pIceAgent)

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

// use the first connected pair as the data sending pair
CHK_STATUS(doubleListGetHeadNode(pIceAgent->iceCandidatePairs, &pCurNode));
while (pCurNode != NULL) {
pIceCandidatePair = (PIceCandidatePair) pCurNode->data;
pCurNode = pCurNode->pNext;

DLOGI("Connected state...%d, %d", pIceCandidatePair->state, pIceCandidatePair->nominated);
if (pIceCandidatePair->state == ICE_CANDIDATE_PAIR_STATE_SUCCEEDED && pIceCandidatePair->nominated) {
pIceAgent->pDataSendingIceCandidatePair = pIceCandidatePair;
DLOGI("Here after selection");
retStatus = updateSelectedLocalRemoteCandidateStats(pIceAgent);
DLOGI("Here after updating stats");
if (STATUS_FAILED(retStatus)) {
DLOGW("Failed to update candidate stats with status code 0x%08x", retStatus);
}
Expand Down Expand Up @@ -2616,7 +2615,7 @@ STATUS handleStunPacket(PIceAgent pIceAgent, PBYTE pBuffer, UINT32 bufferLen, PS
if (!pIceCandidatePair->nominated) {
CHK_STATUS(getStunAttribute(pStunPacket, STUN_ATTRIBUTE_TYPE_USE_CANDIDATE, &pStunAttr));
if (pStunAttr != NULL) {
DLOGD("received candidate with USE_CANDIDATE flag, local candidate type %s(%s:%s).",
DLOGI("received candidate with USE_CANDIDATE flag, local candidate type %s(%s:%s).",
iceAgentGetCandidateTypeStr(pIceCandidatePair->local->iceCandidateType), pIceCandidatePair->local->id,
pIceCandidatePair->remote->id);
pIceCandidatePair->nominated = TRUE;
Expand Down Expand Up @@ -2731,7 +2730,7 @@ STATUS handleStunPacket(PIceAgent pIceAgent, PBYTE pBuffer, UINT32 bufferLen, PS
}

if (pIceCandidatePair->state != ICE_CANDIDATE_PAIR_STATE_SUCCEEDED) {
DLOGD("Pair succeeded! %s %s", pIceCandidatePair->local->id, pIceCandidatePair->remote->id);
DLOGI("Pair succeeded! %s %s", pIceCandidatePair->local->id, pIceCandidatePair->remote->id);
pIceCandidatePair->state = ICE_CANDIDATE_PAIR_STATE_SUCCEEDED;
retStatus = hashTableGet(pIceCandidatePair->requestSentTime, checkSum, &requestSentTime);
if (hashTableGet(pIceCandidatePair->requestSentTime, checkSum, &requestSentTime) == STATUS_SUCCESS) {
Expand Down
4 changes: 4 additions & 0 deletions src/source/Metrics/Metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,22 @@ STATUS getIceCandidateStats(PRtcPeerConnection pRtcPeerConnection, BOOL isRemote
CHK((pRtcPeerConnection != NULL || pRtcIceCandidateStats != NULL), STATUS_NULL_ARG);
MUTEX_LOCK(pIceAgent->lock);
locked = TRUE;
DLOGI("Here");
PRtcIceCandidateDiagnostics pRtcIceCandidateDiagnostics = pIceAgent->pRtcSelectedRemoteIceCandidateDiagnostics;
CHK_WARN(pRtcIceCandidateDiagnostics != NULL, STATUS_NULL_ARG, "Candidate stats not populated");
if (!isRemote) {
DLOGI("Here1");
pRtcIceCandidateDiagnostics = pIceAgent->pRtcSelectedLocalIceCandidateDiagnostics;
STRCPY(pRtcIceCandidateStats->relayProtocol, pRtcIceCandidateDiagnostics->relayProtocol);
STRCPY(pRtcIceCandidateStats->url, pRtcIceCandidateDiagnostics->url);
}
DLOGI("Here2");
STRCPY(pRtcIceCandidateStats->address, pRtcIceCandidateDiagnostics->address);
STRCPY(pRtcIceCandidateStats->candidateType, pRtcIceCandidateDiagnostics->candidateType);
pRtcIceCandidateStats->port = pRtcIceCandidateDiagnostics->port;
pRtcIceCandidateStats->priority = pRtcIceCandidateDiagnostics->priority;
STRCPY(pRtcIceCandidateStats->protocol, pRtcIceCandidateDiagnostics->protocol);
DLOGI("Here3");
CleanUp:
if (locked) {
MUTEX_UNLOCK(pIceAgent->lock);
Expand Down

0 comments on commit ad7d02f

Please sign in to comment.