From 37a84e66917d6e22e03e31b0a115e2c16d23ed21 Mon Sep 17 00:00:00 2001 From: 朱俊杰 <502612493@qq.com> Date: 星期四, 10 二月 2022 14:45:33 +0800 Subject: [PATCH] 新增实时监控功能 --- src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 59 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 1c8f191..afac6eb 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -59,6 +59,9 @@ private IRedisCatchStorage redisCatchStorage; @Autowired + private IVideoManagerStorager storager; + + @Autowired private UserSetup userSetup; @Autowired @@ -146,20 +149,23 @@ result.append(", 鍏宠仈鍥芥爣骞冲彴[ " + param.getPlatformGbId() + " ]澶辫触"); } } - // 鏌ユ壘寮�鍚簡鍏ㄩ儴鐩存挱娴佸叡浜殑涓婄骇骞冲彴 - List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); - if (parentPlatforms.size() > 0) { - for (ParentPlatform parentPlatform : parentPlatforms) { - param.setPlatformId(parentPlatform.getServerGBId()); - param.setCatalogId(parentPlatform.getCatalogId()); - String stream = param.getStream(); - StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId()); - if (streamProxyItems == null) { - platformGbStreamMapper.add(param); - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), param, CatalogEvent.ADD); + if (!StringUtils.isEmpty(param.getGbId())) { + // 鏌ユ壘寮�鍚簡鍏ㄩ儴鐩存挱娴佸叡浜殑涓婄骇骞冲彴 + List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); + if (parentPlatforms.size() > 0) { + for (ParentPlatform parentPlatform : parentPlatforms) { + param.setPlatformId(parentPlatform.getServerGBId()); + param.setCatalogId(parentPlatform.getCatalogId()); + String stream = param.getStream(); + StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId()); + if (streamProxyItems == null) { + platformGbStreamMapper.add(param); + eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), param, CatalogEvent.ADD); + } } } } + wvpResult.setMsg(result.toString()); return wvpResult; } @@ -275,7 +281,27 @@ @Override public void zlmServerOnline(String mediaServerId) { - zlmServerOffline(mediaServerId); + // 绉婚櫎寮�鍚簡鏃犱汉瑙傜湅鑷姩绉婚櫎鐨勬祦 + List<StreamProxyItem> streamProxyItemList = streamProxyMapper.selecAutoRemoveItemByMediaServerId(mediaServerId); + if (streamProxyItemList.size() > 0) { + gbStreamMapper.batchDel(streamProxyItemList); + } + streamProxyMapper.deleteAutoRemoveItemByMediaServerId(mediaServerId); + + // 鎭㈠娴佷唬鐞�, 鍙煡鎵捐繖涓繖涓祦濯掍綋 + List<StreamProxyItem> streamProxyListForEnable = storager.getStreamProxyListForEnableInMediaServer( + mediaServerId, true, false); + for (StreamProxyItem streamProxyDto : streamProxyListForEnable) { + logger.info("鎭㈠娴佷唬鐞嗭紝" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); + JSONObject jsonObject = addStreamProxyToZlm(streamProxyDto); + if (jsonObject == null) { + // 璁剧疆涓虹绾� + logger.info("鎭㈠娴佷唬鐞嗗け璐�" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); + updateStatus(false, streamProxyDto.getApp(), streamProxyDto.getStream()); + }else { + updateStatus(true, streamProxyDto.getApp(), streamProxyDto.getStream()); + } + } } @Override @@ -286,8 +312,8 @@ gbStreamMapper.batchDel(streamProxyItemList); } streamProxyMapper.deleteAutoRemoveItemByMediaServerId(mediaServerId); - // 鍏朵粬鐨勬祦璁剧疆鏈惎鐢� - streamProxyMapper.updateStatus(false, mediaServerId); + // 鍏朵粬鐨勬祦璁剧疆绂荤嚎 + streamProxyMapper.updateStatusByMediaServerId(false, mediaServerId); String type = "PULL"; // 鍙戦�乺edis娑堟伅 @@ -311,4 +337,9 @@ public void clean() { } + + @Override + public int updateStatus(boolean status, String app, String stream) { + return streamProxyMapper.updateStatus(status, app, stream); + } } -- Gitblit v1.8.0