From c3ff83fa56ba3df06f521b6865c93752eceb356d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 5 Oct 2026 18:26:43 -0400 Subject: [PATCH] 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/. go2rtc was given that as the monitor's primary stream and as _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 --- src/zm_monitor_go2rtc.cpp | 8 +++++++- src/zm_monitor_janus.cpp | 7 ++++++- web/js/MonitorStream.js | 5 ++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/zm_monitor_go2rtc.cpp b/src/zm_monitor_go2rtc.cpp index b716f2002..8d620e893 100644 --- a/src/zm_monitor_go2rtc.cpp +++ b/src/zm_monitor_go2rtc.cpp @@ -43,7 +43,13 @@ Monitor::Go2RTCManager::Go2RTCManager(Monitor *parent_) Warning("Go2RTC: No endpoint configured in ZM_GO2RTC_PATH, using default: %s", Go2RTC_endpoint.c_str()); } - Use_RTSP_Restream = parent->RTSPServer(); + // ZoneMinder's RTSP server only runs when ZM_MIN_RTSP_PORT is set, so without it + // there is no restream to point go2rtc at; use the camera's own stream instead. + Use_RTSP_Restream = parent->RTSPServer() && config.min_rtsp_port; + if (parent->RTSPServer() && !config.min_rtsp_port) { + Warning("Go2RTC: monitor %u has RTSP Server enabled but ZM_MIN_RTSP_PORT is not set, " + "so there is no restream; using the camera stream", parent->Id()); + } if (Use_RTSP_Restream) { if (parent->server_id) { Server server(parent->server_id); diff --git a/src/zm_monitor_janus.cpp b/src/zm_monitor_janus.cpp index a23bd9ef0..3a93f5098 100644 --- a/src/zm_monitor_janus.cpp +++ b/src/zm_monitor_janus.cpp @@ -39,7 +39,12 @@ Monitor::JanusManager::~JanusManager() { void Monitor::JanusManager::load_from_monitor() { //constructor takes care of init and calls add_to - Use_RTSP_Restream = parent->restream; + // The restream needs ZoneMinder's RTSP server, which only runs when ZM_MIN_RTSP_PORT is set. + Use_RTSP_Restream = parent->restream && config.min_rtsp_port; + if (parent->restream && !config.min_rtsp_port) { + Warning("Janus: monitor %u is set to use the RTSP restream but ZM_MIN_RTSP_PORT is not set, " + "so there is no restream; using the camera stream", parent->Id()); + } profile_override = parent->janus_profile_override; rtsp_session_timeout = parent->janus_rtsp_session_timeout; if ((config.janus_path != nullptr) && (config.janus_path[0] != '\0')) { diff --git a/web/js/MonitorStream.js b/web/js/MonitorStream.js index e566e5563..e82430621 100644 --- a/web/js/MonitorStream.js +++ b/web/js/MonitorStream.js @@ -35,7 +35,10 @@ function MonitorStream(monitorData) { this.RTSP2WebEnabled = monitorData.RTSP2WebEnabled; this.RTSP2WebType = null; this.StreamChannel = monitorData.StreamChannel; - this.RTSPServer = monitorData.RTSPServer; + // ZoneMinder's RTSP restream only exists when its RTSP server runs, which needs + // ZM_MIN_RTSP_PORT; without it zmc registers no ZoneMinderPrimary stream. + this.RTSPServer = monitorData.RTSPServer && + (typeof ZM_MIN_RTSP_PORT !== 'undefined') && !!ZM_MIN_RTSP_PORT; this.Go2RTCEnabled = monitorData.Go2RTCEnabled; this.Go2RTCMSEBufferCleared = true; this.currentChannelStream = null;