Commit 84cc6e092a4c0f4aba3ffbef71325b844e0a4bea
1 parent
c96ab05d
解决低级编译问题
Showing
2 changed files
with
84 additions
and
69 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
| @@ -4,6 +4,9 @@ import java.text.ParseException; | @@ -4,6 +4,9 @@ import java.text.ParseException; | ||
| 4 | import java.util.ArrayList; | 4 | import java.util.ArrayList; |
| 5 | 5 | ||
| 6 | import javax.sip.InvalidArgumentException; | 6 | import javax.sip.InvalidArgumentException; |
| 7 | +import javax.sip.PeerUnavailableException; | ||
| 8 | +import javax.sip.SipFactory; | ||
| 9 | +import javax.sip.SipProvider; | ||
| 7 | import javax.sip.address.Address; | 10 | import javax.sip.address.Address; |
| 8 | import javax.sip.address.SipURI; | 11 | import javax.sip.address.SipURI; |
| 9 | import javax.sip.header.CSeqHeader; | 12 | import javax.sip.header.CSeqHeader; |
| @@ -16,10 +19,10 @@ import javax.sip.header.ViaHeader; | @@ -16,10 +19,10 @@ import javax.sip.header.ViaHeader; | ||
| 16 | import javax.sip.message.Request; | 19 | import javax.sip.message.Request; |
| 17 | 20 | ||
| 18 | import org.springframework.beans.factory.annotation.Autowired; | 21 | import org.springframework.beans.factory.annotation.Autowired; |
| 22 | +import org.springframework.beans.factory.annotation.Qualifier; | ||
| 19 | import org.springframework.stereotype.Component; | 23 | import org.springframework.stereotype.Component; |
| 20 | 24 | ||
| 21 | import com.genersoft.iot.vmp.conf.SipConfig; | 25 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 22 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | ||
| 23 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 26 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 24 | import com.genersoft.iot.vmp.gb28181.bean.Host; | 27 | import com.genersoft.iot.vmp.gb28181.bean.Host; |
| 25 | 28 | ||
| @@ -32,132 +35,140 @@ import com.genersoft.iot.vmp.gb28181.bean.Host; | @@ -32,132 +35,140 @@ import com.genersoft.iot.vmp.gb28181.bean.Host; | ||
| 32 | public class SIPRequestHeaderProvider { | 35 | public class SIPRequestHeaderProvider { |
| 33 | 36 | ||
| 34 | @Autowired | 37 | @Autowired |
| 35 | - private SipLayer layer; | ||
| 36 | - | ||
| 37 | - @Autowired | ||
| 38 | private SipConfig sipConfig; | 38 | private SipConfig sipConfig; |
| 39 | 39 | ||
| 40 | - public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException { | 40 | + @Autowired |
| 41 | + private SipFactory sipFactory; | ||
| 42 | + | ||
| 43 | + @Autowired | ||
| 44 | + @Qualifier(value="tcpSipProvider") | ||
| 45 | + private SipProvider tcpSipProvider; | ||
| 46 | + | ||
| 47 | + @Autowired | ||
| 48 | + @Qualifier(value="udpSipProvider") | ||
| 49 | + private SipProvider udpSipProvider; | ||
| 50 | + | ||
| 51 | + public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException, PeerUnavailableException { | ||
| 41 | Request request = null; | 52 | Request request = null; |
| 42 | Host host = device.getHost(); | 53 | Host host = device.getHost(); |
| 43 | // sipuri | 54 | // sipuri |
| 44 | - SipURI requestURI = layer.getAddressFactory().createSipURI(device.getDeviceId(), host.getAddress()); | 55 | + SipURI requestURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), host.getAddress()); |
| 45 | // via | 56 | // via |
| 46 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 57 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 47 | - ViaHeader viaHeader = layer.getHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), | 58 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), |
| 48 | device.getTransport(), viaTag); | 59 | device.getTransport(), viaTag); |
| 49 | viaHeader.setRPort(); | 60 | viaHeader.setRPort(); |
| 50 | viaHeaders.add(viaHeader); | 61 | viaHeaders.add(viaHeader); |
| 51 | // from | 62 | // from |
| 52 | - SipURI fromSipURI = layer.getAddressFactory().createSipURI(sipConfig.getSipId(), | 63 | + SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), |
| 53 | sipConfig.getSipIp() + ":" + sipConfig.getSipPort()); | 64 | sipConfig.getSipIp() + ":" + sipConfig.getSipPort()); |
| 54 | - Address fromAddress = layer.getAddressFactory().createAddress(fromSipURI); | ||
| 55 | - FromHeader fromHeader = layer.getHeaderFactory().createFromHeader(fromAddress, fromTag); | 65 | + Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); |
| 66 | + FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); | ||
| 56 | // to | 67 | // to |
| 57 | - SipURI toSipURI = layer.getAddressFactory().createSipURI(device.getDeviceId(), sipConfig.getSipDomain()); | ||
| 58 | - Address toAddress = layer.getAddressFactory().createAddress(toSipURI); | ||
| 59 | - ToHeader toHeader = layer.getHeaderFactory().createToHeader(toAddress, toTag); | 68 | + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), sipConfig.getSipDomain()); |
| 69 | + Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | ||
| 70 | + ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress, toTag); | ||
| 60 | // callid | 71 | // callid |
| 61 | - CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? layer.getTcpSipProvider().getNewCallId() | ||
| 62 | - : layer.getUdpSipProvider().getNewCallId(); | 72 | + CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() |
| 73 | + : udpSipProvider.getNewCallId(); | ||
| 63 | // Forwards | 74 | // Forwards |
| 64 | - MaxForwardsHeader maxForwards = layer.getHeaderFactory().createMaxForwardsHeader(70); | 75 | + MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); |
| 65 | // ceq | 76 | // ceq |
| 66 | - CSeqHeader cSeqHeader = layer.getHeaderFactory().createCSeqHeader(1L, Request.MESSAGE); | 77 | + CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.MESSAGE); |
| 67 | 78 | ||
| 68 | - request = layer.getMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, | 79 | + request = sipFactory.createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, |
| 69 | toHeader, viaHeaders, maxForwards); | 80 | toHeader, viaHeaders, maxForwards); |
| 70 | - ContentTypeHeader contentTypeHeader = layer.getHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); | 81 | + ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| 71 | request.setContent(content, contentTypeHeader); | 82 | request.setContent(content, contentTypeHeader); |
| 72 | return request; | 83 | return request; |
| 73 | } | 84 | } |
| 74 | 85 | ||
| 75 | - public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException { | 86 | + public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 76 | Request request = null; | 87 | Request request = null; |
| 77 | Host host = device.getHost(); | 88 | Host host = device.getHost(); |
| 78 | //请求行 | 89 | //请求行 |
| 79 | - SipURI requestLine = layer.getAddressFactory().createSipURI(channelId, host.getAddress()); | 90 | + SipURI requestLine = sipFactory.createAddressFactory().createSipURI(channelId, host.getAddress()); |
| 80 | //via | 91 | //via |
| 81 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 92 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 82 | - // ViaHeader viaHeader = layer.getHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag); | ||
| 83 | - ViaHeader viaHeader = layer.getHeaderFactory().createViaHeader(device.getHost().getIp(), device.getHost().getPort(), device.getTransport(), viaTag); | 93 | + // ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag); |
| 94 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getHost().getIp(), device.getHost().getPort(), device.getTransport(), viaTag); | ||
| 84 | viaHeader.setRPort(); | 95 | viaHeader.setRPort(); |
| 85 | viaHeaders.add(viaHeader); | 96 | viaHeaders.add(viaHeader); |
| 86 | //from | 97 | //from |
| 87 | - SipURI fromSipURI = layer.getAddressFactory().createSipURI(sipConfig.getSipId(),sipConfig.getSipDomain()); | ||
| 88 | - Address fromAddress = layer.getAddressFactory().createAddress(fromSipURI); | ||
| 89 | - FromHeader fromHeader = layer.getHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | 98 | + SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(),sipConfig.getSipDomain()); |
| 99 | + Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | ||
| 100 | + FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | ||
| 90 | //to | 101 | //to |
| 91 | - SipURI toSipURI = layer.getAddressFactory().createSipURI(channelId,sipConfig.getSipDomain()); | ||
| 92 | - Address toAddress = layer.getAddressFactory().createAddress(toSipURI); | ||
| 93 | - ToHeader toHeader = layer.getHeaderFactory().createToHeader(toAddress,null); | 102 | + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getSipDomain()); |
| 103 | + Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | ||
| 104 | + ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | ||
| 94 | 105 | ||
| 95 | //callid | 106 | //callid |
| 96 | CallIdHeader callIdHeader = null; | 107 | CallIdHeader callIdHeader = null; |
| 97 | if(device.getTransport().equals("TCP")) { | 108 | if(device.getTransport().equals("TCP")) { |
| 98 | - callIdHeader = layer.getTcpSipProvider().getNewCallId(); | 109 | + callIdHeader = tcpSipProvider.getNewCallId(); |
| 99 | } | 110 | } |
| 100 | if(device.getTransport().equals("UDP")) { | 111 | if(device.getTransport().equals("UDP")) { |
| 101 | - callIdHeader = layer.getUdpSipProvider().getNewCallId(); | 112 | + callIdHeader = udpSipProvider.getNewCallId(); |
| 102 | } | 113 | } |
| 103 | 114 | ||
| 104 | //Forwards | 115 | //Forwards |
| 105 | - MaxForwardsHeader maxForwards = layer.getHeaderFactory().createMaxForwardsHeader(70); | 116 | + MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); |
| 106 | 117 | ||
| 107 | //ceq | 118 | //ceq |
| 108 | - CSeqHeader cSeqHeader = layer.getHeaderFactory().createCSeqHeader(1L, Request.INVITE); | ||
| 109 | - request = layer.getMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | 119 | + CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.INVITE); |
| 120 | + request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | ||
| 110 | 121 | ||
| 111 | - Address concatAddress = layer.getAddressFactory().createAddress(layer.getAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort())); | ||
| 112 | - // Address concatAddress = layer.getAddressFactory().createAddress(layer.getAddressFactory().createSipURI(sipConfig.getSipId(), device.getHost().getIp()+":"+device.getHost().getPort())); | ||
| 113 | - request.addHeader(layer.getHeaderFactory().createContactHeader(concatAddress)); | 122 | + Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort())); |
| 123 | + // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), device.getHost().getIp()+":"+device.getHost().getPort())); | ||
| 124 | + request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | ||
| 114 | 125 | ||
| 115 | - ContentTypeHeader contentTypeHeader = layer.getHeaderFactory().createContentTypeHeader("Application", "SDP"); | 126 | + ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "SDP"); |
| 116 | request.setContent(content, contentTypeHeader); | 127 | request.setContent(content, contentTypeHeader); |
| 117 | return request; | 128 | return request; |
| 118 | } | 129 | } |
| 119 | 130 | ||
| 120 | - public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException { | 131 | + public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag) throws ParseException, InvalidArgumentException, PeerUnavailableException { |
| 121 | Request request = null; | 132 | Request request = null; |
| 122 | Host host = device.getHost(); | 133 | Host host = device.getHost(); |
| 123 | //请求行 | 134 | //请求行 |
| 124 | - SipURI requestLine = layer.getAddressFactory().createSipURI(device.getDeviceId(), host.getAddress()); | 135 | + SipURI requestLine = sipFactory.createAddressFactory().createSipURI(device.getDeviceId(), host.getAddress()); |
| 125 | //via | 136 | //via |
| 126 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); | 137 | ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(); |
| 127 | - // ViaHeader viaHeader = layer.getHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag); | ||
| 128 | - ViaHeader viaHeader = layer.getHeaderFactory().createViaHeader(device.getHost().getIp(), device.getHost().getPort(), device.getTransport(), viaTag); | 138 | + // ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(sipConfig.getSipIp(), sipConfig.getSipPort(), device.getTransport(), viaTag); |
| 139 | + ViaHeader viaHeader = sipFactory.createHeaderFactory().createViaHeader(device.getHost().getIp(), device.getHost().getPort(), device.getTransport(), viaTag); | ||
| 129 | viaHeader.setRPort(); | 140 | viaHeader.setRPort(); |
| 130 | viaHeaders.add(viaHeader); | 141 | viaHeaders.add(viaHeader); |
| 131 | //from | 142 | //from |
| 132 | - SipURI fromSipURI = layer.getAddressFactory().createSipURI(sipConfig.getSipId(),sipConfig.getSipDomain()); | ||
| 133 | - Address fromAddress = layer.getAddressFactory().createAddress(fromSipURI); | ||
| 134 | - FromHeader fromHeader = layer.getHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | 143 | + SipURI fromSipURI = sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(),sipConfig.getSipDomain()); |
| 144 | + Address fromAddress = sipFactory.createAddressFactory().createAddress(fromSipURI); | ||
| 145 | + FromHeader fromHeader = sipFactory.createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack | ||
| 135 | //to | 146 | //to |
| 136 | - SipURI toSipURI = layer.getAddressFactory().createSipURI(channelId,sipConfig.getSipDomain()); | ||
| 137 | - Address toAddress = layer.getAddressFactory().createAddress(toSipURI); | ||
| 138 | - ToHeader toHeader = layer.getHeaderFactory().createToHeader(toAddress,null); | 147 | + SipURI toSipURI = sipFactory.createAddressFactory().createSipURI(channelId,sipConfig.getSipDomain()); |
| 148 | + Address toAddress = sipFactory.createAddressFactory().createAddress(toSipURI); | ||
| 149 | + ToHeader toHeader = sipFactory.createHeaderFactory().createToHeader(toAddress,null); | ||
| 139 | 150 | ||
| 140 | //callid | 151 | //callid |
| 141 | CallIdHeader callIdHeader = null; | 152 | CallIdHeader callIdHeader = null; |
| 142 | if(device.getTransport().equals("TCP")) { | 153 | if(device.getTransport().equals("TCP")) { |
| 143 | - callIdHeader = layer.getTcpSipProvider().getNewCallId(); | 154 | + callIdHeader = tcpSipProvider.getNewCallId(); |
| 144 | } | 155 | } |
| 145 | if(device.getTransport().equals("UDP")) { | 156 | if(device.getTransport().equals("UDP")) { |
| 146 | - callIdHeader = layer.getUdpSipProvider().getNewCallId(); | 157 | + callIdHeader = udpSipProvider.getNewCallId(); |
| 147 | } | 158 | } |
| 148 | 159 | ||
| 149 | //Forwards | 160 | //Forwards |
| 150 | - MaxForwardsHeader maxForwards = layer.getHeaderFactory().createMaxForwardsHeader(70); | 161 | + MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70); |
| 151 | 162 | ||
| 152 | //ceq | 163 | //ceq |
| 153 | - CSeqHeader cSeqHeader = layer.getHeaderFactory().createCSeqHeader(1L, Request.INVITE); | ||
| 154 | - request = layer.getMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | 164 | + CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.INVITE); |
| 165 | + request = sipFactory.createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); | ||
| 155 | 166 | ||
| 156 | - Address concatAddress = layer.getAddressFactory().createAddress(layer.getAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort())); | ||
| 157 | - // Address concatAddress = layer.getAddressFactory().createAddress(layer.getAddressFactory().createSipURI(sipConfig.getSipId(), device.getHost().getIp()+":"+device.getHost().getPort())); | ||
| 158 | - request.addHeader(layer.getHeaderFactory().createContactHeader(concatAddress)); | 167 | + Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), sipConfig.getSipIp()+":"+sipConfig.getSipPort())); |
| 168 | + // Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getSipId(), device.getHost().getIp()+":"+device.getHost().getPort())); | ||
| 169 | + request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); | ||
| 159 | 170 | ||
| 160 | - ContentTypeHeader contentTypeHeader = layer.getHeaderFactory().createContentTypeHeader("Application", "SDP"); | 171 | + ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "SDP"); |
| 161 | request.setContent(content, contentTypeHeader); | 172 | request.setContent(content, contentTypeHeader); |
| 162 | return request; | 173 | return request; |
| 163 | } | 174 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | ||
| 3 | import java.text.ParseException; | 3 | import java.text.ParseException; |
| 4 | +import java.util.regex.Matcher; | ||
| 5 | +import java.util.regex.Pattern; | ||
| 4 | 6 | ||
| 5 | import javax.sip.ClientTransaction; | 7 | import javax.sip.ClientTransaction; |
| 6 | import javax.sip.Dialog; | 8 | import javax.sip.Dialog; |
| 7 | import javax.sip.InvalidArgumentException; | 9 | import javax.sip.InvalidArgumentException; |
| 8 | import javax.sip.SipException; | 10 | import javax.sip.SipException; |
| 11 | +import javax.sip.SipFactory; | ||
| 12 | +import javax.sip.SipProvider; | ||
| 9 | import javax.sip.TransactionDoesNotExistException; | 13 | import javax.sip.TransactionDoesNotExistException; |
| 10 | -import javax.sip.address.Address; | ||
| 11 | import javax.sip.address.SipURI; | 14 | import javax.sip.address.SipURI; |
| 12 | import javax.sip.header.ViaHeader; | 15 | import javax.sip.header.ViaHeader; |
| 13 | import javax.sip.message.Request; | 16 | import javax.sip.message.Request; |
| 14 | 17 | ||
| 15 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 16 | -import org.springframework.boot.autoconfigure.security.SecurityProperties.Headers; | 19 | +import org.springframework.beans.factory.annotation.Qualifier; |
| 17 | import org.springframework.stereotype.Component; | 20 | import org.springframework.stereotype.Component; |
| 18 | 21 | ||
| 19 | import com.genersoft.iot.vmp.conf.SipConfig; | 22 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 20 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | ||
| 21 | import com.genersoft.iot.vmp.gb28181.bean.Device; | 23 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 22 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; | 24 | import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; |
| 23 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; | 25 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; |
| 24 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; | 26 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; |
| 25 | import com.genersoft.iot.vmp.gb28181.utils.DateUtil; | 27 | import com.genersoft.iot.vmp.gb28181.utils.DateUtil; |
| 26 | 28 | ||
| 27 | -import java.util.regex.Pattern; | ||
| 28 | -import java.util.regex.Matcher; | ||
| 29 | - | ||
| 30 | /** | 29 | /** |
| 31 | * @Description:设备能力接口,用于定义设备的控制、查询能力 | 30 | * @Description:设备能力接口,用于定义设备的控制、查询能力 |
| 32 | * @author: swwheihei | 31 | * @author: swwheihei |
| @@ -42,10 +41,15 @@ public class SIPCommander implements ISIPCommander { | @@ -42,10 +41,15 @@ public class SIPCommander implements ISIPCommander { | ||
| 42 | private SIPRequestHeaderProvider headerProvider; | 41 | private SIPRequestHeaderProvider headerProvider; |
| 43 | 42 | ||
| 44 | @Autowired | 43 | @Autowired |
| 45 | - private SipLayer sipLayer; | 44 | + private VideoStreamSessionManager streamSession; |
| 46 | 45 | ||
| 47 | @Autowired | 46 | @Autowired |
| 48 | - private VideoStreamSessionManager streamSession; | 47 | + @Qualifier(value="tcpSipProvider") |
| 48 | + private SipProvider tcpSipProvider; | ||
| 49 | + | ||
| 50 | + @Autowired | ||
| 51 | + @Qualifier(value="udpSipProvider") | ||
| 52 | + private SipProvider udpSipProvider; | ||
| 49 | 53 | ||
| 50 | /** | 54 | /** |
| 51 | * 云台方向放控制,使用配置文件中的默认镜头移动速度 | 55 | * 云台方向放控制,使用配置文件中的默认镜头移动速度 |
| @@ -305,9 +309,9 @@ public class SIPCommander implements ISIPCommander { | @@ -305,9 +309,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 305 | String protocol = viaHeader.getTransport().toUpperCase(); | 309 | String protocol = viaHeader.getTransport().toUpperCase(); |
| 306 | ClientTransaction clientTransaction = null; | 310 | ClientTransaction clientTransaction = null; |
| 307 | if("TCP".equals(protocol)) { | 311 | if("TCP".equals(protocol)) { |
| 308 | - clientTransaction = sipLayer.getTcpSipProvider().getNewClientTransaction(byeRequest); | 312 | + clientTransaction = tcpSipProvider.getNewClientTransaction(byeRequest); |
| 309 | } else if("UDP".equals(protocol)) { | 313 | } else if("UDP".equals(protocol)) { |
| 310 | - clientTransaction = sipLayer.getUdpSipProvider().getNewClientTransaction(byeRequest); | 314 | + clientTransaction = udpSipProvider.getNewClientTransaction(byeRequest); |
| 311 | } | 315 | } |
| 312 | dialog.sendRequest(clientTransaction); | 316 | dialog.sendRequest(clientTransaction); |
| 313 | } catch (TransactionDoesNotExistException e) { | 317 | } catch (TransactionDoesNotExistException e) { |
| @@ -541,9 +545,9 @@ public class SIPCommander implements ISIPCommander { | @@ -541,9 +545,9 @@ public class SIPCommander implements ISIPCommander { | ||
| 541 | private ClientTransaction transmitRequest(Device device, Request request) throws SipException { | 545 | private ClientTransaction transmitRequest(Device device, Request request) throws SipException { |
| 542 | ClientTransaction clientTransaction = null; | 546 | ClientTransaction clientTransaction = null; |
| 543 | if("TCP".equals(device.getTransport())) { | 547 | if("TCP".equals(device.getTransport())) { |
| 544 | - clientTransaction = sipLayer.getTcpSipProvider().getNewClientTransaction(request); | 548 | + clientTransaction = tcpSipProvider.getNewClientTransaction(request); |
| 545 | } else if("UDP".equals(device.getTransport())) { | 549 | } else if("UDP".equals(device.getTransport())) { |
| 546 | - clientTransaction = sipLayer.getUdpSipProvider().getNewClientTransaction(request); | 550 | + clientTransaction = udpSipProvider.getNewClientTransaction(request); |
| 547 | } | 551 | } |
| 548 | clientTransaction.sendRequest(); | 552 | clientTransaction.sendRequest(); |
| 549 | return clientTransaction; | 553 | return clientTransaction; |