Commit c96ab05d7d0fb9ede820d89ea5e5b55820554e29
1 parent
d8eeb707
尝试解决内存溢出,并使用多线程提高性能
Showing
14 changed files
with
1139 additions
and
244 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
| ... | ... | @@ -2,115 +2,113 @@ package com.genersoft.iot.vmp.gb28181; |
| 2 | 2 | |
| 3 | 3 | import java.text.ParseException; |
| 4 | 4 | import java.util.Properties; |
| 5 | +import java.util.concurrent.LinkedBlockingQueue; | |
| 6 | +import java.util.concurrent.ThreadPoolExecutor; | |
| 7 | +import java.util.concurrent.TimeUnit; | |
| 5 | 8 | |
| 6 | -import javax.annotation.PostConstruct; | |
| 7 | 9 | import javax.sip.DialogTerminatedEvent; |
| 8 | 10 | import javax.sip.IOExceptionEvent; |
| 9 | 11 | import javax.sip.ListeningPoint; |
| 12 | +import javax.sip.PeerUnavailableException; | |
| 10 | 13 | import javax.sip.RequestEvent; |
| 11 | 14 | import javax.sip.ResponseEvent; |
| 12 | -import javax.sip.ServerTransaction; | |
| 13 | 15 | import javax.sip.SipFactory; |
| 14 | 16 | import javax.sip.SipListener; |
| 15 | 17 | import javax.sip.SipProvider; |
| 16 | 18 | import javax.sip.SipStack; |
| 17 | 19 | import javax.sip.TimeoutEvent; |
| 18 | -import javax.sip.TransactionAlreadyExistsException; | |
| 19 | 20 | import javax.sip.TransactionTerminatedEvent; |
| 20 | -import javax.sip.TransactionUnavailableException; | |
| 21 | -import javax.sip.address.AddressFactory; | |
| 22 | -import javax.sip.header.HeaderFactory; | |
| 23 | -import javax.sip.header.ViaHeader; | |
| 24 | -import javax.sip.message.MessageFactory; | |
| 25 | -import javax.sip.message.Request; | |
| 26 | 21 | import javax.sip.message.Response; |
| 27 | 22 | |
| 28 | 23 | import org.slf4j.Logger; |
| 29 | 24 | import org.slf4j.LoggerFactory; |
| 30 | 25 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | +import org.springframework.context.annotation.Bean; | |
| 27 | +import org.springframework.context.annotation.DependsOn; | |
| 31 | 28 | import org.springframework.stereotype.Component; |
| 32 | 29 | |
| 33 | 30 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 34 | 31 | import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorFactory; |
| 35 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 36 | 32 | import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor; |
| 37 | 33 | |
| 38 | 34 | import gov.nist.javax.sip.SipStackImpl; |
| 39 | 35 | |
| 40 | 36 | @Component |
| 41 | -public class SipLayer implements SipListener, Runnable { | |
| 37 | +public class SipLayer implements SipListener { | |
| 42 | 38 | |
| 43 | 39 | private final static Logger logger = LoggerFactory.getLogger(SipLayer.class); |
| 44 | 40 | |
| 45 | 41 | @Autowired |
| 46 | 42 | private SipConfig sipConfig; |
| 47 | 43 | |
| 48 | - private SipProvider tcpSipProvider; | |
| 49 | - | |
| 50 | - private SipProvider udpSipProvider; | |
| 51 | - | |
| 52 | 44 | @Autowired |
| 53 | 45 | private SIPProcessorFactory processorFactory; |
| 54 | 46 | |
| 55 | 47 | private SipStack sipStack; |
| 56 | 48 | |
| 57 | - private AddressFactory addressFactory; | |
| 58 | - private HeaderFactory headerFactory; | |
| 59 | - private MessageFactory messageFactory; | |
| 49 | + private SipFactory sipFactory; | |
| 60 | 50 | |
| 61 | - @PostConstruct | |
| 62 | - private void initSipServer() { | |
| 63 | - Thread thread = new Thread(this); | |
| 64 | - thread.setDaemon(true); | |
| 65 | - thread.setName("sip server thread start"); | |
| 66 | - thread.start(); | |
| 67 | - } | |
| 51 | + /** | |
| 52 | + * 消息处理器线程池 | |
| 53 | + */ | |
| 54 | + private ThreadPoolExecutor processThreadPool; | |
| 68 | 55 | |
| 69 | - @Override | |
| 70 | - public void run() { | |
| 71 | - SipFactory sipFactory = SipFactory.getInstance(); | |
| 56 | + @Bean("initSipServer") | |
| 57 | + @DependsOn("allOffline") | |
| 58 | + private void initSipServer() { | |
| 59 | + | |
| 60 | + int processThreadNum = Runtime.getRuntime().availableProcessors() * 10; | |
| 61 | + LinkedBlockingQueue<Runnable> processQueue = new LinkedBlockingQueue<Runnable>(10000); | |
| 62 | + processThreadPool = new ThreadPoolExecutor(processThreadNum,processThreadNum, | |
| 63 | + 0L,TimeUnit.MILLISECONDS,processQueue, | |
| 64 | + new ThreadPoolExecutor.CallerRunsPolicy()); | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Bean("sipFactory") | |
| 68 | + @DependsOn("initSipServer") | |
| 69 | + private SipFactory createSipFactory() { | |
| 70 | + sipFactory = SipFactory.getInstance(); | |
| 72 | 71 | sipFactory.setPathName("gov.nist"); |
| 73 | - try { | |
| 74 | - headerFactory = sipFactory.createHeaderFactory(); | |
| 75 | - | |
| 76 | - addressFactory = sipFactory.createAddressFactory(); | |
| 77 | - messageFactory = sipFactory.createMessageFactory(); | |
| 78 | - | |
| 79 | - Properties properties = new Properties(); | |
| 80 | - properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP"); | |
| 81 | - properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getSipIp()); | |
| 82 | - properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false"); | |
| 83 | - /** | |
| 84 | - * sip_server_log.log 和 sip_debug_log.log public static final int TRACE_NONE = | |
| 85 | - * 0; public static final int TRACE_MESSAGES = 16; public static final int | |
| 86 | - * TRACE_EXCEPTION = 17; public static final int TRACE_DEBUG = 32; | |
| 87 | - */ | |
| 88 | - properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32"); | |
| 89 | - properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "sip_server_log"); | |
| 90 | - properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "sip_debug_log"); | |
| 91 | - sipStack = (SipStackImpl) sipFactory.createSipStack(properties); | |
| 92 | - | |
| 93 | - startTcpListener(); | |
| 94 | - startUdpListener(); | |
| 95 | - } catch (Exception e) { | |
| 96 | - logger.error("Sip Server 启动失败! port {" + sipConfig.getSipPort() + "}"); | |
| 97 | - e.printStackTrace(); | |
| 98 | - } | |
| 99 | - logger.info("Sip Server 启动成功 port {" + sipConfig.getSipPort() + "}"); | |
| 100 | - } | |
| 101 | - | |
| 102 | - private void startTcpListener() throws Exception { | |
| 103 | - ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), | |
| 104 | - "TCP"); | |
| 105 | - tcpSipProvider = sipStack.createSipProvider(tcpListeningPoint); | |
| 72 | + return sipFactory; | |
| 73 | + } | |
| 74 | + | |
| 75 | + @Bean("sipStack") | |
| 76 | + @DependsOn({"initSipServer", "sipFactory"}) | |
| 77 | + private SipStack createSipStack() throws PeerUnavailableException { | |
| 78 | + Properties properties = new Properties(); | |
| 79 | + properties.setProperty("javax.sip.STACK_NAME", "GB28181_SIP"); | |
| 80 | + properties.setProperty("javax.sip.IP_ADDRESS", sipConfig.getSipIp()); | |
| 81 | + properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "false"); | |
| 82 | + /** | |
| 83 | + * sip_server_log.log 和 sip_debug_log.log public static final int TRACE_NONE = | |
| 84 | + * 0; public static final int TRACE_MESSAGES = 16; public static final int | |
| 85 | + * TRACE_EXCEPTION = 17; public static final int TRACE_DEBUG = 32; | |
| 86 | + */ | |
| 87 | + properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "0"); | |
| 88 | + properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "sip_server_log"); | |
| 89 | + properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "sip_debug_log"); | |
| 90 | + sipStack = (SipStackImpl) sipFactory.createSipStack(properties); | |
| 91 | + return sipStack; | |
| 92 | + } | |
| 93 | + | |
| 94 | + @Bean("tcpSipProvider") | |
| 95 | + @DependsOn("sipStack") | |
| 96 | + private SipProvider startTcpListener() throws Exception { | |
| 97 | + ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), "TCP"); | |
| 98 | + SipProvider tcpSipProvider = sipStack.createSipProvider(tcpListeningPoint); | |
| 106 | 99 | tcpSipProvider.addSipListener(this); |
| 100 | + logger.info("Sip Server TCP 启动成功 port {" + sipConfig.getSipPort() + "}"); | |
| 101 | + return tcpSipProvider; | |
| 107 | 102 | } |
| 108 | - | |
| 109 | - private void startUdpListener() throws Exception { | |
| 110 | - ListeningPoint udpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), | |
| 111 | - "UDP"); | |
| 112 | - udpSipProvider = sipStack.createSipProvider(udpListeningPoint); | |
| 103 | + | |
| 104 | + @Bean("udpSipProvider") | |
| 105 | + @DependsOn("sipStack") | |
| 106 | + private SipProvider startUdpListener() throws Exception { | |
| 107 | + ListeningPoint udpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), "UDP"); | |
| 108 | + SipProvider udpSipProvider = sipStack.createSipProvider(udpListeningPoint); | |
| 113 | 109 | udpSipProvider.addSipListener(this); |
| 110 | + logger.info("Sip Server TCP 启动成功 port {" + sipConfig.getSipPort() + "}"); | |
| 111 | + return udpSipProvider; | |
| 114 | 112 | } |
| 115 | 113 | |
| 116 | 114 | /** |
| ... | ... | @@ -119,8 +117,10 @@ public class SipLayer implements SipListener, Runnable { |
| 119 | 117 | */ |
| 120 | 118 | @Override |
| 121 | 119 | public void processRequest(RequestEvent evt) { |
| 122 | - ISIPRequestProcessor processor = processorFactory.createRequestProcessor(evt); | |
| 123 | - processor.process(evt, this); | |
| 120 | + // 由于jainsip是单线程程序,为提高性能并发处理 | |
| 121 | + processThreadPool.execute(() -> { | |
| 122 | + processorFactory.createRequestProcessor(evt).process(); | |
| 123 | + }); | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | @Override |
| ... | ... | @@ -212,51 +212,4 @@ public class SipLayer implements SipListener, Runnable { |
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - public ServerTransaction getServerTransaction(RequestEvent evt) { | |
| 216 | - Request request = evt.getRequest(); | |
| 217 | - ServerTransaction serverTransaction = evt.getServerTransaction(); | |
| 218 | - // 判断TCP还是UDP | |
| 219 | - boolean isTcp = false; | |
| 220 | - ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); | |
| 221 | - String transport = reqViaHeader.getTransport(); | |
| 222 | - if (transport.equals("TCP")) { | |
| 223 | - isTcp = true; | |
| 224 | - } | |
| 225 | - | |
| 226 | - if (serverTransaction == null) { | |
| 227 | - try { | |
| 228 | - if (isTcp) { | |
| 229 | - serverTransaction = tcpSipProvider.getNewServerTransaction(request); | |
| 230 | - } else { | |
| 231 | - serverTransaction = udpSipProvider.getNewServerTransaction(request); | |
| 232 | - } | |
| 233 | - } catch (TransactionAlreadyExistsException e) { | |
| 234 | - e.printStackTrace(); | |
| 235 | - } catch (TransactionUnavailableException e) { | |
| 236 | - e.printStackTrace(); | |
| 237 | - } | |
| 238 | - } | |
| 239 | - return serverTransaction; | |
| 240 | - } | |
| 241 | - | |
| 242 | - public AddressFactory getAddressFactory() { | |
| 243 | - return addressFactory; | |
| 244 | - } | |
| 245 | - | |
| 246 | - public HeaderFactory getHeaderFactory() { | |
| 247 | - return headerFactory; | |
| 248 | - } | |
| 249 | - | |
| 250 | - public MessageFactory getMessageFactory() { | |
| 251 | - return messageFactory; | |
| 252 | - } | |
| 253 | - | |
| 254 | - public SipProvider getTcpSipProvider() { | |
| 255 | - return tcpSipProvider; | |
| 256 | - } | |
| 257 | - | |
| 258 | - public SipProvider getUdpSipProvider() { | |
| 259 | - return udpSipProvider; | |
| 260 | - } | |
| 261 | - | |
| 262 | 215 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
| ... | ... | @@ -2,13 +2,23 @@ package com.genersoft.iot.vmp.gb28181.transmit; |
| 2 | 2 | |
| 3 | 3 | import javax.sip.RequestEvent; |
| 4 | 4 | import javax.sip.ResponseEvent; |
| 5 | +import javax.sip.SipProvider; | |
| 5 | 6 | import javax.sip.header.CSeqHeader; |
| 6 | 7 | import javax.sip.message.Request; |
| 7 | 8 | import javax.sip.message.Response; |
| 8 | 9 | |
| 10 | +import org.slf4j.Logger; | |
| 11 | +import org.slf4j.LoggerFactory; | |
| 9 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | +import org.springframework.beans.factory.annotation.Qualifier; | |
| 10 | 14 | import org.springframework.stereotype.Component; |
| 11 | 15 | |
| 16 | +import com.genersoft.iot.vmp.conf.SipConfig; | |
| 17 | +import com.genersoft.iot.vmp.gb28181.auth.RegisterLogicHandler; | |
| 18 | +import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; | |
| 19 | +import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | |
| 20 | +import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | |
| 21 | +import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | |
| 12 | 22 | import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; |
| 13 | 23 | import com.genersoft.iot.vmp.gb28181.transmit.request.impl.AckRequestProcessor; |
| 14 | 24 | import com.genersoft.iot.vmp.gb28181.transmit.request.impl.ByeRequestProcessor; |
| ... | ... | @@ -23,6 +33,8 @@ import com.genersoft.iot.vmp.gb28181.transmit.response.impl.ByeResponseProcessor |
| 23 | 33 | import com.genersoft.iot.vmp.gb28181.transmit.response.impl.CancelResponseProcessor; |
| 24 | 34 | import com.genersoft.iot.vmp.gb28181.transmit.response.impl.InviteResponseProcessor; |
| 25 | 35 | import com.genersoft.iot.vmp.gb28181.transmit.response.impl.OtherResponseProcessor; |
| 36 | +import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | |
| 37 | +import com.genersoft.iot.vmp.utils.redis.RedisUtil; | |
| 26 | 38 | |
| 27 | 39 | /** |
| 28 | 40 | * @Description:TODO(这里用一句话描述这个类的作用) |
| ... | ... | @@ -32,29 +44,31 @@ import com.genersoft.iot.vmp.gb28181.transmit.response.impl.OtherResponseProcess |
| 32 | 44 | @Component |
| 33 | 45 | public class SIPProcessorFactory { |
| 34 | 46 | |
| 47 | + private final static Logger logger = LoggerFactory.getLogger(SIPProcessorFactory.class); | |
| 48 | + | |
| 35 | 49 | @Autowired |
| 36 | - private InviteRequestProcessor inviteRequestProcessor; | |
| 50 | + private SipConfig sipConfig; | |
| 37 | 51 | |
| 38 | 52 | @Autowired |
| 39 | - private RegisterRequestProcessor registerRequestProcessor; | |
| 53 | + private RegisterLogicHandler handler; | |
| 40 | 54 | |
| 41 | 55 | @Autowired |
| 42 | - private SubscribeRequestProcessor subscribeRequestProcessor; | |
| 56 | + private IVideoManagerStorager storager; | |
| 43 | 57 | |
| 44 | 58 | @Autowired |
| 45 | - private AckRequestProcessor ackRequestProcessor; | |
| 59 | + private EventPublisher publisher; | |
| 46 | 60 | |
| 47 | 61 | @Autowired |
| 48 | - private ByeRequestProcessor byeRequestProcessor; | |
| 62 | + private SIPCommander cmder; | |
| 49 | 63 | |
| 50 | 64 | @Autowired |
| 51 | - private CancelRequestProcessor cancelRequestProcessor; | |
| 65 | + private RedisUtil redis; | |
| 52 | 66 | |
| 53 | 67 | @Autowired |
| 54 | - private MessageRequestProcessor messageRequestProcessor; | |
| 68 | + private DeferredResultHolder deferredResultHolder; | |
| 55 | 69 | |
| 56 | 70 | @Autowired |
| 57 | - private OtherRequestProcessor otherRequestProcessor; | |
| 71 | + private DeviceOffLineDetector offLineDetector; | |
| 58 | 72 | |
| 59 | 73 | @Autowired |
| 60 | 74 | private InviteResponseProcessor inviteResponseProcessor; |
| ... | ... | @@ -68,27 +82,64 @@ public class SIPProcessorFactory { |
| 68 | 82 | @Autowired |
| 69 | 83 | private OtherResponseProcessor otherResponseProcessor; |
| 70 | 84 | |
| 85 | + @Autowired | |
| 86 | + @Qualifier(value="tcpSipProvider") | |
| 87 | + private SipProvider tcpSipProvider; | |
| 88 | + | |
| 89 | + @Autowired | |
| 90 | + @Qualifier(value="udpSipProvider") | |
| 91 | + private SipProvider udpSipProvider; | |
| 71 | 92 | |
| 72 | 93 | public ISIPRequestProcessor createRequestProcessor(RequestEvent evt) { |
| 73 | 94 | Request request = evt.getRequest(); |
| 74 | 95 | String method = request.getMethod(); |
| 75 | - | |
| 96 | + logger.info("接收到消息:"+request.getMethod()); | |
| 76 | 97 | if (Request.INVITE.equals(method)) { |
| 77 | - return inviteRequestProcessor; | |
| 98 | + InviteRequestProcessor processor = new InviteRequestProcessor(); | |
| 99 | + processor.setRequestEvent(evt); | |
| 100 | + processor.setTcpSipProvider(tcpSipProvider); | |
| 101 | + processor.setUdpSipProvider(udpSipProvider); | |
| 102 | + return processor; | |
| 78 | 103 | } else if (Request.REGISTER.equals(method)) { |
| 79 | - return registerRequestProcessor; | |
| 104 | + RegisterRequestProcessor processor = new RegisterRequestProcessor(); | |
| 105 | + processor.setRequestEvent(evt); | |
| 106 | + processor.setTcpSipProvider(tcpSipProvider); | |
| 107 | + processor.setUdpSipProvider(udpSipProvider); | |
| 108 | + processor.setHandler(handler); | |
| 109 | + processor.setPublisher(publisher); | |
| 110 | + processor.setSipConfig(sipConfig); | |
| 111 | + processor.setVideoManagerStorager(storager); | |
| 112 | + return processor; | |
| 80 | 113 | } else if (Request.SUBSCRIBE.equals(method)) { |
| 81 | - return subscribeRequestProcessor; | |
| 114 | + SubscribeRequestProcessor processor = new SubscribeRequestProcessor(); | |
| 115 | + processor.setRequestEvent(evt); | |
| 116 | + return processor; | |
| 82 | 117 | } else if (Request.ACK.equals(method)) { |
| 83 | - return ackRequestProcessor; | |
| 118 | + AckRequestProcessor processor = new AckRequestProcessor(); | |
| 119 | + processor.setRequestEvent(evt); | |
| 120 | + return processor; | |
| 84 | 121 | } else if (Request.BYE.equals(method)) { |
| 85 | - return byeRequestProcessor; | |
| 122 | + ByeRequestProcessor processor = new ByeRequestProcessor(); | |
| 123 | + processor.setRequestEvent(evt); | |
| 124 | + return processor; | |
| 86 | 125 | } else if (Request.CANCEL.equals(method)) { |
| 87 | - return cancelRequestProcessor; | |
| 126 | + CancelRequestProcessor processor = new CancelRequestProcessor(); | |
| 127 | + processor.setRequestEvent(evt); | |
| 128 | + return processor; | |
| 88 | 129 | } else if (Request.MESSAGE.equals(method)) { |
| 89 | - return messageRequestProcessor; | |
| 130 | + MessageRequestProcessor processor = new MessageRequestProcessor(); | |
| 131 | + processor.setRequestEvent(evt); | |
| 132 | + processor.setTcpSipProvider(tcpSipProvider); | |
| 133 | + processor.setUdpSipProvider(udpSipProvider); | |
| 134 | + processor.setPublisher(publisher); | |
| 135 | + processor.setRedis(redis); | |
| 136 | + processor.setDeferredResultHolder(deferredResultHolder); | |
| 137 | + processor.setOffLineDetector(offLineDetector); | |
| 138 | + processor.setCmder(cmder); | |
| 139 | + processor.setStorager(storager); | |
| 140 | + return processor; | |
| 90 | 141 | } else { |
| 91 | - return otherRequestProcessor; | |
| 142 | + return new OtherRequestProcessor(); | |
| 92 | 143 | } |
| 93 | 144 | } |
| 94 | 145 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/ISIPRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.request; |
| 2 | 2 | |
| 3 | -import javax.sip.RequestEvent; | |
| 4 | - | |
| 5 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 6 | - | |
| 7 | 3 | /** |
| 8 | 4 | * @Description:处理接收IPCamera发来的SIP协议请求消息 |
| 9 | 5 | * @author: swwheihei |
| ... | ... | @@ -11,6 +7,6 @@ import com.genersoft.iot.vmp.gb28181.SipLayer; |
| 11 | 7 | */ |
| 12 | 8 | public interface ISIPRequestProcessor { |
| 13 | 9 | |
| 14 | - public void process(RequestEvent evt, SipLayer layer); | |
| 10 | + public void process(); | |
| 15 | 11 | |
| 16 | 12 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/SIPRequestAbstractProcessor.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.gb28181.transmit.request; | |
| 2 | + | |
| 3 | +import javax.sip.PeerUnavailableException; | |
| 4 | +import javax.sip.RequestEvent; | |
| 5 | +import javax.sip.ServerTransaction; | |
| 6 | +import javax.sip.SipFactory; | |
| 7 | +import javax.sip.SipProvider; | |
| 8 | +import javax.sip.TransactionAlreadyExistsException; | |
| 9 | +import javax.sip.TransactionUnavailableException; | |
| 10 | +import javax.sip.address.AddressFactory; | |
| 11 | +import javax.sip.header.HeaderFactory; | |
| 12 | +import javax.sip.header.ViaHeader; | |
| 13 | +import javax.sip.message.MessageFactory; | |
| 14 | +import javax.sip.message.Request; | |
| 15 | + | |
| 16 | +import gov.nist.javax.sip.SipStackImpl; | |
| 17 | +import gov.nist.javax.sip.message.SIPRequest; | |
| 18 | +import gov.nist.javax.sip.stack.SIPServerTransaction; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * @Description:处理接收IPCamera发来的SIP协议请求消息 | |
| 22 | + * @author: songww | |
| 23 | + * @date: 2020年5月3日 下午4:42:22 | |
| 24 | + */ | |
| 25 | +public abstract class SIPRequestAbstractProcessor implements ISIPRequestProcessor { | |
| 26 | + | |
| 27 | + protected RequestEvent evt; | |
| 28 | + | |
| 29 | + private SipProvider tcpSipProvider; | |
| 30 | + | |
| 31 | + private SipProvider udpSipProvider; | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public void process() { | |
| 35 | + this.process(evt); | |
| 36 | + } | |
| 37 | + | |
| 38 | + public abstract void process(RequestEvent evt); | |
| 39 | + | |
| 40 | + public ServerTransaction getServerTransaction(RequestEvent evt) { | |
| 41 | + Request request = evt.getRequest(); | |
| 42 | + ServerTransaction serverTransaction = evt.getServerTransaction(); | |
| 43 | + // 判断TCP还是UDP | |
| 44 | + boolean isTcp = false; | |
| 45 | + ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); | |
| 46 | + String transport = reqViaHeader.getTransport(); | |
| 47 | + if (transport.equals("TCP")) { | |
| 48 | + isTcp = true; | |
| 49 | + } | |
| 50 | + | |
| 51 | + if (serverTransaction == null) { | |
| 52 | + try { | |
| 53 | + if (isTcp) { | |
| 54 | + SipStackImpl stack = (SipStackImpl)tcpSipProvider.getSipStack(); | |
| 55 | + serverTransaction = (SIPServerTransaction) stack.findTransaction((SIPRequest)request, true); | |
| 56 | + if (serverTransaction == null) { | |
| 57 | + serverTransaction = tcpSipProvider.getNewServerTransaction(request); | |
| 58 | + } | |
| 59 | + } else { | |
| 60 | + SipStackImpl stack = (SipStackImpl)udpSipProvider.getSipStack(); | |
| 61 | + serverTransaction = (SIPServerTransaction) stack.findTransaction((SIPRequest)request, true); | |
| 62 | + if (serverTransaction == null) { | |
| 63 | + serverTransaction = udpSipProvider.getNewServerTransaction(request); | |
| 64 | + } | |
| 65 | + } | |
| 66 | + } catch (TransactionAlreadyExistsException e) { | |
| 67 | + e.printStackTrace(); | |
| 68 | + } catch (TransactionUnavailableException e) { | |
| 69 | + e.printStackTrace(); | |
| 70 | + } | |
| 71 | + } | |
| 72 | + return serverTransaction; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public AddressFactory getAddressFactory() { | |
| 76 | + try { | |
| 77 | + return SipFactory.getInstance().createAddressFactory(); | |
| 78 | + } catch (PeerUnavailableException e) { | |
| 79 | + e.printStackTrace(); | |
| 80 | + } | |
| 81 | + return null; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public HeaderFactory getHeaderFactory() { | |
| 85 | + try { | |
| 86 | + return SipFactory.getInstance().createHeaderFactory(); | |
| 87 | + } catch (PeerUnavailableException e) { | |
| 88 | + e.printStackTrace(); | |
| 89 | + } | |
| 90 | + return null; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public MessageFactory getMessageFactory() { | |
| 94 | + try { | |
| 95 | + return SipFactory.getInstance().createMessageFactory(); | |
| 96 | + } catch (PeerUnavailableException e) { | |
| 97 | + e.printStackTrace(); | |
| 98 | + } | |
| 99 | + return null; | |
| 100 | + } | |
| 101 | + | |
| 102 | + public RequestEvent getRequestEvent() { | |
| 103 | + return evt; | |
| 104 | + } | |
| 105 | + | |
| 106 | + public void setRequestEvent(RequestEvent evt) { | |
| 107 | + this.evt = evt; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public SipProvider getTcpSipProvider() { | |
| 111 | + return tcpSipProvider; | |
| 112 | + } | |
| 113 | + | |
| 114 | + public void setTcpSipProvider(SipProvider tcpSipProvider) { | |
| 115 | + this.tcpSipProvider = tcpSipProvider; | |
| 116 | + } | |
| 117 | + | |
| 118 | + public SipProvider getUdpSipProvider() { | |
| 119 | + return udpSipProvider; | |
| 120 | + } | |
| 121 | + | |
| 122 | + public void setUdpSipProvider(SipProvider udpSipProvider) { | |
| 123 | + this.udpSipProvider = udpSipProvider; | |
| 124 | + } | |
| 125 | + | |
| 126 | + | |
| 127 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/AckRequestProcessor.java
| ... | ... | @@ -3,14 +3,10 @@ package com.genersoft.iot.vmp.gb28181.transmit.request.impl; |
| 3 | 3 | import javax.sip.Dialog; |
| 4 | 4 | import javax.sip.InvalidArgumentException; |
| 5 | 5 | import javax.sip.RequestEvent; |
| 6 | -import javax.sip.ServerTransaction; | |
| 7 | 6 | import javax.sip.SipException; |
| 8 | 7 | import javax.sip.message.Request; |
| 9 | 8 | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | - | |
| 12 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 13 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 9 | +import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; | |
| 14 | 10 | |
| 15 | 11 | import gov.nist.javax.sip.header.CSeq; |
| 16 | 12 | |
| ... | ... | @@ -19,8 +15,7 @@ import gov.nist.javax.sip.header.CSeq; |
| 19 | 15 | * @author: swwheihei |
| 20 | 16 | * @date: 2020年5月3日 下午5:31:45 |
| 21 | 17 | */ |
| 22 | -@Component | |
| 23 | -public class AckRequestProcessor implements ISIPRequestProcessor { | |
| 18 | +public class AckRequestProcessor extends SIPRequestAbstractProcessor { | |
| 24 | 19 | |
| 25 | 20 | /** |
| 26 | 21 | * 处理 ACK请求 |
| ... | ... | @@ -31,7 +26,7 @@ public class AckRequestProcessor implements ISIPRequestProcessor { |
| 31 | 26 | * @param config |
| 32 | 27 | */ |
| 33 | 28 | @Override |
| 34 | - public void process(RequestEvent evt, SipLayer layer) { | |
| 29 | + public void process(RequestEvent evt) { | |
| 35 | 30 | Request request = evt.getRequest(); |
| 36 | 31 | Dialog dialog = evt.getDialog(); |
| 37 | 32 | try { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/ByeRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.request.impl; |
| 2 | 2 | |
| 3 | 3 | import javax.sip.RequestEvent; |
| 4 | -import javax.sip.ServerTransaction; | |
| 5 | 4 | |
| 6 | -import org.springframework.stereotype.Component; | |
| 7 | - | |
| 8 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 9 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; | |
| 10 | 6 | |
| 11 | 7 | /** |
| 12 | 8 | * @Description: BYE请求处理器 |
| 13 | 9 | * @author: swwheihei |
| 14 | 10 | * @date: 2020年5月3日 下午5:32:05 |
| 15 | 11 | */ |
| 16 | -@Component | |
| 17 | -public class ByeRequestProcessor implements ISIPRequestProcessor { | |
| 12 | +public class ByeRequestProcessor extends SIPRequestAbstractProcessor { | |
| 18 | 13 | |
| 19 | 14 | /** |
| 20 | 15 | * 处理BYE请求 |
| ... | ... | @@ -25,8 +20,8 @@ public class ByeRequestProcessor implements ISIPRequestProcessor { |
| 25 | 20 | * @param config |
| 26 | 21 | */ |
| 27 | 22 | @Override |
| 28 | - public void process(RequestEvent evt, SipLayer layer) { | |
| 29 | - // TODO Auto-generated method stub | |
| 23 | + public void process(RequestEvent evt) { | |
| 24 | + // TODO 优先级99 Bye Request消息实现,此消息一般为级联消息,上级给下级发送视频停止指令 | |
| 30 | 25 | |
| 31 | 26 | } |
| 32 | 27 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/CancelRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.request.impl; |
| 2 | 2 | |
| 3 | 3 | import javax.sip.RequestEvent; |
| 4 | -import javax.sip.ServerTransaction; | |
| 5 | 4 | |
| 6 | -import org.springframework.stereotype.Component; | |
| 7 | - | |
| 8 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 9 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; | |
| 10 | 6 | |
| 11 | 7 | /** |
| 12 | 8 | * @Description:CANCEL请求处理器 |
| 13 | 9 | * @author: swwheihei |
| 14 | 10 | * @date: 2020年5月3日 下午5:32:23 |
| 15 | 11 | */ |
| 16 | -@Component | |
| 17 | -public class CancelRequestProcessor implements ISIPRequestProcessor { | |
| 12 | +public class CancelRequestProcessor extends SIPRequestAbstractProcessor { | |
| 18 | 13 | |
| 19 | 14 | /** |
| 20 | 15 | * 处理CANCEL请求 |
| ... | ... | @@ -25,8 +20,8 @@ public class CancelRequestProcessor implements ISIPRequestProcessor { |
| 25 | 20 | * @param config |
| 26 | 21 | */ |
| 27 | 22 | @Override |
| 28 | - public void process(RequestEvent evt, SipLayer layer) { | |
| 29 | - // TODO Auto-generated method stub | |
| 23 | + public void process(RequestEvent evt) { | |
| 24 | + // TODO 优先级99 Cancel Request消息实现,此消息一般为级联消息,上级给下级发送请求取消指令 | |
| 30 | 25 | |
| 31 | 26 | } |
| 32 | 27 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/InviteRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.request.impl; |
| 2 | 2 | |
| 3 | 3 | import javax.sip.RequestEvent; |
| 4 | -import javax.sip.ServerTransaction; | |
| 5 | 4 | |
| 6 | -import org.springframework.stereotype.Component; | |
| 7 | - | |
| 8 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 9 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; | |
| 10 | 6 | |
| 11 | 7 | /** |
| 12 | 8 | * @Description:处理INVITE请求 |
| 13 | 9 | * @author: swwheihei |
| 14 | 10 | * @date: 2020年5月3日 下午4:43:52 |
| 15 | 11 | */ |
| 16 | -@Component | |
| 17 | -public class InviteRequestProcessor implements ISIPRequestProcessor { | |
| 12 | +public class InviteRequestProcessor extends SIPRequestAbstractProcessor { | |
| 18 | 13 | |
| 19 | 14 | /** |
| 20 | 15 | * 处理invite请求 |
| ... | ... | @@ -23,8 +18,8 @@ public class InviteRequestProcessor implements ISIPRequestProcessor { |
| 23 | 18 | * 请求消息 |
| 24 | 19 | */ |
| 25 | 20 | @Override |
| 26 | - public void process(RequestEvent evt, SipLayer layer) { | |
| 27 | - // TODO Auto-generated method stub | |
| 21 | + public void process(RequestEvent evt) { | |
| 22 | + // TODO 优先级99 Invite Request消息实现,此消息一般为级联消息,上级给下级发送请求视频指令 | |
| 28 | 23 | // Request request = requestEvent.getRequest(); |
| 29 | 24 | // |
| 30 | 25 | // try { |
| ... | ... | @@ -45,7 +40,6 @@ public class InviteRequestProcessor implements ISIPRequestProcessor { |
| 45 | 40 | // Via via = (Via) headerFactory.createViaHeader(SIPMain.ip, SIPMain.port, "UDP", |
| 46 | 41 | // callerVia.getBranch() + "sipphone"); |
| 47 | 42 | // |
| 48 | -// // FIXME 需要测试是否能够通过设置VIA头域来修改VIA头域值 | |
| 49 | 43 | // cliReq.removeHeader(Via.NAME); |
| 50 | 44 | // cliReq.addHeader(via); |
| 51 | 45 | // | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| ... | ... | @@ -10,7 +10,6 @@ import java.util.Map; |
| 10 | 10 | |
| 11 | 11 | import javax.sip.InvalidArgumentException; |
| 12 | 12 | import javax.sip.RequestEvent; |
| 13 | -import javax.sip.ServerTransaction; | |
| 14 | 13 | import javax.sip.SipException; |
| 15 | 14 | import javax.sip.message.Request; |
| 16 | 15 | import javax.sip.message.Response; |
| ... | ... | @@ -22,10 +21,8 @@ import org.dom4j.io.SAXReader; |
| 22 | 21 | import org.slf4j.Logger; |
| 23 | 22 | import org.slf4j.LoggerFactory; |
| 24 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | -import org.springframework.stereotype.Component; | |
| 26 | 24 | |
| 27 | 25 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 28 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 29 | 26 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 30 | 27 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 31 | 28 | import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; |
| ... | ... | @@ -35,7 +32,7 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 35 | 32 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 36 | 33 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| 37 | 34 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 38 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 35 | +import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; | |
| 39 | 36 | import com.genersoft.iot.vmp.gb28181.utils.DateUtil; |
| 40 | 37 | import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; |
| 41 | 38 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| ... | ... | @@ -46,38 +43,28 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 46 | 43 | * @author: swwheihei |
| 47 | 44 | * @date: 2020年5月3日 下午5:32:41 |
| 48 | 45 | */ |
| 49 | -@Component | |
| 50 | -public class MessageRequestProcessor implements ISIPRequestProcessor { | |
| 46 | +public class MessageRequestProcessor extends SIPRequestAbstractProcessor { | |
| 51 | 47 | |
| 52 | 48 | private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); |
| 53 | 49 | |
| 54 | - private ServerTransaction transaction; | |
| 55 | - | |
| 56 | - private SipLayer layer; | |
| 57 | - | |
| 58 | - @Autowired | |
| 59 | 50 | private SIPCommander cmder; |
| 60 | 51 | |
| 61 | - @Autowired | |
| 62 | 52 | private IVideoManagerStorager storager; |
| 63 | 53 | |
| 64 | - @Autowired | |
| 65 | 54 | private EventPublisher publisher; |
| 66 | 55 | |
| 67 | - @Autowired | |
| 68 | 56 | private RedisUtil redis; |
| 69 | 57 | |
| 70 | - @Autowired | |
| 71 | 58 | private DeferredResultHolder deferredResultHolder; |
| 72 | 59 | |
| 73 | - @Autowired | |
| 74 | 60 | private DeviceOffLineDetector offLineDetector; |
| 75 | 61 | |
| 76 | 62 | private final static String CACHE_RECORDINFO_KEY = "CACHE_RECORDINFO_"; |
| 77 | 63 | |
| 64 | + private static final String MESSAGE_KEEP_ALIVE = "Keepalive"; | |
| 65 | + private static final String MESSAGE_CONFIG_DOWNLOAD = "ConfigDownload"; | |
| 78 | 66 | private static final String MESSAGE_CATALOG = "Catalog"; |
| 79 | 67 | private static final String MESSAGE_DEVICE_INFO = "DeviceInfo"; |
| 80 | - private static final String MESSAGE_KEEP_ALIVE = "Keepalive"; | |
| 81 | 68 | private static final String MESSAGE_ALARM = "Alarm"; |
| 82 | 69 | private static final String MESSAGE_RECORD_INFO = "RecordInfo"; |
| 83 | 70 | // private static final String MESSAGE_BROADCAST = "Broadcast"; |
| ... | ... | @@ -93,23 +80,17 @@ public class MessageRequestProcessor implements ISIPRequestProcessor { |
| 93 | 80 | * @param transaction |
| 94 | 81 | */ |
| 95 | 82 | @Override |
| 96 | - public void process(RequestEvent evt, SipLayer layer) { | |
| 97 | - | |
| 98 | - this.layer = layer; | |
| 99 | - this.transaction = layer.getServerTransaction(evt); | |
| 100 | - | |
| 101 | - Request request = evt.getRequest(); | |
| 102 | - SAXReader reader = new SAXReader(); | |
| 103 | - reader.setEncoding("gbk"); | |
| 104 | - Document xml; | |
| 83 | + public void process(RequestEvent evt) { | |
| 84 | + | |
| 105 | 85 | try { |
| 106 | - xml = reader.read(new ByteArrayInputStream(request.getRawContent())); | |
| 107 | - Element rootElement = xml.getRootElement(); | |
| 108 | - String cmd = rootElement.element("CmdType").getStringValue(); | |
| 109 | - | |
| 86 | + Element rootElement = getRootElement(evt); | |
| 87 | + String cmd = XmlUtil.getText(rootElement,"CmdType"); | |
| 88 | + | |
| 110 | 89 | if (MESSAGE_KEEP_ALIVE.equals(cmd)) { |
| 111 | 90 | logger.info("接收到KeepAlive消息"); |
| 112 | 91 | processMessageKeepAlive(evt); |
| 92 | + } else if (MESSAGE_CONFIG_DOWNLOAD.equals(cmd)) { | |
| 93 | + logger.info("接收到ConfigDownload消息"); | |
| 113 | 94 | } else if (MESSAGE_CATALOG.equals(cmd)) { |
| 114 | 95 | logger.info("接收到Catalog消息"); |
| 115 | 96 | processMessageCatalogList(evt); |
| ... | ... | @@ -126,7 +107,6 @@ public class MessageRequestProcessor implements ISIPRequestProcessor { |
| 126 | 107 | } catch (DocumentException e) { |
| 127 | 108 | e.printStackTrace(); |
| 128 | 109 | } |
| 129 | - | |
| 130 | 110 | } |
| 131 | 111 | |
| 132 | 112 | /** |
| ... | ... | @@ -273,15 +253,11 @@ public class MessageRequestProcessor implements ISIPRequestProcessor { |
| 273 | 253 | try { |
| 274 | 254 | Element rootElement = getRootElement(evt); |
| 275 | 255 | String deviceId = XmlUtil.getText(rootElement,"DeviceID"); |
| 276 | - Request request = evt.getRequest(); | |
| 277 | - Response response = null; | |
| 278 | 256 | if (offLineDetector.isOnline(deviceId)) { |
| 279 | - response = layer.getMessageFactory().createResponse(Response.OK,request); | |
| 257 | + responseAck(evt); | |
| 280 | 258 | publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE); |
| 281 | 259 | } else { |
| 282 | - response = layer.getMessageFactory().createResponse(Response.BAD_REQUEST,request); | |
| 283 | 260 | } |
| 284 | - transaction.sendResponse(response); | |
| 285 | 261 | } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { |
| 286 | 262 | e.printStackTrace(); |
| 287 | 263 | } |
| ... | ... | @@ -373,6 +349,11 @@ public class MessageRequestProcessor implements ISIPRequestProcessor { |
| 373 | 349 | } |
| 374 | 350 | } |
| 375 | 351 | |
| 352 | + private void responseAck(RequestEvent evt) throws SipException, InvalidArgumentException, ParseException { | |
| 353 | + Response response = getMessageFactory().createResponse(Response.OK,evt.getRequest()); | |
| 354 | + getServerTransaction(evt).sendResponse(response); | |
| 355 | + } | |
| 356 | + | |
| 376 | 357 | private Element getRootElement(RequestEvent evt) throws DocumentException { |
| 377 | 358 | Request request = evt.getRequest(); |
| 378 | 359 | SAXReader reader = new SAXReader(); |
| ... | ... | @@ -381,4 +362,28 @@ public class MessageRequestProcessor implements ISIPRequestProcessor { |
| 381 | 362 | return xml.getRootElement(); |
| 382 | 363 | } |
| 383 | 364 | |
| 365 | + public void setCmder(SIPCommander cmder) { | |
| 366 | + this.cmder = cmder; | |
| 367 | + } | |
| 368 | + | |
| 369 | + public void setStorager(IVideoManagerStorager storager) { | |
| 370 | + this.storager = storager; | |
| 371 | + } | |
| 372 | + | |
| 373 | + public void setPublisher(EventPublisher publisher) { | |
| 374 | + this.publisher = publisher; | |
| 375 | + } | |
| 376 | + | |
| 377 | + public void setRedis(RedisUtil redis) { | |
| 378 | + this.redis = redis; | |
| 379 | + } | |
| 380 | + | |
| 381 | + public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) { | |
| 382 | + this.deferredResultHolder = deferredResultHolder; | |
| 383 | + } | |
| 384 | + | |
| 385 | + public void setOffLineDetector(DeviceOffLineDetector offLineDetector) { | |
| 386 | + this.offLineDetector = offLineDetector; | |
| 387 | + } | |
| 388 | + | |
| 384 | 389 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/OtherRequestProcessor.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.transmit.request.impl; |
| 2 | 2 | |
| 3 | 3 | import javax.sip.RequestEvent; |
| 4 | -import javax.sip.ServerTransaction; | |
| 5 | 4 | |
| 6 | -import org.springframework.stereotype.Component; | |
| 7 | - | |
| 8 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 9 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 5 | +import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; | |
| 10 | 6 | |
| 11 | 7 | /** |
| 12 | 8 | * @Description:暂不支持的消息请求处理器 |
| 13 | 9 | * @author: swwheihei |
| 14 | 10 | * @date: 2020年5月3日 下午5:32:59 |
| 15 | 11 | */ |
| 16 | -@Component | |
| 17 | -public class OtherRequestProcessor implements ISIPRequestProcessor { | |
| 12 | +public class OtherRequestProcessor extends SIPRequestAbstractProcessor { | |
| 18 | 13 | |
| 19 | 14 | /** |
| 20 | 15 | * <p>Title: process</p> |
| ... | ... | @@ -25,7 +20,7 @@ public class OtherRequestProcessor implements ISIPRequestProcessor { |
| 25 | 20 | * @param config |
| 26 | 21 | */ |
| 27 | 22 | @Override |
| 28 | - public void process(RequestEvent evt, SipLayer layer) { | |
| 23 | + public void process(RequestEvent evt) { | |
| 29 | 24 | System.out.println("no support the method! Method:" + evt.getRequest().getMethod()); |
| 30 | 25 | } |
| 31 | 26 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
| ... | ... | @@ -7,7 +7,6 @@ import java.util.Locale; |
| 7 | 7 | |
| 8 | 8 | import javax.sip.InvalidArgumentException; |
| 9 | 9 | import javax.sip.RequestEvent; |
| 10 | -import javax.sip.ServerTransaction; | |
| 11 | 10 | import javax.sip.SipException; |
| 12 | 11 | import javax.sip.header.AuthorizationHeader; |
| 13 | 12 | import javax.sip.header.ContactHeader; |
| ... | ... | @@ -17,19 +16,16 @@ import javax.sip.header.ViaHeader; |
| 17 | 16 | import javax.sip.message.Request; |
| 18 | 17 | import javax.sip.message.Response; |
| 19 | 18 | |
| 20 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | -import org.springframework.stereotype.Component; | |
| 22 | 19 | import org.springframework.util.StringUtils; |
| 23 | 20 | |
| 24 | 21 | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| 25 | 22 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 26 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 27 | 23 | import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; |
| 28 | 24 | import com.genersoft.iot.vmp.gb28181.auth.RegisterLogicHandler; |
| 29 | 25 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 30 | 26 | import com.genersoft.iot.vmp.gb28181.bean.Host; |
| 31 | 27 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 32 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 28 | +import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; | |
| 33 | 29 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| 34 | 30 | |
| 35 | 31 | import gov.nist.javax.sip.address.AddressImpl; |
| ... | ... | @@ -41,19 +37,14 @@ import gov.nist.javax.sip.header.Expires; |
| 41 | 37 | * @author: swwheihei |
| 42 | 38 | * @date: 2020年5月3日 下午4:47:25 |
| 43 | 39 | */ |
| 44 | -@Component | |
| 45 | -public class RegisterRequestProcessor implements ISIPRequestProcessor { | |
| 40 | +public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { | |
| 46 | 41 | |
| 47 | - @Autowired | |
| 48 | 42 | private SipConfig sipConfig; |
| 49 | 43 | |
| 50 | - @Autowired | |
| 51 | 44 | private RegisterLogicHandler handler; |
| 52 | 45 | |
| 53 | - @Autowired | |
| 54 | 46 | private IVideoManagerStorager storager; |
| 55 | 47 | |
| 56 | - @Autowired | |
| 57 | 48 | private EventPublisher publisher; |
| 58 | 49 | |
| 59 | 50 | /*** |
| ... | ... | @@ -63,7 +54,7 @@ public class RegisterRequestProcessor implements ISIPRequestProcessor { |
| 63 | 54 | * 请求消息 |
| 64 | 55 | */ |
| 65 | 56 | @Override |
| 66 | - public void process(RequestEvent evt, SipLayer layer) { | |
| 57 | + public void process(RequestEvent evt) { | |
| 67 | 58 | try { |
| 68 | 59 | System.out.println("收到注册请求,开始处理"); |
| 69 | 60 | Request request = evt.getRequest(); |
| ... | ... | @@ -88,14 +79,14 @@ public class RegisterRequestProcessor implements ISIPRequestProcessor { |
| 88 | 79 | } else if (!passwordCorrect) { |
| 89 | 80 | System.out.println("密码错误 回复401"); |
| 90 | 81 | } |
| 91 | - response = layer.getMessageFactory().createResponse(Response.UNAUTHORIZED, request); | |
| 92 | - new DigestServerAuthenticationHelper().generateChallenge(layer.getHeaderFactory(), response, sipConfig.getSipDomain()); | |
| 82 | + response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); | |
| 83 | + new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getSipDomain()); | |
| 93 | 84 | } |
| 94 | 85 | // 携带授权头并且密码正确 |
| 95 | 86 | else if (passwordCorrect) { |
| 96 | - response = layer.getMessageFactory().createResponse(Response.OK, request); | |
| 87 | + response = getMessageFactory().createResponse(Response.OK, request); | |
| 97 | 88 | // 添加date头 |
| 98 | - response.addHeader(layer.getHeaderFactory().createDateHeader(Calendar.getInstance(Locale.ENGLISH))); | |
| 89 | + response.addHeader(getHeaderFactory().createDateHeader(Calendar.getInstance(Locale.ENGLISH))); | |
| 99 | 90 | ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME); |
| 100 | 91 | // 添加Contact头 |
| 101 | 92 | response.addHeader(request.getHeader(ContactHeader.NAME)); |
| ... | ... | @@ -141,7 +132,7 @@ public class RegisterRequestProcessor implements ISIPRequestProcessor { |
| 141 | 132 | device.setTransport(isTcp ? "TCP" : "UDP"); |
| 142 | 133 | } |
| 143 | 134 | } |
| 144 | - layer.getServerTransaction(evt).sendResponse(response); | |
| 135 | + getServerTransaction(evt).sendResponse(response); | |
| 145 | 136 | // 注册成功 |
| 146 | 137 | // 保存到redis |
| 147 | 138 | // 下发catelog查询目录 |
| ... | ... | @@ -159,5 +150,21 @@ public class RegisterRequestProcessor implements ISIPRequestProcessor { |
| 159 | 150 | } |
| 160 | 151 | |
| 161 | 152 | } |
| 153 | + | |
| 154 | + public void setSipConfig(SipConfig sipConfig) { | |
| 155 | + this.sipConfig = sipConfig; | |
| 156 | + } | |
| 157 | + | |
| 158 | + public void setHandler(RegisterLogicHandler handler) { | |
| 159 | + this.handler = handler; | |
| 160 | + } | |
| 161 | + | |
| 162 | + public void setVideoManagerStorager(IVideoManagerStorager storager) { | |
| 163 | + this.storager = storager; | |
| 164 | + } | |
| 165 | + | |
| 166 | + public void setPublisher(EventPublisher publisher) { | |
| 167 | + this.publisher = publisher; | |
| 168 | + } | |
| 162 | 169 | |
| 163 | 170 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/SubscribeRequestProcessor.java
| ... | ... | @@ -10,18 +10,14 @@ import javax.sip.header.ExpiresHeader; |
| 10 | 10 | import javax.sip.message.Request; |
| 11 | 11 | import javax.sip.message.Response; |
| 12 | 12 | |
| 13 | -import org.springframework.stereotype.Component; | |
| 14 | - | |
| 15 | -import com.genersoft.iot.vmp.gb28181.SipLayer; | |
| 16 | -import com.genersoft.iot.vmp.gb28181.transmit.request.ISIPRequestProcessor; | |
| 13 | +import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; | |
| 17 | 14 | |
| 18 | 15 | /** |
| 19 | 16 | * @Description:SUBSCRIBE请求处理器 |
| 20 | 17 | * @author: swwheihei |
| 21 | 18 | * @date: 2020年5月3日 下午5:31:20 |
| 22 | 19 | */ |
| 23 | -@Component | |
| 24 | -public class SubscribeRequestProcessor implements ISIPRequestProcessor { | |
| 20 | +public class SubscribeRequestProcessor extends SIPRequestAbstractProcessor { | |
| 25 | 21 | |
| 26 | 22 | /** |
| 27 | 23 | * 处理SUBSCRIBE请求 |
| ... | ... | @@ -32,18 +28,18 @@ public class SubscribeRequestProcessor implements ISIPRequestProcessor { |
| 32 | 28 | * @param config |
| 33 | 29 | */ |
| 34 | 30 | @Override |
| 35 | - public void process(RequestEvent evt, SipLayer layer) { | |
| 31 | + public void process(RequestEvent evt) { | |
| 36 | 32 | Request request = evt.getRequest(); |
| 37 | 33 | |
| 38 | 34 | try { |
| 39 | 35 | Response response = null; |
| 40 | - response = layer.getMessageFactory().createResponse(200, request); | |
| 36 | + response = getMessageFactory().createResponse(200, request); | |
| 41 | 37 | if (response != null) { |
| 42 | - ExpiresHeader expireHeader = layer.getHeaderFactory().createExpiresHeader(30); | |
| 38 | + ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30); | |
| 43 | 39 | response.setExpires(expireHeader); |
| 44 | 40 | } |
| 45 | 41 | System.out.println("response : " + response.toString()); |
| 46 | - ServerTransaction transaction = layer.getServerTransaction(evt); | |
| 42 | + ServerTransaction transaction = getServerTransaction(evt); | |
| 47 | 43 | if (transaction != null) { |
| 48 | 44 | transaction.sendResponse(response); |
| 49 | 45 | transaction.terminate(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/Device.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.vmanager.device.entity; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import javax.persistence.Column; | |
| 6 | +import javax.persistence.Id; | |
| 7 | +import javax.persistence.Table; | |
| 8 | +import javax.persistence.Transient; | |
| 9 | +import javax.validation.constraints.Max; | |
| 10 | +import javax.validation.constraints.NotNull; | |
| 11 | +import javax.validation.constraints.Size; | |
| 12 | + | |
| 13 | +import io.swagger.annotations.ApiModel; | |
| 14 | +import io.swagger.annotations.ApiModelProperty; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * @Description:视频设备信息 | |
| 18 | + * @author: songww | |
| 19 | + * @date: 2020年5月8日 下午2:05:56 | |
| 20 | + */ | |
| 21 | +@ApiModel(value = "视频设备信息", description = "视频设备信息") | |
| 22 | +@Table(name="VMP_VIDEODEVICES") | |
| 23 | +public class Device { | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 设备Id | |
| 27 | + */ | |
| 28 | + @ApiModelProperty("设备编号") | |
| 29 | + @Id | |
| 30 | + @Column(name="DEVICE_ID") | |
| 31 | + @NotNull(message = "deviceId 不能为 null") | |
| 32 | + @Size(min = 4, max = 32, message = "deviceId 必须大于 4 位并且小于 32 位") | |
| 33 | + private String deviceId; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 设备名称 | |
| 37 | + */ | |
| 38 | + @ApiModelProperty("设备名称") | |
| 39 | + @Column(name="DEVICE_NAME") | |
| 40 | + @Size(max = 32, message = "deviceName 必须小于 32 位") | |
| 41 | + private String deviceName; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 生产厂商 | |
| 45 | + */ | |
| 46 | + @ApiModelProperty("生产厂商") | |
| 47 | + @Column(name="MANUFACTURER") | |
| 48 | + @Size(max = 64, message = "manufacturer 必须小于 64 位") | |
| 49 | + private String manufacturer; | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 型号 | |
| 53 | + */ | |
| 54 | + @ApiModelProperty("型号") | |
| 55 | + @Column(name="MODEL") | |
| 56 | + @Size(max = 64, message = "manufacturer 必须小于 64 位") | |
| 57 | + private String model; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 固件版本 | |
| 61 | + */ | |
| 62 | + @ApiModelProperty("固件版本") | |
| 63 | + @Column(name="FIRMWARE") | |
| 64 | + @Size(max = 64, message = "firmware 必须小于 64 位") | |
| 65 | + private String firmware; | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * 通信协议 | |
| 69 | + * GB28181 ONVIF | |
| 70 | + */ | |
| 71 | + @ApiModelProperty("通信协议") | |
| 72 | + @Column(name="PROTOCOL") | |
| 73 | + @NotNull(message = "protocol 不能为 null") | |
| 74 | + @Size(max = 16, message = "protocol 必须小于 16 位") | |
| 75 | + private String protocol; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * SIP 传输协议 | |
| 79 | + * UDP/TCP | |
| 80 | + */ | |
| 81 | + @ApiModelProperty("SIP 传输协议") | |
| 82 | + @Column(name="TRANSPORT") | |
| 83 | + @Size(min = 3,max = 3 ,message = "transport 必须为 3 位") | |
| 84 | + private String transport; | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * 数据流传输模式 | |
| 88 | + * UDP:udp传输 | |
| 89 | + * TCP-ACTIVE:tcp主动模式 | |
| 90 | + * TCP-PASSIVE:tcp被动模式 | |
| 91 | + */ | |
| 92 | + @ApiModelProperty("数据流传输模式") | |
| 93 | + @Column(name="STREAM_MODE") | |
| 94 | + @Size(max = 64, message = "streamMode 必须小于 16 位") | |
| 95 | + private String streamMode; | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * IP地址 | |
| 99 | + */ | |
| 100 | + @ApiModelProperty("IP地址") | |
| 101 | + @Column(name="IP") | |
| 102 | + @Size(max = 15, message = "streamMode 必须小于 15 位") | |
| 103 | + private String ip; | |
| 104 | + | |
| 105 | + /** | |
| 106 | + * 端口号 | |
| 107 | + */ | |
| 108 | + @ApiModelProperty("端口号") | |
| 109 | + @Column(name="PORT") | |
| 110 | + @Max(value = 65535,message = "port 最大值为 65535") | |
| 111 | + private Integer port; | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * 在线状态 1在线, 0离线 | |
| 115 | + */ | |
| 116 | + @ApiModelProperty("在线状态") | |
| 117 | + @Size(min = 1,max = 1 ,message = "online 必须为 1 位") | |
| 118 | + @Column(name="ONLINE") | |
| 119 | + private String online; | |
| 120 | + | |
| 121 | + /** | |
| 122 | + * 通道数量 | |
| 123 | + */ | |
| 124 | + @ApiModelProperty("通道数量") | |
| 125 | + @Column(name="CHANNEL_SUM") | |
| 126 | + @Max(value = 1000000000,message = "channelSum 最大值为 1000000000") | |
| 127 | + private Integer channelSum; | |
| 128 | + | |
| 129 | + @Override | |
| 130 | + public String toString() { | |
| 131 | + return "Device{" + | |
| 132 | + "deviceId='" + deviceId + '\'' + | |
| 133 | + ", deviceName='" + deviceName + '\'' + | |
| 134 | + ", manufacturer='" + manufacturer + '\'' + | |
| 135 | + ", model='" + model + '\'' + | |
| 136 | + ", firmware='" + firmware + '\'' + | |
| 137 | + ", protocol='" + protocol + '\'' + | |
| 138 | + ", transport='" + transport + '\'' + | |
| 139 | + ", streamMode='" + streamMode + '\'' + | |
| 140 | + ", ip='" + ip + '\'' + | |
| 141 | + ", port=" + port + | |
| 142 | + ", online='" + online + '\'' + | |
| 143 | + ", channelSum=" + channelSum + | |
| 144 | + ", createTime='" + createTime + '\'' + | |
| 145 | + ", registerTime='" + registerTime + '\'' + | |
| 146 | + ", heartbeatTime='" + heartbeatTime + '\'' + | |
| 147 | + ", updateTime='" + updateTime + '\'' + | |
| 148 | + ", updatePerson='" + updatePerson + '\'' + | |
| 149 | + ", syncTime='" + syncTime + '\'' + | |
| 150 | + ", syncPerson='" + syncPerson + '\'' + | |
| 151 | + ", username='" + username + '\'' + | |
| 152 | + ", password='" + password + '\'' + | |
| 153 | + ", channelList=" + channelList + | |
| 154 | + '}'; | |
| 155 | + } | |
| 156 | + | |
| 157 | + /** | |
| 158 | + * 创建时间 | |
| 159 | + */ | |
| 160 | + @ApiModelProperty("创建时间") | |
| 161 | + @Column(name="CREATE_TIME") | |
| 162 | + private String createTime; | |
| 163 | + | |
| 164 | + /** | |
| 165 | + * 注册时间 | |
| 166 | + */ | |
| 167 | + @ApiModelProperty("注册时间") | |
| 168 | + @Column(name="REGISTER_TIME") | |
| 169 | + private String registerTime; | |
| 170 | + | |
| 171 | + /** | |
| 172 | + * 心跳时间 | |
| 173 | + */ | |
| 174 | + @ApiModelProperty("心跳时间") | |
| 175 | + @Column(name="HEARTBEAT_TIME") | |
| 176 | + private String heartbeatTime; | |
| 177 | + | |
| 178 | + /** | |
| 179 | + * 修改时间 | |
| 180 | + */ | |
| 181 | + @ApiModelProperty("更新时间") | |
| 182 | + @Column(name="UPDATE_TIME") | |
| 183 | + private String updateTime; | |
| 184 | + | |
| 185 | + /** | |
| 186 | + * 修改人 | |
| 187 | + */ | |
| 188 | + @ApiModelProperty("修改人") | |
| 189 | + @Column(name="UPDATE_PERSON") | |
| 190 | + private String updatePerson; | |
| 191 | + | |
| 192 | + /** | |
| 193 | + * 同步时间 | |
| 194 | + */ | |
| 195 | + @ApiModelProperty("同步时间") | |
| 196 | + @Column(name="SYNC_TIME") | |
| 197 | + private String syncTime; | |
| 198 | + | |
| 199 | + /** | |
| 200 | + * 同步人 | |
| 201 | + */ | |
| 202 | + @ApiModelProperty("同步人") | |
| 203 | + @Column(name="SYNC_PERSON") | |
| 204 | + private String syncPerson; | |
| 205 | + | |
| 206 | + /** | |
| 207 | + * ONVIF协议-用户名 | |
| 208 | + */ | |
| 209 | + @ApiModelProperty("用户名") | |
| 210 | + @Column(name="USERNAME") | |
| 211 | + @Size(max = 32, message = "username 必须小于 32 位") | |
| 212 | + private String username; | |
| 213 | + | |
| 214 | + /** | |
| 215 | + * ONVIF协议-密码 | |
| 216 | + */ | |
| 217 | + @ApiModelProperty("密码") | |
| 218 | + @Size(max = 32, message = "password 必须小于 32 位") | |
| 219 | + @Column(name="PASSWORD") | |
| 220 | + private String password; | |
| 221 | + | |
| 222 | + @Transient | |
| 223 | + private List<DeviceChannel> channelList; | |
| 224 | + | |
| 225 | + public String getDeviceId() { | |
| 226 | + return deviceId; | |
| 227 | + } | |
| 228 | + | |
| 229 | + public void setDeviceId(String deviceId) { | |
| 230 | + this.deviceId = deviceId; | |
| 231 | + } | |
| 232 | + | |
| 233 | + public String getDeviceName() { | |
| 234 | + return deviceName; | |
| 235 | + } | |
| 236 | + | |
| 237 | + public void setDeviceName(String deviceName) { | |
| 238 | + this.deviceName = deviceName; | |
| 239 | + } | |
| 240 | + | |
| 241 | + public String getTransport() { | |
| 242 | + return transport; | |
| 243 | + } | |
| 244 | + | |
| 245 | + public void setTransport(String transport) { | |
| 246 | + this.transport = transport; | |
| 247 | + } | |
| 248 | + | |
| 249 | + public String getIp() { | |
| 250 | + return ip; | |
| 251 | + } | |
| 252 | + | |
| 253 | + public void setIp(String ip) { | |
| 254 | + this.ip = ip; | |
| 255 | + } | |
| 256 | + | |
| 257 | + public Integer getPort() { | |
| 258 | + return port; | |
| 259 | + } | |
| 260 | + | |
| 261 | + public void setPort(Integer port) { | |
| 262 | + this.port = port; | |
| 263 | + } | |
| 264 | + | |
| 265 | + public String getManufacturer() { | |
| 266 | + return manufacturer; | |
| 267 | + } | |
| 268 | + | |
| 269 | + public void setManufacturer(String manufacturer) { | |
| 270 | + this.manufacturer = manufacturer; | |
| 271 | + } | |
| 272 | + | |
| 273 | + public String getModel() { | |
| 274 | + return model; | |
| 275 | + } | |
| 276 | + | |
| 277 | + public void setModel(String model) { | |
| 278 | + this.model = model; | |
| 279 | + } | |
| 280 | + | |
| 281 | + public String getFirmware() { | |
| 282 | + return firmware; | |
| 283 | + } | |
| 284 | + | |
| 285 | + public void setFirmware(String firmware) { | |
| 286 | + this.firmware = firmware; | |
| 287 | + } | |
| 288 | + | |
| 289 | + public String getOnline() { | |
| 290 | + return online; | |
| 291 | + } | |
| 292 | + | |
| 293 | + public void setOnline(String online) { | |
| 294 | + this.online = online; | |
| 295 | + } | |
| 296 | + | |
| 297 | + public String getStreamMode() { | |
| 298 | + return streamMode; | |
| 299 | + } | |
| 300 | + | |
| 301 | + public void setStreamMode(String streamMode) { | |
| 302 | + this.streamMode = streamMode; | |
| 303 | + } | |
| 304 | + | |
| 305 | + public List<DeviceChannel> getChannelList() { | |
| 306 | + return channelList; | |
| 307 | + } | |
| 308 | + | |
| 309 | + public void setChannelList(List<DeviceChannel> channelList) { | |
| 310 | + this.channelList = channelList; | |
| 311 | + } | |
| 312 | + | |
| 313 | + public Integer getChannelSum() { | |
| 314 | + return channelSum; | |
| 315 | + } | |
| 316 | + | |
| 317 | + public void setChannelSum(Integer channelSum) { | |
| 318 | + this.channelSum = channelSum; | |
| 319 | + } | |
| 320 | + | |
| 321 | + public String getCreateTime() { | |
| 322 | + return createTime; | |
| 323 | + } | |
| 324 | + | |
| 325 | + public void setCreateTime(String createTime) { | |
| 326 | + this.createTime = createTime; | |
| 327 | + } | |
| 328 | + | |
| 329 | + public String getRegisterTime() { | |
| 330 | + return registerTime; | |
| 331 | + } | |
| 332 | + | |
| 333 | + public void setRegisterTime(String registerTime) { | |
| 334 | + this.registerTime = registerTime; | |
| 335 | + } | |
| 336 | + | |
| 337 | + public String getHeartbeatTime() { | |
| 338 | + return heartbeatTime; | |
| 339 | + } | |
| 340 | + | |
| 341 | + public void setHeartbeatTime(String heartbeatTime) { | |
| 342 | + this.heartbeatTime = heartbeatTime; | |
| 343 | + } | |
| 344 | + | |
| 345 | + public String getUpdateTime() { | |
| 346 | + return updateTime; | |
| 347 | + } | |
| 348 | + | |
| 349 | + public void setUpdateTime(String updateTime) { | |
| 350 | + this.updateTime = updateTime; | |
| 351 | + } | |
| 352 | + | |
| 353 | + public String getUpdatePerson() { | |
| 354 | + return updatePerson; | |
| 355 | + } | |
| 356 | + | |
| 357 | + public void setUpdatePerson(String updatePerson) { | |
| 358 | + this.updatePerson = updatePerson; | |
| 359 | + } | |
| 360 | + | |
| 361 | + public String getSyncTime() { | |
| 362 | + return syncTime; | |
| 363 | + } | |
| 364 | + | |
| 365 | + public void setSyncTime(String syncTime) { | |
| 366 | + this.syncTime = syncTime; | |
| 367 | + } | |
| 368 | + | |
| 369 | + public String getSyncPerson() { | |
| 370 | + return syncPerson; | |
| 371 | + } | |
| 372 | + | |
| 373 | + public void setSyncPerson(String syncPerson) { | |
| 374 | + this.syncPerson = syncPerson; | |
| 375 | + } | |
| 376 | + | |
| 377 | + public String getUsername() { | |
| 378 | + return username; | |
| 379 | + } | |
| 380 | + | |
| 381 | + public void setUsername(String username) { | |
| 382 | + this.username = username; | |
| 383 | + } | |
| 384 | + | |
| 385 | + public String getPassword() { | |
| 386 | + return password; | |
| 387 | + } | |
| 388 | + | |
| 389 | + public void setPassword(String password) { | |
| 390 | + this.password = password; | |
| 391 | + } | |
| 392 | + | |
| 393 | + public String getProtocol() { | |
| 394 | + return protocol; | |
| 395 | + } | |
| 396 | + | |
| 397 | + public void setProtocol(String protocol) { | |
| 398 | + this.protocol = protocol; | |
| 399 | + } | |
| 400 | + | |
| 401 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/device/entity/DeviceChannel.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.vmanager.device.entity; | |
| 2 | + | |
| 3 | +import javax.persistence.Column; | |
| 4 | +import javax.persistence.Id; | |
| 5 | +import javax.persistence.Table; | |
| 6 | + | |
| 7 | +import io.swagger.annotations.ApiModel; | |
| 8 | +import io.swagger.annotations.ApiModelProperty; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * @Description:设备通道信息 | |
| 12 | + * @author: songww | |
| 13 | + * @date: 2020年5月20日 下午9:00:46 | |
| 14 | + */ | |
| 15 | +@ApiModel(value = "设备通道信息", description = "设备通道信息") | |
| 16 | +@Table(name="VMP_VIDEOCHANNELS") | |
| 17 | +public class DeviceChannel { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 通道编号 | |
| 21 | + */ | |
| 22 | + @ApiModelProperty("通道编号") | |
| 23 | + @Id | |
| 24 | + @Column(name="CHANNEL_ID") | |
| 25 | + private String channelId; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 设备编号 | |
| 29 | + */ | |
| 30 | + @ApiModelProperty("设备编号") | |
| 31 | + @Column(name="DEVICE_ID") | |
| 32 | + private String deviceId; | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 通道名 | |
| 36 | + */ | |
| 37 | + @ApiModelProperty("通道名") | |
| 38 | + @Column(name="CHANNEL_NAME") | |
| 39 | + private String channelName; | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 生产厂商 | |
| 43 | + */ | |
| 44 | + @ApiModelProperty("生产厂商") | |
| 45 | + @Column(name="MANUFACTURER") | |
| 46 | + private String manufacture; | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 型号 | |
| 50 | + */ | |
| 51 | + @ApiModelProperty("型号") | |
| 52 | + @Column(name="MODEL") | |
| 53 | + private String model; | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 设备归属 | |
| 57 | + */ | |
| 58 | + @ApiModelProperty("设备归属") | |
| 59 | + @Column(name="OWNER") | |
| 60 | + private String owner; | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 行政区域 | |
| 64 | + */ | |
| 65 | + @ApiModelProperty("行政区域") | |
| 66 | + @Column(name="CIVIL_CODE") | |
| 67 | + private String civilCode; | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * 警区 | |
| 71 | + */ | |
| 72 | + @ApiModelProperty("警区") | |
| 73 | + @Column(name="BLOCK") | |
| 74 | + private String block; | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 安装地址 | |
| 78 | + */ | |
| 79 | + @ApiModelProperty("安装地址") | |
| 80 | + @Column(name="ADDRESS") | |
| 81 | + private String address; | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 是否有子设备 1有, 0没有 | |
| 85 | + */ | |
| 86 | + @ApiModelProperty("是否有子设备") | |
| 87 | + @Column(name="PARENTAL") | |
| 88 | + private String parental; | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 父级id | |
| 92 | + */ | |
| 93 | + @ApiModelProperty("父级编码") | |
| 94 | + @Column(name="PARENT_ID") | |
| 95 | + private String parentId; | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式 | |
| 99 | + */ | |
| 100 | + @ApiModelProperty("信令安全模式") | |
| 101 | + @Column(name="SAFETY_WAY") | |
| 102 | + private String safetyWay; | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式 | |
| 106 | + */ | |
| 107 | + @ApiModelProperty("注册方式") | |
| 108 | + @Column(name="REGISTER_WAY") | |
| 109 | + private String registerWay; | |
| 110 | + | |
| 111 | + /** | |
| 112 | + * 证书序列号 | |
| 113 | + */ | |
| 114 | + @ApiModelProperty("证书序列号") | |
| 115 | + @Column(name="CERT_NUM") | |
| 116 | + private String certNum; | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效 | |
| 120 | + */ | |
| 121 | + @ApiModelProperty("证书有效标识") | |
| 122 | + @Column(name="CERT_VALID") | |
| 123 | + private String certValid; | |
| 124 | + | |
| 125 | + /** | |
| 126 | + * 证书无效原因码 | |
| 127 | + */ | |
| 128 | + @ApiModelProperty("证书无效原因码") | |
| 129 | + @Column(name="CERT_ERRCODE") | |
| 130 | + private String certErrCode; | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * 证书终止有效期 | |
| 134 | + */ | |
| 135 | + @ApiModelProperty("证书终止有效期") | |
| 136 | + @Column(name="CERT_ENDTIME") | |
| 137 | + private String certEndTime; | |
| 138 | + | |
| 139 | + /** | |
| 140 | + * 保密属性 缺省为0; 0:不涉密, 1:涉密 | |
| 141 | + */ | |
| 142 | + @ApiModelProperty("保密属性") | |
| 143 | + @Column(name="SECRECY") | |
| 144 | + private String secrecy; | |
| 145 | + | |
| 146 | + /** | |
| 147 | + * IP地址 | |
| 148 | + */ | |
| 149 | + @ApiModelProperty("IP地址") | |
| 150 | + @Column(name="IP") | |
| 151 | + private String ip; | |
| 152 | + | |
| 153 | + /** | |
| 154 | + * 端口号 | |
| 155 | + */ | |
| 156 | + @ApiModelProperty("端口号") | |
| 157 | + @Column(name="PORT") | |
| 158 | + private Integer port; | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * 密码 | |
| 162 | + */ | |
| 163 | + @ApiModelProperty("密码") | |
| 164 | + @Column(name="PASSWORD") | |
| 165 | + private String password; | |
| 166 | + | |
| 167 | + /** | |
| 168 | + * 在线/离线 | |
| 169 | + * 1在线,0离线 | |
| 170 | + * 默认在线 | |
| 171 | + * 信令: | |
| 172 | + * <Status>ON</Status> | |
| 173 | + * <Status>OFF</Status> | |
| 174 | + * 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF | |
| 175 | + */ | |
| 176 | + @ApiModelProperty("状态") | |
| 177 | + @Column(name="ONLINE") | |
| 178 | + private String online; | |
| 179 | + | |
| 180 | + /** | |
| 181 | + * 经度 | |
| 182 | + */ | |
| 183 | + @ApiModelProperty("经度") | |
| 184 | + @Column(name="LONGITUDE") | |
| 185 | + private double longitude; | |
| 186 | + | |
| 187 | + /** | |
| 188 | + * 纬度 | |
| 189 | + */ | |
| 190 | + @ApiModelProperty("纬度") | |
| 191 | + @Column(name="LATITUDE") | |
| 192 | + private double latitude; | |
| 193 | + | |
| 194 | + public String getChannelId() { | |
| 195 | + return channelId; | |
| 196 | + } | |
| 197 | + | |
| 198 | + public void setChannelId(String channelId) { | |
| 199 | + this.channelId = channelId; | |
| 200 | + } | |
| 201 | + | |
| 202 | + public String getDeviceId() { | |
| 203 | + return deviceId; | |
| 204 | + } | |
| 205 | + | |
| 206 | + public void setDeviceId(String deviceId) { | |
| 207 | + this.deviceId = deviceId; | |
| 208 | + } | |
| 209 | + | |
| 210 | + public String getChannelName() { | |
| 211 | + return channelName; | |
| 212 | + } | |
| 213 | + | |
| 214 | + public void setChannelName(String channelName) { | |
| 215 | + this.channelName = channelName; | |
| 216 | + } | |
| 217 | + | |
| 218 | + public String getOnline() { | |
| 219 | + return online; | |
| 220 | + } | |
| 221 | + | |
| 222 | + public void setOnline(String online) { | |
| 223 | + this.online = online; | |
| 224 | + } | |
| 225 | + | |
| 226 | + public String getManufacture() { | |
| 227 | + return manufacture; | |
| 228 | + } | |
| 229 | + | |
| 230 | + public void setManufacture(String manufacture) { | |
| 231 | + this.manufacture = manufacture; | |
| 232 | + } | |
| 233 | + | |
| 234 | + public String getModel() { | |
| 235 | + return model; | |
| 236 | + } | |
| 237 | + | |
| 238 | + public void setModel(String model) { | |
| 239 | + this.model = model; | |
| 240 | + } | |
| 241 | + | |
| 242 | + public String getOwner() { | |
| 243 | + return owner; | |
| 244 | + } | |
| 245 | + | |
| 246 | + public void setOwner(String owner) { | |
| 247 | + this.owner = owner; | |
| 248 | + } | |
| 249 | + | |
| 250 | + public String getCivilCode() { | |
| 251 | + return civilCode; | |
| 252 | + } | |
| 253 | + | |
| 254 | + public void setCivilCode(String civilCode) { | |
| 255 | + this.civilCode = civilCode; | |
| 256 | + } | |
| 257 | + | |
| 258 | + public String getBlock() { | |
| 259 | + return block; | |
| 260 | + } | |
| 261 | + | |
| 262 | + public void setBlock(String block) { | |
| 263 | + this.block = block; | |
| 264 | + } | |
| 265 | + | |
| 266 | + public String getAddress() { | |
| 267 | + return address; | |
| 268 | + } | |
| 269 | + | |
| 270 | + public void setAddress(String address) { | |
| 271 | + this.address = address; | |
| 272 | + } | |
| 273 | + | |
| 274 | + public String getParental() { | |
| 275 | + return parental; | |
| 276 | + } | |
| 277 | + | |
| 278 | + public void setParental(String parental) { | |
| 279 | + this.parental = parental; | |
| 280 | + } | |
| 281 | + | |
| 282 | + public String getParentId() { | |
| 283 | + return parentId; | |
| 284 | + } | |
| 285 | + | |
| 286 | + public void setParentId(String parentId) { | |
| 287 | + this.parentId = parentId; | |
| 288 | + } | |
| 289 | + | |
| 290 | + public String getSafetyWay() { | |
| 291 | + return safetyWay; | |
| 292 | + } | |
| 293 | + | |
| 294 | + public void setSafetyWay(String safetyWay) { | |
| 295 | + this.safetyWay = safetyWay; | |
| 296 | + } | |
| 297 | + | |
| 298 | + public String getRegisterWay() { | |
| 299 | + return registerWay; | |
| 300 | + } | |
| 301 | + | |
| 302 | + public void setRegisterWay(String registerWay) { | |
| 303 | + this.registerWay = registerWay; | |
| 304 | + } | |
| 305 | + | |
| 306 | + public String getCertNum() { | |
| 307 | + return certNum; | |
| 308 | + } | |
| 309 | + | |
| 310 | + public void setCertNum(String certNum) { | |
| 311 | + this.certNum = certNum; | |
| 312 | + } | |
| 313 | + | |
| 314 | + public String getCertValid() { | |
| 315 | + return certValid; | |
| 316 | + } | |
| 317 | + | |
| 318 | + public void setCertValid(String certValid) { | |
| 319 | + this.certValid = certValid; | |
| 320 | + } | |
| 321 | + | |
| 322 | + public String getCertErrCode() { | |
| 323 | + return certErrCode; | |
| 324 | + } | |
| 325 | + | |
| 326 | + public void setCertErrCode(String certErrCode) { | |
| 327 | + this.certErrCode = certErrCode; | |
| 328 | + } | |
| 329 | + | |
| 330 | + public String getCertEndTime() { | |
| 331 | + return certEndTime; | |
| 332 | + } | |
| 333 | + | |
| 334 | + public void setCertEndTime(String certEndTime) { | |
| 335 | + this.certEndTime = certEndTime; | |
| 336 | + } | |
| 337 | + | |
| 338 | + public String getSecrecy() { | |
| 339 | + return secrecy; | |
| 340 | + } | |
| 341 | + | |
| 342 | + public void setSecrecy(String secrecy) { | |
| 343 | + this.secrecy = secrecy; | |
| 344 | + } | |
| 345 | + | |
| 346 | + public String getIp() { | |
| 347 | + return ip; | |
| 348 | + } | |
| 349 | + | |
| 350 | + public void setIp(String ip) { | |
| 351 | + this.ip = ip; | |
| 352 | + } | |
| 353 | + | |
| 354 | + public Integer getPort() { | |
| 355 | + return port; | |
| 356 | + } | |
| 357 | + | |
| 358 | + public void setPort(Integer port) { | |
| 359 | + this.port = port; | |
| 360 | + } | |
| 361 | + | |
| 362 | + public String getPassword() { | |
| 363 | + return password; | |
| 364 | + } | |
| 365 | + | |
| 366 | + public void setPassword(String password) { | |
| 367 | + this.password = password; | |
| 368 | + } | |
| 369 | + | |
| 370 | + public double getLongitude() { | |
| 371 | + return longitude; | |
| 372 | + } | |
| 373 | + | |
| 374 | + public void setLongitude(double longitude) { | |
| 375 | + this.longitude = longitude; | |
| 376 | + } | |
| 377 | + | |
| 378 | + public double getLatitude() { | |
| 379 | + return latitude; | |
| 380 | + } | |
| 381 | + | |
| 382 | + public void setLatitude(double latitude) { | |
| 383 | + this.latitude = latitude; | |
| 384 | + } | |
| 385 | +} | ... | ... |