lawrencehj
2021-06-23 0acf13445a2e3120f3d3599238401c9f2885d711
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java
@@ -2,8 +2,8 @@
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import gov.nist.javax.sip.message.MessageFactoryImpl;
import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
@@ -30,14 +30,6 @@
   
   @Autowired
   private SipFactory sipFactory;
//   @Autowired
//   @Qualifier(value="tcpSipProvider")
//   private SipProvider tcpSipProvider;
//
//   @Autowired
//   @Qualifier(value="udpSipProvider")
//   private SipProvider udpSipProvider;
   public Request createKeetpaliveMessageRequest(ParentPlatform parentPlatform, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException {
@@ -192,12 +184,12 @@
      viaHeader.setRPort();
      viaHeaders.add(viaHeader);
      // from
      SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(),
      SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(),
            parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort());
      Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI);
      FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag);
      // to
      SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getServerGBDomain());
      SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain());
      Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI);
      ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, null);
@@ -205,8 +197,10 @@
      MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
      // ceq
      CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.MESSAGE);
      request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
      MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory();
      // 设置编码, 防止中文乱码
      messageFactory.setDefaultContentEncodingCharset("gb2312");
      request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
            toHeader, viaHeaders, maxForwards);
      ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "MANSCDP+xml");
      request.setContent(content, contentTypeHeader);