From ffb21248cb270475ce9156b5056e591e14cbc20d Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 30 五月 2023 11:20:22 +0800
Subject: [PATCH] 去除多余配置
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java | 81 ++++++++++++++++++++++++++++------------
1 files changed, 57 insertions(+), 24 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
index b9d2c4c..b1e2196 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
@@ -16,6 +16,7 @@
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
import com.genersoft.iot.vmp.utils.DateUtil;
+import com.genersoft.iot.vmp.utils.GitUtil;
import gov.nist.javax.sip.message.MessageFactoryImpl;
import gov.nist.javax.sip.message.SIPRequest;
import org.slf4j.Logger;
@@ -28,6 +29,7 @@
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
+import javax.sip.SipFactory;
import javax.sip.header.CallIdHeader;
import javax.sip.header.WWWAuthenticateHeader;
import javax.sip.message.Request;
@@ -65,26 +67,49 @@
@Autowired
private DynamicTask dynamicTask;
+ @Autowired
+ private GitUtil gitUtil;
+
@Override
public void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException {
- register(parentPlatform, null, null, errorEvent, okEvent, false, true);
+ register(parentPlatform, null, null, errorEvent, okEvent, true);
}
@Override
- public void unregister(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException {
- register(parentPlatform, null, null, errorEvent, okEvent, false, false);
+ public void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException {
+
+ register(parentPlatform, sipTransactionInfo, null, errorEvent, okEvent, true);
}
@Override
- public void register(ParentPlatform parentPlatform, @Nullable String callId, @Nullable WWWAuthenticateHeader www,
- SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister) throws SipException, InvalidArgumentException, ParseException {
+ public void unregister(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException {
+ register(parentPlatform, sipTransactionInfo, null, errorEvent, okEvent, false);
+ }
+
+ @Override
+ public void register(ParentPlatform parentPlatform, @Nullable SipTransactionInfo sipTransactionInfo, @Nullable WWWAuthenticateHeader www,
+ SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean isRegister) throws SipException, InvalidArgumentException, ParseException {
Request request;
- if (!registerAgain ) {
- CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
+ CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
+ String fromTag = SipUtils.getNewFromTag();
+ String toTag = null;
+ if (sipTransactionInfo != null ) {
+ if (sipTransactionInfo.getCallId() != null) {
+ callIdHeader.setCallId(sipTransactionInfo.getCallId());
+ }
+ if (sipTransactionInfo.getFromTag() != null) {
+ fromTag = sipTransactionInfo.getFromTag();
+ }
+ if (sipTransactionInfo.getToTag() != null) {
+ toTag = sipTransactionInfo.getToTag();
+ }
+ }
+
+ if (www == null ) {
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform,
- redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(),
- SipUtils.getNewViaTag(), callIdHeader, isRegister);
+ redisCatchStorage.getCSEQ(), fromTag,
+ toTag, callIdHeader, isRegister? parentPlatform.getExpires() : 0);
// 灏� callid 鍐欏叆缂撳瓨锛� 绛夋敞鍐屾垚鍔熷彲浠ユ洿鏂扮姸鎬�
String callIdFromHeader = callIdHeader.getCallId();
redisCatchStorage.updatePlatformRegisterInfo(callIdFromHeader, PlatformRegisterInfo.getInstance(parentPlatform.getServerGBId(), isRegister));
@@ -102,8 +127,7 @@
});
}else {
- CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
- request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister);
+ request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, fromTag, toTag, www, callIdHeader, isRegister? parentPlatform.getExpires() : 0);
}
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent);
@@ -197,7 +221,7 @@
if (!channel.getChannelId().equals(parentPlatform.getDeviceGBId())) {
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
if (channel.getParental() == 0) {
- catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
+ catalogXml.append("<Status>" + (channel.isStatus() ? "ON" : "OFF") + "</Status>\r\n");
}
}
if (channel.getParental() == 0) {
@@ -225,7 +249,8 @@
catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");
catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n");
catalogXml.append("<Password>" + channel.getPort() + "</Password>\r\n");
- catalogXml.append("<Status>" + (channel.getStatus() == 1?"ON":"OFF") + "</Status>\r\n");
+ catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");
+ catalogXml.append("<Status>" + (channel.isStatus() ? "ON":"OFF") + "</Status>\r\n");
catalogXml.append("<Longitude>" +
(channel.getLongitudeWgs84() != 0? channel.getLongitudeWgs84():channel.getLongitude())
+ "</Longitude>\r\n");
@@ -265,6 +290,9 @@
String callId = request.getCallIdHeader().getCallId();
+ logger.info("[鍛戒护鍙戦�乚 鍥芥爣绾ц仈{} 鐩綍鏌ヨ鍥炲: 鍏眥}鏉★紝宸插彂閫亄}鏉�", parentPlatform.getServerGBId(),
+ channels.size(), Math.min(index + parentPlatform.getCatalogGroup(), channels.size()));
+ logger.debug(catalogXml);
if (sendAfterResponse) {
// 榛樿鎸夌収鏀跺埌200鍥炲鍚庡彂閫佷笅涓�鏉★紝 濡傛灉瓒呮椂鏀朵笉鍒板洖澶嶏紝灏变互30姣鐨勯棿闅旂洿鎺ュ彂閫併��
dynamicTask.startDelay(timeoutTaskKey, ()->{
@@ -316,17 +344,22 @@
if (parentPlatform == null) {
return;
}
+ String deviceId = device == null ? parentPlatform.getDeviceGBId() : device.getDeviceId();
+ String deviceName = device == null ? parentPlatform.getName() : device.getName();
+ String manufacturer = device == null ? "WVP-28181-PRO" : device.getManufacturer();
+ String model = device == null ? "platform" : device.getModel();
+ String firmware = device == null ? gitUtil.getBuildVersion() : device.getFirmware();
String characterSet = parentPlatform.getCharacterSet();
StringBuffer deviceInfoXml = new StringBuffer(600);
deviceInfoXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
deviceInfoXml.append("<Response>\r\n");
deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n");
deviceInfoXml.append("<SN>" +sn + "</SN>\r\n");
- deviceInfoXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
- deviceInfoXml.append("<DeviceName>" + device.getName() + "</DeviceName>\r\n");
- deviceInfoXml.append("<Manufacturer>" + device.getManufacturer() + "</Manufacturer>\r\n");
- deviceInfoXml.append("<Model>" + device.getModel() + "</Model>\r\n");
- deviceInfoXml.append("<Firmware>" + device.getFirmware() + "</Firmware>\r\n");
+ deviceInfoXml.append("<DeviceID>" + deviceId + "</DeviceID>\r\n");
+ deviceInfoXml.append("<DeviceName>" + deviceName + "</DeviceName>\r\n");
+ deviceInfoXml.append("<Manufacturer>" + manufacturer + "</Manufacturer>\r\n");
+ deviceInfoXml.append("<Model>" + model + "</Model>\r\n");
+ deviceInfoXml.append("<Firmware>" + firmware + "</Firmware>\r\n");
deviceInfoXml.append("<Result>OK</Result>\r\n");
deviceInfoXml.append("</Response>\r\n");
@@ -344,11 +377,11 @@
* @return
*/
@Override
- public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,int status) throws SipException, InvalidArgumentException, ParseException {
+ public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,boolean status) throws SipException, InvalidArgumentException, ParseException {
if (parentPlatform == null) {
return ;
}
- String statusStr = (status==1)?"ONLINE":"OFFLINE";
+ String statusStr = (status)?"ONLINE":"OFFLINE";
String characterSet = parentPlatform.getCharacterSet();
StringBuffer deviceStatusXml = new StringBuffer(600);
deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
@@ -465,10 +498,10 @@
private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent,
SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent )
throws SipException, ParseException, InvalidArgumentException {
- MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory();
+ MessageFactoryImpl messageFactory = (MessageFactoryImpl) SipFactory.getInstance().createMessageFactory();
String characterSet = parentPlatform.getCharacterSet();
- // 璁剧疆缂栫爜锛� 闃叉涓枃涔辩爜
- messageFactory.setDefaultContentEncodingCharset(characterSet);
+ // 璁剧疆缂栫爜锛� 闃叉涓枃涔辩爜
+ messageFactory.setDefaultContentEncodingCharset(characterSet);
SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo);
@@ -509,7 +542,7 @@
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n")
.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n")
.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n")
- .append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
+ .append("<Status>" + (channel.isStatus() ? "ON" : "OFF") + "</Status>\r\n");
if (channel.getChannelType() != 2) { // 涓氬姟鍒嗙粍/铏氭嫙缁勭粐/琛屾斂鍖哄垝 涓嶈缃互涓嬪睘鎬�
catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n")
--
Gitblit v1.8.0