Commit 22efd0f56c20e1aedb18fa7b9bcdc48007fcc954
1 parent
4418c62e
添加心跳到期时验证zlm是否真的离线。
Showing
3 changed files
with
18 additions
and
2 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -262,7 +262,7 @@ public class SIPCommander implements ISIPCommander { | @@ -262,7 +262,7 @@ public class SIPCommander implements ISIPCommander { | ||
| 262 | public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) { | 262 | public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) { |
| 263 | try { | 263 | try { |
| 264 | String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2); | 264 | String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2); |
| 265 | - logger.info("控制字符串:" + cmdStr); | 265 | + logger.debug("控制字符串:" + cmdStr); |
| 266 | StringBuffer ptzXml = new StringBuffer(200); | 266 | StringBuffer ptzXml = new StringBuffer(200); |
| 267 | ptzXml.append("<?xml version=\"1.0\" ?>\r\n"); | 267 | ptzXml.append("<?xml version=\"1.0\" ?>\r\n"); |
| 268 | ptzXml.append("<Control>\r\n"); | 268 | ptzXml.append("<Control>\r\n"); |
src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java
| 1 | package com.genersoft.iot.vmp.media.zlm.event; | 1 | package com.genersoft.iot.vmp.media.zlm.event; |
| 2 | 2 | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 3 | import com.genersoft.iot.vmp.common.VideoManagerConstants; | 4 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 4 | import com.genersoft.iot.vmp.conf.UserSetup; | 5 | import com.genersoft.iot.vmp.conf.UserSetup; |
| 5 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 6 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 7 | +import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; | ||
| 8 | +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; | ||
| 9 | +import com.genersoft.iot.vmp.service.IMediaServerService; | ||
| 6 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
| 7 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -25,8 +29,14 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene | @@ -25,8 +29,14 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene | ||
| 25 | private EventPublisher publisher; | 29 | private EventPublisher publisher; |
| 26 | 30 | ||
| 27 | @Autowired | 31 | @Autowired |
| 32 | + private ZLMRESTfulUtils zlmresTfulUtils; | ||
| 33 | + | ||
| 34 | + @Autowired | ||
| 28 | private UserSetup userSetup; | 35 | private UserSetup userSetup; |
| 29 | 36 | ||
| 37 | + @Autowired | ||
| 38 | + private IMediaServerService mediaServerService; | ||
| 39 | + | ||
| 30 | public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { | 40 | public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) { |
| 31 | super(listenerContainer); | 41 | super(listenerContainer); |
| 32 | // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 | 42 | // 配置springboot默认Config为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 |
| @@ -48,7 +58,12 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene | @@ -48,7 +58,12 @@ public class ZLMKeepliveTimeoutListener extends KeyExpirationEventMessageListene | ||
| 48 | } | 58 | } |
| 49 | 59 | ||
| 50 | String mediaServerId = expiredKey.substring(KEEPLIVEKEY_PREFIX.length(),expiredKey.length()); | 60 | String mediaServerId = expiredKey.substring(KEEPLIVEKEY_PREFIX.length(),expiredKey.length()); |
| 61 | + // 发起http请求验证zlm是否确实无法连接,如果确实无法连接则发送离线事件,否则不作处理 | ||
| 62 | + MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); | ||
| 63 | + JSONObject mediaServerConfig = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); | ||
| 64 | + if (mediaServerConfig == null) { | ||
| 65 | + publisher.zlmOfflineEventPublish(mediaServerId); | ||
| 66 | + } | ||
| 51 | 67 | ||
| 52 | - publisher.zlmOfflineEventPublish(mediaServerId); | ||
| 53 | } | 68 | } |
| 54 | } | 69 | } |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -145,6 +145,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -145,6 +145,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 145 | MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); | 145 | MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId()); |
| 146 | String streamUrl = streamInfoForSuccess.getFmp4(); | 146 | String streamUrl = streamInfoForSuccess.getFmp4(); |
| 147 | // 请求截图 | 147 | // 请求截图 |
| 148 | + logger.info("[请求截图]: " + fileName); | ||
| 148 | zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName); | 149 | zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName); |
| 149 | } | 150 | } |
| 150 | } | 151 | } |