Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
disa6302 committed Mar 21, 2024
1 parent cbf7acf commit 2ef577f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/source/PeerConnection/PeerConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ STATUS freePeerConnection(PRtcPeerConnection* ppPeerConnection)
{
ENTERS();
STATUS retStatus = STATUS_SUCCESS;
PKvsPeerConnection pKvsPeerConnection;
PKvsPeerConnection pKvsPeerConnection = NULL;
PDoubleListNode pCurNode = NULL;
UINT64 item = 0;
UINT64 startTime;
Expand Down Expand Up @@ -1082,14 +1082,21 @@ STATUS freePeerConnection(PRtcPeerConnection* ppPeerConnection)
twccLocked = FALSE;
}
MUTEX_FREE(pKvsPeerConnection->twccLock);
pKvsPeerConnection->twccLock = INVALID_MUTEX_VALUE;
}
SAFE_MEMFREE(pKvsPeerConnection->pTwccManager);
}

PROFILE_WITH_START_TIME_OBJ(startTime, pKvsPeerConnection->peerConnectionDiagnostics.freePeerConnectionTime, "Free peer connection");
SAFE_MEMFREE(*ppPeerConnection);
CleanUp:

if (pKvsPeerConnection != NULL && IS_VALID_MUTEX_VALUE(pKvsPeerConnection->twccLock)) {
if (twccLocked) {
MUTEX_UNLOCK(pKvsPeerConnection->twccLock);
twccLocked = FALSE;
}
MUTEX_FREE(pKvsPeerConnection->twccLock);
}
LEAVES();
return retStatus;
}
Expand Down
6 changes: 3 additions & 3 deletions src/source/PeerConnection/Rtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ STATUS onRtcpTwccPacket(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConn
STATUS retStatus = STATUS_SUCCESS;
PTwccManager pTwccManager = NULL;
BOOL locked = FALSE;
UINT64 sn = 0;
UINT16 baseSeqNum = 0;
UINT64 localStartTimeKvs, localEndTimeKvs;
UINT64 sentBytes = 0, receivedBytes = 0;
UINT64 sentPackets = 0, receivedPackets = 0;
Expand All @@ -330,14 +330,14 @@ STATUS onRtcpTwccPacket(PRtcpPacket pRtcpPacket, PKvsPeerConnection pKvsPeerConn
locked = TRUE;
pTwccManager = pKvsPeerConnection->pTwccManager;
CHK_STATUS(parseRtcpTwccPacket(pRtcpPacket, pTwccManager));
sn = pTwccManager->prevReportedBaseSeqNum;
baseSeqNum = pTwccManager->prevReportedBaseSeqNum;

// Use != instead to cover the case where the group of sequence numbers being checked
// are trending towards MAX_UINT16 and rolling over to 0+, example range [65534, 10]
// We also check for twcc->lastReportedSeqNum + 1 to include the last seq number in the
// report. Without this, we do not check for the seqNum that could cause it to not be cleared
// from memory
for (seqNum = sn; seqNum != (pTwccManager->lastReportedSeqNum + 1); seqNum++) {
for (seqNum = baseSeqNum; seqNum != (pTwccManager->lastReportedSeqNum + 1); seqNum++) {
if (!localStartTimeRecorded) {
// This could happen if the prev packet was deleted as part of rolling window or if there
// is an overlap of RTP packet statuses between TWCC packets. This could also fail if it is
Expand Down
5 changes: 3 additions & 2 deletions tst/RtcpFunctionalityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ static void parseTwcc(const std::string& hex, const uint32_t expectedReceived, c
RtcConfiguration config{};
UINT64 value;
UINT16 twsn;
UINT16 i = 0;
UINT32 extpayload, received = 0, lost = 0;

rtcpPacket.header.packetLength = payloadLen / 4;
Expand All @@ -333,7 +334,7 @@ static void parseTwcc(const std::string& hex, const uint32_t expectedReceived, c
UINT16 baseSeqNum = getUnalignedInt16BigEndian(rtcpPacket.payload + 8);
UINT16 pktCount = TWCC_PACKET_STATUS_COUNT(rtcpPacket.payload);

for(auto i = baseSeqNum; i < baseSeqNum + pktCount; i++) {
for(i = baseSeqNum; i < baseSeqNum + pktCount; i++) {
rtpPacket.header.extension = TRUE;
rtpPacket.header.extensionProfile = TWCC_EXT_PROFILE;
rtpPacket.header.extensionLength = SIZEOF(UINT32);
Expand All @@ -345,7 +346,7 @@ static void parseTwcc(const std::string& hex, const uint32_t expectedReceived, c

EXPECT_EQ(STATUS_SUCCESS, parseRtcpTwccPacket(&rtcpPacket, pKvsPeerConnection->pTwccManager));

for(auto i = 0; i < MAX_UINT16; i++) {
for(i = 0; i < MAX_UINT16; i++) {
if(hashTableGet(pKvsPeerConnection->pTwccManager->pTwccRtpPktInfosHashTable, i, &value) == STATUS_SUCCESS) {
PTwccRtpPacketInfo tempTwccRtpPktInfo = (PTwccRtpPacketInfo) value;
if(tempTwccRtpPktInfo->remoteTimeKvs == TWCC_PACKET_LOST_TIME) {
Expand Down

0 comments on commit 2ef577f

Please sign in to comment.