Manage live video stream lifecycle across multiple viewers
Multiple viewers interrupt the same live video stream
I have tested the same JT808/JT1078 live stream from multiple devices.
When a second or third device opens the same device and channel, the existing viewers lose playback and only the most recently connected viewer continues working.
All viewers request the same server-side HLS playlist and segments. The problem appears to be the hardware stream lifecycle: every player sends its own videoStart when mounted and videoStop when unmounted.
Current behavior:
Viewer A opens channel 1
→ videoStart
Viewer B opens channel 1
→ another videoStart
Viewer B closes or remounts
→ videoStop
Viewer A loses the streamExample captured for the same device and channel:
11:51:09 videoStart
11:51:32 videoStop
11:51:33 videoStart
11:51:37 videoStop
11:52:02 videoStart
11:52:54 videoStopDuring the failure, the remaining clients continued requesting the same HLS playlist, but it returned an empty 73-byte playlist.
Expected behavior:
- the first viewer starts the device stream;
- additional viewers reuse the existing stream;
- closing one viewer does not stop the stream for others;
- the stream stops only after the last viewer leaves.
A frontend-only counter would not work across different browsers and devices, so the active viewer count would need to be coordinated server-side.
I can work on the implementation once the preferred approach is confirmed.
Source: traccar/traccar