Commit 1dcdbc3742835ccab28a8983ae002d2bbdba87eb
Merge branch 'wvp-28181-2.0' into wvp-pro-record
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
Showing
12 changed files
with
117 additions
and
76 deletions
README.md
| @@ -105,6 +105,10 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git | @@ -105,6 +105,10 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git | ||
| 105 | - [X] WEB端支持播放H264与H265,音频支持G.711A/G.711U/AAC,覆盖国标常用编码格式。 | 105 | - [X] WEB端支持播放H264与H265,音频支持G.711A/G.711U/AAC,覆盖国标常用编码格式。 |
| 106 | 106 | ||
| 107 | # docker快速体验 | 107 | # docker快速体验 |
| 108 | +目前作者的docker-compose因为时间有限维护不及时,这里提供第三方提供的供大家使用,维护不易,大家记得给这位小伙伴点个star。 | ||
| 109 | +https://github.com/SaltFish001/wvp_pro_compose | ||
| 110 | +[https://github.com/SaltFish001/wvp_pro_compose](https://github.com/SaltFish001/wvp_pro_compose) | ||
| 111 | +这是作者维护的一个镜像,可能存在不及时的问题。 | ||
| 108 | ```shell | 112 | ```shell |
| 109 | docker pull 648540858/wvp_pro | 113 | docker pull 648540858/wvp_pro |
| 110 | 114 |
src/main/java/com/genersoft/iot/vmp/conf/Swagger3Config.java
| @@ -14,7 +14,7 @@ import springfox.documentation.spring.web.plugins.Docket; | @@ -14,7 +14,7 @@ import springfox.documentation.spring.web.plugins.Docket; | ||
| 14 | @Configuration | 14 | @Configuration |
| 15 | public class Swagger3Config { | 15 | public class Swagger3Config { |
| 16 | 16 | ||
| 17 | - @Value("${swagger-ui.enabled}") | 17 | + @Value("${swagger-ui.enabled: true}") |
| 18 | private boolean enable; | 18 | private boolean enable; |
| 19 | 19 | ||
| 20 | @Bean | 20 | @Bean |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java
| @@ -21,6 +21,8 @@ public class SubscribeInfo { | @@ -21,6 +21,8 @@ public class SubscribeInfo { | ||
| 21 | EventHeader eventHeader = (EventHeader)request.getHeader(EventHeader.NAME); | 21 | EventHeader eventHeader = (EventHeader)request.getHeader(EventHeader.NAME); |
| 22 | this.eventId = eventHeader.getEventId(); | 22 | this.eventId = eventHeader.getEventId(); |
| 23 | this.eventType = eventHeader.getEventType(); | 23 | this.eventType = eventHeader.getEventType(); |
| 24 | + ViaHeader viaHeader = (ViaHeader)request.getHeader(ViaHeader.NAME); | ||
| 25 | + this.branch = viaHeader.getBranch(); | ||
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | private String id; | 28 | private String id; |
| @@ -30,6 +32,7 @@ public class SubscribeInfo { | @@ -30,6 +32,7 @@ public class SubscribeInfo { | ||
| 30 | private String eventType; | 32 | private String eventType; |
| 31 | private String fromTag; | 33 | private String fromTag; |
| 32 | private String toTag; | 34 | private String toTag; |
| 35 | + private String branch; | ||
| 33 | 36 | ||
| 34 | public String getId() { | 37 | public String getId() { |
| 35 | return id; | 38 | return id; |
| @@ -86,4 +89,12 @@ public class SubscribeInfo { | @@ -86,4 +89,12 @@ public class SubscribeInfo { | ||
| 86 | public void setEventType(String eventType) { | 89 | public void setEventType(String eventType) { |
| 87 | this.eventType = eventType; | 90 | this.eventType = eventType; |
| 88 | } | 91 | } |
| 92 | + | ||
| 93 | + public String getBranch() { | ||
| 94 | + return branch; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void setBranch(String branch) { | ||
| 98 | + this.branch = branch; | ||
| 99 | + } | ||
| 89 | } | 100 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
| @@ -106,7 +106,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | @@ -106,7 +106,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | ||
| 106 | } | 106 | } |
| 107 | if (deviceChannelList.size() > 0) { | 107 | if (deviceChannelList.size() > 0) { |
| 108 | logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); | 108 | logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); |
| 109 | - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, deviceChannelList, subscribe); | 109 | + sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, deviceChannelList, subscribe, null); |
| 110 | } | 110 | } |
| 111 | }else if (parentPlatformMap.keySet().size() > 0) { | 111 | }else if (parentPlatformMap.keySet().size() > 0) { |
| 112 | for (String gbId : parentPlatformMap.keySet()) { | 112 | for (String gbId : parentPlatformMap.keySet()) { |
| @@ -121,7 +121,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | @@ -121,7 +121,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | ||
| 121 | DeviceChannel deviceChannel = new DeviceChannel(); | 121 | DeviceChannel deviceChannel = new DeviceChannel(); |
| 122 | deviceChannel.setChannelId(gbId); | 122 | deviceChannel.setChannelId(gbId); |
| 123 | deviceChannelList.add(deviceChannel); | 123 | deviceChannelList.add(deviceChannel); |
| 124 | - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo); | 124 | + sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo, null); |
| 125 | } | 125 | } |
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| @@ -163,7 +163,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | @@ -163,7 +163,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { | ||
| 163 | GbStream gbStream = storager.queryStreamInParentPlatform(platform.getServerGBId(), gbId); | 163 | GbStream gbStream = storager.queryStreamInParentPlatform(platform.getServerGBId(), gbId); |
| 164 | DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), platform.getDeviceGBId()); | 164 | DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), platform.getDeviceGBId()); |
| 165 | deviceChannelList.add(deviceChannelByStream); | 165 | deviceChannelList.add(deviceChannelByStream); |
| 166 | - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo); | 166 | + sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo, null); |
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
| @@ -86,7 +86,7 @@ public interface ISIPCommanderForPlatform { | @@ -86,7 +86,7 @@ public interface ISIPCommanderForPlatform { | ||
| 86 | * @param parentPlatform | 86 | * @param parentPlatform |
| 87 | * @param deviceChannels | 87 | * @param deviceChannels |
| 88 | */ | 88 | */ |
| 89 | - boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo); | 89 | + boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index); |
| 90 | 90 | ||
| 91 | /** | 91 | /** |
| 92 | * 回复recordInfo | 92 | * 回复recordInfo |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
| @@ -236,19 +236,18 @@ public class SIPRequestHeaderPlarformProvider { | @@ -236,19 +236,18 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 236 | // via | 236 | // via |
| 237 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 237 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 238 | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), | 238 | ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), |
| 239 | - parentPlatform.getTransport(), viaTag); | 239 | + parentPlatform.getTransport(), subscribeInfo.getBranch()); |
| 240 | viaHeader.setRPort(); | 240 | viaHeader.setRPort(); |
| 241 | viaHeaders.add(viaHeader); | 241 | viaHeaders.add(viaHeader); |
| 242 | // from | 242 | // from |
| 243 | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), | 243 | SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), |
| 244 | parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort()); | 244 | parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort()); |
| 245 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | 245 | Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| 246 | - String tm = Long.toString(System.currentTimeMillis()); | ||
| 247 | - FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, "fromtag" + tm); | 246 | + FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getToTag()); |
| 248 | // to | 247 | // to |
| 249 | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); | 248 | SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); |
| 250 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | 249 | Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); |
| 251 | - ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, subscribeInfo.getToTag()); | 250 | + ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, subscribeInfo.getFromTag()); |
| 252 | 251 | ||
| 253 | // Forwards | 252 | // Forwards |
| 254 | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); | 253 | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); |
| @@ -265,7 +264,10 @@ public class SIPRequestHeaderPlarformProvider { | @@ -265,7 +264,10 @@ public class SIPRequestHeaderPlarformProvider { | ||
| 265 | request.addHeader(userAgentHeader); | 264 | request.addHeader(userAgentHeader); |
| 266 | 265 | ||
| 267 | EventHeader event = sipFactory.createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); | 266 | EventHeader event = sipFactory.createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); |
| 268 | - event.setEventId(subscribeInfo.getEventId()); | 267 | + if (subscribeInfo.getEventId() != null) { |
| 268 | + event.setEventId(subscribeInfo.getEventId()); | ||
| 269 | + } | ||
| 270 | + | ||
| 269 | request.addHeader(event); | 271 | request.addHeader(event); |
| 270 | 272 | ||
| 271 | SubscriptionStateHeader active = sipFactory.createHeaderFactory().createSubscriptionStateHeader("active"); | 273 | SubscriptionStateHeader active = sipFactory.createHeaderFactory().createSubscriptionStateHeader("active"); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| @@ -89,7 +89,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -89,7 +89,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 89 | 89 | ||
| 90 | sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{ | 90 | sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{ |
| 91 | if (event != null) { | 91 | if (event != null) { |
| 92 | - logger.info("向上级平台 [ {} ] 注册发上错误: {} ", | 92 | + logger.info("向上级平台 [ {} ] 注册发生错误: {} ", |
| 93 | parentPlatform.getServerGBId(), | 93 | parentPlatform.getServerGBId(), |
| 94 | event.msg); | 94 | event.msg); |
| 95 | } | 95 | } |
| @@ -370,10 +370,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -370,10 +370,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | try { | 372 | try { |
| 373 | - if (index == deviceChannels.size() - 1) { | 373 | + if (index > deviceChannels.size() - 1) { |
| 374 | return true; | 374 | return true; |
| 375 | } | 375 | } |
| 376 | - Request request = getCatalogNotifyRequest(parentPlatform, deviceChannels.get(index), deviceChannels.size(), type, subscribeInfo); | 376 | + Request request = getCatalogNotifyRequestForCatalogAddOrUpdate(parentPlatform, deviceChannels.get(index), deviceChannels.size(), type, subscribeInfo); |
| 377 | index += 1; | 377 | index += 1; |
| 378 | Integer finalIndex = index; | 378 | Integer finalIndex = index; |
| 379 | transmitRequest(parentPlatform, request, null, (eventResult -> { | 379 | transmitRequest(parentPlatform, request, null, (eventResult -> { |
| @@ -386,10 +386,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -386,10 +386,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 386 | return true; | 386 | return true; |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | - private Request getCatalogNotifyRequest(ParentPlatform parentPlatform, DeviceChannel channel, int size, String type, | 389 | + private Request getCatalogNotifyRequestForCatalogAddOrUpdate(ParentPlatform parentPlatform, DeviceChannel channel, int size, String type, |
| 390 | SubscribeInfo subscribeInfo) throws ParseException, InvalidArgumentException, | 390 | SubscribeInfo subscribeInfo) throws ParseException, InvalidArgumentException, |
| 391 | PeerUnavailableException { | 391 | PeerUnavailableException { |
| 392 | - String catalogXmlContent = getCatalogXmlContent(parentPlatform, channel, size, type); | 392 | + String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channel, size, type, subscribeInfo); |
| 393 | 393 | ||
| 394 | CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 394 | CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() |
| 395 | : udpSipProvider.getNewCallId(); | 395 | : udpSipProvider.getNewCallId(); |
| @@ -399,14 +399,17 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -399,14 +399,17 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 399 | return request; | 399 | return request; |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | - private String getCatalogXmlContent(ParentPlatform parentPlatform, DeviceChannel channel, int sumNum, String type) { | 402 | + private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, DeviceChannel channel, int sumNum, String type, SubscribeInfo subscribeInfo) { |
| 403 | StringBuffer catalogXml = new StringBuffer(600); | 403 | StringBuffer catalogXml = new StringBuffer(600); |
| 404 | + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { | ||
| 405 | + channel.setParentId(parentPlatform.getDeviceGBId()); | ||
| 406 | + } | ||
| 404 | catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); | 407 | catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); |
| 405 | catalogXml.append("<Notify>\r\n"); | 408 | catalogXml.append("<Notify>\r\n"); |
| 406 | catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); | 409 | catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); |
| 407 | catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); | 410 | catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); |
| 408 | catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | 411 | catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); |
| 409 | - catalogXml.append("<SumNum>" + sumNum + "</SumNum>\r\n"); | 412 | + catalogXml.append("<SumNum>1</SumNum>\r\n"); |
| 410 | catalogXml.append("<DeviceList Num=\"1\">\r\n"); | 413 | catalogXml.append("<DeviceList Num=\"1\">\r\n"); |
| 411 | catalogXml.append("<Item>\r\n"); | 414 | catalogXml.append("<Item>\r\n"); |
| 412 | catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); | 415 | catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); |
| @@ -417,11 +420,15 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -417,11 +420,15 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 417 | catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n"); | 420 | catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n"); |
| 418 | catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); | 421 | catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); |
| 419 | catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); | 422 | catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); |
| 420 | - catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); | 423 | + if (channel.getParentId() != null) { |
| 424 | + catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); | ||
| 425 | + } | ||
| 421 | catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); | 426 | catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); |
| 422 | catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); | 427 | catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); |
| 423 | catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); | 428 | catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); |
| 424 | - catalogXml.append("<Event>" + type + "</Event>\r\n"); | 429 | + if (!"presence".equals(subscribeInfo.getEventType())) { |
| 430 | + catalogXml.append("<Event>" + type + "</Event>\r\n"); | ||
| 431 | + } | ||
| 425 | catalogXml.append("</Item>\r\n"); | 432 | catalogXml.append("</Item>\r\n"); |
| 426 | catalogXml.append("</DeviceList>\r\n"); | 433 | catalogXml.append("</DeviceList>\r\n"); |
| 427 | catalogXml.append("</Notify>\r\n"); | 434 | catalogXml.append("</Notify>\r\n"); |
| @@ -429,7 +436,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -429,7 +436,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 429 | } | 436 | } |
| 430 | 437 | ||
| 431 | @Override | 438 | @Override |
| 432 | - public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo) { | 439 | + public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index) { |
| 433 | if (parentPlatform == null | 440 | if (parentPlatform == null |
| 434 | || deviceChannels == null | 441 | || deviceChannels == null |
| 435 | || deviceChannels.size() == 0 | 442 | || deviceChannels.size() == 0 |
| @@ -437,44 +444,56 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -437,44 +444,56 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 437 | return false; | 444 | return false; |
| 438 | } | 445 | } |
| 439 | 446 | ||
| 440 | - for (DeviceChannel channel : deviceChannels) { | ||
| 441 | - try { | ||
| 442 | - StringBuffer catalogXml = new StringBuffer(600); | ||
| 443 | - catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); | ||
| 444 | - catalogXml.append("<Notify>\r\n"); | ||
| 445 | - catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); | ||
| 446 | - catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); | ||
| 447 | - catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | ||
| 448 | - catalogXml.append("<SumNum>" + deviceChannels.size() + "</SumNum>\r\n"); | ||
| 449 | - catalogXml.append("<DeviceList Num=\"1\">\r\n"); | ||
| 450 | - catalogXml.append("<Item>\r\n"); | ||
| 451 | - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); | ||
| 452 | - catalogXml.append("<Event>" + type + "</Event>\r\n"); | ||
| 453 | - catalogXml.append("</Item>\r\n"); | ||
| 454 | - catalogXml.append("</DeviceList>\r\n"); | ||
| 455 | - catalogXml.append("</Notify>\r\n"); | 447 | + if (index == null) { |
| 448 | + index = 0; | ||
| 449 | + } | ||
| 456 | 450 | ||
| 457 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 451 | + if (index > deviceChannels.size() - 1) { |
| 452 | + return true; | ||
| 453 | + } | ||
| 454 | + try { | ||
| 455 | + String catalogXml = getCatalogXmlContentForCatalogOther(deviceChannels.get(index), type, parentPlatform); | ||
| 456 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | ||
| 458 | : udpSipProvider.getNewCallId(); | 457 | : udpSipProvider.getNewCallId(); |
| 459 | - callIdHeader.setCallId(subscribeInfo.getCallId()); | ||
| 460 | - | ||
| 461 | - String tm = Long.toString(System.currentTimeMillis()); | ||
| 462 | - | ||
| 463 | - Request request = headerProviderPlarformProvider.createNotifyRequest(parentPlatform, catalogXml.toString(), | 458 | + Request request = headerProviderPlarformProvider.createNotifyRequest(parentPlatform, catalogXml, |
| 464 | callIdHeader, | 459 | callIdHeader, |
| 465 | "z9hG4bK-" + UUID.randomUUID().toString().replace("-", ""), subscribeInfo); | 460 | "z9hG4bK-" + UUID.randomUUID().toString().replace("-", ""), subscribeInfo); |
| 466 | - transmitRequest(parentPlatform, request); | ||
| 467 | - Thread.sleep(200); | ||
| 468 | - } catch (SipException | ParseException | InvalidArgumentException e) { | ||
| 469 | - e.printStackTrace(); | ||
| 470 | - return false; | ||
| 471 | - } catch (InterruptedException e) { | ||
| 472 | - e.printStackTrace(); | ||
| 473 | - } | 461 | + index += 1; |
| 462 | + Integer finalIndex = index; | ||
| 463 | + transmitRequest(parentPlatform, request, null, eventResult -> { | ||
| 464 | + sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo, finalIndex); | ||
| 465 | + }); | ||
| 466 | + } catch (SipException e) { | ||
| 467 | + e.printStackTrace(); | ||
| 468 | + } catch (InvalidArgumentException e) { | ||
| 469 | + e.printStackTrace(); | ||
| 470 | + } catch (ParseException e) { | ||
| 471 | + e.printStackTrace(); | ||
| 474 | } | 472 | } |
| 473 | + | ||
| 475 | return true; | 474 | return true; |
| 476 | } | 475 | } |
| 477 | 476 | ||
| 477 | + private String getCatalogXmlContentForCatalogOther(DeviceChannel channel, String type, ParentPlatform parentPlatform) { | ||
| 478 | + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { | ||
| 479 | + channel.setParentId(parentPlatform.getDeviceGBId()); | ||
| 480 | + } | ||
| 481 | + StringBuffer catalogXml = new StringBuffer(600); | ||
| 482 | + catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); | ||
| 483 | + catalogXml.append("<Notify>\r\n"); | ||
| 484 | + catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); | ||
| 485 | + catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); | ||
| 486 | + catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | ||
| 487 | + catalogXml.append("<SumNum>1</SumNum>\r\n"); | ||
| 488 | + catalogXml.append("<DeviceList Num=\"1\">\r\n"); | ||
| 489 | + catalogXml.append("<Item>\r\n"); | ||
| 490 | + catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); | ||
| 491 | + catalogXml.append("<Event>" + type + "</Event>\r\n"); | ||
| 492 | + catalogXml.append("</Item>\r\n"); | ||
| 493 | + catalogXml.append("</DeviceList>\r\n"); | ||
| 494 | + catalogXml.append("</Notify>\r\n"); | ||
| 495 | + return catalogXml.toString(); | ||
| 496 | + } | ||
| 478 | @Override | 497 | @Override |
| 479 | public boolean recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) { | 498 | public boolean recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) { |
| 480 | if ( parentPlatform ==null) { | 499 | if ( parentPlatform ==null) { |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
| @@ -22,7 +22,7 @@ import org.springframework.util.StringUtils; | @@ -22,7 +22,7 @@ import org.springframework.util.StringUtils; | ||
| 22 | 22 | ||
| 23 | import javax.sip.RequestEvent; | 23 | import javax.sip.RequestEvent; |
| 24 | 24 | ||
| 25 | -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; | 25 | +import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.*; |
| 26 | 26 | ||
| 27 | @Component | 27 | @Component |
| 28 | public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { | 28 | public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { |
| @@ -105,6 +105,11 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | @@ -105,6 +105,11 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme | ||
| 105 | storager.insertMobilePosition(mobilePosition); | 105 | storager.insertMobilePosition(mobilePosition); |
| 106 | } | 106 | } |
| 107 | } | 107 | } |
| 108 | + if (!StringUtils.isEmpty(deviceAlarm.getDeviceId())) { | ||
| 109 | + if (deviceAlarm.getAlarmMethod().equals("5")) { | ||
| 110 | + deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); | ||
| 111 | + } | ||
| 112 | + } | ||
| 108 | logger.debug("存储报警信息、报警分类"); | 113 | logger.debug("存储报警信息、报警分类"); |
| 109 | // 存储报警信息、报警分类 | 114 | // 存储报警信息、报警分类 |
| 110 | deviceAlarmService.add(deviceAlarm); | 115 | deviceAlarmService.add(deviceAlarm); |
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
| @@ -191,7 +191,7 @@ public class XmlUtil { | @@ -191,7 +191,7 @@ public class XmlUtil { | ||
| 191 | String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : ""; | 191 | String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : ""; |
| 192 | deviceChannel.setChannelId(channelId); | 192 | deviceChannel.setChannelId(channelId); |
| 193 | // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 | 193 | // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 |
| 194 | - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { | 194 | + if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) { |
| 195 | deviceChannel.setStatus(1); | 195 | deviceChannel.setStatus(1); |
| 196 | } | 196 | } |
| 197 | if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { | 197 | if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { |
| @@ -255,9 +255,14 @@ public class XmlUtil { | @@ -255,9 +255,14 @@ public class XmlUtil { | ||
| 255 | } else { | 255 | } else { |
| 256 | deviceChannel.setLatitude(0.00); | 256 | deviceChannel.setLatitude(0.00); |
| 257 | } | 257 | } |
| 258 | - if (XmlUtil.getText(itemDevice, "PTZType") == null | ||
| 259 | - || XmlUtil.getText(itemDevice, "PTZType") == "") { | ||
| 260 | - deviceChannel.setPTZType(0); | 258 | + if (XmlUtil.getText(itemDevice, "PTZType") == null || "".equals(XmlUtil.getText(itemDevice, "PTZType"))) { |
| 259 | + //兼容INFO中的信息 | ||
| 260 | + Element info = itemDevice.element("Info"); | ||
| 261 | + if(XmlUtil.getText(info, "PTZType") == null || "".equals(XmlUtil.getText(info, "PTZType"))){ | ||
| 262 | + deviceChannel.setPTZType(0); | ||
| 263 | + }else{ | ||
| 264 | + deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(info, "PTZType"))); | ||
| 265 | + } | ||
| 261 | } else { | 266 | } else { |
| 262 | deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); | 267 | deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); |
| 263 | } | 268 | } |
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
| @@ -61,7 +61,7 @@ public interface GbStreamMapper { | @@ -61,7 +61,7 @@ public interface GbStreamMapper { | ||
| 61 | List<GbStream> selectByGBId(String gbId); | 61 | List<GbStream> selectByGBId(String gbId); |
| 62 | 62 | ||
| 63 | @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + | 63 | @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + |
| 64 | - "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.catalogId " + | 64 | + "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " + |
| 65 | "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") | 65 | "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") |
| 66 | GbStream queryStreamInPlatform(String platformId, String gbId); | 66 | GbStream queryStreamInPlatform(String platformId, String gbId); |
| 67 | 67 |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
| @@ -57,9 +57,9 @@ public interface PlatformChannelMapper { | @@ -57,9 +57,9 @@ public interface PlatformChannelMapper { | ||
| 57 | @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE dc.channelId='${channelId}' and pgc.platformId='${platformId}'") | 57 | @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE dc.channelId='${channelId}' and pgc.platformId='${platformId}'") |
| 58 | DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); | 58 | DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); |
| 59 | 59 | ||
| 60 | - @Select("select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " + | ||
| 61 | - "from device_channel dc left join platform_gb_channel pgc on dc.id = pgc.deviceChannelId" + | ||
| 62 | - "where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}") | 60 | + @Select(" select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " + |
| 61 | + " from device_channel dc left join platform_gb_channel pgc on dc.id = pgc.deviceChannelId " + | ||
| 62 | + " where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}") | ||
| 63 | List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); | 63 | List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); |
| 64 | 64 | ||
| 65 | @Select("select d.*\n" + | 65 | @Select("select d.*\n" + |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
| @@ -216,26 +216,21 @@ public class PlatformController { | @@ -216,26 +216,21 @@ public class PlatformController { | ||
| 216 | if (updateResult) { | 216 | if (updateResult) { |
| 217 | // 保存时启用就发送注册 | 217 | // 保存时启用就发送注册 |
| 218 | if (parentPlatform.isEnable()) { | 218 | if (parentPlatform.isEnable()) { |
| 219 | - // 保存时启用就发送注册 | ||
| 220 | - if (parentPlatform.isEnable()) { | ||
| 221 | - if (parentPlatformOld.isStatus()) { | ||
| 222 | - commanderForPlatform.unregister(parentPlatformOld, null, null); | ||
| 223 | - try { | ||
| 224 | - Thread.sleep(500); | ||
| 225 | - } catch (InterruptedException e) { | ||
| 226 | - e.printStackTrace(); | ||
| 227 | - } | ||
| 228 | - // 只要保存就发送注册 | ||
| 229 | - commanderForPlatform.register(parentPlatform, null, null); | ||
| 230 | - }else { | ||
| 231 | - // 只要保存就发送注册 | ||
| 232 | - commanderForPlatform.register(parentPlatform, null, null); | ||
| 233 | - } | ||
| 234 | - } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 | 219 | + if (parentPlatformOld.isStatus()) { |
| 235 | commanderForPlatform.unregister(parentPlatformOld, null, null); | 220 | commanderForPlatform.unregister(parentPlatformOld, null, null); |
| 221 | + try { | ||
| 222 | + Thread.sleep(500); | ||
| 223 | + } catch (InterruptedException e) { | ||
| 224 | + e.printStackTrace(); | ||
| 225 | + } | ||
| 226 | + // 只要保存就发送注册 | ||
| 227 | + commanderForPlatform.register(parentPlatform, null, null); | ||
| 228 | + }else { | ||
| 229 | + // 只要保存就发送注册 | ||
| 230 | + commanderForPlatform.register(parentPlatform, null, null); | ||
| 236 | } | 231 | } |
| 237 | } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 | 232 | } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 |
| 238 | - commanderForPlatform.unregister(parentPlatform, null, null); | 233 | + commanderForPlatform.unregister(parentPlatformOld, null, null); |
| 239 | } | 234 | } |
| 240 | wvpResult.setCode(0); | 235 | wvpResult.setCode(0); |
| 241 | wvpResult.setMsg("success"); | 236 | wvpResult.setMsg("success"); |