mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 20:26:05 -05:00
When an event is streamed by zms (the MJPEG/mpeg path, not the video.js MP4
player), zms advanced to the next/prev event itself with a hardcoded query:
SELECT Id FROM Events WHERE MonitorId = <same> AND Id <>> <current> ...
That ignores the filter and sort the user is viewing, so gapless playback of a
cross-monitor filtered list skipped every event that did not belong to the
current event's monitor -- e.g. playing monitor A's event jumped straight to
A's next event, hopping over all the interleaved monitor B events. The earlier
getNearEvents fix only corrected the video.js path and the Prev/Next buttons;
this zms auto-advance was a separate path and still wrong.
Rather than reimplement filter/sort knowledge in C++, let the UI -- which
already computes the correct next/prev from the active filter via getNearEvents
-- tell zms which events those are. A new CMD_SET_EVENT command carries a
direction, a target event id, and the source event the hint was computed for;
EventStream stores them and checkEventLoaded loads the UI-provided event when
advancing. When the UI has not supplied a usable hint it falls back to the
existing by-monitor query, so behaviour is unchanged for clients that do not
send the command.
The event view sends CMD_SET_EVENT for both next and prev after each
getNearEvents response, but only when playback is served by zms (vid == null);
the video.js path already navigates correctly on its own.
Hardening in this path:
- Authorisation: zms only authorises the event the stream started on and loads
forwarded targets without re-checking, so a client could hand it an event
from a monitor it cannot view. ajax/stream.php now resolves the target's
monitor and requires canView('Events', MonitorId) before forwarding (gated on
ZM_OPT_USE_AUTH, matching zms).
- Filter boundaries: getNearEvents returns 0 when the filter has no neighbour
in a direction. A hint now records whether the UI supplied a value, so an
explicit 0 stops at the boundary instead of being treated as "no hint" and
falling back to the same-monitor query (which would leave the filtered list).
- Stale hints: next and prev arrive as separate requests and can land out of
order. Each hint carries the source event id; processCommand refuses to store
one whose source is not the event playing (so a late command cannot overwrite
a valid hint), and checkEventLoaded honours a stored hint only while its
source still matches. The event view tags each hint with the getNearEvents
response's own EventId, not the current event, so a slow response cannot send
a self-referential hint that loops zms on one event.
- Deleted targets: a cached neighbour may be removed by retention or another
user before it is used. checkEventLoaded checks existence first and falls back
rather than hitting loadEventData's fatal "not found" path; ajax/stream.php
treats a target that no longer exists as a filter boundary instead of
returning an error that would flag the stream broken and stop UI polling.
- Cross-resolution MPEG: the mpeg encoder is created once at the first event's
dimensions and cannot resize mid-stream. Frame and text-frame paths share a
scaleToEncoder() helper that scales a later, differently sized image (a
cross-monitor advance, or a boundary text frame built at another monitor's
size) to the encoder's dimensions before encoding rather than overrunning its
buffers.
- Portable packing: stream.php encodes the ids as big-endian 32-bit words
instead of pack('J'), which 32-bit PHP (still supported in the status decode)
cannot feed a 64-bit value.
Known limitation: in a multi-server install with non-shared storage a
cross-monitor neighbour can live on another server, whose recording this zms
cannot read. Such an advance degrades to failed frames; zms self-advance is
effectively same-server (or shared-storage) only. Routing it to the serving
server, as the video.js reload path does, is left to a separate change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Modern ZoneMinder Skin
This web frontend to ZoneMinder is a complete rewrite of the classic frontend, based on CakePHP.