Commit d0f5d684a93db3a0c9a6f2373657b8f596cc47ca
1 parent
0f58218b
同步主线
Showing
2 changed files
with
84 additions
and
77 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| ... | ... | @@ -11,9 +11,15 @@ import javax.sip.header.FromHeader; |
| 11 | 11 | import javax.sip.message.Request; |
| 12 | 12 | import javax.sip.message.Response; |
| 13 | 13 | |
| 14 | +import com.alibaba.fastjson.JSONObject; | |
| 15 | +import com.genersoft.iot.vmp.conf.UserSetup; | |
| 14 | 16 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 17 | +import com.genersoft.iot.vmp.gb28181.transmit.callback.CheckForAllRecordsThread; | |
| 15 | 18 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| 19 | +import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; | |
| 16 | 20 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 21 | +import com.genersoft.iot.vmp.utils.GpsUtil; | |
| 22 | +import com.genersoft.iot.vmp.utils.SpringBeanFactory; | |
| 17 | 23 | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; |
| 18 | 24 | import gov.nist.javax.sip.address.AddressImpl; |
| 19 | 25 | import gov.nist.javax.sip.address.SipUri; |
| ... | ... | @@ -49,6 +55,10 @@ import com.genersoft.iot.vmp.common.StreamInfo; |
| 49 | 55 | */ |
| 50 | 56 | public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 51 | 57 | |
| 58 | + public static volatile List<String> threadNameList = new ArrayList(); | |
| 59 | + | |
| 60 | + private UserSetup userSetup = (UserSetup) SpringBeanFactory.getBean("userSetup"); | |
| 61 | + | |
| 52 | 62 | private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); |
| 53 | 63 | |
| 54 | 64 | private SIPCommander cmder; |
| ... | ... | @@ -412,12 +422,12 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 412 | 422 | String platformId = uri.getUser(); |
| 413 | 423 | // if (deviceListElement == null) { // 存在DeviceList则为响应 catalog, 不存在DeviceList则为查询请求 |
| 414 | 424 | if (name.equalsIgnoreCase("Query")) { // 区分是Response——查询响应,还是Query——查询请求 |
| 415 | - // TODO 后续将代码拆分 | |
| 425 | + // TODO 后续将代码拆分 | |
| 416 | 426 | ParentPlatform parentPlatform = storager.queryParentPlatById(platformId); |
| 417 | 427 | if (parentPlatform == null) { |
| 418 | 428 | response404Ack(evt); |
| 419 | 429 | return; |
| 420 | - }else { | |
| 430 | + } else { | |
| 421 | 431 | // 回复200 OK |
| 422 | 432 | responseAck(evt); |
| 423 | 433 | |
| ... | ... | @@ -425,7 +435,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 425 | 435 | String sn = snElement.getText(); |
| 426 | 436 | // 准备回复通道信息 |
| 427 | 437 | List<ChannelReduce> channelReduces = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); |
| 428 | - if (channelReduces.size() >0 ) { | |
| 438 | + if (channelReduces.size() > 0) { | |
| 429 | 439 | for (ChannelReduce channelReduce : channelReduces) { |
| 430 | 440 | DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); |
| 431 | 441 | cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), channelReduces.size()); |
| ... | ... | @@ -435,7 +445,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 435 | 445 | } |
| 436 | 446 | |
| 437 | 447 | |
| 438 | - }else { | |
| 448 | + } else { | |
| 439 | 449 | Iterator<Element> deviceListIterator = deviceListElement.elementIterator(); |
| 440 | 450 | if (deviceListIterator != null) { |
| 441 | 451 | Device device = storager.queryVideoDevice(deviceId); |
| ... | ... | @@ -465,76 +475,77 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 465 | 475 | deviceChannel.setStatus(0); |
| 466 | 476 | } |
| 467 | 477 | |
| 468 | - deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer")); | |
| 469 | - deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model")); | |
| 470 | - deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner")); | |
| 471 | - deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); | |
| 472 | - deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); | |
| 473 | - deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); | |
| 474 | - if (XmlUtil.getText(itemDevice, "Parental") == null || XmlUtil.getText(itemDevice, "Parental") == "") { | |
| 475 | - deviceChannel.setParental(0); | |
| 476 | - } else { | |
| 477 | - deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); | |
| 478 | - } | |
| 479 | - deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); | |
| 480 | - if (XmlUtil.getText(itemDevice, "SafetyWay") == null || XmlUtil.getText(itemDevice, "SafetyWay")== "") { | |
| 481 | - deviceChannel.setSafetyWay(0); | |
| 482 | - } else { | |
| 483 | - deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); | |
| 484 | - } | |
| 485 | - if (XmlUtil.getText(itemDevice, "RegisterWay") == null || XmlUtil.getText(itemDevice, "RegisterWay") =="") { | |
| 486 | - deviceChannel.setRegisterWay(1); | |
| 487 | - } else { | |
| 488 | - deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); | |
| 489 | - } | |
| 490 | - deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); | |
| 491 | - if (XmlUtil.getText(itemDevice, "Certifiable") == null || XmlUtil.getText(itemDevice, "Certifiable") == "") { | |
| 492 | - deviceChannel.setCertifiable(0); | |
| 493 | - } else { | |
| 494 | - deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); | |
| 495 | - } | |
| 496 | - if (XmlUtil.getText(itemDevice, "ErrCode") == null || XmlUtil.getText(itemDevice, "ErrCode") == "") { | |
| 497 | - deviceChannel.setErrCode(0); | |
| 498 | - } else { | |
| 499 | - deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); | |
| 500 | - } | |
| 501 | - deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); | |
| 502 | - deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); | |
| 503 | - deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); | |
| 504 | - if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") =="") { | |
| 505 | - deviceChannel.setPort(0); | |
| 506 | - } else { | |
| 507 | - deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); | |
| 508 | - } | |
| 509 | - deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); | |
| 510 | - if (XmlUtil.getText(itemDevice, "Longitude") == null || XmlUtil.getText(itemDevice, "Longitude") == "") { | |
| 511 | - deviceChannel.setLongitude(0.00); | |
| 512 | - } else { | |
| 513 | - deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude"))); | |
| 514 | - } | |
| 515 | - if (XmlUtil.getText(itemDevice, "Latitude") == null || XmlUtil.getText(itemDevice, "Latitude") =="") { | |
| 516 | - deviceChannel.setLatitude(0.00); | |
| 517 | - } else { | |
| 518 | - deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude"))); | |
| 519 | - } | |
| 520 | - if (XmlUtil.getText(itemDevice, "PTZType") == null || XmlUtil.getText(itemDevice, "PTZType") == "") { | |
| 521 | - deviceChannel.setPTZType(0); | |
| 522 | - } else { | |
| 523 | - deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); | |
| 478 | + deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer")); | |
| 479 | + deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model")); | |
| 480 | + deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner")); | |
| 481 | + deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); | |
| 482 | + deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); | |
| 483 | + deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); | |
| 484 | + if (XmlUtil.getText(itemDevice, "Parental") == null || XmlUtil.getText(itemDevice, "Parental") == "") { | |
| 485 | + deviceChannel.setParental(0); | |
| 486 | + } else { | |
| 487 | + deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); | |
| 488 | + } | |
| 489 | + deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); | |
| 490 | + if (XmlUtil.getText(itemDevice, "SafetyWay") == null || XmlUtil.getText(itemDevice, "SafetyWay") == "") { | |
| 491 | + deviceChannel.setSafetyWay(0); | |
| 492 | + } else { | |
| 493 | + deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); | |
| 494 | + } | |
| 495 | + if (XmlUtil.getText(itemDevice, "RegisterWay") == null || XmlUtil.getText(itemDevice, "RegisterWay") == "") { | |
| 496 | + deviceChannel.setRegisterWay(1); | |
| 497 | + } else { | |
| 498 | + deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); | |
| 499 | + } | |
| 500 | + deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); | |
| 501 | + if (XmlUtil.getText(itemDevice, "Certifiable") == null || XmlUtil.getText(itemDevice, "Certifiable") == "") { | |
| 502 | + deviceChannel.setCertifiable(0); | |
| 503 | + } else { | |
| 504 | + deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); | |
| 505 | + } | |
| 506 | + if (XmlUtil.getText(itemDevice, "ErrCode") == null || XmlUtil.getText(itemDevice, "ErrCode") == "") { | |
| 507 | + deviceChannel.setErrCode(0); | |
| 508 | + } else { | |
| 509 | + deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); | |
| 510 | + } | |
| 511 | + deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); | |
| 512 | + deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); | |
| 513 | + deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); | |
| 514 | + if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") == "") { | |
| 515 | + deviceChannel.setPort(0); | |
| 516 | + } else { | |
| 517 | + deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); | |
| 518 | + } | |
| 519 | + deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); | |
| 520 | + if (XmlUtil.getText(itemDevice, "Longitude") == null || XmlUtil.getText(itemDevice, "Longitude") == "") { | |
| 521 | + deviceChannel.setLongitude(0.00); | |
| 522 | + } else { | |
| 523 | + deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude"))); | |
| 524 | + } | |
| 525 | + if (XmlUtil.getText(itemDevice, "Latitude") == null || XmlUtil.getText(itemDevice, "Latitude") == "") { | |
| 526 | + deviceChannel.setLatitude(0.00); | |
| 527 | + } else { | |
| 528 | + deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude"))); | |
| 529 | + } | |
| 530 | + if (XmlUtil.getText(itemDevice, "PTZType") == null || XmlUtil.getText(itemDevice, "PTZType") == "") { | |
| 531 | + deviceChannel.setPTZType(0); | |
| 532 | + } else { | |
| 533 | + deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); | |
| 534 | + } | |
| 535 | + deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC | |
| 536 | + storager.updateChannel(device.getDeviceId(), deviceChannel); | |
| 524 | 537 | } |
| 525 | - deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC | |
| 526 | - storager.updateChannel(device.getDeviceId(), deviceChannel); | |
| 527 | - } | |
| 528 | 538 | |
| 529 | - RequestMessage msg = new RequestMessage(); | |
| 530 | - msg.setDeviceId(deviceId); | |
| 531 | - msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG); | |
| 532 | - msg.setData(device); | |
| 533 | - deferredResultHolder.invokeResult(msg); | |
| 534 | - // 回复200 OK | |
| 535 | - responseAck(evt); | |
| 536 | - if (offLineDetector.isOnline(deviceId)) { | |
| 537 | - publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); | |
| 539 | + RequestMessage msg = new RequestMessage(); | |
| 540 | + msg.setDeviceId(deviceId); | |
| 541 | + msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG); | |
| 542 | + msg.setData(device); | |
| 543 | + deferredResultHolder.invokeResult(msg); | |
| 544 | + // 回复200 OK | |
| 545 | + responseAck(evt); | |
| 546 | + if (offLineDetector.isOnline(deviceId)) { | |
| 547 | + publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); | |
| 548 | + } | |
| 538 | 549 | } |
| 539 | 550 | } |
| 540 | 551 | } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { |
| ... | ... | @@ -723,11 +734,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 723 | 734 | } |
| 724 | 735 | } |
| 725 | 736 | |
| 726 | - /** | |
| 727 | - * 收到MediaStatus消息处理 | |
| 728 | - * | |
| 729 | - * @param evt | |
| 730 | - */ | |
| 737 | + | |
| 731 | 738 | private void processMessageMediaStatus(RequestEvent evt){ |
| 732 | 739 | try { |
| 733 | 740 | // 回复200 OK | ... | ... |
src/main/resources/wvp.sqlite
No preview for this file type