Repository navigation
feat: robust RTP depacketizer — STAP-A/AP, CSRC/extension, loss handling (#10) - #47
Conversation
PR Summary by QodoHandle RTP aggregation, variable headers, and fragmented NAL loss
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1.
|
NalAssembler now takes the whole RTP packet at an offset and hands every complete NAL unit to a sink (fixes #10): - The real RTP header length is used (CSRC list, header extension, padding) instead of a fixed 12 bytes; such packets were dropped before. - Aggregation packets are split: STAP-A (H.264) and AP (H.265), as some servers send SPS/PPS/VPS that way. - RTP sequence numbers are tracked (with wrap-around). A fragmented NAL unit with a missing piece, a continuation without its start, or a start without its end is dropped instead of being passed on corrupted. - A NAL unit larger than the buffer is dropped instead of silently truncated. - Single NAL units are copied straight from the packet, and the per packet copy into a Frame in RtspClient/QuadCell is gone. Tests: STAP-A, AP, truncated aggregation, CSRC + extension + padding, malformed headers, lost middle fragment, continuation without start, start without end, loss between single NALs, sequence wrap, oversized NAL, offset input.
- A continuation without its FU start is counted as one dropped unit (not once per piece, and not again after a loss already counted it). - Any non-FU packet ends an unfinished fragmented NAL unit, so a later continuation cannot attach to stale bytes. - "Queue full" warnings are rate-limited in both sinks; one aggregation packet can carry many NAL units. - Quad cells return decoded NAL frames to the pool.
ab87348 to
13bc771
Compare
feat: robust RTP depacketizer — STAP-A/AP, CSRC/extension, loss handling (#10)
Fixes #10.
Changes in
NalAssemblerassemble()returned oneFrameassemble(buf, offset, length, h265, sink)hands every NAL toSink(an aggregation packet yields several)Side effects:
RtspClientandQuadCellno longer copy each video packet into aFramebefore parsing; the NAL is built straight from the receive buffer.RtspSession.rtpPayloadEnd()gets a variant with an offset.Diagnostics:
droppedCount()counts dropped NAL units. The log records the first three and then every hundredth.Tests
68 in total; 12 of them are new in
NalAssemblerTest.lostMiddleFragmentDropsTheNal.Notes
#10line in the README's "Known limitations" will be removed after feat: RTSP Digest authentication and keepalive (#8, #11) #46 is merged, to avoid a conflict in the same block.