| | |
| | |
|
| | | import javax.sip.*;
|
| | | import javax.sip.header.CallIdHeader;
|
| | | import javax.sip.header.Header;
|
| | | import javax.sip.message.Response;
|
| | |
|
| | | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
| | |
| | | ListeningPoint tcpListeningPoint = null;
|
| | | SipProviderImpl tcpSipProvider = null;
|
| | | try {
|
| | | tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getSipPort(), "TCP");
|
| | | tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "TCP");
|
| | | tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint);
|
| | | tcpSipProvider.addSipListener(this);
|
| | | logger.info("Sip Server TCP 启动成功 port {" + sipConfig.getMonitorIp() + ":" + sipConfig.getSipPort() + "}");
|
| | | logger.info("Sip Server TCP 启动成功 port {" + sipConfig.getMonitorIp() + ":" + sipConfig.getPort() + "}");
|
| | | } catch (TransportNotSupportedException e) {
|
| | | e.printStackTrace();
|
| | | } catch (InvalidArgumentException e) {
|
| | | logger.error("无法使用 [ {}:{} ]作为SIP[ TCP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用"
|
| | | , sipConfig.getMonitorIp(), sipConfig.getSipPort());
|
| | | , sipConfig.getMonitorIp(), sipConfig.getPort());
|
| | | } catch (TooManyListenersException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ObjectInUseException e) {
|
| | |
| | | ListeningPoint udpListeningPoint = null;
|
| | | SipProviderImpl udpSipProvider = null;
|
| | | try {
|
| | | udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getSipPort(), "UDP");
|
| | | udpListeningPoint = sipStack.createListeningPoint(sipConfig.getMonitorIp(), sipConfig.getPort(), "UDP");
|
| | | udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint);
|
| | | udpSipProvider.addSipListener(this);
|
| | | // udpSipProvider.setAutomaticDialogSupportEnabled(false);
|
| | |
| | | e.printStackTrace();
|
| | | } catch (InvalidArgumentException e) {
|
| | | logger.error("无法使用 [ {}:{} ]作为SIP[ UDP ]服务,可排查: 1. sip.monitor-ip 是否为本机网卡IP; 2. sip.port 是否已被占用"
|
| | | , sipConfig.getMonitorIp(), sipConfig.getSipPort());
|
| | | , sipConfig.getMonitorIp(), sipConfig.getPort());
|
| | | } catch (TooManyListenersException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ObjectInUseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | logger.info("Sip Server UDP 启动成功 port [" + sipConfig.getMonitorIp() + ":" + sipConfig.getSipPort() + "]");
|
| | | logger.info("Sip Server UDP 启动成功 port [" + sipConfig.getMonitorIp() + ":" + sipConfig.getPort() + "]");
|
| | | return udpSipProvider;
|
| | | }
|
| | |
|
| | |
| | | if (callIdHeader != null) {
|
| | | SipSubscribe.Event subscribe = sipSubscribe.getOkSubscribe(callIdHeader.getCallId());
|
| | | if (subscribe != null) {
|
| | | subscribe.response(evt);
|
| | | SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(evt);
|
| | | subscribe.response(eventResult);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | if (callIdHeader != null) {
|
| | | SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId());
|
| | | if (subscribe != null) {
|
| | | subscribe.response(evt);
|
| | | SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(evt);
|
| | | subscribe.response(eventResult);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | @Override
|
| | | public void processTimeout(TimeoutEvent timeoutEvent) {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | CallIdHeader callIdHeader = timeoutEvent.getClientTransaction().getDialog().getCallId();
|
| | | String callId = callIdHeader.getCallId();
|
| | | SipSubscribe.Event errorSubscribe = sipSubscribe.getErrorSubscribe(callId);
|
| | | SipSubscribe.EventResult<TimeoutEvent> timeoutEventEventResult = new SipSubscribe.EventResult<>(timeoutEvent);
|
| | | errorSubscribe.response(timeoutEventEventResult);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @Override
|
| | | public void processIOException(IOExceptionEvent exceptionEvent) {
|
| | | // TODO Auto-generated method stub
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @Override
|
| | | public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent) {
|
| | | // TODO Auto-generated method stub
|
| | | // CallIdHeader callIdHeader = transactionTerminatedEvent.getClientTransaction().getDialog().getCallId();
|
| | | // String callId = callIdHeader.getCallId();
|
| | | // SipSubscribe.Event errorSubscribe = sipSubscribe.getErrorSubscribe(callId);
|
| | | // SipSubscribe.EventResult<TransactionTerminatedEvent> eventResult = new SipSubscribe.EventResult<>(transactionTerminatedEvent);
|
| | | // errorSubscribe.response(eventResult);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @Override
|
| | | public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) {
|
| | | // TODO Auto-generated method stub
|
| | | // CallIdHeader callIdHeader = dialogTerminatedEvent.getDialog().getCallId();
|
| | | // String callId = callIdHeader.getCallId();
|
| | | // SipSubscribe.Event errorSubscribe = sipSubscribe.getErrorSubscribe(callId);
|
| | | // SipSubscribe.EventResult<DialogTerminatedEvent> eventResult = new SipSubscribe.EventResult<>(dialogTerminatedEvent);
|
| | | // errorSubscribe.response(eventResult);
|
| | |
|
| | | }
|
| | |
|