Skip to content

fix(rtp): unwrap long sequences, scan late RTP, cap totals, one deadline, drop FU-A gaps - #36

Merged
dexRand merged 1 commit into
mainfrom
feat/26-rtp-order
Nov 19, 2026
Merged

dexRand merged 1 commit into
mainfrom
feat/26-rtp-order

Conversation

@dexRand

@dexRand dexRand commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Fixes the five defects from the ARBITER REJECT of 20c7fee (#26).

Cosa

  • order_packets: unwraps the 16-bit RTP sequence to a 32-bit extended sequence in arrival order (dedup + sort). 40k in-order packets and real 65535→0 wraps keep order.
  • Gate: scans the whole capture up to MAX_SCAN_PACKETS + a byte bound, so RTP after the first 5000 frames is found (no more analysis lost).
  • parse_capture: global byte budget (MAX_TOTAL_BYTES=96 MiB) + SSRC cap (MAX_SSRCS=32), enforced before retaining payload.
  • One shared FFMPEG_BUDGET_S=240 deadline across all ffmpeg calls; no call starts after it.
  • depacketize_h264: a sequence gap in an FU-A fragment drops the partial NAL instead of emitting a corrupt one.

Come è stata lavorata

  • Builder (ASU-001) in worktree feat/26-rtp-order (TDD: 7 test nuovi che fallivano col codice vecchio), poi ARBITER a contesto pulito: 1 giro, APPROVE.
  • Verifica: unit 542 passed (20 in test_rtp.py, 7 nuovi) · ./ctf lint clean · real case wani24-streamer.pcap [PASS].

Rischi residui

  • Il gate ora cammina l'intero capture (bounded a 500k pacchetti): un pcap senza RTP costa ~3.6 s invece dei ~36 ms di prima (solo per file .pcap; i non-pcap escono al magic in millisecondi). Conseguenza diretta e voluta del "scan the whole capture".
  • Un capture con RTP viene letto due volte (gate + scan completo): design a due passi, I/O dimezzabile in futuro unendo rilevazione e retention in un solo passaggio.

Closes #26

…ine, drop FU-A gaps

- order_packets unwraps the 16-bit RTP sequence into a 32-bit extended
  sequence in arrival order, so captures past 32768 packets and real
  65535->0 wraps keep their order; dedup is unchanged.
- The presence gate now walks the whole capture (bounded by
  MAX_SCAN_PACKETS and GATE_BYTES) so RTP starting after 5000 frames is
  still found, while the full scan stays a separate bounded pass.
- parse_capture enforces MAX_TOTAL_BYTES across all SSRCs and MAX_SSRCS
  candidate streams, checked before retaining payload.
- run() computes one FFMPEG_BUDGET_S deadline shared by every ffmpeg
  call; _extract_frames never starts a call after it expires.
- depacketize_h264 tracks the expected next sequence while reassembling
  FU-A and drops a partial NAL when the sequence jumps.

Tests: 542 passed (7 new, 535 pre-existing).
Real case: wani24-streamer.pcap PASS 194.0 s.
Lint: ./ctf lint clean; docker compose config -q ok.

Refs #26
@dexRand
dexRand merged commit d0e6852 into main Nov 19, 2026
6 checks passed
@dexRand
dexRand deleted the feat/26-rtp-order branch November 19, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtp: wrong packet order past 32768 packets, video after the first 5000 packets missed

1 participant