From 52656bb89314142c5c96d7bbfcdf452235603a28 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 3 Dec 2021 17:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DmediaserverId=E6=9C=AA?= =?UTF-8?q?=E5=AD=98=E5=85=A5=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/conf/ProxyServletConfig.java | 12 ++++++++-- .../service/impl/MediaServerServiceImpl.java | 4 +++- .../vmp/storager/dao/MediaServerMapper.java | 24 +++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) 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);