diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 7b3f0b21..67be2471 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -119,8 +119,8 @@ public interface ISIPCommander { /** * 视频流停止 */ - void streamByeCmd(String deviceId, String channelId, String ssrc, SipSubscribe.Event okEvent); - void streamByeCmd(String deviceId, String channelId, String ssrc); + void streamByeCmd(String deviceId, String channelId, String stream, SipSubscribe.Event okEvent); + void streamByeCmd(String deviceId, String channelId, String stream); /** * 回放暂停 diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java index de5d4832..9d0e354c 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java @@ -92,6 +92,7 @@ public class ZLMRunner implements CommandLineRunner { // 获取所有的zlm, 并开启主动连接 List all = mediaServerService.getAllFromDatabase(); + mediaServerService.updateVmServer(all); if (all.size() == 0) { all.add(mediaConfig.getMediaSerItem()); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java index 3a4c3ee2..2e8a68ee 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java @@ -42,6 +42,8 @@ public interface IMediaServerService { void setZLMConfig(MediaServerItem mediaServerItem, boolean restart); + void updateVmServer(List mediaServerItemList); + SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId); SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, boolean isPlayback); @@ -74,6 +76,8 @@ public interface IMediaServerService { void delete(String id); + void deleteDb(String id); + MediaServerItem getDefaultMediaServer(); void updateMediaServerKeepalive(String mediaServerId, JSONObject data); 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 6a5642e1..4f08c99d 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 @@ -46,8 +46,7 @@ import java.util.*; * 媒体服务器节点管理 */ @Service -@Order(value=2) -public class MediaServerServiceImpl implements IMediaServerService, CommandLineRunner { +public class MediaServerServiceImpl implements IMediaServerService { private final static Logger logger = LoggerFactory.getLogger(MediaServerServiceImpl.class); @@ -102,9 +101,8 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR * 初始化 */ @Override - public void run(String... args) throws Exception { + public void updateVmServer(List mediaServerItemList) { logger.info("[缓存初始化] Media Server "); - List mediaServerItemList = mediaServerMapper.queryAll(); for (MediaServerItem mediaServerItem : mediaServerItemList) { if (StringUtils.isEmpty(mediaServerItem.getId())) { continue; @@ -225,7 +223,8 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR String key = (String) mediaServerKey; MediaServerItem mediaServerItem = (MediaServerItem) redisUtil.get(key); // 检查状态 - if (redisUtil.zScore(onlineKey, mediaServerItem.getId()) != null) { + Double aDouble = redisUtil.zScore(onlineKey, mediaServerItem.getId()); + if (aDouble != null) { mediaServerItem.setStatus(true); } result.add(mediaServerItem); @@ -610,6 +609,11 @@ public class MediaServerServiceImpl implements IMediaServerService, CommandLineR String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + id; redisUtil.del(key); } + @Override + public void deleteDb(String id){ + //同步删除数据库中的数据 + mediaServerMapper.delOne(id); + } @Override public void updateMediaServerKeepalive(String mediaServerId, JSONObject data) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java index c27fb0e1..1500f351 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -158,6 +158,7 @@ public class ServerController { public WVPResult deleteMediaServer(@RequestParam String id){ if (mediaServerService.getOne(id) != null) { mediaServerService.delete(id); + mediaServerService.deleteDb(id); }else { WVPResult result = new WVPResult<>(); result.setCode(-1);