From 02d498ff100a7ed06c7e1b9af7303cb3018933df Mon Sep 17 00:00:00 2001 From: liyufang Date: Wed, 1 Sep 2021 15:02:26 +0800 Subject: [PATCH] filter out invalid candidate in sdp --- src/source/Ice/IceAgent.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/source/Ice/IceAgent.c b/src/source/Ice/IceAgent.c index 0408388e03..95f4983a3e 100644 --- a/src/source/Ice/IceAgent.c +++ b/src/source/Ice/IceAgent.c @@ -693,6 +693,7 @@ STATUS iceAgentPopulateSdpMediaDescriptionCandidates(PIceAgent pIceAgent, PSdpMe PDoubleListNode pCurNode = NULL; BOOL locked = FALSE; UINT32 attrIndex; + PIceCandidate pCandidate = NULL; CHK(pIceAgent != NULL && pSdpMediaDescription != NULL && pIndex != NULL, STATUS_NULL_ARG); @@ -705,10 +706,12 @@ STATUS iceAgentPopulateSdpMediaDescriptionCandidates(PIceAgent pIceAgent, PSdpMe while (pCurNode != NULL) { CHK_STATUS(doubleListGetNodeData(pCurNode, &data)); pCurNode = pCurNode->pNext; - - STRCPY(pSdpMediaDescription->sdpAttributes[attrIndex].attributeName, "candidate"); - CHK_STATUS(iceCandidateSerialize((PIceCandidate) data, pSdpMediaDescription->sdpAttributes[attrIndex].attributeValue, &attrBufferLen)); - attrIndex++; + pCandidate = (PIceCandidate) data; + if (pCandidate->state == ICE_CANDIDATE_STATE_VALID) { + STRCPY(pSdpMediaDescription->sdpAttributes[attrIndex].attributeName, "candidate"); + CHK_STATUS(iceCandidateSerialize((PIceCandidate) data, pSdpMediaDescription->sdpAttributes[attrIndex].attributeValue, &attrBufferLen)); + attrIndex++; + } } *pIndex = attrIndex;