When the embedded recorder writes segments (live_mode on, live_record on),
the alarm clips now come from those segments and the old encoder is not
started, so the video is no longer encoded and written twice.
- Recorder: ServerConf::onSegmentDone is called for every closed segment
(file, local start time, duration, size).
- kernelModuleEmbedVideo keeps the closed segments of each path for
3 minutes. An alarm (saveStreamPicture -> clipAlarm) hands over the
segments within 5 s before / 5 s after it to the kernel like the old
encoder's clips (hard link <scratch>/<md5>.mp4 + EVT_CAPTURE_DONE). The
event is bound to the segment it happened in, with its frame offset.
Old and left-over segments are deleted (sweepClips); the MediaMTX
helper no longer indexes or deletes them.
- With live_record off the old encoder makes the clips as before.
- streamHandler: no encoder thread in decode-only mode (it left an empty
segment file in the scratch folder per stream).
- VIDEO_SEGMENT_INFO of EVT_CAPTURE_DONE is a heap copy owned by the
receiver (mojoKernel deletes it). The old encoder memcpy'd a struct
with std::vector members (shared buffers) and leaked the copy.
- streamHandler: m_mEncodedProtector was unlocked every frame without
being locked when EVE_WORK_WITH_MEDIAMTX is defined.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Earlier edits rewrote these files with LF endings, which made the diff
show every line as changed. Content is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
- Move reusable MediaMtx code (logger, codecs, stream, httpp, recorder,
webrtc server) to lib/data/media/mtx; add ServerConf, MediaPath/
PathProvider and H264Feeder. Standalone Projects/MediaMtx builds against it.
- kernelModuleEmbedVideo hosts a WHEP server (:8889/stream_<node>/whep)
and one MediaPath per camera stream with fMP4 segment recording.
- streamHandler feeds each path either with camera H264 passthrough
(videoAVLIBSource / videoLive555AVLibSource forward encoded NALs) or
with re-encoded processed frames incl. overlays (streamLiveEncoder),
selected by module_eve.live_mode (optional columns, defaults apply).
- kernelHelperMediaMTX: external mediamtx.service is stopped, segment
indexing of the scratch folder is kept.
- live555 watch variable type deduced so old and new live555 build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Every pass of the mojo kernel loop ran these synchronously; each could
stall the loop (and get la_mojo killed by the watchdog):
- Report cleanup (validateReports -> deleteReportDate): deleteRDFDir
ran "rm -f -R <whole day>" (seconds to minutes on an SD card), daily or
every second while the disk is above preserve_empty. The day is now
deleted in a background thread (one at a time; calls during it return
false). ~sqliteDBC waits for a running deletion (max 60 s).
- MediaMTX (validateService -> restart): "systemctl restart" waited for
the service to stop and start, every second if the config kept failing
validation. Now "systemctl --no-block restart" (only queues the job),
at most once per KH_MTX_RESTART_MIN_S (30 s).
- IP UART serial provider (hardwareManager::validate -> create_SOL): a
blocking connect() to an address that doesn't answer took ~2 min (SYN
retries). Now non-blocking with SERIAL_SOL_CONNECT_TIMEOUT_MS (5 s),
the socket mode restored afterwards, and the socket closed on failure
(it leaked).
- Ethernet2UART gateway nodes: hardwareManager::validate (kernel loop)
validated and reconnected them again, although the node factory thread
does it (deviceNode::validate). Connects of up to 5 s blocked the kernel
loop, plus the wait for the node's connection lock.
hardwareResource::selfValidating() (default false) is true for
deviceETH2UART, and the hardware manager skips such resources.
Tested: the connect timeout on its own (extracted unchanged). A peer
that drops the SYN failed after 5002 ms ("Connection timed out") instead
of ~2 min; refused and accepted connects are immediate; the socket is
blocking again in every case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16