Assert that recovered packets are valid

This commit is contained in:
Cameron Gutman 2018-09-04 22:13:37 -07:00
parent ea0f06ded0
commit ddab05c56e
2 changed files with 14 additions and 0 deletions

View File

@ -160,6 +160,18 @@ cleanup_packets:
PNV_VIDEO_PACKET nvPacket = (PNV_VIDEO_PACKET)(((char*)rtpPacket) + dataOffset);
nvPacket->frameIndex = queue->currentFrameNumber;
// Do some rudamentary checks to see that the recovered packet is sane
if (i == 0) {
LC_ASSERT(nvPacket->flags & FLAG_SOF);
}
if (i == queue->bufferDataPackets - 1) {
LC_ASSERT(nvPacket->flags & FLAG_EOF);
}
if (i > 0 && i < queue->bufferDataPackets - 1) {
LC_ASSERT(nvPacket->flags & FLAG_CONTAINS_PIC_DATA);
}
LC_ASSERT((nvPacket->flags & ~(FLAG_SOF | FLAG_EOF | FLAG_CONTAINS_PIC_DATA)) == 0);
// FEC recovered frames may have extra zero padding at the end. This is
// fine per H.264 Annex B which states trailing zero bytes must be
// discarded by decoders. It's not safe to strip all zero padding because

View File

@ -467,6 +467,8 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, unsigned long l
flags = videoPacket->flags;
firstPacket = isFirstPacket(flags);
LC_ASSERT((flags & ~(FLAG_SOF | FLAG_EOF | FLAG_CONTAINS_PIC_DATA)) == 0);
streamPacketIndex = videoPacket->streamPacketIndex;
// The packets and frames must be in sequence from the FEC queue