Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing error handling concerns for an edge case #1443

Merged
merged 3 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/source/PeerConnection/JitterBuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ STATUS jitterBufferInternalParse(PJitterBuffer pJitterBuffer, BOOL bufferClosed)
} else {
lastNonNullIndex = index;
retStatus = hashTableGet(pJitterBuffer->pPkgBufferHashTable, index, &hashValue);
pCurPacket = (PRtpPacket) hashValue;
if (retStatus == STATUS_SUCCESS || retStatus == STATUS_HASH_KEY_NOT_PRESENT) {
retStatus = STATUS_SUCCESS;
if (retStatus == STATUS_HASH_KEY_NOT_PRESENT) {
// should be unreachable, this means hashTablContains() said we had it but hashTableGet() couldn't find it.
continue;
} else {
CHK(FALSE, retStatus);
CHK_STATUS(retStatus);
}
pCurPacket = (PRtpPacket) hashValue;
CHK(pCurPacket != NULL, STATUS_NULL_ARG);
curTimestamp = pCurPacket->header.timestamp;
// new timestamp on an RTP packet means new frame
if (curTimestamp != pJitterBuffer->headTimestamp) {
Expand Down Expand Up @@ -315,7 +317,9 @@ STATUS jitterBufferDropBufferData(PJitterBuffer pJitterBuffer, UINT16 startIndex
if (hasEntry) {
CHK_STATUS(hashTableGet(pJitterBuffer->pPkgBufferHashTable, index, &hashValue));
pCurPacket = (PRtpPacket) hashValue;
freeRtpPacket(&pCurPacket);
if (pCurPacket) {
freeRtpPacket(&pCurPacket);
}
CHK_STATUS(hashTableRemove(pJitterBuffer->pPkgBufferHashTable, index));
}
}
Expand Down Expand Up @@ -344,13 +348,8 @@ STATUS jitterBufferFillFrameData(PJitterBuffer pJitterBuffer, PBYTE pFrame, UINT
CHK(pJitterBuffer != NULL && pFrame != NULL && pFilledSize != NULL, STATUS_NULL_ARG);
for (; UINT16_DEC(index) != endIndex; index++) {
hashValue = 0;
retStatus = hashTableGet(pJitterBuffer->pPkgBufferHashTable, index, &hashValue);
CHK_STATUS(hashTableGet(pJitterBuffer->pPkgBufferHashTable, index, &hashValue));
jdelapla marked this conversation as resolved.
Show resolved Hide resolved
pCurPacket = (PRtpPacket) hashValue;
if (retStatus == STATUS_SUCCESS || retStatus == STATUS_HASH_KEY_NOT_PRESENT) {
retStatus = STATUS_SUCCESS;
} else {
CHK(FALSE, retStatus);
}
CHK(pCurPacket != NULL, STATUS_NULL_ARG);
partialFrameSize = remainingFrameSize;
CHK_STATUS(pJitterBuffer->depayPayloadFn(pCurPacket->payload, pCurPacket->payloadLength, pCurPtrInFrame, &partialFrameSize, NULL));
Expand Down
2 changes: 1 addition & 1 deletion tst/JitterBufferFunctionalityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ TEST_F(JitterBufferFunctionalityTest, fillDataReturnErrorWithImcompleteFrame)
EXPECT_EQ(STATUS_SUCCESS, jitterBufferPush(mJitterBuffer, mPRtpPackets[i], nullptr));
}

EXPECT_EQ(STATUS_NULL_ARG, jitterBufferFillFrameData(mJitterBuffer, buffer, 2, &filledSize, 0, 1));
EXPECT_EQ(STATUS_HASH_KEY_NOT_PRESENT, jitterBufferFillFrameData(mJitterBuffer, buffer, 2, &filledSize, 0, 1));

clearJitterBufferForTest();
MEMFREE(buffer);
Expand Down