fix: work around GStreamer jitterbuffer stall after mute gap#472
Merged
fix: work around GStreamer jitterbuffer stall after mute gap#472
Conversation
Add per-buffer packet counters at every element in the WHEP pipeline chain (NiceSrc through LiveAdder) to diagnose intermittent audio delivery failures. Activated via STROM_WHEP_PROBE=1, output written to file (path configurable via STROM_WHEP_PROBE_DIR). Uses AtomicU64 counters only in the hot path — no mutex, no allocation, no string formatting in buffer probe callbacks. A periodic reporter task writes changed counters to a log file every 5 seconds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Set drop-on-latency=true on rtpbin in WHEP input blocks (both whepsrc and whepclientsrc). This works around a long-standing GStreamer bug where rtpjitterbuffer's calculate_packet_spacing interprets the RTP timestamp jump after a mute gap as packet spacing. The corrupted spacing causes lost timers to be scheduled far in the future, stalling audio output for the duration of the mute gap when packet loss occurs after unmute. Upstream references (none merged as of 2026-04): - https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/570 - https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/951 - https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/221 Includes regression test reproducing the bug with and without the fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extend the jitterbuffer packet_spacing workaround to all input blocks that use rtpjitterbuffer: WHIP ingest (whipserversrc) and AES67 input. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The jitterbuffer_mute_test requires rtpjitterbuffer from plugins-good. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
drop-on-latency=trueon rtpbin in WHEP input blocks to work around a GStreamer rtpjitterbuffer bug that causes audio to stall after mute/unmute with packet lossSTROM_WHEP_PROBE=1)The bug
GStreamer's
rtpjitterbufferhas acalculate_packet_spacingfunction that uses an exponential moving average to estimate the time between packets. When a mute gap ends (RTP resumes with continuous sequence numbers but a large timestamp jump), the function interprets the timestamp jump as packet spacing. If packet loss then occurs, lost timers are scheduled based on this corrupted spacing — potentially seconds or minutes into the future — stalling audio output.This has been a known issue upstream since 2018 with multiple unmerged fix attempts:
The workaround
drop-on-latency=truecauses the jitterbuffer to drop queued packets exceeding the configured latency, advancingnext_seqnumpast the stall point. For live audio this is the correct behavior — packets older than the latency window should never be output.Test plan
test_jitterbuffer_stalls_without_drop_on_latency— proves the bug existstest_jitterbuffer_recovers_with_drop_on_latency— proves the workaround worksdrop-on-latency=TRUEvisible on rtpjitterbuffer for both whepsrc and whepclientsrc🤖 Generated with Claude Code