A pOnvif problem could delete and re-create the whole camera node, which
dropped the video stream bound to it, so recordings were cut although the
video was fine.
deviceNodeCamera::validate() compared the whole camera record with
memcmp; any difference rebuilt the node:
- CAM_WS_INIT sets m_sCamData.online = false before re-creating the
PTZ protocol and writes the DB only afterwards. A validate() during a
slow ONVIF re-init saw "online" differ and deleted the camera
mid-re-init.
- The ONVIF discovery (updateIPCam) wrote online=1 and the whole XAddrs
list into onvif_ctrl (the web UI and la_mojo store only the path), so
the record changed on discovery rounds.
- A failed read (SQLite busy, queries fail at once) returned NULL =
"camera deleted".
Now:
- Field classes (camDataChange):
- runtime and discovery fields (online, status, session, max_range,
uuid, mac): ignored;
- name and hardware: taken over;
- PTZ access (onvif_ctrl, onvif_access, port, auth_mode, ptz_token):
the camera thread re-creates only the PTZ protocol, keeping the node
and the stream;
- anything else (ip and credentials used by the stream, stream_id,
type, geometry, ...): rebuild as before, logged with the reason.
- A lasting PTZ problem rebuilds the camera only after
CAM_REBUILD_AFTER_FAILED_INITS (10) failed protocol initialisations
in a row (several minutes with the retry back-off).
- Node / camera record not read: rebuild only after
NODE_DATA_MISSES_TO_REBUILD (3) validations in a row, for all nodes
(deviceNode::validate).
- updateIPCam: onvif_ctrl = path of the first XAddr. Host and port come
from the first XAddr only: ':' was searched in the whole list, so a
second, IPv6 XAddr gave a broken IP. A result without an address
doesn't wipe the IP.
Tested (functions extracted unchanged): camDataChange classifies
online / status / max_range / uuid / mac as ignored, rename as
cosmetic, port / onvif_ctrl / auth / ptz token as PTZ re-init, and ip /
password / stream / geometry as rebuild. The XAddrs parser was checked
with a port, without a port, with an IPv6 second XAddr, with a query, and
with no address.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
PTZ health per camera (deviceNodeCamera):
- PTZ_HEALTH_INFO: state (NONE / INIT / OK / FAILED), failure and
recovery counters, consecutive failed initialisations, time of the
last state change / failure, next retry and the last error text.
getPtzHealth() returns a copy (mutex-protected, any thread).
- getPtzStatus() - already sent to the remote server as
CAMERA_STATUS_PTZ_OK - now reflects it: 1 for OK (or no PTZ protocol),
0 while PTZ is initialising or failed. Before it was 1 as soon as the
state machine left CAM_WS_INIT, whatever the protocol did.
Failure detection and re-initialisation:
- While idle (CAM_WS_READY) the camera checks the protocol's validate()
every loop and calls the new protocolPTZ::probe() every 30 s
(ONVIF: GetStatus; a SOAP Fault still means "reachable", only a
communication error marks the camera lost). Default probe() is the
protocol's validate(), so serial protocols are unchanged.
- On failure the PTZ protocol is recreated through CAM_WS_INIT: first
attempt at once, then 5, 10, 20, 40, 60 s (capped) between attempts;
recoveries are logged and counted.
- A failed target-driven goAbsolute/goPreset no longer ends the camera
thread (CAM_WS_END rebuilt the whole node): for ONVIF a command the
camera rejected (connection OK) only drops that ROI, anything else
re-initialises the PTZ protocol.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Target-driven moves of deviceNodePTZCamControl (AbsoluteMove) and
deviceNodePresetCamControl (preset for the ROI) both end in
CAM_WS_WAIT_ONPOS, which waits for the end of the move and then
broadcasts EVT_CAMERA_ON_POSITION (EVT_CLASS_CAMERA_CTRL).
- AbsoluteMove: with video output enabled (m_bSkeepPositioningWait) the
event was broadcast right after the command, before the camera moved.
It now always goes through CAM_WS_WAIT_ONPOS, like the preset path.
- New m_bNoMoveDoneReport: set when the protocol cannot report the end
of a move (waitMoveIsDone() returns false). Then a fixed
CAM_MOVE_FIXED_WAIT_MS (3 s) wait is used before the event. Before, the
same failure set m_bSkeepPositioningWait, which made every later
AbsoluteMove broadcast the event immediately. Reset when the protocol
is (re)created.
- protocolPTZ_ONVIF::goPreset: forget the last AbsoluteMove target so
waitMoveIsDone() cannot end early by comparing with it.
Homing, init go-home and web/IR/wiper presets are unchanged (no event).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16