fix: 配置推送时增强 rtsp_url 日志和校验
当摄像头没有有效的 RTSP 地址时: 1. 添加详细的警告日志,说明可能的原因(stream_proxy 表或媒体服务器配置) 2. 添加 rtsp_url_valid 标志位,方便 Edge 端调试 这有助于排查为什么推送配置后 Edge 无法连接视频流。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -527,24 +527,39 @@ public class AiRedisConfigServiceImpl implements IAiRedisConfigService {
|
||||
// cameraId格式为 {app}/{stream},ZLM的RTSP路径直接使用该格式
|
||||
try {
|
||||
MediaServer mediaServer = mediaServerService.getDefaultMediaServer();
|
||||
if (mediaServer != null && mediaServer.getRtspPort() != 0) {
|
||||
if (mediaServer == null) {
|
||||
log.warn("[AiRedis] 无法获取媒体服务器配置,请检查 ZLM 媒体服务器是否已配置");
|
||||
} else if (mediaServer.getRtspPort() != 0) {
|
||||
rtspUrl = String.format("rtsp://%s:%s/%s",
|
||||
mediaServer.getStreamIp() != null ? mediaServer.getStreamIp() : mediaServer.getIp(),
|
||||
mediaServer.getRtspPort(), cameraId);
|
||||
} else if (mediaServer != null) {
|
||||
log.debug("[AiRedis] 使用媒体服务器构建RTSP: {}", rtspUrl);
|
||||
} else if (mediaServer.getHttpPort() != 0) {
|
||||
rtspUrl = String.format("http://%s:%s/%s.live.flv",
|
||||
mediaServer.getStreamIp() != null ? mediaServer.getStreamIp() : mediaServer.getIp(),
|
||||
mediaServer.getHttpPort(), cameraId);
|
||||
log.debug("[AiRedis] 使用媒体服务器构建HTTP: {}", rtspUrl);
|
||||
} else {
|
||||
log.warn("[AiRedis] 媒体服务器 {} 未配置 RTSP/HTTP 端口", mediaServer.getIp());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("[AiRedis] 获取媒体服务器信息失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
cameraMap.put("rtsp_url", rtspUrl);
|
||||
cameraMap.put("camera_name", cameraName);
|
||||
cameraMap.put("enabled", true);
|
||||
cameraMap.put("location", "");
|
||||
|
||||
// 如果没有有效的 RTSP URL,记录警告但仍然添加摄像头(让 Edge 知道它的存在)
|
||||
if (rtspUrl == null || rtspUrl.isEmpty()) {
|
||||
log.warn("[AiRedis] 摄像头 {} 没有有效的 RTSP 地址(请检查 stream_proxy 表或媒体服务器配置)", cameraId);
|
||||
cameraMap.put("rtsp_url", "");
|
||||
cameraMap.put("rtsp_url_valid", false);
|
||||
} else {
|
||||
cameraMap.put("rtsp_url", rtspUrl);
|
||||
cameraMap.put("rtsp_url_valid", true);
|
||||
}
|
||||
cameras.add(cameraMap);
|
||||
|
||||
// 该摄像头下的 ROI 和绑定
|
||||
|
||||
Reference in New Issue
Block a user