Commit Graph
717 Commits
Author SHA1 Message Date
Isaac Connor f6586acf07 Merge pull request #6698 from AJ0070/fix-rtsp2web-path-prefix
fix: keep the ZM_RTSP2WEB_PATH path prefix in browser stream URLs
2026-11-18 23:31:00 -05:00
singhharsh1708 0d1e30f654 fix: treat empty boolean config as off in the js logger 2026-11-18 23:34:03 +05:30
Jash 0828401324 fix: keep the ZM_RTSP2WEB_PATH path prefix in browser stream URLs refs #6697 2026-11-18 18:39:25 +05:30
Isaac Connor cb265a4fd4 Merge pull request #6546 from AJ0070/fix-stopmse-resolve
fix: MonitorStream stopMse resolves with an empty source buffer list
2026-11-17 19:18:50 -05:00
Isaac Connor ae49dd0148 Merge pull request #6524 from singhharsh1708/fix/dms-negative-degrees
fix: negative degrees in the monitor DMS location fields
2026-11-17 08:22:01 -05:00
Isaac Connor 65cf2e38a7 Revert "fix: choose the event player client-side so HEVC plays natively when supported" 2026-11-17 08:00:47 -05:00
Isaac Connor 4a05a4d58c Merge pull request #6454 from AJ0070/fix-linkui-null-values
fix: Linked Monitors editor null and blank bracket values
2026-11-16 22:49:40 -05:00
Jash d204919adb fix: MonitorStream stopMse resolves when there is no source buffer to clear refs #6545 2026-11-17 09:00:27 +05:30
Jash 1aa94411fc fix: Linked Monitors editor never writes null or a stray 0 into the expression refs #6453 2026-11-17 08:21:59 +05:30
Isaac Connor dfa8150977 Merge pull request #6422 from AJ0070/fix-monitorstream-player-state
fix: MonitorStream volume listener, failed-player restart and maxfps
2026-11-16 20:43:18 -05:00
singhharsh1708 1d38d0cc3f fix: negative degrees in the monitor DMS location fields 2026-11-17 03:53:41 +05:30
Jash 1a33a08b1f fix: panzoom disable removes its wheel listener refs #6473 2026-11-16 19:09:58 +05:30
Jash e2425bb42d fix: keep MonitorStream volume sync after pause, let Play retry after all players failed, send maxfps only to zms refs #6421 2026-11-16 15:23:28 +05:30
Isaac ConnorandClaude Opus 4.8 b4e6ad2053 fix: address review on the event player selection
- Escape the emitted stream URLs (mp4Src/hlsSrc/zmsImgSrc) with validJsStr like
  every other JS string. They carry query params that can include the session
  username and an auth hash, so an unescaped quote or backslash could break out
  of the JS string literal.
- For codec=auto, offer the HLS source only for a live event. The codec probe
  that selected the native player tested the recorded mp4, so a finished event
  plays that mp4 directly; HLS is needed only while the manifest is still growing
  at the recording edge. Keeps the played source consistent with what was probed.
- Drop the meaningless format=h264 from the auto mp4 src: view_video serves the
  raw recorded file and ignores format.
- Give the caption track a valid data URI media type (text/vtt).

tests/js/event-player-selection.test.js gains cases for the live-vs-finished HLS
source ordering (7 assertions total).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-15 21:24:31 -05:00
Isaac ConnorandClaude Opus 4.8 696ebecd1c fix: choose the event player client-side so HEVC plays natively when supported
The event view decided server-side (event.php $video_tag) whether to play the
recording's MP4 directly or fall back to a zms MJPEG re-stream. For H.265/HEVC
on codec=auto it always chose zms, because PHP cannot know whether the browser
can decode HEVC. On busy or high-resolution installs that zms process misses its
per-second status check, flooding the logs (web_php timeout, web_js error,
"Can't sendto on sd N") and stuttering, even on browsers that could have played
the file natively.

Move the decision to the browser, which is the only place that knows. For
codec=auto, event.php now renders a single-frame JPEG placeholder and emits the
candidate stream sources; after load, EventStream.chooseEventPlayer() uses the
existing canPlayCodec() probe to build the native video.js player when the
browser can decode the file's codec, otherwise the zms <img> the rest of
event.js already drives. The explicit MP4 / MP4HLS / MJPEG codec picks stay
server-rendered and unchanged.

This also capability-gates AV1 on auto (previously always native, which could
fail silently on browsers without AV1 decode).

Stage 1: the zms fallback keeps the legacy <img id="evtStream"> path, so every
existing zms function in event.js is untouched. Migrating that path onto the
EventStream canvas client is a later change.

The player-selection logic lives in web/js/EventStream.js
(canPlayFile/buildMp4Player/buildZmsImg/chooseEventPlayer);
tests/js/event-player-selection.test.js covers the branch and the DOM each side
builds (5 assertions).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-15 21:24:31 -05:00
Isaac Connor 511b18ef92 Merge pull request #6070 from AJ0070/sonnet-js-zone-link
fix: tokenize linked monitor expressions with parentheses
2026-11-15 21:13:00 -05:00
Jash 74ef5cacaf fix: carry rounded seconds in DMS coordinates instead of showing 60 seconds refs #6075 2026-11-16 01:54:01 +05:30
Jash e0a1f40d15 fix: tokenize linked monitor expressions with parentheses refs #6069 2026-11-16 01:47:37 +05:30
Isaac Connor 66c585b10a Merge pull request #5723 from AJ0070/nosocket-grace
fix: tolerate a brief no_socket so stream.php can stop waiting a second for zms
2026-11-14 19:45:28 -05:00
Isaac Connor 7d3a95182a Merge pull request #5789 from AJ0070/monitorstream-fixes
fix: MonitorStream reconnect timer on stop, RTSP2Web wss and buffer level
2026-11-14 18:53:27 -05:00
Isaac Connor 46930054bd Merge pull request #5793 from AJ0070/watch-fixes
fix: watch page state, handlers, resize observer and controls
2026-11-14 18:51:51 -05:00
Isaac Connor 29dab837ca Merge pull request #5895 from AJ0070/map-fixes
fix: map popups, empty map, fit to monitors, DMS fields and empty locations
2026-11-14 18:44:51 -05:00
Jash f85dc1f41a fix: remove the previous wheel listener when zoom and pan is re-enabled refs #5902 2026-11-14 22:54:00 +05:30
Jash 9ac91480a9 fix: fit the map view to the located monitors refs #5894 2026-11-14 22:47:56 +05:30
Jash afdbe9db6a fix: show 0% instead of NaN% on the map view when no monitor has a location refs #5894 2026-11-14 22:47:56 +05:30
Jash 3423b18e27 fix: use the default server for map popups of monitors without a ServerId refs #5894 2026-11-14 22:47:56 +05:30
Jash 58f65af18e fix: stop percent-encoding client log messages before they are posted refs #5816 2026-11-14 18:46:13 +05:30
Jash 7f3f64be6e fix: show the zoom readout when zoomed and register the zoom-out button under its real key refs #5792 2026-11-14 18:27:23 +05:30
Jash 61e2e8c08e fix: keep the watch ResizeObserver on the current stream element refs #5792 2026-11-14 18:27:23 +05:30
Jash d06954cb5f fix: look up the per-monitor buffer level element refs #5788 2026-11-14 18:22:32 +05:30
Jash 8f583d307a fix: use wss for the RTSP2Web MSE websocket on https servers refs #5788 2026-11-14 18:22:31 +05:30
Jash 41a98654ad fix: cancel pending auth reconnect when a stream is stopped refs #5788 2026-11-14 18:22:31 +05:30
Jash ce1b37d174 fix: retry a stream command until no_socket persists before treating it as fatal refs #5722 2026-11-14 17:37:51 +05:30
Isaac ConnorandClaude Opus 5.5 f223b38e04 fix: ignore MonitorStream replies for a connkey that was already replaced
When a monitor's zms exits, the status poll gets reason=no_socket and the
stream is reloaded under a new connkey. A no_socket reply takes over a second
(stream.php waits for the socket file to appear) while the poll runs every
second, and every request on the page shares one ajaxQueue, so a second poll
for the dead connkey is usually already queued when the first reply arrives.
Its reply then reloaded the stream again: it sent CMD_QUIT to the zms the
first reload had just started and replaced the connkey a second time.

Each restart of an unreachable monitor therefore left an orphaned zms behind,
and a poll queued for that orphan between the two reloads could find it
shutting down. stream.php then waited the full MSG_TIMEOUT and logged
"Timed out waiting for msg ... after waiting 5000 milliseconds", while every
other monitor's poll on the page waited behind it in the shared queue.

Bind each reply to the connkey its request was sent with and drop replies
for a connkey we no longer hold, as EventStream already does. alarmCommand()
passes its connkey explicitly, since binding getStreamCmdResponse directly
would hand it jQuery's textStatus in that argument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 17:12:27 -04:00
IgorA100 310a71e31e Refactor RTSP2WebType handling in MonitorStream
Removed conditional check for RTSP2WebType and added comments indicating its potential redundancy.
2026-10-23 10:44:47 +03:00
IgorA100 8d1a9054ec - On the Zone page, when changePlayer() is called, execute monitorStream.start() with a 200ms delay; otherwise, the preceding stop() call might not have enough time to complete properly.
- When calling `monitorStream.manageAvailablePlayers()`, now pass the candidate player as an argument instead of determining the player from stored cookies inside `manageAvailablePlayers()`. This is necessary because cookies could belong to either the Watch page or the Zone page.
- On the Zone page, load `hls.min.js` if Go2RTC or RTSP2Web is being used for the monitor.
- `monitorStream.setPlayer()` is now executed within `monitorStream.manageAvailablePlayers()`. Previously, `manageAvailablePlayers()` only handled the assignment of `monitorStream.player`.
- Added a new function, `this.setRTSP2WebType()`, to avoid code duplication. This ensures that `RTSP2WebType` is checked and set even if `setPlayer()` is not called on the page.
- Minor optimization regarding variable usage.
- If `hls.min.js` is not loaded, attempting to play via HLS will now trigger a "The HLS library is not loaded" warning in the browser console and initiate a stream restart. Previously, this would result in an error.
2026-10-17 20:54:57 +03:00
IgorA100 75fa7e2df0 Update Janus condition to include 'zone' view 2026-10-16 17:07:41 +03:00
IgorA100 9996e8967f Fix syntax error in MonitorStream.js 2026-10-16 13:09:18 +03:00
IgorA100 a266a82998 Refactor Janus handling in MonitorStream.js
- The `janus` variable is no longer global; it now belongs to `MonitorStream`.
- In the `Janus.init` callback, do not perform any actions if the monitor is in a stopping state or is already stopped.
- Check for the existence of the `destroy` method before calling `janus.destroy()`.
- Allow the Janus player to be selected in `this.selectPlayer` regardless of the `streamChannel` on the Montage page. This will not cause visual confusion, as the Montage page does not allow selecting a `streamChannel` (it uses the default one). 
However, if the default `streamChannel` is a secondary one and the default player is set to Janus, the Janus player would never be selected on the Montage page. I believe this is incorrect, as we should allow for more flexibility.
2026-10-16 13:05:33 +03:00
IgorA100 c398c6356e Avoiding errors when stopping a Janus stream (MonitorStream.js) 2026-10-15 23:22:24 +03:00
Isaac ConnorandClaude Opus 5.5 575e5484b3 fix: skip an unconfigured go2rtc under the Auto player
With its player left on Auto, a monitor with go2rtc enabled had
selectNextPlayer() pick go2rtc_webrtc first, and with ZM_GO2RTC_PATH
empty select_go2rtc() then alerted "ZM_GO2RTC_PATH is empty", on the
montage for every such monitor, although nobody had chosen go2rtc.

The fallback chain already skipped go2rtc for a monitor without it
enabled; skip it when ZM_GO2RTC_PATH is empty too. A monitor or browser
that chose go2rtc reaches select_go2rtc() directly and still gets the
alert.

A node test drives selectPlayer() through the restart chain for Auto
without a path, Auto with one, and go2rtc chosen explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 18:36:33 -04:00
Isaac ConnorandClaude Opus 5.5 c3ff83fa56 fix: do not use the RTSP restream when ZM_MIN_RTSP_PORT is not set
ZoneMinder's RTSP server only starts when ZM_MIN_RTSP_PORT is set, and it
defaults to empty. The go2rtc and Janus managers decided to use the
restream from the monitor's RTSP Server flag (Janus: its restream flag)
alone, so with the port unset they built rtsp://127.0.0.1:0/<name>.
go2rtc was given that as the monitor's primary stream and as
<id>_ZoneMinderPrimary, neither of which can play; Janus pointed its
mountpoint at it.

Use the restream only when the port is set as well, and warn when a
monitor asks for it without one, so the camera's own stream is used.
MonitorStream applies the same test before choosing the
_ZoneMinderPrimary stream, which is no longer registered in that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 18:34:04 -04:00
Isaac ConnorandClaude Opus 5.5 0d6ebcd42c fix: accept ZM_GO2RTC_PATH with or without its /api suffix
go2rtc serves its API under /api, and its websocket at /api/ws. zmc
appends /streams to ZM_GO2RTC_PATH and the browser appends /ws, so the
setting only worked if it ended in /api. The natural value to enter is
the server address, http://host:1984, and with that zmc reached
/streams, which is go2rtc's RTSPtoWeb compatibility endpoint, so no
stream was ever registered, and the browser's /ws was a 404. Where
another player was available the failure went unnoticed.

Normalise the setting where URLs are built from it: a trailing slash is
dropped and /api is added unless the path already ends in it, which also
covers go2rtc behind a reverse proxy at a sub-path.

- Go2RTCApiEndpoint() in zm_utils, used by zmc's Go2RTCManager.
- go2rtcApiUrl() in skin.js, used by MonitorStream and the console
  thumbnail stream. It assigns the path once, since stripping the slash
  from a bare host's "/" and appending gave "//api", as the old
  pathname += '/ws' gave "//ws".
- The option's help says the suffix is optional.

Catch2 and node tests cover bare hosts, trailing slashes, an existing
/api, a proxy sub-path and credentials in the URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 18:34:04 -04:00
Isaac ConnorandClaude Opus 5 a5860e02b2 fix: read MJPEG frames with createImageBitmap so Firefox keeps up
EventStream receives the stream into a DOM <img> and copies it to the
canvas from a rAF loop.  Gecko hands canvas drawImage() the frame the
img held when it was first decoded and never refreshes that snapshot,
so a multipart/x-mixed-replace img drawn to a canvas repaints one frame
forever while the stream keeps arriving.  Montage review showed a single
frozen frame in Firefox while the timeline advanced; Chrome, whose
drawImage() tracks the element, played the same streams normally.

createImageBitmap() reads the frame the element is showing now.  It is
async, so a tick is skipped while a request is outstanding rather than
queueing requests up behind the stream rate, and the pending flag is
cleared on teardown along with the img.

The img is left offscreen: measured against a reference
multipart/x-mixed-replace server, an img at left:-9999px, 1x1,
visibility:hidden still yields a fresh frame on every
createImageBitmap(), so Gecko is not culling the decode.

Verified against montage review on Firefox 154 and Chrome 154, driving
both from a script that hashes each monitor's canvas 40 times at 250ms:
before, Firefox saw 1 distinct frame per canvas and Chrome 40; after,
both see 40.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KLYswrguKc6bBYL8JZbpmZ
2026-10-05 17:24:13 -04:00
Isaac ConnorandClaude Opus 5 9f69694f67 fix: define the bootstrap-table icons before the view scripts refs #5153
icons is the toolbar icon map that thirteen view scripts, and logpanel.js,
pass to bootstrapTable(). It was defined in skin.js, which xhtmlFooter()
loads last of all, after every view's own script. A client that loads the
whole page is fine, because skin.js still runs before DOMContentLoaded,
but one that stops short -- a crawler that caps resource loading, an
aborted load -- runs the view's ready handler against an undefined icons
and the table never initialises:

  Uncaught ReferenceError: icons is not defined
      at HTMLDocument.initPage (.../views_js_console-....js:458:12)

Move it to web/js/table-helpers.js, which already exists to hold what the
bootstrap-table views share and is loaded well before them, and export it
alongside the other helpers for the node tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-26 11:23:38 -04:00
Isaac ConnorandClaude Opus 5 428c048bac feat: measure the audio level on demand, with a meter in the editor
Reverts the previous commit's always-on measurement. Decoding audio for every
monitor that has it spends CPU on a number almost nothing reads, which is the
wrong trade even though it did solve the chicken and egg of picking a
threshold without ever seeing a level.

Measure when something is actually going to use the reading instead:

 - AudioDetection is on, as before, so nothing changes for a monitor that
   scores on audio; or
 - somebody asked. SharedData gains audio_level_until, a wall clock second
   the capture thread keeps measuring up to. The monitor editor's new level
   meter pushes it forward while it is on screen and the measurement lapses a
   few seconds after the page is left, so nothing has to send a stop and a
   crashed browser cannot leave a monitor decoding forever.

When the reading stops being wanted the decoder is released and the published
level and peak are cleared, so a stale number is not left looking current and
an old peak does not land on the next frame row written.

audio_level_until is carved out of analysis_pad rather than appended, so
SharedData stays 888 bytes and no existing offset moves; the static_asserts,
Memory.pm and Monitor.php are updated together and all three now agree the
field is at +880.

The meter itself is on the audio settings, shown whether or not
AudioDetection is checked, because the level is what you need in order to
choose a threshold. It draws the threshold currently in the input as a mark on
the bar so a reading can be judged against it before saving, and a monitor
whose zmc is not running reads "no reading" rather than a confident 0, which
would be indistinguishable from silence.

Frames.AudioLevel is therefore 0 again on monitors that do not score on audio.
That is what the graph already treats as "no audio data", so it draws no line
rather than a flat one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JpiSWBmtQkR5bcgpHWY4ME
2026-09-20 18:17:44 -05:00
Isaac ConnorandClaude Opus 5 4619258293 feat: measure the audio level whatever AudioDetection is set to
Gating the measurement on AudioDetection made the graph useless for the job
it is most wanted for. AudioThreshold is a per-device number -- the floor on
one camera's mic is nothing like another's -- so it has to be measured before
it can be set, but nothing was measured until it was already set. Enabling
detection with a guessed threshold to find out what the real one should be is
backwards.

The level is now read for every monitor with decodable audio.  AudioDetection
governs only whether crossing the threshold contributes a score, which is
what the setting is named for. shared_data->audio_alarm stays 0 when it is
off, so nothing downstream changes for a monitor that does not want audio
alarms.

Nothing here depends on Analysing either. The measurement is in
Monitor::Capture, which runs on whatever Analysing is set to, and frame rows
come from Event::AddFrame, which a continuously recording monitor reaches
through the RECORDING_ALWAYS path with motion detection off. So a monitor
that only records continuously still gets levels on its rows.

Since Monitor::Capture retries Open on every audio packet until it succeeds,
and that now happens for every monitor with audio rather than the handful with
detection on, AudioDetector remembers a codec it has already failed to find a
decoder for. Without it a stream ZoneMinder cannot decode logs a warning at
the audio packet rate for as long as the monitor runs. A reconnect bringing a
different codec is still tried.

The cost is one audio decode per monitor with audio, where before it was one
per monitor with detection enabled. That is small next to the video path, but
it is not nothing on a box with many cameras.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JpiSWBmtQkR5bcgpHWY4ME
2026-09-20 18:17:44 -05:00
Isaac ConnorandClaude Opus 5 4ea307a1cf feat: graph motion score and audio level under the event video
The cue strip under the video showed one flat red band per alarm period. It
tried to encode the score as a bar height, 'height: '+frame.Score+'px', but
never could: the frames ajax did not return Score, so every bar got
'height: undefinedpx' and fell back to the stylesheet's height: 100%. So the
motion level it looks like it is drawing has never actually been drawn.

Replace it with a line graph of both series over the length of the event. The
alarm periods stay, as a pale wash behind the lines, so nothing that was
readable before is lost.

The two series do not share a vertical scale. Audio level is 0-100 by
construction, but a motion score is a sum over zones with no upper bound, so
pinning both to 0-100 would flatten the audio line against the floor on any
event scoring above 100. Each is scaled to its own maximum, and hovering reads
out the exact values, which is what the numbers are wanted for. An event whose
rows are all zero -- recorded before the column existed, or by a monitor with
AudioDetection off -- draws no audio line at all, rather than a flat line
claiming silence was measured.

The readout goes into the existing #indicator, which already tracks the mouse
across the whole progress bar, instead of a second tooltip competing for the
same pixels.

The geometry lives in web/js/LevelGraph.js so it can be tested without a DOM,
and so the polyline and the hover readout cannot disagree about where a given
second sits. The bar grows from 1.25em to fit the graph, which needed two
consequential CSS changes: #indicator now spans the taller bar, and
.progressBox drops from 0.66 opacity to 0.25, because at full strength the
played part of the graph is unreadable behind it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JpiSWBmtQkR5bcgpHWY4ME
2026-09-20 18:17:44 -05:00
IgorA100 f1b89471e4 Avoiding errors when changing the "src" attribute during playback with go2rtc "video-stream.js"
This can happen, for example, on the Console page when hovering over an image thumbnail, because the `video-stream` element created for go2rtc in `createGo2rtcStream()` is not assigned an ID.
2026-09-19 23:46:24 +03:00
IgorA100 7e4159da81 Merge branch 'master' into patch-756163 2026-09-13 23:38:02 +03:00