mirror of
https://github.com/livekit/livekit.git
synced 2026-12-04 14:58:09 +00:00
master
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ee75008bea |
Generate downstream FlexFEC with per-track protection modes (#5195)
* Do not recover FlexFEC from RTX repaired packets A packet repaired from RTX takes its header from the RTX packet: libwebrtc adds a MID to retransmissions until the RTX SSRC is acknowledged, and sets abs-send-time and transport-cc at send time. The stored packet therefore differs from the media the publisher protected, so using it as a protected packet recovered the wrong length, failing with "invalid recovered packet size", or silently corrupted the recovered packet's header extensions when the length happened to match. Like libwebrtc's FlexfecReceiver, which skips packets recovered by RTX, mark RTX repaired sequence numbers and treat them as missing for FEC recovery. They are still forwarded and update NACK state as before. With a libwebrtc publisher at 10% upstream loss, every recovery attempt in a block containing a retransmitted packet failed; with retransmissions excluded recoveries succeed. * Move RTX repair tracking into BufferBase Keep the RTX repaired history, its lookup and the publisher sequence number extension in BufferBase, so every buffer built on it, such as the relay, can exclude RTX repaired packets from FlexFEC recovery the same way. The history is now cleared with the rest of the sequence number state when the stream restarts. Buffer only marks repaired packets from writeRTX. Packets recovered by FEC also enter with isRTX set, but they are exact reconstructions and stay usable, so marking is explicit rather than tied to that flag. * Keep RTX-repaired history safe with large packet caches The RTX repair history had 512 fixed slots. With a larger video packet cache, e.g. packet_buffer_size_video: 1500, two cached repairs could share a slot, the earlier mark was lost, and FlexFEC could recover from the altered retransmission. - Size the history from the video packet cache, at least 512 slots, and allocate it on the first repair. - When a later repair reuses a slot, the earlier packet counts as repaired: losing a recovery is better than corrupting one. - Do not mark a retransmission of a packet that is already cached. The bucket rejects it as a duplicate and keeps the exact packet, which stays usable for recovery. - Mark a repair before ingesting it and do not feed RTX repaired packets to the FEC decoder, as BufferBase now feeds ingested media to the decoder. * Generate downstream FlexFEC with per-track protection presets Generate FlexFEC-03 repairs for subscribed video tracks. Subscribers select none (default), low, medium or high through UpdateTrackSettings.fec; repairs require rtc.flexfec.downstream_enabled and negotiated flexfec-03 support. Generate repairs at each frame marker, splitting large frames into blocks of at most 48 packets, with upstream Q8 repair-count rounding and at least one repair per block. Reserve measured repair overhead during layer allocation and charge repair traffic to pacing, bandwidth estimation and metrics. Carry repair sequence state through the DownTrack GetState/SeedState handoff, apply subscriber settings from immutable snapshots, and preserve upstream FEC on shared sendrecv codec lists when downstream generation is disabled. This squashes the three commits of dc/feature/fec_down ( |
||
|
|
8179b3a117 |
Do not recover FlexFEC from RTX repaired packets (#5194)
* Do not recover FlexFEC from RTX repaired packets A packet repaired from RTX takes its header from the RTX packet: libwebrtc adds a MID to retransmissions until the RTX SSRC is acknowledged, and sets abs-send-time and transport-cc at send time. The stored packet therefore differs from the media the publisher protected, so using it as a protected packet recovered the wrong length, failing with "invalid recovered packet size", or silently corrupted the recovered packet's header extensions when the length happened to match. Like libwebrtc's FlexfecReceiver, which skips packets recovered by RTX, mark RTX repaired sequence numbers and treat them as missing for FEC recovery. They are still forwarded and update NACK state as before. With a libwebrtc publisher at 10% upstream loss, every recovery attempt in a block containing a retransmitted packet failed; with retransmissions excluded recoveries succeed. * Move RTX repair tracking into BufferBase Keep the RTX repaired history, its lookup and the publisher sequence number extension in BufferBase, so every buffer built on it, such as the relay, can exclude RTX repaired packets from FlexFEC recovery the same way. The history is now cleared with the rest of the sequence number state when the stream restarts. Buffer only marks repaired packets from writeRTX. Packets recovered by FEC also enter with isRTX set, but they are exact reconstructions and stay usable, so marking is explicit rather than tied to that flag. * Keep RTX-repaired history safe with large packet caches The RTX repair history had 512 fixed slots. With a larger video packet cache, e.g. packet_buffer_size_video: 1500, two cached repairs could share a slot, the earlier mark was lost, and FlexFEC could recover from the altered retransmission. - Size the history from the video packet cache, at least 512 slots, and allocate it on the first repair. - When a later repair reuses a slot, the earlier packet counts as repaired: losing a recovery is better than corrupting one. - Do not mark a retransmission of a packet that is already cached. The bucket rejects it as a duplicate and keeps the exact packet, which stays usable for recovery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep the newest RTX repair mark of a history slot A late retransmission of an older packet that has aged out of the cache overwrote the slot of a newer repair sharing it. The newer repair, which carries the RTX packet's header, could then be used for FlexFEC recovery and corrupt the recovered packet. Keep the highest extended sequence number written to a slot until the stream restarts. isRTXRepairedLocked already treats an older packet in a slot with a newer mark as repaired. --------- Co-authored-by: Jules Testard <jules.testard@livekit.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
35c4357d90 |
migrate FEC logic into buffer_base (#5039)
* Add upstream FlexFEC recovery support * Guard short TWCC extensions in FEC packets * Release completed FlexFEC states * Validate FlexFEC payload type range * Invoke FEC callbacks after unlocking * Reduce FlexFEC protection state allocations * Avoid allocations for complete FlexFEC packets * Optimize ordered FlexFEC packet insertion * Reuse RTP packet storage for FlexFEC recovery * Limit pending FlexFEC repair packets * Lower FlexFEC repair window to two seconds * Harden upstream FlexFEC handling * Test FlexFEC with E2EE media * Fix FlexFEC negotiation with libwebrtc publishers * Enhance payload length validation in decoder Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * remove the ability to configure payload type for FlexFEC * moved some helpers into protocol * Handle big gaps in media sequence numbers Reset buffers when a big gap in media sequence numbers is detected. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * bump protocol & psrpc deps * Handle FEC packet recovery failure Increment FEC packets discarded counter and remove packet. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * do not NACK on fec recovered packet (#4896) * do not NACK on fec recovered packet * fix test race in CI * Fix FEC write return after merging RTX feedback changes * PR fixes for FlexFEC implementation (#4898) * do not NACK on fec recovered packet * refactor common code into unlockAndInvokeFECRecovery * add FEC stats to RTPStats * add log for when fecdecoder unavailable after creation * rename markAsFECRepair to setFECRepairBufferLimit for clarity * refactor packet generation for tests into util * fix test race in CI * move the unlocks back inline for readability * update RTPstats * Fix FEC write return after merging RTX feedback changes * Use shared RTP packet helper in merged FEC NACK test * Remove redundant return from FEC write handler * packet post process (#5020) * packet post process * remove redundant writeRTX * send out RTCP (NACK and RR) from packetPostProcess only * handle FEC decoder on receiver restart (#5032) * handle FEC decoder on receiver restart * move onStreamRestartLocked into BufferBaseParams * migrate fec into buffer_base --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Raja Subramanian <raja.gobi@tutanota.com> Co-authored-by: Jules Testard <jules.testard@livekit.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
e269e3e355 |
Update webrtc fork to dtls1.3 (#5142)
* Update webrtc fork to dtls1.3 * update dep * Remove debug line * Fix test |
||
|
|
6342d8fd1b |
Enable upstream FlexFEC03 (#4845)
* Add upstream FlexFEC recovery support * Guard short TWCC extensions in FEC packets * Release completed FlexFEC states * Validate FlexFEC payload type range * Invoke FEC callbacks after unlocking * Reduce FlexFEC protection state allocations * Avoid allocations for complete FlexFEC packets * Optimize ordered FlexFEC packet insertion * Reuse RTP packet storage for FlexFEC recovery * Limit pending FlexFEC repair packets * Lower FlexFEC repair window to two seconds * Harden upstream FlexFEC handling * Test FlexFEC with E2EE media * Fix FlexFEC negotiation with libwebrtc publishers * Enhance payload length validation in decoder Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * remove the ability to configure payload type for FlexFEC * moved some helpers into protocol * Handle big gaps in media sequence numbers Reset buffers when a big gap in media sequence numbers is detected. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * bump protocol & psrpc deps * Handle FEC packet recovery failure Increment FEC packets discarded counter and remove packet. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * do not NACK on fec recovered packet (#4896) * do not NACK on fec recovered packet * fix test race in CI * Fix FEC write return after merging RTX feedback changes * PR fixes for FlexFEC implementation (#4898) * do not NACK on fec recovered packet * refactor common code into unlockAndInvokeFECRecovery * add FEC stats to RTPStats * add log for when fecdecoder unavailable after creation * rename markAsFECRepair to setFECRepairBufferLimit for clarity * refactor packet generation for tests into util * fix test race in CI * move the unlocks back inline for readability * update RTPstats * Fix FEC write return after merging RTX feedback changes * Use shared RTP packet helper in merged FEC NACK test * Remove redundant return from FEC write handler * packet post process (#5020) * packet post process * remove redundant writeRTX * send out RTCP (NACK and RR) from packetPostProcess only * handle FEC decoder on receiver restart (#5032) * handle FEC decoder on receiver restart * move onStreamRestartLocked into BufferBaseParams --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Raja Subramanian <raja.gobi@tutanota.com> |