Commit 2a5404c68f387523a833b8e9f17cda5b0c9ad727

Authored by 648540858
1 parent dc676966

兼容海康信令问题 #493

src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java
@@ -112,6 +112,13 @@ public class VideoStreamSessionManager { @@ -112,6 +112,13 @@ public class VideoStreamSessionManager {
112 } 112 }
113 113
114 public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){ 114 public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){
  115 +
  116 + if (StringUtils.isEmpty(deviceId)) {
  117 + deviceId ="*";
  118 + }
  119 + if (StringUtils.isEmpty(channelId)) {
  120 + channelId ="*";
  121 + }
115 if (StringUtils.isEmpty(callId)) { 122 if (StringUtils.isEmpty(callId)) {
116 callId ="*"; 123 callId ="*";
117 } 124 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
@@ -708,22 +708,22 @@ public class SIPCommander implements ISIPCommander { @@ -708,22 +708,22 @@ public class SIPCommander implements ISIPCommander {
708 } 708 }
709 SIPDialog dialog; 709 SIPDialog dialog;
710 if (callId != null) { 710 if (callId != null) {
711 - dialog = streamSession.getDialogByCallId(deviceId, channelId, callId); 711 + dialog = streamSession.getDialogByCallId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), callId);
712 }else { 712 }else {
713 - if (stream == null) { 713 + if (stream == null && ssrcTransaction == null && ssrcTransaction.getStream() == null) {
714 return; 714 return;
715 } 715 }
716 - dialog = streamSession.getDialogByStream(deviceId, channelId, stream); 716 + dialog = streamSession.getDialogByStream(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
717 } 717 }
718 if (ssrcTransaction != null) { 718 if (ssrcTransaction != null) {
719 MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId()); 719 MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId());
720 mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); 720 mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc());
721 - mediaServerService.closeRTPServer(deviceId, channelId, ssrcTransaction.getStream());  
722 - streamSession.remove(deviceId, channelId, ssrcTransaction.getStream()); 721 + mediaServerService.closeRTPServer(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
  722 + streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
723 } 723 }
724 724
725 if (dialog == null) { 725 if (dialog == null) {
726 - logger.warn("[ {} -> {}]停止视频流的时候发现对话已丢失", deviceId, channelId); 726 + logger.warn("[ {} -> {}]停止视频流的时候发现对话已丢失", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
727 return; 727 return;
728 } 728 }
729 SipStack sipStack = udpSipProvider.getSipStack(); 729 SipStack sipStack = udpSipProvider.getSipStack();
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java
@@ -72,7 +72,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement @@ -72,7 +72,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
72 String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); 72 String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest());
73 CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); 73 CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME);
74 // 先从会话内查找 74 // 先从会话内查找
75 - SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, null, callIdHeader.getCallId()); 75 + SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
76 if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题 76 if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题
77 deviceId = ssrcTransaction.getDeviceId(); 77 deviceId = ssrcTransaction.getDeviceId();
78 } 78 }
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java
@@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify @@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify
3 import com.genersoft.iot.vmp.common.StreamInfo; 3 import com.genersoft.iot.vmp.common.StreamInfo;
4 import com.genersoft.iot.vmp.gb28181.bean.Device; 4 import com.genersoft.iot.vmp.gb28181.bean.Device;
5 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; 5 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
  6 +import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
  7 +import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
6 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; 8 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
7 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; 9 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
8 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; 10 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
@@ -39,6 +41,9 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i @@ -39,6 +41,9 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i
39 @Autowired 41 @Autowired
40 private IRedisCatchStorage redisCatchStorage; 42 private IRedisCatchStorage redisCatchStorage;
41 43
  44 + @Autowired
  45 + private VideoStreamSessionManager sessionManager;
  46 +
42 @Override 47 @Override
43 public void afterPropertiesSet() throws Exception { 48 public void afterPropertiesSet() throws Exception {
44 notifyMessageHandler.addHandler(cmdType, this); 49 notifyMessageHandler.addHandler(cmdType, this);
@@ -61,13 +66,19 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i @@ -61,13 +66,19 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i
61 String NotifyType =getText(rootElement, "NotifyType"); 66 String NotifyType =getText(rootElement, "NotifyType");
62 if (NotifyType.equals("121")){ 67 if (NotifyType.equals("121")){
63 logger.info("[录像流]推送完毕,收到关流通知"); 68 logger.info("[录像流]推送完毕,收到关流通知");
64 - String channelId =getText(rootElement, "DeviceID");  
65 // 查询是设备 69 // 查询是设备
66 - StreamInfo streamInfo = redisCatchStorage.queryDownload(device.getDeviceId(), channelId, null, callIdHeader.getCallId());  
67 - // 设置进度100%  
68 - streamInfo.setProgress(1);  
69 - redisCatchStorage.startDownload(streamInfo, callIdHeader.getCallId());  
70 - cmder.streamByeCmd(device.getDeviceId(), channelId, null, callIdHeader.getCallId()); 70 + StreamInfo streamInfo = redisCatchStorage.queryDownload(null, null, null, callIdHeader.getCallId());
  71 + if (streamInfo != null) {
  72 + // 设置进度100%
  73 + streamInfo.setProgress(1);
  74 + redisCatchStorage.startDownload(streamInfo, callIdHeader.getCallId());
  75 + }
  76 +
  77 + // 先从会话内查找
  78 + SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
  79 + if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题
  80 + cmder.streamByeCmd(device.getDeviceId(), ssrcTransaction.getChannelId(), null, callIdHeader.getCallId());
  81 + }
71 // TODO 如果级联播放,需要给上级发送此通知 82 // TODO 如果级联播放,需要给上级发送此通知
72 83
73 } 84 }
src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java
1 package com.genersoft.iot.vmp.utils; 1 package com.genersoft.iot.vmp.utils;
2 2
3 3
4 -import java.text.SimpleDateFormat;  
5 import java.time.Instant; 4 import java.time.Instant;
6 import java.time.LocalDate; 5 import java.time.LocalDate;
7 import java.time.LocalDateTime; 6 import java.time.LocalDateTime;