Fix xiaomi/cs2 stream restart on pop buffer overflow - #2377
Open
DongbinNie wants to merge 1 commit into
Open
Conversation
When the media channel pop buffer fills up (e.g. the consumer pipeline is temporarily slower than the camera: CPU throttling, slow downstream client), dataChannel.Push returned a fatal error, which killed the whole camera connection and forced a stream restart with re-probing. Users saw repeated 'miss: read media: cs2: pop buffer is full' warnings and periodic video interruptions. Drop the oldest queued packet instead of failing the connection. Consumers already tolerate packet loss (RTP sequence gaps) and decoders resync on the next keyframe, which is far better than restarting the whole stream. Also make the pop buffer size configurable via the 'buffer' URL param (default 256, previously hardcoded 100), so setups with slow consumers can trade memory for fewer drops, e.g. xiaomi://...&buffer=1024.
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.
Problem
When the media channel pop buffer (hardcoded capacity 100 packets) fills up — e.g. the consumer pipeline is temporarily slower than the camera (CPU throttling, slow downstream client) —
dataChannel.Pushreturns a fatal error. This kills the whole camera connection and forces a stream restart with re-probing. Users see repeated warnings:and periodic video interruptions (in my setup every ~10 seconds).
Fix
bufferURL param (default 256, previously hardcoded 100), so setups with slow consumers can trade memory for fewer drops, e.g.xiaomi://...&buffer=1024.Tested with a chuangmi.camera.81ac1 (cs2+tcp): the stream no longer restarts under consumer-side slowdowns.