Commit f5640fddb711cb05defe691e9817057e35c03c6e
1 parent
8f9a5302
优化国标级联的目录订阅
Showing
11 changed files
with
111 additions
and
74 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
| @@ -85,6 +85,6 @@ public interface ISIPCommanderForPlatform { | @@ -85,6 +85,6 @@ public interface ISIPCommanderForPlatform { | ||
| 85 | * @param parentPlatform | 85 | * @param parentPlatform |
| 86 | * @param deviceChannels | 86 | * @param deviceChannels |
| 87 | */ | 87 | */ |
| 88 | - boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo); | 88 | + boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index); |
| 89 | 89 | ||
| 90 | } | 90 | } |
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
| @@ -371,10 +371,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -371,10 +371,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | try { | 373 | try { |
| 374 | - if (index == deviceChannels.size() - 1) { | 374 | + if (index > deviceChannels.size() - 1) { |
| 375 | return true; | 375 | return true; |
| 376 | } | 376 | } |
| 377 | - Request request = getCatalogNotifyRequest(parentPlatform, deviceChannels.get(index), deviceChannels.size(), type, subscribeInfo); | 377 | + Request request = getCatalogNotifyRequestForCatalogAddOrUpdate(parentPlatform, deviceChannels.get(index), deviceChannels.size(), type, subscribeInfo); |
| 378 | index += 1; | 378 | index += 1; |
| 379 | Integer finalIndex = index; | 379 | Integer finalIndex = index; |
| 380 | transmitRequest(parentPlatform, request, null, (eventResult -> { | 380 | transmitRequest(parentPlatform, request, null, (eventResult -> { |
| @@ -387,10 +387,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -387,10 +387,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 387 | return true; | 387 | return true; |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | - private Request getCatalogNotifyRequest(ParentPlatform parentPlatform, DeviceChannel channel, int size, String type, | 390 | + private Request getCatalogNotifyRequestForCatalogAddOrUpdate(ParentPlatform parentPlatform, DeviceChannel channel, int size, String type, |
| 391 | SubscribeInfo subscribeInfo) throws ParseException, InvalidArgumentException, | 391 | SubscribeInfo subscribeInfo) throws ParseException, InvalidArgumentException, |
| 392 | PeerUnavailableException { | 392 | PeerUnavailableException { |
| 393 | - String catalogXmlContent = getCatalogXmlContent(parentPlatform, channel, size, type); | 393 | + String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channel, size, type, subscribeInfo); |
| 394 | 394 | ||
| 395 | CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 395 | CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() |
| 396 | : udpSipProvider.getNewCallId(); | 396 | : udpSipProvider.getNewCallId(); |
| @@ -400,14 +400,17 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -400,14 +400,17 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 400 | return request; | 400 | return request; |
| 401 | } | 401 | } |
| 402 | 402 | ||
| 403 | - private String getCatalogXmlContent(ParentPlatform parentPlatform, DeviceChannel channel, int sumNum, String type) { | 403 | + private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, DeviceChannel channel, int sumNum, String type, SubscribeInfo subscribeInfo) { |
| 404 | StringBuffer catalogXml = new StringBuffer(600); | 404 | StringBuffer catalogXml = new StringBuffer(600); |
| 405 | + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { | ||
| 406 | + channel.setParentId(parentPlatform.getDeviceGBId()); | ||
| 407 | + } | ||
| 405 | catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); | 408 | catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); |
| 406 | catalogXml.append("<Notify>\r\n"); | 409 | catalogXml.append("<Notify>\r\n"); |
| 407 | catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); | 410 | catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); |
| 408 | catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); | 411 | catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); |
| 409 | catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | 412 | catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); |
| 410 | - catalogXml.append("<SumNum>" + sumNum + "</SumNum>\r\n"); | 413 | + catalogXml.append("<SumNum>1</SumNum>\r\n"); |
| 411 | catalogXml.append("<DeviceList Num=\"1\">\r\n"); | 414 | catalogXml.append("<DeviceList Num=\"1\">\r\n"); |
| 412 | catalogXml.append("<Item>\r\n"); | 415 | catalogXml.append("<Item>\r\n"); |
| 413 | catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); | 416 | catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); |
| @@ -418,11 +421,15 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -418,11 +421,15 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 418 | catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n"); | 421 | catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n"); |
| 419 | catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); | 422 | catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); |
| 420 | catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); | 423 | catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n"); |
| 421 | - catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); | 424 | + if (channel.getParentId() != null) { |
| 425 | + catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); | ||
| 426 | + } | ||
| 422 | catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); | 427 | catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); |
| 423 | catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); | 428 | catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); |
| 424 | catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); | 429 | catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); |
| 425 | - catalogXml.append("<Event>" + type + "</Event>\r\n"); | 430 | + if (!"presence".equals(subscribeInfo.getEventType())) { |
| 431 | + catalogXml.append("<Event>" + type + "</Event>\r\n"); | ||
| 432 | + } | ||
| 426 | catalogXml.append("</Item>\r\n"); | 433 | catalogXml.append("</Item>\r\n"); |
| 427 | catalogXml.append("</DeviceList>\r\n"); | 434 | catalogXml.append("</DeviceList>\r\n"); |
| 428 | catalogXml.append("</Notify>\r\n"); | 435 | catalogXml.append("</Notify>\r\n"); |
| @@ -430,7 +437,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -430,7 +437,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 430 | } | 437 | } |
| 431 | 438 | ||
| 432 | @Override | 439 | @Override |
| 433 | - public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo) { | 440 | + public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index) { |
| 434 | if (parentPlatform == null | 441 | if (parentPlatform == null |
| 435 | || deviceChannels == null | 442 | || deviceChannels == null |
| 436 | || deviceChannels.size() == 0 | 443 | || deviceChannels.size() == 0 |
| @@ -438,42 +445,55 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -438,42 +445,55 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 438 | return false; | 445 | return false; |
| 439 | } | 446 | } |
| 440 | 447 | ||
| 441 | - for (DeviceChannel channel : deviceChannels) { | ||
| 442 | - try { | ||
| 443 | - StringBuffer catalogXml = new StringBuffer(600); | ||
| 444 | - catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); | ||
| 445 | - catalogXml.append("<Notify>\r\n"); | ||
| 446 | - catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); | ||
| 447 | - catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); | ||
| 448 | - catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | ||
| 449 | - catalogXml.append("<SumNum>" + deviceChannels.size() + "</SumNum>\r\n"); | ||
| 450 | - catalogXml.append("<DeviceList Num=\"1\">\r\n"); | ||
| 451 | - catalogXml.append("<Item>\r\n"); | ||
| 452 | - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); | ||
| 453 | - catalogXml.append("<Event>" + type + "</Event>\r\n"); | ||
| 454 | - catalogXml.append("</Item>\r\n"); | ||
| 455 | - catalogXml.append("</DeviceList>\r\n"); | ||
| 456 | - catalogXml.append("</Notify>\r\n"); | 448 | + if (index == null) { |
| 449 | + index = 0; | ||
| 450 | + } | ||
| 457 | 451 | ||
| 458 | - CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | 452 | + if (index > deviceChannels.size() - 1) { |
| 453 | + return true; | ||
| 454 | + } | ||
| 455 | + try { | ||
| 456 | + String catalogXml = getCatalogXmlContentForCatalogOther(deviceChannels.get(index), type, parentPlatform); | ||
| 457 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | ||
| 459 | : udpSipProvider.getNewCallId(); | 458 | : udpSipProvider.getNewCallId(); |
| 460 | - callIdHeader.setCallId(subscribeInfo.getCallId()); | ||
| 461 | - | ||
| 462 | - String tm = Long.toString(System.currentTimeMillis()); | ||
| 463 | - | ||
| 464 | - Request request = headerProviderPlarformProvider.createNotifyRequest(parentPlatform, catalogXml.toString(), | 459 | + Request request = headerProviderPlarformProvider.createNotifyRequest(parentPlatform, catalogXml, |
| 465 | callIdHeader, | 460 | callIdHeader, |
| 466 | "z9hG4bK-" + UUID.randomUUID().toString().replace("-", ""), subscribeInfo); | 461 | "z9hG4bK-" + UUID.randomUUID().toString().replace("-", ""), subscribeInfo); |
| 467 | - transmitRequest(parentPlatform, request); | ||
| 468 | - Thread.sleep(200); | ||
| 469 | - } catch (SipException | ParseException | InvalidArgumentException e) { | ||
| 470 | - e.printStackTrace(); | ||
| 471 | - return false; | ||
| 472 | - } catch (InterruptedException e) { | ||
| 473 | - e.printStackTrace(); | ||
| 474 | - } | 462 | + index += 1; |
| 463 | + Integer finalIndex = index; | ||
| 464 | + transmitRequest(parentPlatform, request, null, eventResult -> { | ||
| 465 | + sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo, finalIndex); | ||
| 466 | + }); | ||
| 467 | + } catch (SipException e) { | ||
| 468 | + e.printStackTrace(); | ||
| 469 | + } catch (InvalidArgumentException e) { | ||
| 470 | + e.printStackTrace(); | ||
| 471 | + } catch (ParseException e) { | ||
| 472 | + e.printStackTrace(); | ||
| 475 | } | 473 | } |
| 474 | + | ||
| 476 | return true; | 475 | return true; |
| 477 | } | 476 | } |
| 478 | 477 | ||
| 478 | + private String getCatalogXmlContentForCatalogOther(DeviceChannel channel, String type, ParentPlatform parentPlatform) { | ||
| 479 | + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { | ||
| 480 | + channel.setParentId(parentPlatform.getDeviceGBId()); | ||
| 481 | + } | ||
| 482 | + StringBuffer catalogXml = new StringBuffer(600); | ||
| 483 | + catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); | ||
| 484 | + catalogXml.append("<Notify>\r\n"); | ||
| 485 | + catalogXml.append("<CmdType>Catalog</CmdType>\r\n"); | ||
| 486 | + catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); | ||
| 487 | + catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); | ||
| 488 | + catalogXml.append("<SumNum>1</SumNum>\r\n"); | ||
| 489 | + catalogXml.append("<DeviceList Num=\"1\">\r\n"); | ||
| 490 | + catalogXml.append("<Item>\r\n"); | ||
| 491 | + catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); | ||
| 492 | + catalogXml.append("<Event>" + type + "</Event>\r\n"); | ||
| 493 | + catalogXml.append("</Item>\r\n"); | ||
| 494 | + catalogXml.append("</DeviceList>\r\n"); | ||
| 495 | + catalogXml.append("</Notify>\r\n"); | ||
| 496 | + return catalogXml.toString(); | ||
| 497 | + } | ||
| 498 | + | ||
| 479 | } | 499 | } |
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
| @@ -211,26 +211,21 @@ public class PlatformController { | @@ -211,26 +211,21 @@ public class PlatformController { | ||
| 211 | if (updateResult) { | 211 | if (updateResult) { |
| 212 | // 保存时启用就发送注册 | 212 | // 保存时启用就发送注册 |
| 213 | if (parentPlatform.isEnable()) { | 213 | if (parentPlatform.isEnable()) { |
| 214 | - // 保存时启用就发送注册 | ||
| 215 | - if (parentPlatform.isEnable()) { | ||
| 216 | - if (parentPlatformOld.isStatus()) { | ||
| 217 | - commanderForPlatform.unregister(parentPlatformOld, null, null); | ||
| 218 | - try { | ||
| 219 | - Thread.sleep(500); | ||
| 220 | - } catch (InterruptedException e) { | ||
| 221 | - e.printStackTrace(); | ||
| 222 | - } | ||
| 223 | - // 只要保存就发送注册 | ||
| 224 | - commanderForPlatform.register(parentPlatform, null, null); | ||
| 225 | - }else { | ||
| 226 | - // 只要保存就发送注册 | ||
| 227 | - commanderForPlatform.register(parentPlatform, null, null); | ||
| 228 | - } | ||
| 229 | - } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 | 214 | + if (parentPlatformOld.isStatus()) { |
| 230 | commanderForPlatform.unregister(parentPlatformOld, null, null); | 215 | commanderForPlatform.unregister(parentPlatformOld, null, null); |
| 216 | + try { | ||
| 217 | + Thread.sleep(500); | ||
| 218 | + } catch (InterruptedException e) { | ||
| 219 | + e.printStackTrace(); | ||
| 220 | + } | ||
| 221 | + // 只要保存就发送注册 | ||
| 222 | + commanderForPlatform.register(parentPlatform, null, null); | ||
| 223 | + }else { | ||
| 224 | + // 只要保存就发送注册 | ||
| 225 | + commanderForPlatform.register(parentPlatform, null, null); | ||
| 231 | } | 226 | } |
| 232 | } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 | 227 | } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销 |
| 233 | - commanderForPlatform.unregister(parentPlatform, null, null); | 228 | + commanderForPlatform.unregister(parentPlatformOld, null, null); |
| 234 | } | 229 | } |
| 235 | wvpResult.setCode(0); | 230 | wvpResult.setCode(0); |
| 236 | wvpResult.setMsg("success"); | 231 | wvpResult.setMsg("success"); |