Browse Source

统一userAgent

pull/459/merge
648540858 3 years ago
parent
commit
ee62f17170
  1. 11
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
  2. 18
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

11
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java

@ -68,9 +68,6 @@ public class SIPRequestHeaderPlarformProvider {
toHeader, viaHeaders, maxForwards); toHeader, viaHeaders, maxForwards);
List<String> agentParam = new ArrayList<>(); List<String> agentParam = new ArrayList<>();
agentParam.add("wvp-pro");
UserAgentHeader userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
request.addHeader(userAgentHeader);
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
request.setContent(content, contentTypeHeader); request.setContent(content, contentTypeHeader);
@ -115,10 +112,6 @@ public class SIPRequestHeaderPlarformProvider {
ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(Integer.parseInt(platform.getExpires())); ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(Integer.parseInt(platform.getExpires()));
request.addHeader(expires); request.addHeader(expires);
List<String> agentParam = new ArrayList<>();
agentParam.add("wvp-pro");
UserAgentHeader userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
request.addHeader(userAgentHeader);
return request; return request;
} }
@ -226,10 +219,6 @@ public class SIPRequestHeaderPlarformProvider {
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);
List<String> agentParam = new ArrayList<>();
agentParam.add("wvp-pro");
UserAgentHeader userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
request.addHeader(userAgentHeader);
ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml");
request.setContent(content, contentTypeHeader); request.setContent(content, contentTypeHeader);

18
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@ -27,6 +27,7 @@ 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.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringBootVersion;
import org.springframework.context.annotation.DependsOn; import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -37,7 +38,9 @@ import javax.sip.header.*;
import javax.sip.message.Request; import javax.sip.message.Request;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
/** /**
* @description:设备能力接口用于定义设备的控制查询能力 * @description:设备能力接口用于定义设备的控制查询能力
@ -49,7 +52,7 @@ import java.util.HashSet;
public class SIPCommander implements ISIPCommander { public class SIPCommander implements ISIPCommander {
private final Logger logger = LoggerFactory.getLogger(SIPCommander.class); private final Logger logger = LoggerFactory.getLogger(SIPCommander.class);
@Autowired @Autowired
private SipConfig sipConfig; private SipConfig sipConfig;
@ -1643,7 +1646,18 @@ public class SIPCommander implements ISIPCommander {
} else if("UDP".equals(device.getTransport())) { } else if("UDP".equals(device.getTransport())) {
clientTransaction = udpSipProvider.getNewClientTransaction(request); clientTransaction = udpSipProvider.getNewClientTransaction(request);
} }
if (request.getHeader(UserAgentHeader.NAME) == null) {
List<String> agentParam = new ArrayList<>();
agentParam.add("wvp-pro");
// TODO 添加版本信息以及日期
UserAgentHeader userAgentHeader = null;
try {
userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam);
} catch (ParseException e) {
throw new RuntimeException(e);
}
request.addHeader(userAgentHeader);
}
CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME); CallIdHeader callIdHeader = (CallIdHeader)request.getHeader(CallIdHeader.NAME);
// 添加错误订阅 // 添加错误订阅
if (errorEvent != null) { if (errorEvent != null) {

Loading…
Cancel
Save