支持多网卡
parent
f3454caaf6
commit
1ab73f69eb
|
@ -13,6 +13,9 @@ alter table device
|
||||||
alter table device
|
alter table device
|
||||||
add sdpIp varchar(50) default null;
|
add sdpIp varchar(50) default null;
|
||||||
|
|
||||||
|
alter table device
|
||||||
|
add localIp varchar(50) default null;
|
||||||
|
|
||||||
alter table device
|
alter table device
|
||||||
add password varchar(255) default null;
|
add password varchar(255) default null;
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,6 @@ public class SipConfig {
|
||||||
|
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认使用 0.0.0.0
|
|
||||||
*/
|
|
||||||
private String monitorIp = "0.0.0.0";
|
|
||||||
|
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
private String domain;
|
private String domain;
|
||||||
|
@ -35,10 +30,6 @@ public class SipConfig {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMonitorIp(String monitorIp) {
|
|
||||||
this.monitorIp = monitorIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(Integer port) {
|
public void setPort(Integer port) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
@ -67,10 +58,6 @@ public class SipConfig {
|
||||||
this.registerTimeInterval = registerTimeInterval;
|
this.registerTimeInterval = registerTimeInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMonitorIp() {
|
|
||||||
return monitorIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIp() {
|
public String getIp() {
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,17 @@ import gov.nist.javax.sip.SipStackImpl;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.sip.*;
|
import javax.sip.*;
|
||||||
import java.util.Properties;
|
import java.util.*;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Configuration
|
@Component
|
||||||
public class SipLayer{
|
@Order(value=1)
|
||||||
|
public class SipLayer implements CommandLineRunner {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);
|
private final static Logger logger = LoggerFactory.getLogger(SipLayer.class);
|
||||||
|
|
||||||
|
@ -27,70 +28,103 @@ public class SipLayer{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISIPProcessorObserver sipProcessorObserver;
|
private ISIPProcessorObserver sipProcessorObserver;
|
||||||
|
|
||||||
private SipStackImpl sipStack;
|
|
||||||
|
|
||||||
|
private final Map<String, SipProviderImpl> tcpSipProviderMap = new ConcurrentHashMap<>();
|
||||||
|
private final Map<String, SipProviderImpl> udpSipProviderMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private SipFactory sipFactory;
|
private SipFactory sipFactory;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(String... args) {
|
||||||
|
List<String> monitorIps = new ArrayList<>();
|
||||||
|
// 使用逗号分割多个ip
|
||||||
|
String separator = ",";
|
||||||
|
if (sipConfig.getIp().indexOf(separator) > 0) {
|
||||||
|
String[] split = sipConfig.getIp().split(separator);
|
||||||
|
monitorIps.addAll(Arrays.asList(split));
|
||||||
|
}else {
|
||||||
|
monitorIps.add(sipConfig.getIp());
|
||||||
|
}
|
||||||
|
|
||||||
@Bean("sipFactory")
|
|
||||||
SipFactory createSipFactory() {
|
|
||||||
sipFactory = SipFactory.getInstance();
|
sipFactory = SipFactory.getInstance();
|
||||||
sipFactory.setPathName("gov.nist");
|
sipFactory.setPathName("gov.nist");
|
||||||
|
if (monitorIps.size() > 0) {
|
||||||
|
for (String monitorIp : monitorIps) {
|
||||||
|
addListeningPoint(monitorIp, sipConfig.getPort());
|
||||||
|
}
|
||||||
|
if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) {
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addListeningPoint(String monitorIp, int port){
|
||||||
|
SipStackImpl sipStack;
|
||||||
|
try {
|
||||||
|
sipStack = (SipStackImpl)sipFactory.createSipStack(DefaultProperties.getProperties(monitorIp, false));
|
||||||
|
} catch (PeerUnavailableException e) {
|
||||||
|
logger.error("[Sip Server] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP");
|
||||||
|
SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
|
||||||
|
tcpSipProvider.setDialogErrorsAutomaticallyHandled();
|
||||||
|
tcpSipProvider.addSipListener(sipProcessorObserver);
|
||||||
|
tcpSipProviderMap.put(monitorIp, tcpSipProvider);
|
||||||
|
|
||||||
|
logger.info("[Sip Server] tcp://{}:{} 启动成功", monitorIp, port);
|
||||||
|
} catch (TransportNotSupportedException
|
||||||
|
| TooManyListenersException
|
||||||
|
| ObjectInUseException
|
||||||
|
| InvalidArgumentException e) {
|
||||||
|
logger.error("[Sip Server] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
|
||||||
|
, monitorIp, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP");
|
||||||
|
|
||||||
|
SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
|
||||||
|
udpSipProvider.addSipListener(sipProcessorObserver);
|
||||||
|
|
||||||
|
udpSipProviderMap.put(monitorIp, udpSipProvider);
|
||||||
|
|
||||||
|
logger.info("[Sip Server] udp://{}:{} 启动成功", monitorIp, port);
|
||||||
|
} catch (TransportNotSupportedException
|
||||||
|
| TooManyListenersException
|
||||||
|
| ObjectInUseException
|
||||||
|
| InvalidArgumentException e) {
|
||||||
|
logger.error("[Sip Server] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确"
|
||||||
|
, monitorIp, port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SipFactory getSipFactory() {
|
||||||
return sipFactory;
|
return sipFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("sipStack")
|
public SipProviderImpl getUdpSipProvider(String ip) {
|
||||||
@DependsOn({"sipFactory"})
|
return udpSipProviderMap.get(ip);
|
||||||
SipStackImpl createSipStack() throws PeerUnavailableException {
|
|
||||||
sipStack = ( SipStackImpl )sipFactory.createSipStack(DefaultProperties.getProperties(sipConfig.getMonitorIp(), false));
|
|
||||||
return sipStack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "tcpSipProvider")
|
public SipProviderImpl getUdpSipProvider() {
|
||||||
@DependsOn("sipStack")
|
if (udpSipProviderMap.size() != 1) {
|
||||||
SipProviderImpl startTcpListener() {
|
return null;
|
||||||
ListeningPoint tcpListeningPoint = null;
|
|
||||||
SipProviderImpl tcpSipProvider = null;
|
|
||||||
try {
|
|
||||||
tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "TCP");
|
|
||||||
tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
|
|
||||||
tcpSipProvider.setDialogErrorsAutomaticallyHandled();
|
|
||||||
tcpSipProvider.addSipListener(sipProcessorObserver);
|
|
||||||
logger.info("[Sip Server] TCP 启动成功 {}:{}", sipConfig.getMonitorIp(), sipConfig.getPort());
|
|
||||||
} catch (TransportNotSupportedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvalidArgumentException e) {
|
|
||||||
logger.error("[Sip Server] 无法使用 [ {}:{} ]作为SIP[ TCP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用"
|
|
||||||
, sipConfig.getMonitorIp(), sipConfig.getPort());
|
|
||||||
} catch (TooManyListenersException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ObjectInUseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return tcpSipProvider;
|
return udpSipProviderMap.values().stream().findFirst().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "udpSipProvider")
|
public SipProviderImpl getTcpSipProvider() {
|
||||||
@DependsOn("sipStack")
|
if (tcpSipProviderMap.size() != 1) {
|
||||||
SipProviderImpl startUdpListener() {
|
return null;
|
||||||
ListeningPoint udpListeningPoint = null;
|
|
||||||
SipProviderImpl udpSipProvider = null;
|
|
||||||
try {
|
|
||||||
udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "UDP");
|
|
||||||
udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
|
|
||||||
udpSipProvider.addSipListener(sipProcessorObserver);
|
|
||||||
} catch (TransportNotSupportedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvalidArgumentException e) {
|
|
||||||
logger.error("[Sip Server] 无法使用 [ {}:{} ]作为SIP[ UDP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用"
|
|
||||||
, sipConfig.getMonitorIp(), sipConfig.getPort());
|
|
||||||
} catch (TooManyListenersException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (ObjectInUseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
logger.info("[Sip Server] UDP 启动成功 {}:{}", sipConfig.getMonitorIp(), sipConfig.getPort());
|
return tcpSipProviderMap.values().stream().findFirst().get();
|
||||||
return udpSipProvider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SipProviderImpl getTcpSipProvider(String ip) {
|
||||||
|
return tcpSipProviderMap.get(ip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,9 @@ public class Device {
|
||||||
@Schema(description = "收流IP")
|
@Schema(description = "收流IP")
|
||||||
private String sdpIp;
|
private String sdpIp;
|
||||||
|
|
||||||
|
@Schema(description = "SIP交互IP(设备访问平台的IP)")
|
||||||
|
private String localIp;
|
||||||
|
|
||||||
|
|
||||||
public String getDeviceId() {
|
public String getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
|
@ -402,4 +405,12 @@ public class Device {
|
||||||
public void setSdpIp(String sdpIp) {
|
public void setSdpIp(String sdpIp) {
|
||||||
this.sdpIp = sdpIp;
|
this.sdpIp = sdpIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLocalIp() {
|
||||||
|
return localIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocalIp(String localIp) {
|
||||||
|
this.localIp = localIp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor;
|
||||||
|
import gov.nist.javax.sip.message.SIPRequest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -15,6 +16,7 @@ import javax.sip.*;
|
||||||
import javax.sip.header.*;
|
import javax.sip.header.*;
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -75,6 +77,7 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
|
||||||
ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method);
|
ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method);
|
||||||
if (sipRequestProcessor == null) {
|
if (sipRequestProcessor == null) {
|
||||||
logger.warn("不支持方法{}的request", method);
|
logger.warn("不支持方法{}的request", method);
|
||||||
|
// TODO 回复错误玛
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
requestProcessorMap.get(method).process(requestEvent);
|
requestProcessorMap.get(method).process(requestEvent);
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.transmit;
|
package com.genersoft.iot.vmp.gb28181.transmit;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.gb28181.SipLayer;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||||
import gov.nist.javax.sip.SipProviderImpl;
|
import gov.nist.javax.sip.SipProviderImpl;
|
||||||
|
import gov.nist.javax.sip.message.SIPRequest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -18,6 +20,7 @@ import javax.sip.header.ViaHeader;
|
||||||
import javax.sip.message.Message;
|
import javax.sip.message.Message;
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
import javax.sip.message.Response;
|
import javax.sip.message.Response;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,15 +33,7 @@ public class SIPSender {
|
||||||
private final Logger logger = LoggerFactory.getLogger(SIPSender.class);
|
private final Logger logger = LoggerFactory.getLogger(SIPSender.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier(value = "tcpSipProvider")
|
private SipLayer sipLayer;
|
||||||
private SipProviderImpl tcpSipProvider;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
@Qualifier(value = "udpSipProvider")
|
|
||||||
private SipProviderImpl udpSipProvider;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SipFactory sipFactory;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GitUtil gitUtil;
|
private GitUtil gitUtil;
|
||||||
|
@ -46,25 +41,25 @@ public class SIPSender {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipSubscribe sipSubscribe;
|
private SipSubscribe sipSubscribe;
|
||||||
|
|
||||||
public void transmitRequest(Message message) throws SipException, ParseException {
|
public void transmitRequest(String ip, Message message) throws SipException, ParseException {
|
||||||
transmitRequest(message, null, null);
|
transmitRequest(ip, message, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transmitRequest(Message message, SipSubscribe.Event errorEvent) throws SipException, ParseException {
|
public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent) throws SipException, ParseException {
|
||||||
transmitRequest(message, errorEvent, null);
|
transmitRequest(ip, message, errorEvent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transmitRequest(Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException {
|
public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException {
|
||||||
ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME);
|
ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME);
|
||||||
String transport = "UDP";
|
String transport = "UDP";
|
||||||
if (viaHeader == null) {
|
if (viaHeader == null) {
|
||||||
logger.warn("[消息头缺失]: ViaHeader");
|
logger.warn("[消息头缺失]: ViaHeader, 使用默认的UDP方式处理数据");
|
||||||
}else {
|
}else {
|
||||||
transport = viaHeader.getTransport();
|
transport = viaHeader.getTransport();
|
||||||
}
|
}
|
||||||
if (message.getHeader(UserAgentHeader.NAME) == null) {
|
if (message.getHeader(UserAgentHeader.NAME) == null) {
|
||||||
try {
|
try {
|
||||||
message.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
message.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
logger.error("添加UserAgentHeader失败", e);
|
logger.error("添加UserAgentHeader失败", e);
|
||||||
}
|
}
|
||||||
|
@ -88,6 +83,11 @@ public class SIPSender {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ("TCP".equals(transport)) {
|
if ("TCP".equals(transport)) {
|
||||||
|
SipProviderImpl tcpSipProvider = sipLayer.getTcpSipProvider(ip);
|
||||||
|
if (tcpSipProvider == null) {
|
||||||
|
logger.error("[发送信息失败] 未找到tcp://{}的监听信息", ip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (message instanceof Request) {
|
if (message instanceof Request) {
|
||||||
tcpSipProvider.sendRequest((Request)message);
|
tcpSipProvider.sendRequest((Request)message);
|
||||||
}else if (message instanceof Response) {
|
}else if (message instanceof Response) {
|
||||||
|
@ -95,16 +95,21 @@ public class SIPSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("UDP".equals(transport)) {
|
} else if ("UDP".equals(transport)) {
|
||||||
|
SipProviderImpl sipProvider = sipLayer.getUdpSipProvider(ip);
|
||||||
|
if (sipProvider == null) {
|
||||||
|
logger.error("[发送信息失败] 未找到udp://{}的监听信息", ip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (message instanceof Request) {
|
if (message instanceof Request) {
|
||||||
udpSipProvider.sendRequest((Request)message);
|
sipProvider.sendRequest((Request)message);
|
||||||
}else if (message instanceof Response) {
|
}else if (message instanceof Response) {
|
||||||
udpSipProvider.sendResponse((Response)message);
|
sipProvider.sendResponse((Response)message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CallIdHeader getNewCallIdHeader(String transport){
|
public CallIdHeader getNewCallIdHeader(String ip, String transport){
|
||||||
return transport.equalsIgnoreCase("TCP") ? tcpSipProvider.getNewCallId()
|
return transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider(ip).getNewCallId()
|
||||||
: udpSipProvider.getNewCallId();
|
: sipLayer.getUdpSipProvider(ip).getNewCallId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
package com.genersoft.iot.vmp.gb28181.transmit.cmd;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.SipLayer;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
|
||||||
|
@ -36,7 +37,7 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
private SipConfig sipConfig;
|
private SipConfig sipConfig;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipFactory sipFactory;
|
private SipLayer sipLayer;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GitUtil gitUtil;
|
private GitUtil gitUtil;
|
||||||
|
@ -48,38 +49,38 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
Request request = null;
|
Request request = null;
|
||||||
String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort();
|
String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort();
|
||||||
//请求行
|
//请求行
|
||||||
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(),
|
SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(),
|
||||||
platform.getServerIP() + ":" + platform.getServerPort());
|
platform.getServerIP() + ":" + platform.getServerPort());
|
||||||
//via
|
//via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getServerIP(), platform.getServerPort(), platform.getTransport(), viaTag);
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(platform.getServerIP(), platform.getServerPort(), platform.getTransport(), viaTag);
|
||||||
viaHeader.setRPort();
|
viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
//from
|
//from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain());
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
||||||
//to
|
//to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(), sipConfig.getDomain());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null);
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null);
|
||||||
|
|
||||||
//Forwards
|
//Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
|
|
||||||
//ceq
|
//ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER);
|
||||||
request = sipFactory.createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader,
|
request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader,
|
||||||
cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory()
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory()
|
||||||
.createSipURI(platform.getDeviceGBId(), sipAddress));
|
.createSipURI(platform.getDeviceGBId(), sipAddress));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
|
|
||||||
ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0);
|
ExpiresHeader expires = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(isRegister ? platform.getExpires() : 0);
|
||||||
request.addHeader(expires);
|
request.addHeader(expires);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -89,9 +90,9 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
|
|
||||||
|
|
||||||
Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, viaTag, callIdHeader, isRegister);
|
Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, viaTag, callIdHeader, isRegister);
|
||||||
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort());
|
SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP() + ":" + parentPlatform.getServerPort());
|
||||||
if (www == null) {
|
if (www == null) {
|
||||||
AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader("Digest");
|
AuthorizationHeader authorizationHeader = sipLayer.getSipFactory().createHeaderFactory().createAuthorizationHeader("Digest");
|
||||||
authorizationHeader.setUsername(parentPlatform.getDeviceGBId());
|
authorizationHeader.setUsername(parentPlatform.getDeviceGBId());
|
||||||
authorizationHeader.setURI(requestURI);
|
authorizationHeader.setURI(requestURI);
|
||||||
authorizationHeader.setAlgorithm("MD5");
|
authorizationHeader.setAlgorithm("MD5");
|
||||||
|
@ -140,7 +141,7 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
|
|
||||||
String RESPONSE = DigestUtils.md5DigestAsHex(reStr.toString().getBytes());
|
String RESPONSE = DigestUtils.md5DigestAsHex(reStr.toString().getBytes());
|
||||||
|
|
||||||
AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader(scheme);
|
AuthorizationHeader authorizationHeader = sipLayer.getSipFactory().createHeaderFactory().createAuthorizationHeader(scheme);
|
||||||
authorizationHeader.setUsername(parentPlatform.getDeviceGBId());
|
authorizationHeader.setUsername(parentPlatform.getDeviceGBId());
|
||||||
authorizationHeader.setRealm(realm);
|
authorizationHeader.setRealm(realm);
|
||||||
authorizationHeader.setNonce(nonce);
|
authorizationHeader.setNonce(nonce);
|
||||||
|
@ -158,7 +159,7 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Request createMessageRequest(ParentPlatform parentPlatform, String content, SendRtpItem sendRtpItem) throws PeerUnavailableException, ParseException, InvalidArgumentException {
|
public Request createMessageRequest(ParentPlatform parentPlatform, String content, SendRtpItem sendRtpItem) throws PeerUnavailableException, ParseException, InvalidArgumentException {
|
||||||
CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId());
|
CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId());
|
||||||
return createMessageRequest(parentPlatform, content, sendRtpItem.getToTag(), SipUtils.getNewViaTag(), sendRtpItem.getFromTag(), callIdHeader);
|
return createMessageRequest(parentPlatform, content, sendRtpItem.getToTag(), SipUtils.getNewViaTag(), sendRtpItem.getFromTag(), callIdHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,36 +172,36 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
Request request = null;
|
Request request = null;
|
||||||
String serverAddress = parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort();
|
String serverAddress = parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort();
|
||||||
// sipuri
|
// sipuri
|
||||||
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress);
|
SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress);
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()),
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()),
|
||||||
parentPlatform.getTransport(), viaTag);
|
parentPlatform.getTransport(), viaTag);
|
||||||
viaHeader.setRPort();
|
viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
// from
|
// from
|
||||||
// SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp());
|
// SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp());
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain());
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
||||||
// to
|
// to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress);
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress);
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag);
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag);
|
||||||
|
|
||||||
// Forwards
|
// Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
// ceq
|
// ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
|
||||||
MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory();
|
MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory();
|
||||||
// 设置编码, 防止中文乱码
|
// 设置编码, 防止中文乱码
|
||||||
messageFactory.setDefaultContentEncodingCharset(parentPlatform.getCharacterSet());
|
messageFactory.setDefaultContentEncodingCharset(parentPlatform.getCharacterSet());
|
||||||
request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
||||||
toHeader, viaHeaders, maxForwards);
|
toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||||
request.setContent(content, contentTypeHeader);
|
request.setContent(content, contentTypeHeader);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -208,54 +209,54 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
public SIPRequest createNotifyRequest(ParentPlatform parentPlatform, String content, SubscribeInfo subscribeInfo) throws PeerUnavailableException, ParseException, InvalidArgumentException {
|
public SIPRequest createNotifyRequest(ParentPlatform parentPlatform, String content, SubscribeInfo subscribeInfo) throws PeerUnavailableException, ParseException, InvalidArgumentException {
|
||||||
SIPRequest request = null;
|
SIPRequest request = null;
|
||||||
// sipuri
|
// sipuri
|
||||||
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort());
|
SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIP()+ ":" + parentPlatform.getServerPort());
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()),
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()),
|
||||||
parentPlatform.getTransport(), SipUtils.getNewViaTag());
|
parentPlatform.getTransport(), SipUtils.getNewViaTag());
|
||||||
viaHeader.setRPort();
|
viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
// from
|
// from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(),
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(),
|
||||||
parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort());
|
parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag());
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse().getToTag());
|
||||||
// to
|
// to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag());
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest().getFromTag());
|
||||||
|
|
||||||
// Forwards
|
// Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
// ceq
|
// ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY);
|
||||||
MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory();
|
MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory();
|
||||||
// 设置编码, 防止中文乱码
|
// 设置编码, 防止中文乱码
|
||||||
messageFactory.setDefaultContentEncodingCharset("gb2312");
|
messageFactory.setDefaultContentEncodingCharset("gb2312");
|
||||||
|
|
||||||
CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId());
|
CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest().getCallIdHeader().getCallId());
|
||||||
|
|
||||||
request = (SIPRequest) messageFactory.createRequest(requestURI, Request.NOTIFY, callIdHeader, cSeqHeader, fromHeader,
|
request = (SIPRequest) messageFactory.createRequest(requestURI, Request.NOTIFY, callIdHeader, cSeqHeader, fromHeader,
|
||||||
toHeader, viaHeaders, maxForwards);
|
toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
EventHeader event = sipFactory.createHeaderFactory().createEventHeader(subscribeInfo.getEventType());
|
EventHeader event = sipLayer.getSipFactory().createHeaderFactory().createEventHeader(subscribeInfo.getEventType());
|
||||||
if (subscribeInfo.getEventId() != null) {
|
if (subscribeInfo.getEventId() != null) {
|
||||||
event.setEventId(subscribeInfo.getEventId());
|
event.setEventId(subscribeInfo.getEventId());
|
||||||
}
|
}
|
||||||
|
|
||||||
request.addHeader(event);
|
request.addHeader(event);
|
||||||
|
|
||||||
SubscriptionStateHeader active = sipFactory.createHeaderFactory().createSubscriptionStateHeader("active");
|
SubscriptionStateHeader active = sipLayer.getSipFactory().createHeaderFactory().createSubscriptionStateHeader("active");
|
||||||
request.setHeader(active);
|
request.setHeader(active);
|
||||||
|
|
||||||
String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort();
|
String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort();
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory()
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory()
|
||||||
.createSipURI(parentPlatform.getDeviceGBId(), sipAddress));
|
.createSipURI(parentPlatform.getDeviceGBId(), sipAddress));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
|
|
||||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||||
request.setContent(content, contentTypeHeader);
|
request.setContent(content, contentTypeHeader);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -268,42 +269,42 @@ public class SIPRequestHeaderPlarformProvider {
|
||||||
|
|
||||||
SIPRequest request = null;
|
SIPRequest request = null;
|
||||||
// sipuri
|
// sipuri
|
||||||
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort());
|
SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIP()+ ":" + platform.getServerPort());
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()),
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()),
|
||||||
platform.getTransport(), SipUtils.getNewViaTag());
|
platform.getTransport(), SipUtils.getNewViaTag());
|
||||||
viaHeader.setRPort();
|
viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
// from
|
// from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(platform.getDeviceGBId(),
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getDeviceGBId(),
|
||||||
platform.getDeviceIp() + ":" + platform.getDevicePort());
|
platform.getDeviceIp() + ":" + platform.getDevicePort());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag());
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag());
|
||||||
// to
|
// to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag());
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag());
|
||||||
|
|
||||||
// Forwards
|
// Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
// ceq
|
// ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
|
||||||
MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory();
|
MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory();
|
||||||
// 设置编码, 防止中文乱码
|
// 设置编码, 防止中文乱码
|
||||||
messageFactory.setDefaultContentEncodingCharset("gb2312");
|
messageFactory.setDefaultContentEncodingCharset("gb2312");
|
||||||
|
|
||||||
CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId());
|
CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId());
|
||||||
|
|
||||||
request = (SIPRequest) messageFactory.createRequest(requestURI, Request.BYE, callIdHeader, cSeqHeader, fromHeader,
|
request = (SIPRequest) messageFactory.createRequest(requestURI, Request.BYE, callIdHeader, cSeqHeader, fromHeader,
|
||||||
toHeader, viaHeaders, maxForwards);
|
toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort();
|
String sipAddress = sipConfig.getIp() + ":" + sipConfig.getPort();
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory()
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory()
|
||||||
.createSipURI(platform.getDeviceGBId(), sipAddress));
|
.createSipURI(platform.getDeviceGBId(), sipAddress));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,21 +9,15 @@ import javax.sip.address.SipURI;
|
||||||
import javax.sip.header.*;
|
import javax.sip.header.*;
|
||||||
import javax.sip.message.Request;
|
import javax.sip.message.Request;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.gb28181.SipLayer;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SipMsgInfo;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
import com.genersoft.iot.vmp.utils.GitUtil;
|
||||||
import gov.nist.javax.sip.SipProviderImpl;
|
|
||||||
import gov.nist.javax.sip.SipStackImpl;
|
|
||||||
import gov.nist.javax.sip.message.SIPRequest;
|
import gov.nist.javax.sip.message.SIPRequest;
|
||||||
import gov.nist.javax.sip.message.SIPResponse;
|
import gov.nist.javax.sip.message.SIPResponse;
|
||||||
import gov.nist.javax.sip.stack.SIPDialog;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
|
@ -41,7 +35,7 @@ public class SIPRequestHeaderProvider {
|
||||||
private SipConfig sipConfig;
|
private SipConfig sipConfig;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipFactory sipFactory;
|
private SipLayer sipLayer;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GitUtil gitUtil;
|
private GitUtil gitUtil;
|
||||||
|
@ -55,32 +49,32 @@ public class SIPRequestHeaderProvider {
|
||||||
public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||||
Request request = null;
|
Request request = null;
|
||||||
// sipuri
|
// sipuri
|
||||||
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||||
viaHeader.setRPort();
|
viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
// from
|
// from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag);
|
||||||
// to
|
// to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag);
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, toTag);
|
||||||
|
|
||||||
// Forwards
|
// Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
// ceq
|
// ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE);
|
||||||
|
|
||||||
request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
|
||||||
toHeader, viaHeaders, maxForwards);
|
toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||||
request.setContent(content, contentTypeHeader);
|
request.setContent(content, contentTypeHeader);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -88,38 +82,38 @@ public class SIPRequestHeaderProvider {
|
||||||
public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||||
Request request = null;
|
Request request = null;
|
||||||
//请求行
|
//请求行
|
||||||
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||||
//via
|
//via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||||
viaHeader.setRPort();
|
viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
|
|
||||||
//from
|
//from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
||||||
//to
|
//to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null);
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null);
|
||||||
|
|
||||||
//Forwards
|
//Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
|
|
||||||
//ceq
|
//ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
||||||
request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||||
// Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
// Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
// Subject
|
// Subject
|
||||||
SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
SubjectHeader subjectHeader = sipLayer.getSipFactory().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
||||||
request.addHeader(subjectHeader);
|
request.addHeader(subjectHeader);
|
||||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
||||||
request.setContent(content, contentTypeHeader);
|
request.setContent(content, contentTypeHeader);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -127,39 +121,39 @@ public class SIPRequestHeaderProvider {
|
||||||
public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||||
Request request = null;
|
Request request = null;
|
||||||
//请求行
|
//请求行
|
||||||
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), viaTag);
|
||||||
viaHeader.setRPort();
|
viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
//from
|
//from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack
|
||||||
//to
|
//to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null);
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress,null);
|
||||||
|
|
||||||
//Forwards
|
//Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
|
|
||||||
//ceq
|
//ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE);
|
||||||
request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||||
// Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
// Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort()));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
// Subject
|
// Subject
|
||||||
SubjectHeader subjectHeader = sipFactory.createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
SubjectHeader subjectHeader = sipLayer.getSipFactory().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0));
|
||||||
request.addHeader(subjectHeader);
|
request.addHeader(subjectHeader);
|
||||||
|
|
||||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP");
|
||||||
request.setContent(content, contentTypeHeader);
|
request.setContent(content, contentTypeHeader);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -167,34 +161,34 @@ public class SIPRequestHeaderProvider {
|
||||||
public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||||
Request request = null;
|
Request request = null;
|
||||||
//请求行
|
//请求行
|
||||||
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
//from
|
//from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
||||||
//to
|
//to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
||||||
|
|
||||||
//Forwards
|
//Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
|
|
||||||
//ceq
|
//ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE);
|
||||||
CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
||||||
request = sipFactory.createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -202,50 +196,50 @@ public class SIPRequestHeaderProvider {
|
||||||
public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
||||||
Request request = null;
|
Request request = null;
|
||||||
// sipuri
|
// sipuri
|
||||||
SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
SipURI requestURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(),
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(),
|
||||||
device.getTransport(), SipUtils.getNewViaTag());
|
device.getTransport(), SipUtils.getNewViaTag());
|
||||||
viaHeader.setRPort();
|
viaHeader.setRPort();
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
// from
|
// from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag());
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag());
|
||||||
// to
|
// to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag());
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag());
|
||||||
|
|
||||||
// Forwards
|
// Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
|
|
||||||
// ceq
|
// ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE);
|
||||||
|
|
||||||
request = sipFactory.createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader,
|
request = sipLayer.getSipFactory().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader,
|
||||||
toHeader, viaHeaders, maxForwards);
|
toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
|
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
|
|
||||||
// Expires
|
// Expires
|
||||||
ExpiresHeader expireHeader = sipFactory.createHeaderFactory().createExpiresHeader(expires);
|
ExpiresHeader expireHeader = sipLayer.getSipFactory().createHeaderFactory().createExpiresHeader(expires);
|
||||||
request.addHeader(expireHeader);
|
request.addHeader(expireHeader);
|
||||||
|
|
||||||
// Event
|
// Event
|
||||||
EventHeader eventHeader = sipFactory.createHeaderFactory().createEventHeader(event);
|
EventHeader eventHeader = sipLayer.getSipFactory().createHeaderFactory().createEventHeader(event);
|
||||||
|
|
||||||
int random = (int) Math.floor(Math.random() * 10000);
|
int random = (int) Math.floor(Math.random() * 10000);
|
||||||
eventHeader.setEventId(random + "");
|
eventHeader.setEventId(random + "");
|
||||||
request.addHeader(eventHeader);
|
request.addHeader(eventHeader);
|
||||||
|
|
||||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
|
||||||
request.setContent(content, contentTypeHeader);
|
request.setContent(content, contentTypeHeader);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -257,37 +251,37 @@ public class SIPRequestHeaderProvider {
|
||||||
}
|
}
|
||||||
SIPRequest request = null;
|
SIPRequest request = null;
|
||||||
//请求行
|
//请求行
|
||||||
SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
SipURI requestLine = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId, device.getHostAddress());
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
//from
|
//from
|
||||||
SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
SipURI fromSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain());
|
||||||
Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
|
Address fromAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(fromSipURI);
|
||||||
FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
FromHeader fromHeader = sipLayer.getSipFactory().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag());
|
||||||
//to
|
//to
|
||||||
SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
SipURI toSipURI = sipLayer.getSipFactory().createAddressFactory().createSipURI(channelId,device.getHostAddress());
|
||||||
Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
|
Address toAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(toSipURI);
|
||||||
ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
ToHeader toHeader = sipLayer.getSipFactory().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag());
|
||||||
|
|
||||||
//Forwards
|
//Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
|
|
||||||
//ceq
|
//ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO);
|
||||||
CallIdHeader callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
CallIdHeader callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId());
|
||||||
request = (SIPRequest)sipFactory.createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
request = (SIPRequest)sipLayer.getSipFactory().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application",
|
ContentTypeHeader contentTypeHeader = sipLayer.getSipFactory().createHeaderFactory().createContentTypeHeader("Application",
|
||||||
"MANSRTSP");
|
"MANSRTSP");
|
||||||
request.setContent(content, contentTypeHeader);
|
request.setContent(content, contentTypeHeader);
|
||||||
}
|
}
|
||||||
|
@ -298,23 +292,23 @@ public class SIPRequestHeaderProvider {
|
||||||
|
|
||||||
// via
|
// via
|
||||||
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
|
||||||
ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag());
|
ViaHeader viaHeader = sipLayer.getSipFactory().createHeaderFactory().createViaHeader(sipConfig.getIp(), sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag());
|
||||||
viaHeaders.add(viaHeader);
|
viaHeaders.add(viaHeader);
|
||||||
|
|
||||||
//Forwards
|
//Forwards
|
||||||
MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
MaxForwardsHeader maxForwards = sipLayer.getSipFactory().createHeaderFactory().createMaxForwardsHeader(70);
|
||||||
|
|
||||||
//ceq
|
//ceq
|
||||||
CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK);
|
CSeqHeader cSeqHeader = sipLayer.getSipFactory().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK);
|
||||||
|
|
||||||
Request request = sipFactory.createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards);
|
Request request = sipLayer.getSipFactory().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards);
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
Address concatAddress = sipLayer.getSipFactory().createAddressFactory().createAddress(sipLayer.getSipFactory().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort()));
|
||||||
request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
request.addHeader(sipLayer.getSipFactory().createHeaderFactory().createContactHeader(concatAddress));
|
||||||
|
|
||||||
request.addHeader(SipUtils.createUserAgentHeader(sipFactory, gitUtil));
|
request.addHeader(SipUtils.createUserAgentHeader(sipLayer.getSipFactory(), gitUtil));
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.SipLayer;
|
||||||
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.session.VideoStreamSessionManager;
|
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||||
|
@ -21,23 +22,12 @@ import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
|
||||||
import com.genersoft.iot.vmp.utils.GitUtil;
|
|
||||||
import gov.nist.javax.sip.SIPConstants;
|
|
||||||
import gov.nist.javax.sip.SipProviderImpl;
|
|
||||||
import gov.nist.javax.sip.SipStackImpl;
|
|
||||||
import gov.nist.javax.sip.message.SIPRequest;
|
import gov.nist.javax.sip.message.SIPRequest;
|
||||||
import gov.nist.javax.sip.message.SIPResponse;
|
import gov.nist.javax.sip.message.SIPResponse;
|
||||||
import gov.nist.javax.sip.stack.SIPClientTransaction;
|
|
||||||
import gov.nist.javax.sip.stack.SIPClientTransactionImpl;
|
|
||||||
import gov.nist.javax.sip.stack.SIPDialog;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.context.annotation.Lazy;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
@ -67,7 +57,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
private SipConfig sipConfig;
|
private SipConfig sipConfig;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipFactory sipFactory;
|
private SipLayer sipLayer;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SIPSender sipSender;
|
private SIPSender sipSender;
|
||||||
|
@ -196,9 +186,9 @@ public class SIPCommander implements ISIPCommander {
|
||||||
ptzXml.append("</Info>\r\n");
|
ptzXml.append("</Info>\r\n");
|
||||||
ptzXml.append("</Control>\r\n");
|
ptzXml.append("</Control>\r\n");
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
|
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(device.getLocalIp(),request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,8 +221,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest(request);
|
sipSender.transmitRequest(device.getLocalIp(),request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,8 +250,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
ptzXml.append("</Control>\r\n");
|
ptzXml.append("</Control>\r\n");
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest(request, errorEvent, okEvent);
|
sipSender.transmitRequest(device.getLocalIp(),request, errorEvent, okEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,8 +345,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, (e -> {
|
sipSender.transmitRequest(device.getLocalIp(), request, (e -> {
|
||||||
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
|
streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream());
|
||||||
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc());
|
||||||
errorEvent.response(e);
|
errorEvent.response(e);
|
||||||
|
@ -438,36 +428,39 @@ public class SIPCommander implements ISIPCommander {
|
||||||
content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
content.append("a=rtpmap:97 MPEG4/90000\r\n");
|
||||||
content.append("a=rtpmap:98 H264/90000\r\n");
|
content.append("a=rtpmap:98 H264/90000\r\n");
|
||||||
content.append("a=rtpmap:99 H265/90000\r\n");
|
content.append("a=rtpmap:99 H265/90000\r\n");
|
||||||
if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { // tcp被动模式
|
if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) {
|
||||||
|
// tcp被动模式
|
||||||
content.append("a=setup:passive\r\n");
|
content.append("a=setup:passive\r\n");
|
||||||
content.append("a=connection:new\r\n");
|
content.append("a=connection:new\r\n");
|
||||||
} else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式
|
} else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) {
|
||||||
|
// tcp主动模式
|
||||||
content.append("a=setup:active\r\n");
|
content.append("a=setup:active\r\n");
|
||||||
content.append("a=connection:new\r\n");
|
content.append("a=connection:new\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc
|
//ssrc
|
||||||
|
content.append("y=" + ssrcInfo.getSsrc() + "\r\n");
|
||||||
|
|
||||||
HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId());
|
HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId());
|
||||||
// 添加订阅
|
// 添加订阅
|
||||||
subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
|
subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
|
||||||
if (hookEvent != null) {
|
if (hookEvent != null) {
|
||||||
InviteStreamInfo inviteStreamInfo = new InviteStreamInfo(mediaServerItemInUse, json,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream());
|
InviteStreamInfo inviteStreamInfo = new InviteStreamInfo(mediaServerItemInUse, json,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream());
|
||||||
hookEvent.call(inviteStreamInfo);
|
hookEvent.call(inviteStreamInfo);
|
||||||
}
|
}
|
||||||
subscribe.removeSubscribe(hookSubscribe);
|
subscribe.removeSubscribe(hookSubscribe);
|
||||||
});
|
});
|
||||||
Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()), ssrcInfo.getSsrc());
|
Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()), ssrcInfo.getSsrc());
|
||||||
|
|
||||||
sipSender.transmitRequest( request, errorEvent, event -> {
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent, event -> {
|
||||||
ResponseEvent responseEvent = (ResponseEvent) event.event;
|
ResponseEvent responseEvent = (ResponseEvent) event.event;
|
||||||
SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
||||||
streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.playback);
|
streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.playback);
|
||||||
okEvent.response(event);
|
okEvent.response(event);
|
||||||
});
|
});
|
||||||
if (inviteStreamCallback != null) {
|
if (inviteStreamCallback != null) {
|
||||||
inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +549,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId());
|
HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, null, mediaServerItem.getId());
|
||||||
// 添加订阅
|
// 添加订阅
|
||||||
subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
|
subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, JSONObject json) -> {
|
||||||
hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
hookEvent.call(new InviteStreamInfo(mediaServerItem, json,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
||||||
subscribe.removeSubscribe(hookSubscribe);
|
subscribe.removeSubscribe(hookSubscribe);
|
||||||
hookSubscribe.getContent().put("regist", false);
|
hookSubscribe.getContent().put("regist", false);
|
||||||
hookSubscribe.getContent().put("schema", "rtsp");
|
hookSubscribe.getContent().put("schema", "rtsp");
|
||||||
|
@ -565,7 +558,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
(MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd) -> {
|
(MediaServerItem mediaServerItemForEnd, JSONObject jsonForEnd) -> {
|
||||||
logger.info("[录像]下载结束, 发送BYE");
|
logger.info("[录像]下载结束, 发送BYE");
|
||||||
try {
|
try {
|
||||||
streamByeCmd(device, channelId, ssrcInfo.getStream(),sipSender.getNewCallIdHeader(device.getTransport()).getCallId());
|
streamByeCmd(device, channelId, ssrcInfo.getStream(),sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()).getCallId());
|
||||||
} catch (InvalidArgumentException | ParseException | SipException |
|
} catch (InvalidArgumentException | ParseException | SipException |
|
||||||
SsrcTransactionNotFoundException e) {
|
SsrcTransactionNotFoundException e) {
|
||||||
logger.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage());
|
logger.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage());
|
||||||
|
@ -573,14 +566,14 @@ public class SIPCommander implements ISIPCommander {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()), ssrcInfo.getSsrc());
|
Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()), ssrcInfo.getSsrc());
|
||||||
if (inviteStreamCallback != null) {
|
if (inviteStreamCallback != null) {
|
||||||
inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
inviteStreamCallback.call(new InviteStreamInfo(mediaServerItem, null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()).getCallId(), "rtp", ssrcInfo.getStream()));
|
||||||
}
|
}
|
||||||
sipSender.transmitRequest( request, errorEvent, okEvent -> {
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent, okEvent -> {
|
||||||
ResponseEvent responseEvent = (ResponseEvent) okEvent.event;
|
ResponseEvent responseEvent = (ResponseEvent) okEvent.event;
|
||||||
SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
SIPResponse response = (SIPResponse) responseEvent.getResponse();
|
||||||
streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download);
|
streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, VideoStreamSessionManager.SessionType.download);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,7 +600,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
streamSession.remove(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
|
||||||
|
|
||||||
Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo());
|
Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo());
|
||||||
sipSender.transmitRequest( byteRequest, null, okEvent);
|
sipSender.transmitRequest(device.getLocalIp(), byteRequest, null, okEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -640,8 +633,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(device.getLocalIp(), request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,8 +653,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,8 +684,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -715,8 +708,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(device.getLocalIp(), request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -740,8 +733,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -776,8 +769,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -805,8 +798,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(device.getLocalIp(), request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -852,8 +845,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -915,8 +908,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -938,9 +931,9 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
|
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -962,9 +955,9 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
|
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(device.getLocalIp(), request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,9 +980,9 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
|
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1033,9 +1026,9 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(),
|
Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(),
|
||||||
SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
|
|
||||||
sipSender.transmitRequest( request, errorEvent, okEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent, okEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1083,8 +1076,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1113,8 +1106,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1140,8 +1133,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1164,9 +1157,9 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
|
|
||||||
sipSender.transmitRequest( request, errorEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,13 +1187,13 @@ public class SIPCommander implements ISIPCommander {
|
||||||
CallIdHeader callIdHeader;
|
CallIdHeader callIdHeader;
|
||||||
|
|
||||||
if (requestOld != null) {
|
if (requestOld != null) {
|
||||||
callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId());
|
callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId());
|
||||||
} else {
|
} else {
|
||||||
callIdHeader = sipSender.getNewCallIdHeader(device.getTransport());
|
callIdHeader = sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport());
|
||||||
}
|
}
|
||||||
SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), requestOld, device.getSubscribeCycleForMobilePosition(), "presence",callIdHeader); //Position;id=" + tm.substring(tm.length() - 4));
|
SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), requestOld, device.getSubscribeCycleForMobilePosition(), "presence",callIdHeader); //Position;id=" + tm.substring(tm.length() - 4));
|
||||||
|
|
||||||
sipSender.transmitRequest( request, errorEvent, okEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent, okEvent);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,8 +1242,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(device.getLocalIp(), request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1269,15 +1262,15 @@ public class SIPCommander implements ISIPCommander {
|
||||||
CallIdHeader callIdHeader;
|
CallIdHeader callIdHeader;
|
||||||
|
|
||||||
if (requestOld != null) {
|
if (requestOld != null) {
|
||||||
callIdHeader = sipFactory.createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId());
|
callIdHeader = sipLayer.getSipFactory().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId());
|
||||||
} else {
|
} else {
|
||||||
callIdHeader = sipSender.getNewCallIdHeader(device.getTransport());
|
callIdHeader = sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 有效时间默认为60秒以上
|
// 有效时间默认为60秒以上
|
||||||
SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, cmdXml.toString(), requestOld, device.getSubscribeCycleForCatalog(), "Catalog",
|
SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, cmdXml.toString(), requestOld, device.getSubscribeCycleForCatalog(), "Catalog",
|
||||||
callIdHeader);
|
callIdHeader);
|
||||||
sipSender.transmitRequest( request, errorEvent, okEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent, okEvent);
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1298,9 +1291,9 @@ public class SIPCommander implements ISIPCommander {
|
||||||
dragXml.append(cmdString);
|
dragXml.append(cmdString);
|
||||||
dragXml.append("</Control>\r\n");
|
dragXml.append("</Control>\r\n");
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
logger.debug("拉框信令: " + request.toString());
|
logger.debug("拉框信令: " + request.toString());
|
||||||
sipSender.transmitRequest(request);
|
sipSender.transmitRequest(device.getLocalIp(),request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1379,7 +1372,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sipSender.transmitRequest( request, errorEvent, okEvent);
|
sipSender.transmitRequest(device.getLocalIp(), request, errorEvent, okEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1409,8 +1402,8 @@ public class SIPCommander implements ISIPCommander {
|
||||||
deviceStatusXml.append("</Notify>\r\n");
|
deviceStatusXml.append("</Notify>\r\n");
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(device.getLocalIp(),device.getTransport()));
|
||||||
sipSender.transmitRequest(request);
|
sipSender.transmitRequest(device.getLocalIp(),request);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
|
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.SipLayer;
|
||||||
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.SIPSender;
|
||||||
|
@ -56,7 +57,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
private ZLMRTPServerFactory zlmrtpServerFactory;
|
private ZLMRTPServerFactory zlmrtpServerFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipFactory sipFactory;
|
private SipLayer sipLayer;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SIPSender sipSender;
|
private SIPSender sipSender;
|
||||||
|
@ -76,7 +77,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 = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
|
|
||||||
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform,
|
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform,
|
||||||
redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(),
|
redisCatchStorage.getCSEQ(), SipUtils.getNewFromTag(),
|
||||||
|
@ -98,11 +99,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
});
|
});
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister);
|
request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, SipUtils.getNewFromTag(), null, callId, www, callIdHeader, isRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
sipSender.transmitRequest( request, null, okEvent);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,7 +118,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 = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(
|
Request request = headerProviderPlatformProvider.createMessageRequest(
|
||||||
parentPlatform,
|
parentPlatform,
|
||||||
|
@ -125,7 +126,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
SipUtils.getNewFromTag(),
|
SipUtils.getNewFromTag(),
|
||||||
SipUtils.getNewViaTag(),
|
SipUtils.getNewViaTag(),
|
||||||
callIdHeader);
|
callIdHeader);
|
||||||
sipSender.transmitRequest( request, errorEvent, okEvent);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, errorEvent, okEvent);
|
||||||
return callIdHeader.getCallId();
|
return callIdHeader.getCallId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,10 +149,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
String catalogXml = getCatalogXml(channels, sn, parentPlatform, size);
|
String catalogXml = getCatalogXml(channels, sn, parentPlatform, size);
|
||||||
|
|
||||||
// callid
|
// callid
|
||||||
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,10 +235,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 = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
sipSender.transmitRequest( request, null, eventResult -> {
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), 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);
|
||||||
|
@ -273,10 +274,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 = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -303,10 +304,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 = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,10 +366,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 = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader);
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,14 +409,14 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent,
|
private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent,
|
||||||
SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent )
|
SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent )
|
||||||
throws SipException, ParseException, InvalidArgumentException {
|
throws SipException, ParseException, InvalidArgumentException {
|
||||||
MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory();
|
MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipLayer.getSipFactory().createMessageFactory();
|
||||||
String characterSet = parentPlatform.getCharacterSet();
|
String characterSet = parentPlatform.getCharacterSet();
|
||||||
// 设置编码, 防止中文乱码
|
// 设置编码, 防止中文乱码
|
||||||
messageFactory.setDefaultContentEncodingCharset(characterSet);
|
messageFactory.setDefaultContentEncodingCharset(characterSet);
|
||||||
|
|
||||||
SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo);
|
SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo);
|
||||||
|
|
||||||
sipSender.transmitRequest( notifyRequest);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), 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) {
|
||||||
|
@ -580,21 +581,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
recordXml.append("</Response>\r\n");
|
recordXml.append("</Response>\r\n");
|
||||||
|
|
||||||
// callid
|
// callid
|
||||||
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getTransport());
|
CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
|
||||||
|
|
||||||
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader);
|
||||||
sipSender.transmitRequest( request);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(), request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMediaStatusNotify(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException {
|
public void sendMediaStatusNotify(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException {
|
||||||
if (sendRtpItem == null || platform == null) {
|
if (sendRtpItem == null || parentPlatform == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String characterSet = platform.getCharacterSet();
|
String characterSet = parentPlatform.getCharacterSet();
|
||||||
StringBuffer mediaStatusXml = new StringBuffer(200);
|
StringBuffer mediaStatusXml = new StringBuffer(200);
|
||||||
mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
|
mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
|
||||||
mediaStatusXml.append("<Notify>\r\n");
|
mediaStatusXml.append("<Notify>\r\n");
|
||||||
|
@ -604,10 +605,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
mediaStatusXml.append("<NotifyType>121</NotifyType>\r\n");
|
mediaStatusXml.append("<NotifyType>121</NotifyType>\r\n");
|
||||||
mediaStatusXml.append("</Notify>\r\n");
|
mediaStatusXml.append("</Notify>\r\n");
|
||||||
|
|
||||||
SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(platform, mediaStatusXml.toString(),
|
SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, mediaStatusXml.toString(),
|
||||||
sendRtpItem);
|
sendRtpItem);
|
||||||
|
|
||||||
sipSender.transmitRequest(messageRequest);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(),messageRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,26 +624,26 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void streamByeCmd(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException {
|
public void streamByeCmd(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException {
|
||||||
if (sendRtpItem == null ) {
|
if (sendRtpItem == null ) {
|
||||||
logger.info("[向上级发送BYE], sendRtpItem 为NULL");
|
logger.info("[向上级发送BYE], sendRtpItem 为NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (platform == null) {
|
if (parentPlatform == null) {
|
||||||
logger.info("[向上级发送BYE], platform 为NULL");
|
logger.info("[向上级发送BYE], platform 为NULL");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.info("[向上级发送BYE], {}/{}", platform.getServerGBId(), sendRtpItem.getChannelId());
|
logger.info("[向上级发送BYE], {}/{}", parentPlatform.getServerGBId(), sendRtpItem.getChannelId());
|
||||||
String mediaServerId = sendRtpItem.getMediaServerId();
|
String mediaServerId = sendRtpItem.getMediaServerId();
|
||||||
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||||
if (mediaServerItem != null) {
|
if (mediaServerItem != null) {
|
||||||
mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc());
|
mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc());
|
||||||
zlmrtpServerFactory.closeRTPServer(mediaServerItem, sendRtpItem.getStreamId());
|
zlmrtpServerFactory.closeRTPServer(mediaServerItem, sendRtpItem.getStreamId());
|
||||||
}
|
}
|
||||||
SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(platform, sendRtpItem);
|
SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(parentPlatform, sendRtpItem);
|
||||||
if (byeRequest == null) {
|
if (byeRequest == null) {
|
||||||
logger.warn("[向上级发送bye]:无法创建 byeRequest");
|
logger.warn("[向上级发送bye]:无法创建 byeRequest");
|
||||||
}
|
}
|
||||||
sipSender.transmitRequest(byeRequest);
|
sipSender.transmitRequest(parentPlatform.getDeviceIp(),byeRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ public abstract class SIPRequestProcessorParent {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送response
|
// 发送response
|
||||||
sipSender.transmitRequest(response);
|
sipSender.transmitRequest(sipRequest.getLocalAddress().getHostAddress(), response);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
|
||||||
// 未知错误。直接转发设备点播的错误
|
// 未知错误。直接转发设备点播的错误
|
||||||
try {
|
try {
|
||||||
Response response = getMessageFactory().createResponse(event.statusCode, evt.getRequest());
|
Response response = getMessageFactory().createResponse(event.statusCode, evt.getRequest());
|
||||||
sipSender.transmitRequest(response);
|
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||||
} catch (ParseException | SipException e) {
|
} catch (ParseException | SipException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import gov.nist.javax.sip.address.AddressImpl;
|
||||||
import gov.nist.javax.sip.address.SipUri;
|
import gov.nist.javax.sip.address.SipUri;
|
||||||
import gov.nist.javax.sip.header.Expires;
|
import gov.nist.javax.sip.header.Expires;
|
||||||
import gov.nist.javax.sip.header.SIPDateHeader;
|
import gov.nist.javax.sip.header.SIPDateHeader;
|
||||||
|
import gov.nist.javax.sip.message.SIPRequest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
@ -71,8 +72,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||||
RequestEventExt evtExt = (RequestEventExt) evt;
|
RequestEventExt evtExt = (RequestEventExt) evt;
|
||||||
String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort();
|
String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort();
|
||||||
logger.info("[注册请求] 开始处理: {}", requestAddress);
|
logger.info("[注册请求] 开始处理: {}", requestAddress);
|
||||||
Request request = evt.getRequest();
|
SIPRequest request = (SIPRequest)evt.getRequest();
|
||||||
ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME);
|
|
||||||
Response response = null;
|
Response response = null;
|
||||||
boolean passwordCorrect = false;
|
boolean passwordCorrect = false;
|
||||||
// 注册标志
|
// 注册标志
|
||||||
|
@ -88,7 +88,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||||
logger.info("[注册请求] 未携带授权头 回复401: {}", requestAddress);
|
logger.info("[注册请求] 未携带授权头 回复401: {}", requestAddress);
|
||||||
response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
|
response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
|
||||||
new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain());
|
new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain());
|
||||||
sipSender.transmitRequest(response);
|
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||||
response = getMessageFactory().createResponse(Response.FORBIDDEN, request);
|
response = getMessageFactory().createResponse(Response.FORBIDDEN, request);
|
||||||
response.setReasonPhrase("wrong password");
|
response.setReasonPhrase("wrong password");
|
||||||
logger.info("[注册请求] 密码/SIP服务器ID错误, 回复403: {}", requestAddress);
|
logger.info("[注册请求] 密码/SIP服务器ID错误, 回复403: {}", requestAddress);
|
||||||
sipSender.transmitRequest(response);
|
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +114,9 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||||
dateHeader.setDate(wvpSipDate);
|
dateHeader.setDate(wvpSipDate);
|
||||||
response.addHeader(dateHeader);
|
response.addHeader(dateHeader);
|
||||||
|
|
||||||
if (expiresHeader == null) {
|
if (request.getExpires() == null) {
|
||||||
response = getMessageFactory().createResponse(Response.BAD_REQUEST, request);
|
response = getMessageFactory().createResponse(Response.BAD_REQUEST, request);
|
||||||
sipSender.transmitRequest(response);
|
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 添加Contact头
|
// 添加Contact头
|
||||||
|
@ -145,12 +145,13 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||||
device.setIp(received);
|
device.setIp(received);
|
||||||
device.setPort(rPort);
|
device.setPort(rPort);
|
||||||
device.setHostAddress(received.concat(":").concat(String.valueOf(rPort)));
|
device.setHostAddress(received.concat(":").concat(String.valueOf(rPort)));
|
||||||
if (expiresHeader.getExpires() == 0) {
|
device.setLocalIp(request.getLocalAddress().getHostAddress());
|
||||||
|
if (request.getExpires().getExpires() == 0) {
|
||||||
// 注销成功
|
// 注销成功
|
||||||
registerFlag = false;
|
registerFlag = false;
|
||||||
} else {
|
} else {
|
||||||
// 注册成功
|
// 注册成功
|
||||||
device.setExpires(expiresHeader.getExpires());
|
device.setExpires(request.getExpires().getExpires());
|
||||||
registerFlag = true;
|
registerFlag = true;
|
||||||
// 判断TCP还是UDP
|
// 判断TCP还是UDP
|
||||||
ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
|
ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
|
||||||
|
@ -158,7 +159,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||||
device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP");
|
device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP");
|
||||||
}
|
}
|
||||||
|
|
||||||
sipSender.transmitRequest(response);
|
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||||
// 注册成功
|
// 注册成功
|
||||||
// 保存到redis
|
// 保存到redis
|
||||||
if (registerFlag) {
|
if (registerFlag) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
|
||||||
response.setExpires(expireHeader);
|
response.setExpires(expireHeader);
|
||||||
}
|
}
|
||||||
logger.info("response : " + response);
|
logger.info("response : " + response);
|
||||||
sipSender.transmitRequest(response);
|
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||||
}
|
}
|
||||||
} catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
|
} catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -84,23 +84,24 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
|
logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
taskExecutor.execute(()->{
|
taskExecutor.execute(()->{
|
||||||
try {
|
// 远程启动
|
||||||
Thread.sleep(3000);
|
// try {
|
||||||
SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
|
// Thread.sleep(3000);
|
||||||
SipStackImpl stack = (SipStackImpl)up.getSipStack();
|
// SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
|
||||||
stack.stop();
|
// SipStackImpl stack = (SipStackImpl)up.getSipStack();
|
||||||
Iterator listener = stack.getListeningPoints();
|
// stack.stop();
|
||||||
while (listener.hasNext()) {
|
// Iterator listener = stack.getListeningPoints();
|
||||||
stack.deleteListeningPoint((ListeningPoint) listener.next());
|
// while (listener.hasNext()) {
|
||||||
}
|
// stack.deleteListeningPoint((ListeningPoint) listener.next());
|
||||||
Iterator providers = stack.getSipProviders();
|
// }
|
||||||
while (providers.hasNext()) {
|
// Iterator providers = stack.getSipProviders();
|
||||||
stack.deleteSipProvider((SipProvider) providers.next());
|
// while (providers.hasNext()) {
|
||||||
}
|
// stack.deleteSipProvider((SipProvider) providers.next());
|
||||||
VManageBootstrap.restart();
|
// }
|
||||||
} catch (InterruptedException | ObjectInUseException e) {
|
// VManageBootstrap.restart();
|
||||||
logger.error("[任务执行失败] 服务重启: {}", e.getMessage());
|
// } catch (InterruptedException | ObjectInUseException e) {
|
||||||
}
|
// logger.error("[任务执行失败] 服务重启: {}", e.getMessage());
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 远程启动指定设备
|
// 远程启动指定设备
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl;
|
package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.SipLayer;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
|
||||||
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
|
||||||
|
@ -54,7 +55,7 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SipFactory sipFactory;
|
private SipLayer sipLayer;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SIPSender sipSender;
|
private SIPSender sipSender;
|
||||||
|
@ -103,11 +104,11 @@ public class InviteResponseProcessor extends SIPResponseProcessorAbstract {
|
||||||
} else {
|
} else {
|
||||||
sdp = SdpFactory.getInstance().createSessionDescription(contentString);
|
sdp = SdpFactory.getInstance().createSessionDescription(contentString);
|
||||||
}
|
}
|
||||||
SipURI requestUri = sipFactory.createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort());
|
SipURI requestUri = sipLayer.getSipFactory().createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort());
|
||||||
Request reqAck = headerProvider.createAckRequest(requestUri, response);
|
Request reqAck = headerProvider.createAckRequest(requestUri, response);
|
||||||
|
|
||||||
logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort());
|
logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort());
|
||||||
sipSender.transmitRequest(reqAck);
|
sipSender.transmitRequest(response.getLocalAddress().getHostAddress(), reqAck);
|
||||||
}
|
}
|
||||||
} catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) {
|
} catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) {
|
||||||
logger.info("[点播回复ACK],异常:", e );
|
logger.info("[点播回复ACK],异常:", e );
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Order(value=1)
|
@Order(value=2)
|
||||||
public class ZLMRunner implements CommandLineRunner {
|
public class ZLMRunner implements CommandLineRunner {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class);
|
private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class);
|
||||||
|
|
|
@ -25,6 +25,7 @@ public interface DeviceMapper {
|
||||||
"streamMode," +
|
"streamMode," +
|
||||||
"ip," +
|
"ip," +
|
||||||
"sdpIp," +
|
"sdpIp," +
|
||||||
|
"localIp," +
|
||||||
"port," +
|
"port," +
|
||||||
"hostAddress," +
|
"hostAddress," +
|
||||||
"expires," +
|
"expires," +
|
||||||
|
@ -54,6 +55,7 @@ public interface DeviceMapper {
|
||||||
"streamMode," +
|
"streamMode," +
|
||||||
"ip," +
|
"ip," +
|
||||||
"sdpIp," +
|
"sdpIp," +
|
||||||
|
"localIp," +
|
||||||
"port," +
|
"port," +
|
||||||
"hostAddress," +
|
"hostAddress," +
|
||||||
"expires," +
|
"expires," +
|
||||||
|
@ -80,6 +82,7 @@ public interface DeviceMapper {
|
||||||
"#{streamMode}," +
|
"#{streamMode}," +
|
||||||
"#{ip}," +
|
"#{ip}," +
|
||||||
"#{sdpIp}," +
|
"#{sdpIp}," +
|
||||||
|
"#{localIp}," +
|
||||||
"#{port}," +
|
"#{port}," +
|
||||||
"#{hostAddress}," +
|
"#{hostAddress}," +
|
||||||
"#{expires}," +
|
"#{expires}," +
|
||||||
|
@ -129,6 +132,7 @@ public interface DeviceMapper {
|
||||||
"streamMode," +
|
"streamMode," +
|
||||||
"ip," +
|
"ip," +
|
||||||
"sdpIp," +
|
"sdpIp," +
|
||||||
|
"localIp," +
|
||||||
"port," +
|
"port," +
|
||||||
"hostAddress," +
|
"hostAddress," +
|
||||||
"expires," +
|
"expires," +
|
||||||
|
@ -165,6 +169,7 @@ public interface DeviceMapper {
|
||||||
"streamMode," +
|
"streamMode," +
|
||||||
"ip," +
|
"ip," +
|
||||||
"sdpIp," +
|
"sdpIp," +
|
||||||
|
"localIp," +
|
||||||
"port," +
|
"port," +
|
||||||
"hostAddress," +
|
"hostAddress," +
|
||||||
"expires," +
|
"expires," +
|
||||||
|
@ -194,6 +199,7 @@ public interface DeviceMapper {
|
||||||
"streamMode," +
|
"streamMode," +
|
||||||
"ip," +
|
"ip," +
|
||||||
"sdpIp," +
|
"sdpIp," +
|
||||||
|
"localIp," +
|
||||||
"port," +
|
"port," +
|
||||||
"hostAddress," +
|
"hostAddress," +
|
||||||
"expires," +
|
"expires," +
|
||||||
|
|
|
@ -164,25 +164,25 @@ public class ServerController {
|
||||||
@GetMapping(value = "/restart")
|
@GetMapping(value = "/restart")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public void restart() {
|
public void restart() {
|
||||||
taskExecutor.execute(()-> {
|
// taskExecutor.execute(()-> {
|
||||||
try {
|
// try {
|
||||||
Thread.sleep(3000);
|
// Thread.sleep(3000);
|
||||||
SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
|
// SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider");
|
||||||
SipStackImpl stack = (SipStackImpl) up.getSipStack();
|
// SipStackImpl stack = (SipStackImpl) up.getSipStack();
|
||||||
stack.stop();
|
// stack.stop();
|
||||||
Iterator listener = stack.getListeningPoints();
|
// Iterator listener = stack.getListeningPoints();
|
||||||
while (listener.hasNext()) {
|
// while (listener.hasNext()) {
|
||||||
stack.deleteListeningPoint((ListeningPoint) listener.next());
|
// stack.deleteListeningPoint((ListeningPoint) listener.next());
|
||||||
}
|
// }
|
||||||
Iterator providers = stack.getSipProviders();
|
// Iterator providers = stack.getSipProviders();
|
||||||
while (providers.hasNext()) {
|
// while (providers.hasNext()) {
|
||||||
stack.deleteSipProvider((SipProvider) providers.next());
|
// stack.deleteSipProvider((SipProvider) providers.next());
|
||||||
}
|
// }
|
||||||
VManageBootstrap.restart();
|
// VManageBootstrap.restart();
|
||||||
} catch (InterruptedException | ObjectInUseException e) {
|
// } catch (InterruptedException | ObjectInUseException e) {
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
// throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
@Operation(summary = "获取系统信息信息")
|
@Operation(summary = "获取系统信息信息")
|
||||||
|
|
Loading…
Reference in New Issue