diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java index 93b975e2..a6facd57 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java @@ -143,9 +143,13 @@ public class ProxyServletConfig { MediaServerItem mediaInfo = getMediaInfoByUri(requestURI); String url = super.rewriteUrlFromRequest(servletRequest); if (mediaInfo == null) { + logger.error("[ZLM服务访问代理],错误:处理url信息时未找到流媒体信息=>{}", requestURI); return url; } - return url.replace(mediaInfo.getId() + "/", "").replace("default/", ""); + if (!StringUtils.isEmpty(mediaInfo.getId())) { + url = url.replace(mediaInfo.getId() + "/", ""); + } + return url.replace("default/", ""); } } @@ -258,9 +262,13 @@ public class ProxyServletConfig { MediaServerItem mediaInfo = getMediaInfoByUri(requestURI); String url = super.rewriteUrlFromRequest(servletRequest); if (mediaInfo == null) { + logger.error("[录像服务访问代理],错误:处理url信息时未找到流媒体信息=>{}", requestURI); return url; } - return url.replace(mediaInfo.getId() + "/", "").replace("default/", ""); + if (!StringUtils.isEmpty(mediaInfo.getId())) { + url = url.replace(mediaInfo.getId() + "/", ""); + } + return url.replace("default/", ""); } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 3339676e..78911cd5 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -324,6 +324,9 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR } if (StringUtils.isEmpty(serverItem.getId())) { serverItem.setId(zlmServerConfig.getGeneralMediaServerId()); + mediaServerMapper.updateByHostAndPort(serverItem); + }else { + mediaServerMapper.update(serverItem); } if (redisUtil.get(VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + serverItem.getId()) == null) { SsrcConfig ssrcConfig = new SsrcConfig(serverItem.getId(), null, sipConfig.getDomain()); @@ -332,7 +335,6 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR } serverItem.setStatus(true); - mediaServerMapper.update(serverItem); resetOnlineServerItem(serverItem); setZLMConfig(serverItem); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java index 8cd5d6a9..aaa18459 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerMapper.java @@ -88,6 +88,30 @@ public interface MediaServerMapper { " "}) int update(MediaServerItem mediaServerItem); + @Update(value = {" "}) + int updateByHostAndPort(MediaServerItem mediaServerItem); + @Select("SELECT * FROM media_server WHERE id='${id}'") MediaServerItem queryOne(String id);