添加心跳到期时验证zlm是否真的离线。

This commit is contained in:
648540858 2021-12-20 09:51:51 +08:00
parent 4418c62e5c
commit 22efd0f56c
3 changed files with 18 additions and 2 deletions

View File

@ -262,7 +262,7 @@ public class SIPCommander implements ISIPCommander {
public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) { public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) {
try { try {
String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2); String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2);
logger.info("控制字符串:" + cmdStr); logger.debug("控制字符串:" + cmdStr);
StringBuffer ptzXml = new StringBuffer(200); StringBuffer ptzXml = new StringBuffer(200);
ptzXml.append("<?xml version=\"1.0\" ?>\r\n"); ptzXml.append("<?xml version=\"1.0\" ?>\r\n");
ptzXml.append("<Control>\r\n"); ptzXml.append("<Control>\r\n");

View File

@ -1,8 +1,12 @@
package com.genersoft.iot.vmp.media.zlm.event; package com.genersoft.iot.vmp.media.zlm.event;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.UserSetup; import com.genersoft.iot.vmp.conf.UserSetup;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -24,9 +28,15 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene
@Autowired @Autowired
private EventPublisher publisher; private EventPublisher publisher;
@Autowired
private ZLMRESTfulUtils zlmresTfulUtils;
@Autowired @Autowired
private UserSetup userSetup; private UserSetup userSetup;
@Autowired
private IMediaServerService mediaServerService;
public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer); super(listenerContainer);
// 配置springboot默认Config为空即不让应用去修改redis的默认配置因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 // 配置springboot默认Config为空即不让应用去修改redis的默认配置因为Redis服务出于安全会禁用CONFIG命令给远程用户使用
@ -48,7 +58,12 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene
} }
String mediaServerId = expiredKey.substring(KEEPLIVEKEY_PREFIX.length(),expiredKey.length()); String mediaServerId = expiredKey.substring(KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
// 发起http请求验证zlm是否确实无法连接如果确实无法连接则发送离线事件否则不作处理
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
JSONObject mediaServerConfig = zlmresTfulUtils.getMediaServerConfig(mediaServerItem);
if (mediaServerConfig == null) {
publisher.zlmOfflineEventPublish(mediaServerId);
}
publisher.zlmOfflineEventPublish(mediaServerId);
} }
} }

View File

@ -145,6 +145,7 @@ public class PlayServiceImpl implements IPlayService {
MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
String streamUrl = streamInfoForSuccess.getFmp4(); String streamUrl = streamInfoForSuccess.getFmp4();
// 请求截图 // 请求截图
logger.info("[请求截图]: " + fileName);
zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName); zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
} }
} }