What's New
Video Support
- H.264 (RFC 6184) — packetization mode 1, FU-A fragmentation, STAP-A aggregation, keyframe detection
- VP8 (RFC 7741) — S-bit frame start, marker-bit frame end, bitstream keyframe detection
- VP9 (RFC 9628) — B/E bit frame boundaries, scalability structure parsing, flexible mode
- VideoRTPSession — codec-aware depacketization, RTCP feedback (PLI/NACK/FIR), keyframe gating after loss
- Codec dispatch registry (
_VideoCodecHandler) eliminates if-chains for 3 video codecs
RTCP Improvements
- Sender Reports now include the real RTP timestamp (was hardcoded to 0)
- Receiver Reports generated from
StreamStatistics with LSR/DLSR
- Incoming RR processing —
on_receiver_report callback, exposed in stats
- FIR handling — Full Intra Request treated like PLI
- NACK retransmission — sender keeps packet history buffer, retransmits on incoming NACK
Architecture
- BaseRTPSession extracted — eliminates ~150 lines of duplicated lifecycle/RTCP code between audio and video sessions
- DtmfSender encapsulation — uses
RtpSender.send_raw() instead of mutating private state
- PortAllocator — managed even/odd RTP/RTCP port pairs, wired into sessions as optional parameter
Developer Experience
- Auto-timestamps —
send_audio_auto(), send_audio_pcm_auto(), send_frame_auto() with configurable fps
- GitHub CI — test matrix (Python 3.11/3.12/3.13), ruff lint+format, bandit security scan, mypy typecheck
- 208 tests covering all codecs, sessions, RTCP, jitter buffer, DTMF, and port allocator
Bug Fixes
- Fix VP9 layer indices: 2 bytes in non-flexible mode per RFC 9628 §4.2
- Fix
_pending_payloads ordering: sort by sequence number before depacketization
- Bound
_pending_payloads to 32 timestamps to prevent memory leaks
- Fix PLI recovery: preserve current frame payloads instead of clearing all
- Fix
update_remote port-0 handling
- Fix VP9 scalability structure bounds check on malformed input
- Fix
__version__ to match pyproject.toml
Install
pip install aiortp==0.3.0