Avoid spurious audio data loss warning on connection start

This commit is contained in:
Cameron Gutman 2021-06-03 21:02:27 -05:00
parent ef33aaa3c8
commit a8aed6b344

View File

@ -167,6 +167,15 @@ static PRTPA_FEC_BLOCK getFecBlockForRtpPacket(PRTP_AUDIO_QUEUE queue, PRTP_PACK
return NULL; return NULL;
} }
// Synchronize the nextRtpSequenceNumber and oldestRtpBaseSequenceNumber values
// when the connection begins. Start on the next FEC block boundary, so we can
// be sure we aren't starting in the middle (which will lead to a spurious audio
// data block recovery warning on connection start if we miss more than 2 packets).
if (queue->nextRtpSequenceNumber == UINT16_MAX && queue->oldestRtpBaseSequenceNumber == 0) {
queue->nextRtpSequenceNumber = queue->oldestRtpBaseSequenceNumber = fecBlockBaseSeqNum + RTPA_DATA_SHARDS;
return NULL;
}
// Drop packets from FEC blocks that have already been completed // Drop packets from FEC blocks that have already been completed
if (isBefore16(fecBlockBaseSeqNum, queue->oldestRtpBaseSequenceNumber)) { if (isBefore16(fecBlockBaseSeqNum, queue->oldestRtpBaseSequenceNumber)) {
return NULL; return NULL;
@ -390,13 +399,6 @@ int RtpaAddPacket(PRTP_AUDIO_QUEUE queue, PRTP_PACKET packet, uint16_t length) {
return 0; return 0;
} }
// Synchronize the nextRtpSequenceNumber and oldestRtpBaseSequenceNumber values
// when the connection begins. We want to always start on FEC block boundaries.
if (queue->nextRtpSequenceNumber == UINT16_MAX && queue->oldestRtpBaseSequenceNumber == 0) {
queue->nextRtpSequenceNumber = queue->oldestRtpBaseSequenceNumber = fecBlock->fecHeader.baseSequenceNumber;
validateFecBlockState(queue);
}
if (packet->packetType == 97) { if (packet->packetType == 97) {
uint16_t pos = packet->sequenceNumber - fecBlock->fecHeader.baseSequenceNumber; uint16_t pos = packet->sequenceNumber - fecBlock->fecHeader.baseSequenceNumber;