去除国标级联中ServerTransaction的使用
This commit is contained in:
parent
dbaf0fdbf4
commit
dd986dcbdd
@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider;
|
||||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||||
@ -54,21 +55,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ZLMRTPServerFactory zlmrtpServerFactory;
|
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||||
|
|
||||||
@Lazy
|
|
||||||
@Autowired
|
|
||||||
@Qualifier(value="tcpSipProvider")
|
|
||||||
private SipProviderImpl tcpSipProvider;
|
|
||||||
|
|
||||||
@Lazy
|
|
||||||
@Autowired
|
|
||||||
@Qualifier(value="udpSipProvider")
|
|
||||||
private SipProviderImpl udpSipProvider;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipFactory sipFactory;
|
private SipFactory sipFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SubscribeHolder subscribeHolder;
|
private SIPSender sipSender;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException {
|
public void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException {
|
||||||
@ -85,13 +76,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister) throws SipException, InvalidArgumentException, ParseException {
|
SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean registerAgain, boolean isRegister) throws SipException, InvalidArgumentException, ParseException {
|
||||||
Request request;
|
Request request;
|
||||||
if (!registerAgain ) {
|
if (!registerAgain ) {
|
||||||
CallIdHeader callIdHeader = null;
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
if(parentPlatform.getTransport().equalsIgnoreCase("TCP")) {
|
|
||||||
callIdHeader = tcpSipProvider.getNewCallId();
|
|
||||||
}
|
|
||||||
if(parentPlatform.getTransport().equalsIgnoreCase("UDP")) {
|
|
||||||
callIdHeader = udpSipProvider.getNewCallId();
|
|
||||||
}
|
|
||||||
|
|
||||||
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform,
|
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform,
|
||||||
redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(),
|
redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(),
|
||||||
@ -113,12 +98,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
: udpSipProvider.getNewCallId();
|
|
||||||
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister);
|
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
transmitRequest(parentPlatform, request, null, okEvent);
|
sipSender.transmitRequest( request, null, okEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -133,8 +117,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
keepaliveXml.append("<Status>OK</Status>\r\n");
|
keepaliveXml.append("<Status>OK</Status>\r\n");
|
||||||
keepaliveXml.append("</Notify>\r\n");
|
keepaliveXml.append("</Notify>\r\n");
|
||||||
|
|
||||||
CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
: udpSipProvider.getNewCallId();
|
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(
|
Request request = headerProviderPlatformProvider.createMessageRequest(
|
||||||
parentPlatform,
|
parentPlatform,
|
||||||
@ -142,39 +125,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
SipUtils.getNewFromTag(),
|
SipUtils.getNewFromTag(),
|
||||||
SipUtils.getNewViaTag(),
|
SipUtils.getNewViaTag(),
|
||||||
callIdHeader);
|
callIdHeader);
|
||||||
transmitRequest(parentPlatform, request, errorEvent, okEvent);
|
sipSender.transmitRequest( request, errorEvent, okEvent);
|
||||||
return callIdHeader.getCallId();
|
return callIdHeader.getCallId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transmitRequest(ParentPlatform parentPlatform, Request request) throws SipException {
|
|
||||||
transmitRequest(parentPlatform, request, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent) throws SipException {
|
|
||||||
transmitRequest(parentPlatform, request, errorEvent, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void transmitRequest(ParentPlatform parentPlatform, Request request, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException {
|
|
||||||
logger.debug("\n发送消息:\n{}", request);
|
|
||||||
if("TCP".equalsIgnoreCase(parentPlatform.getTransport())) {
|
|
||||||
tcpSipProvider.sendRequest(request);
|
|
||||||
|
|
||||||
} else if("UDP".equalsIgnoreCase(parentPlatform.getTransport())) {
|
|
||||||
udpSipProvider.sendRequest(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME);
|
|
||||||
// 添加错误订阅
|
|
||||||
if (errorEvent != null) {
|
|
||||||
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), errorEvent);
|
|
||||||
}
|
|
||||||
// 添加订阅
|
|
||||||
if (okEvent != null) {
|
|
||||||
sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), okEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 向上级回复通道信息
|
* 向上级回复通道信息
|
||||||
* @param channel 通道信息
|
* @param channel 通道信息
|
||||||
@ -194,11 +148,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
String catalogXml = getCatalogXml(channels, sn, parentPlatform, size);
|
String catalogXml = getCatalogXml(channels, sn, parentPlatform, size);
|
||||||
|
|
||||||
// callid
|
// callid
|
||||||
CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
: udpSipProvider.getNewCallId();
|
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
transmitRequest(parentPlatform, request);
|
sipSender.transmitRequest( request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,11 +234,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
}
|
}
|
||||||
String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size());
|
String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size());
|
||||||
// callid
|
// callid
|
||||||
CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
: udpSipProvider.getNewCallId();
|
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
transmitRequest(parentPlatform, request, null, eventResult -> {
|
sipSender.transmitRequest( request, null, eventResult -> {
|
||||||
int indexNext = index + parentPlatform.getCatalogGroup();
|
int indexNext = index + parentPlatform.getCatalogGroup();
|
||||||
try {
|
try {
|
||||||
sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext);
|
sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext);
|
||||||
@ -321,11 +273,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
deviceInfoXml.append("<Result>OK</Result>\r\n");
|
deviceInfoXml.append("<Result>OK</Result>\r\n");
|
||||||
deviceInfoXml.append("</Response>\r\n");
|
deviceInfoXml.append("</Response>\r\n");
|
||||||
|
|
||||||
CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
: udpSipProvider.getNewCallId();
|
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
transmitRequest(parentPlatform, request);
|
sipSender.transmitRequest( request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -352,11 +303,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
deviceStatusXml.append("<Status>OK</Status>\r\n");
|
deviceStatusXml.append("<Status>OK</Status>\r\n");
|
||||||
deviceStatusXml.append("</Response>\r\n");
|
deviceStatusXml.append("</Response>\r\n");
|
||||||
|
|
||||||
CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
: udpSipProvider.getNewCallId();
|
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
transmitRequest(parentPlatform, request);
|
sipSender.transmitRequest( request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,11 +365,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
deviceStatusXml.append("</info>\r\n");
|
deviceStatusXml.append("</info>\r\n");
|
||||||
deviceStatusXml.append("</Notify>\r\n");
|
deviceStatusXml.append("</Notify>\r\n");
|
||||||
|
|
||||||
CallIdHeader callIdHeader = parentPlatform.getTransport().equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
: udpSipProvider.getNewCallId();
|
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader);
|
||||||
transmitRequest(parentPlatform, request);
|
sipSender.transmitRequest( request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,7 +415,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
|
|
||||||
SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo);
|
SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo);
|
||||||
|
|
||||||
transmitRequest(parentPlatform, notifyRequest);
|
sipSender.transmitRequest( notifyRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) {
|
private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) {
|
||||||
@ -631,10 +580,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
recordXml.append("</Response>\r\n");
|
recordXml.append("</Response>\r\n");
|
||||||
|
|
||||||
// callid
|
// callid
|
||||||
CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
||||||
: udpSipProvider.getNewCallId();
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
transmitRequest(parentPlatform, request);
|
sipSender.transmitRequest( request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,7 +607,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(platform, mediaStatusXml.toString(),
|
SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(platform, mediaStatusXml.toString(),
|
||||||
sendRtpItem);
|
sendRtpItem);
|
||||||
|
|
||||||
transmitRequest(platform, messageRequest);
|
sipSender.transmitRequest(messageRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,6 +643,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
|||||||
if (byeRequest == null) {
|
if (byeRequest == null) {
|
||||||
logger.warn("[向上级发送bye]:无法创建 byeRequest");
|
logger.warn("[向上级发送bye]:无法创建 byeRequest");
|
||||||
}
|
}
|
||||||
transmitRequest(platform,byeRequest);
|
sipSender.transmitRequest(byeRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user