Skip to content

Fix xiaomi/cs2 stream restart on pop buffer overflow - #2377

Open
DongbinNie wants to merge 1 commit into
AlexxIT:masterfrom
DongbinNie:fix-xiaomi-cs2-pop-buffer
Open

Fix xiaomi/cs2 stream restart on pop buffer overflow#2377
DongbinNie wants to merge 1 commit into
AlexxIT:masterfrom
DongbinNie:fix-xiaomi-cs2-pop-buffer

Conversation

@DongbinNie

Copy link
Copy Markdown

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.Push returns a fatal error. This kills the whole camera connection and forces a stream restart with re-probing. Users see repeated warnings:

miss: read media: cs2: pop buffer is full

and periodic video interruptions (in my setup every ~10 seconds).

Fix

  • 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 — far better than restarting the whole stream.
  • 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.

Tested with a chuangmi.camera.81ac1 (cs2+tcp): the stream no longer restarts under consumer-side slowdowns.

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.
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.

1 participant