Address rtsp consumer review findings:
- MonitorRtspStream drops media whose generation does not match the one
the current xop session was built for. After a parameter change the
reader thread records the new HELLO and generation before the main
thread rebuilds the session; feeding that media to the old packer
produced codec-mismatch output. Update() now also rebuilds on a
generation change and treats audio as current only when its generation
matches the video's, so an audio stream dropped at a generation bump is
not rebuilt into the new session.
- Stop and join each packer's write thread (StopAndJoin) before deleting
the source, while the object is still the most-derived type. The write
thread calls the virtual PushFrame; joining only in the base destructor
raced it against a call that had devolved to the pure base.
- Use 8 kHz as the G.711 timebase fallback when the HELLO omits the
sample rate, rather than the AAC-oriented 44.1 kHz default.
refs #5143
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T4UcdJLt1bxwdpcigGxZRD
zm_rtsp_server now consumes the per-monitor stream socket instead of
the media FIFOs; zm_monitor's FIFO output is now unconsumed in-tree.
Source classes: the FIFO read thread, 'ZM <size> <pts>' header parsing,
memmem resync scanning and 4KB chunk buffer are gone from
ZoneMinderStreamSource. Packets arrive via OnPacket(data, size, pts);
the NAL/OBU splitting, parameter-set extraction and FU fragmentation
logic is unchanged. Constructors lose the fifo path argument.
zm_rtsp_server.cpp: each monitor gets a MonitorRtspStream owning a
StreamSocketClient. Sessions are built from the HELLO handshake instead
of guessing: codec chosen by codec id (H264/HEVC/AV1, AAC/G711A/G711U)
rather than sniffing the fifo path extension, AAC sample rate and
channel count come from the HELLO rather than shared memory, and the
HELLO extradata primes the packers (replacing the FIFO's
extradata-before-keyframe rewrites). When stream parameters change -
camera reconfigure or zmc restart with a different codec - the session
is rebuilt; a condition variable wakes the main loop so rebuilds do not
wait out the 10s poll. The monitor poll loop, RTSPServer gating and
last-viewed accounting are retained.
Known limitation: xop RtspServer::RemoveSession in dep/RtspServer has
pre-existing thread-safety issues, so frequent runtime session
recreation (a camera whose parameters change often) should wait for a
fix in that dependency.
Tests: full suite 103/103 via ctest; all binaries build with no new
warnings.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mechanical rename ahead of the transport swap: the source classes that
pack NALs/OBUs for the xop RTSP layer are about to be fed from the
monitor stream socket instead of the media FIFOs.
zm_rtsp_server_fifo_*.{h,cpp} -> zm_rtsp_server_stream_*.{h,cpp};
ZoneMinder*FifoSource -> ZoneMinder*StreamSource and codec subclasses to
match; include guards and CMake source list updated. No behavioural
change - the sources still read the FIFOs in this commit.
Tests: full build green; suite 103/103 via ctest.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>