diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 7daa89c0..780c5f67 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -127,7 +127,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements SipURI sipUri = (SipURI) request.getRequestURI(); //从subject读取channelId,不再从request-line读取。 有些平台request-line是平台国标编码,不是设备国标编码。 //String channelId = sipURI.getUser(); - String channelId = SipUtils.getChannelIdFromHeader(request); + String channelId = SipUtils.getChannelIdFromRequest(request); String requesterId = SipUtils.getUserIdFromFromHeader(request); CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); if (requesterId == null || channelId == null) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index cd858896..e004b89f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -27,6 +27,7 @@ import javax.sip.SipException; import javax.sip.address.SipURI; import javax.sip.header.CSeqHeader; import javax.sip.header.CallIdHeader; +import javax.sip.message.Request; import javax.sip.message.Response; import java.text.ParseException; import java.util.Map; @@ -68,22 +69,23 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement @Override public void process(RequestEvent evt) { + SIPRequest sipRequest = (SIPRequest)evt.getRequest(); logger.debug("接收到消息:" + evt.getRequest()); String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); - CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); + CallIdHeader callIdHeader = sipRequest.getCallIdHeader(); // 先从会话内查找 SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); - if (ssrcTransaction != null) { // 兼容海康 媒体通知 消息from字段不是设备ID的问题 + // 兼容海康 媒体通知 消息from字段不是设备ID的问题 + if (ssrcTransaction != null) { deviceId = ssrcTransaction.getDeviceId(); } // 查询设备是否存在 - CSeqHeader cseqHeader = (CSeqHeader) evt.getRequest().getHeader(CSeqHeader.NAME); - String method = cseqHeader.getMethod(); Device device = redisCatchStorage.getDevice(deviceId); // 查询上级平台是否存在 ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId); try { if (device != null && parentPlatform != null) { + logger.warn("[重复]平台与设备编号重复:{}", deviceId); SIPRequest request = (SIPRequest) evt.getRequest(); String hostAddress = request.getRemoteAddress().getHostAddress(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java index 35ec6404..44e13372 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java @@ -23,9 +23,10 @@ public class SipUtils { /** * 从subject读取channelId * */ - public static String getChannelIdFromHeader(Request request) { + public static String getChannelIdFromRequest(Request request) { Header subject = request.getHeader("subject"); if (subject == null) { + // 如果缺失subject return null; } return ((Subject) subject).getSubject().split(":")[0]; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index 18654dd1..0dc6bd38 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -451,7 +451,6 @@ public class ZLMHttpHookListener { redisCatchStorage.stopPlayback(streamInfo.getDeviceID(), streamInfo.getChannelId(), streamInfo.getStream(), null); } - } }else { if (!"rtp".equals(app)){ diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java index f78ca4a1..a8b4a8d9 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java @@ -85,6 +85,7 @@ public class ZLMMediaListManager { streamPushMapper.add(transform); }else { streamPushMapper.update(transform); + gbStreamMapper.updateMediaServer(mediaItem.getApp(), mediaItem.getStream(), mediaItem.getMediaServerId()); } if (transform != null) { if (getChannelOnlineEventLister(transform.getApp(), transform.getStream()) != null) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java index 061f807f..6c6c04b1 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -492,6 +492,7 @@ public class StreamPushServiceImpl implements IStreamPushService { try { int addStreamResult = streamPushMapper.add(stream); if (!StringUtils.isEmpty(stream.getGbId())) { + stream.setStreamType("push"); gbStreamMapper.add(stream); } dataSourceTransactionManager.commit(transactionStatus); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java index 73fff576..7ed6b5ab 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java @@ -143,4 +143,9 @@ public interface GbStreamMapper { "" + "") List selectAllForAppAndStream(List streamPushItems); + + @Update("UPDATE gb_stream " + + "SET mediaServerId=#{mediaServerId}" + + "WHERE app=#{app} AND stream=#{stream}") + void updateMediaServer(String app, String stream, String mediaServerId); } diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index ef14c242..b4ec9ef2 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -149,7 +149,7 @@ media: enable: true # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功 port-range: 30000,30500 # 端口范围 - # [可选] 国标级联在此范围内选择端口发送媒体流, + # [可选] 国标级联在此范围内选择端口发送媒体流 send-port-range: 30000,30500 # 端口范围 # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 record-assist-port: 0