Commit ff1e9f79c2992777fb7a1ecaeb85c8acb1250535

Authored by 648540858
1 parent 9fc9a298

优化海康发送的Message消息设置的消息体长度为0,导致无法解析的问题 #920

src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181; @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181;
2 2
3 import com.genersoft.iot.vmp.conf.SipConfig; 3 import com.genersoft.iot.vmp.conf.SipConfig;
4 import com.genersoft.iot.vmp.conf.UserSetting; 4 import com.genersoft.iot.vmp.conf.UserSetting;
  5 +import com.genersoft.iot.vmp.gb28181.bean.GbStringMsgParserFactory;
5 import com.genersoft.iot.vmp.gb28181.conf.DefaultProperties; 6 import com.genersoft.iot.vmp.gb28181.conf.DefaultProperties;
6 import com.genersoft.iot.vmp.gb28181.transmit.ISIPProcessorObserver; 7 import com.genersoft.iot.vmp.gb28181.transmit.ISIPProcessorObserver;
7 import gov.nist.javax.sip.SipProviderImpl; 8 import gov.nist.javax.sip.SipProviderImpl;
@@ -63,6 +64,7 @@ public class SipLayer implements CommandLineRunner { @@ -63,6 +64,7 @@ public class SipLayer implements CommandLineRunner {
63 SipStackImpl sipStack; 64 SipStackImpl sipStack;
64 try { 65 try {
65 sipStack = (SipStackImpl)SipFactory.getInstance().createSipStack(DefaultProperties.getProperties(monitorIp, userSetting.getSipLog())); 66 sipStack = (SipStackImpl)SipFactory.getInstance().createSipStack(DefaultProperties.getProperties(monitorIp, userSetting.getSipLog()));
  67 + sipStack.setMessageParserFactory(new GbStringMsgParserFactory());
66 } catch (PeerUnavailableException e) { 68 } catch (PeerUnavailableException e) {
67 logger.error("[SIP SERVER] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp); 69 logger.error("[SIP SERVER] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp);
68 return; 70 return;
@@ -75,7 +77,6 @@ public class SipLayer implements CommandLineRunner { @@ -75,7 +77,6 @@ public class SipLayer implements CommandLineRunner {
75 tcpSipProvider.setDialogErrorsAutomaticallyHandled(); 77 tcpSipProvider.setDialogErrorsAutomaticallyHandled();
76 tcpSipProvider.addSipListener(sipProcessorObserver); 78 tcpSipProvider.addSipListener(sipProcessorObserver);
77 tcpSipProviderMap.put(monitorIp, tcpSipProvider); 79 tcpSipProviderMap.put(monitorIp, tcpSipProvider);
78 -  
79 logger.info("[SIP SERVER] tcp://{}:{} 启动成功", monitorIp, port); 80 logger.info("[SIP SERVER] tcp://{}:{} 启动成功", monitorIp, port);
80 } catch (TransportNotSupportedException 81 } catch (TransportNotSupportedException
81 | TooManyListenersException 82 | TooManyListenersException
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GBStringMsgParser.java 0 → 100644
  1 +package com.genersoft.iot.vmp.gb28181.bean;
  2 +
  3 +import gov.nist.core.CommonLogger;
  4 +import gov.nist.core.Host;
  5 +import gov.nist.core.HostNameParser;
  6 +import gov.nist.core.StackLogger;
  7 +import gov.nist.javax.sip.SIPConstants;
  8 +import gov.nist.javax.sip.address.AddressImpl;
  9 +import gov.nist.javax.sip.address.GenericURI;
  10 +import gov.nist.javax.sip.address.SipUri;
  11 +import gov.nist.javax.sip.address.TelephoneNumber;
  12 +import gov.nist.javax.sip.header.*;
  13 +import gov.nist.javax.sip.message.SIPMessage;
  14 +import gov.nist.javax.sip.message.SIPRequest;
  15 +import gov.nist.javax.sip.message.SIPResponse;
  16 +import gov.nist.javax.sip.parser.*;
  17 +
  18 +import java.io.UnsupportedEncodingException;
  19 +import java.text.ParseException;
  20 +
  21 +public class GBStringMsgParser implements MessageParser {
  22 +
  23 + protected static boolean computeContentLengthFromMessage = false;
  24 +
  25 + private static StackLogger logger = CommonLogger.getLogger(StringMsgParser.class);
  26 +
  27 + /**
  28 + * @since v0.9
  29 + */
  30 + public GBStringMsgParser() {
  31 + super();
  32 + }
  33 +
  34 + /**
  35 + * Parse a buffer containing a single SIP Message where the body is an array
  36 + * of un-interpreted bytes. This is intended for parsing the message from a
  37 + * memory buffer when the buffer. Incorporates a bug fix for a bug that was
  38 + * noted by Will Sullin of Callcast
  39 + *
  40 + * @param msgBuffer
  41 + * a byte buffer containing the messages to be parsed. This can
  42 + * consist of multiple SIP Messages concatenated together.
  43 + * @return a SIPMessage[] structure (request or response) containing the
  44 + * parsed SIP message.
  45 + * @exception ParseException
  46 + * is thrown when an illegal message has been encountered
  47 + * (and the rest of the buffer is discarded).
  48 + * @see ParseExceptionListener
  49 + */
  50 + public SIPMessage parseSIPMessage(byte[] msgBuffer, boolean readBody, boolean strict, ParseExceptionListener parseExceptionListener) throws ParseException {
  51 + if (msgBuffer == null || msgBuffer.length == 0)
  52 + return null;
  53 +
  54 + int i = 0;
  55 +
  56 + // Squeeze out any leading control character.
  57 + try {
  58 + while (msgBuffer[i] < 0x20)
  59 + i++;
  60 + }
  61 + catch (ArrayIndexOutOfBoundsException e) {
  62 + // Array contains only control char, return null.
  63 + if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
  64 + logger.logDebug("handled only control char so returning null");
  65 + }
  66 + return null;
  67 + }
  68 +
  69 + // Iterate thru the request/status line and headers.
  70 + String currentLine = null;
  71 + String currentHeader = null;
  72 + boolean isFirstLine = true;
  73 + SIPMessage message = null;
  74 + do
  75 + {
  76 + int lineStart = i;
  77 +
  78 + // Find the length of the line.
  79 + try {
  80 + while (msgBuffer[i] != '\r' && msgBuffer[i] != '\n')
  81 + i++;
  82 + }
  83 + catch (ArrayIndexOutOfBoundsException e) {
  84 + // End of the message.
  85 + break;
  86 + }
  87 + int lineLength = i - lineStart;
  88 +
  89 + // Make it a String.
  90 + try {
  91 + currentLine = new String(msgBuffer, lineStart, lineLength, "UTF-8");
  92 + } catch (UnsupportedEncodingException e) {
  93 + throw new ParseException("Bad message encoding!", 0);
  94 + }
  95 +
  96 + currentLine = trimEndOfLine(currentLine);
  97 +
  98 + if (currentLine.length() == 0) {
  99 + // Last header line, process the previous buffered header.
  100 + if (currentHeader != null && message != null) {
  101 + processHeader(currentHeader, message, parseExceptionListener, msgBuffer);
  102 + }
  103 +
  104 + }
  105 + else {
  106 + if (isFirstLine) {
  107 + message = processFirstLine(currentLine, parseExceptionListener, msgBuffer);
  108 + } else {
  109 + char firstChar = currentLine.charAt(0);
  110 + if (firstChar == '\t' || firstChar == ' ') {
  111 + if (currentHeader == null)
  112 + throw new ParseException("Bad header continuation.", 0);
  113 +
  114 + // This is a continuation, append it to the previous line.
  115 + currentHeader += currentLine.substring(1);
  116 + }
  117 + else {
  118 + if (currentHeader != null && message != null) {
  119 + processHeader(currentHeader, message, parseExceptionListener, msgBuffer);
  120 + }
  121 + currentHeader = currentLine;
  122 + }
  123 + }
  124 + }
  125 +
  126 + if (msgBuffer[i] == '\r' && msgBuffer.length > i+1 && msgBuffer[i+1] == '\n')
  127 + i++;
  128 +
  129 + i++;
  130 +
  131 + isFirstLine = false;
  132 + } while (currentLine.length() > 0); // End do - while
  133 +
  134 + if (message == null) throw new ParseException("Bad message", 0);
  135 + message.setSize(i);
  136 +
  137 + // Check for content legth header
  138 + if (readBody && message.getContentLength() != null ) {
  139 + if ( message.getContentLength().getContentLength() != 0) {
  140 + int bodyLength = msgBuffer.length - i;
  141 +
  142 + byte[] body = new byte[bodyLength];
  143 + System.arraycopy(msgBuffer, i, body, 0, bodyLength);
  144 + message.setMessageContent(body,!strict,computeContentLengthFromMessage,message.getContentLength().getContentLength());
  145 + } else if (message.getCSeqHeader().getMethod().equalsIgnoreCase("MESSAGE")) {
  146 + int bodyLength = msgBuffer.length - i;
  147 +
  148 + byte[] body = new byte[bodyLength];
  149 + System.arraycopy(msgBuffer, i, body, 0, bodyLength);
  150 + message.setMessageContent(body,!strict,computeContentLengthFromMessage,bodyLength);
  151 + }else if (!computeContentLengthFromMessage && strict) {
  152 + String last4Chars = new String(msgBuffer, msgBuffer.length - 4, 4);
  153 + if(!"\r\n\r\n".equals(last4Chars)) {
  154 + throw new ParseException("Extraneous characters at the end of the message ",i);
  155 + }
  156 + }
  157 + }
  158 +
  159 + return message;
  160 + }
  161 +
  162 + protected static String trimEndOfLine(String line) {
  163 + if (line == null)
  164 + return line;
  165 +
  166 + int i = line.length() - 1;
  167 + while (i >= 0 && line.charAt(i) <= 0x20)
  168 + i--;
  169 +
  170 + if (i == line.length() - 1)
  171 + return line;
  172 +
  173 + if (i == -1)
  174 + return "";
  175 +
  176 + return line.substring(0, i+1);
  177 + }
  178 +
  179 + protected SIPMessage processFirstLine(String firstLine, ParseExceptionListener parseExceptionListener, byte[] msgBuffer) throws ParseException {
  180 + SIPMessage message;
  181 + if (!firstLine.startsWith(SIPConstants.SIP_VERSION_STRING)) {
  182 + message = new SIPRequest();
  183 + try {
  184 + RequestLine requestLine = new RequestLineParser(firstLine + "\n")
  185 + .parse();
  186 + ((SIPRequest) message).setRequestLine(requestLine);
  187 + } catch (ParseException ex) {
  188 + if (parseExceptionListener != null)
  189 + try {
  190 + parseExceptionListener.handleException(ex, message,
  191 + RequestLine.class, firstLine, new String(msgBuffer, "UTF-8"));
  192 + } catch (UnsupportedEncodingException e) {
  193 + e.printStackTrace();
  194 + }
  195 + else
  196 + throw ex;
  197 +
  198 + }
  199 + } else {
  200 + message = new SIPResponse();
  201 + try {
  202 + StatusLine sl = new StatusLineParser(firstLine + "\n").parse();
  203 + ((SIPResponse) message).setStatusLine(sl);
  204 + } catch (ParseException ex) {
  205 + if (parseExceptionListener != null) {
  206 + try {
  207 + parseExceptionListener.handleException(ex, message,
  208 + StatusLine.class, firstLine, new String(msgBuffer, "UTF-8"));
  209 + } catch (UnsupportedEncodingException e) {
  210 + e.printStackTrace();
  211 + }
  212 + } else
  213 + throw ex;
  214 +
  215 + }
  216 + }
  217 + return message;
  218 + }
  219 +
  220 + protected void processHeader(String header, SIPMessage message, ParseExceptionListener parseExceptionListener, byte[] rawMessage) throws ParseException {
  221 + if (header == null || header.length() == 0)
  222 + return;
  223 +
  224 + HeaderParser headerParser = null;
  225 + try {
  226 + headerParser = ParserFactory.createParser(header + "\n");
  227 + } catch (ParseException ex) {
  228 + // https://java.net/jira/browse/JSIP-456
  229 + if (parseExceptionListener != null) {
  230 + parseExceptionListener.handleException(ex, message, null,
  231 + header, null);
  232 + return;
  233 + } else {
  234 + throw ex;
  235 + }
  236 + }
  237 +
  238 + try {
  239 + SIPHeader sipHeader = headerParser.parse();
  240 + message.attachHeader(sipHeader, false);
  241 + } catch (ParseException ex) {
  242 + if (parseExceptionListener != null) {
  243 + String headerName = Lexer.getHeaderName(header);
  244 + Class headerClass = NameMap.getClassFromName(headerName);
  245 + if (headerClass == null) {
  246 + headerClass = ExtensionHeaderImpl.class;
  247 +
  248 + }
  249 + try {
  250 + parseExceptionListener.handleException(ex, message,
  251 + headerClass, header, new String(rawMessage, "UTF-8"));
  252 + } catch (UnsupportedEncodingException e) {
  253 + e.printStackTrace();
  254 + }
  255 +
  256 + }
  257 + }
  258 + }
  259 +
  260 + /**
  261 + * Parse an address (nameaddr or address spec) and return and address
  262 + * structure.
  263 + *
  264 + * @param address
  265 + * is a String containing the address to be parsed.
  266 + * @return a parsed address structure.
  267 + * @since v1.0
  268 + * @exception ParseException
  269 + * when the address is badly formatted.
  270 + */
  271 + public AddressImpl parseAddress(String address) throws ParseException {
  272 + AddressParser addressParser = new AddressParser(address);
  273 + return addressParser.address(true);
  274 + }
  275 +
  276 + /**
  277 + * Parse a host:port and return a parsed structure.
  278 + *
  279 + * @param hostport
  280 + * is a String containing the host:port to be parsed
  281 + * @return a parsed address structure.
  282 + * @since v1.0
  283 + * @exception throws
  284 + * a ParseException when the address is badly formatted.
  285 + *
  286 + public HostPort parseHostPort(String hostport) throws ParseException {
  287 + Lexer lexer = new Lexer("charLexer", hostport);
  288 + return new HostNameParser(lexer).hostPort();
  289 +
  290 + }
  291 + */
  292 +
  293 + /**
  294 + * Parse a host name and return a parsed structure.
  295 + *
  296 + * @param host
  297 + * is a String containing the host name to be parsed
  298 + * @return a parsed address structure.
  299 + * @since v1.0
  300 + * @exception ParseException
  301 + * a ParseException when the hostname is badly formatted.
  302 + */
  303 + public Host parseHost(String host) throws ParseException {
  304 + Lexer lexer = new Lexer("charLexer", host);
  305 + return new HostNameParser(lexer).host();
  306 +
  307 + }
  308 +
  309 + /**
  310 + * Parse a telephone number return a parsed structure.
  311 + *
  312 + * @param telephone_number
  313 + * is a String containing the telephone # to be parsed
  314 + * @return a parsed address structure.
  315 + * @since v1.0
  316 + * @exception ParseException
  317 + * a ParseException when the address is badly formatted.
  318 + */
  319 + public TelephoneNumber parseTelephoneNumber(String telephone_number)
  320 + throws ParseException {
  321 + // Bug fix contributed by Will Scullin
  322 + return new URLParser(telephone_number).parseTelephoneNumber(true);
  323 +
  324 + }
  325 +
  326 + /**
  327 + * Parse a SIP url from a string and return a URI structure for it.
  328 + *
  329 + * @param url
  330 + * a String containing the URI structure to be parsed.
  331 + * @return A parsed URI structure
  332 + * @exception ParseException
  333 + * if there was an error parsing the message.
  334 + */
  335 +
  336 + public SipUri parseSIPUrl(String url) throws ParseException {
  337 + try {
  338 + return new URLParser(url).sipURL(true);
  339 + } catch (ClassCastException ex) {
  340 + throw new ParseException(url + " Not a SIP URL ", 0);
  341 + }
  342 + }
  343 +
  344 + /**
  345 + * Parse a uri from a string and return a URI structure for it.
  346 + *
  347 + * @param url
  348 + * a String containing the URI structure to be parsed.
  349 + * @return A parsed URI structure
  350 + * @exception ParseException
  351 + * if there was an error parsing the message.
  352 + */
  353 +
  354 + public GenericURI parseUrl(String url) throws ParseException {
  355 + return new URLParser(url).parse();
  356 + }
  357 +
  358 + /**
  359 + * Parse an individual SIP message header from a string.
  360 + *
  361 + * @param header
  362 + * String containing the SIP header.
  363 + * @return a SIPHeader structure.
  364 + * @exception ParseException
  365 + * if there was an error parsing the message.
  366 + */
  367 + public static SIPHeader parseSIPHeader(String header) throws ParseException {
  368 + int start = 0;
  369 + int end = header.length() - 1;
  370 + try {
  371 + // Squeeze out any leading control character.
  372 + while (header.charAt(start) <= 0x20)
  373 + start++;
  374 +
  375 + // Squeeze out any trailing control character.
  376 + while (header.charAt(end) <= 0x20)
  377 + end--;
  378 + }
  379 + catch (ArrayIndexOutOfBoundsException e) {
  380 + // Array contains only control char.
  381 + throw new ParseException("Empty header.", 0);
  382 + }
  383 +
  384 + StringBuilder buffer = new StringBuilder(end + 1);
  385 + int i = start;
  386 + int lineStart = start;
  387 + boolean endOfLine = false;
  388 + while (i <= end) {
  389 + char c = header.charAt(i);
  390 + if (c == '\r' || c == '\n') {
  391 + if (!endOfLine) {
  392 + buffer.append(header.substring(lineStart, i));
  393 + endOfLine = true;
  394 + }
  395 + }
  396 + else {
  397 + if (endOfLine) {
  398 + endOfLine = false;
  399 + if (c == ' ' || c == '\t') {
  400 + buffer.append(' ');
  401 + lineStart = i + 1;
  402 + }
  403 + else {
  404 + lineStart = i;
  405 + }
  406 + }
  407 + }
  408 +
  409 + i++;
  410 + }
  411 + buffer.append(header.substring(lineStart, i));
  412 + buffer.append('\n');
  413 +
  414 + HeaderParser hp = ParserFactory.createParser(buffer.toString());
  415 + if (hp == null)
  416 + throw new ParseException("could not create parser", 0);
  417 + return hp.parse();
  418 + }
  419 +
  420 + /**
  421 + * Parse the SIP Request Line
  422 + *
  423 + * @param requestLine
  424 + * a String containing the request line to be parsed.
  425 + * @return a RequestLine structure that has the parsed RequestLine
  426 + * @exception ParseException
  427 + * if there was an error parsing the requestLine.
  428 + */
  429 +
  430 + public RequestLine parseSIPRequestLine(String requestLine)
  431 + throws ParseException {
  432 + requestLine += "\n";
  433 + return new RequestLineParser(requestLine).parse();
  434 + }
  435 +
  436 + /**
  437 + * Parse the SIP Response message status line
  438 + *
  439 + * @param statusLine
  440 + * a String containing the Status line to be parsed.
  441 + * @return StatusLine class corresponding to message
  442 + * @exception ParseException
  443 + * if there was an error parsing
  444 + * @see StatusLine
  445 + */
  446 +
  447 + public StatusLine parseSIPStatusLine(String statusLine)
  448 + throws ParseException {
  449 + statusLine += "\n";
  450 + return new StatusLineParser(statusLine).parse();
  451 + }
  452 +
  453 + public static void setComputeContentLengthFromMessage(
  454 + boolean computeContentLengthFromMessage) {
  455 + GBStringMsgParser.computeContentLengthFromMessage = computeContentLengthFromMessage;
  456 + }
  457 +}
src/main/java/com/genersoft/iot/vmp/gb28181/bean/WvpSipDate.java renamed to src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbSipDate.java
@@ -8,7 +8,7 @@ import java.util.*; @@ -8,7 +8,7 @@ import java.util.*;
8 /** 8 /**
9 * 重写jain sip的SIPDate解决与国标时间格式不一致的问题 9 * 重写jain sip的SIPDate解决与国标时间格式不一致的问题
10 */ 10 */
11 -public class WvpSipDate extends SIPDate { 11 +public class GbSipDate extends SIPDate {
12 12
13 /** 13 /**
14 * 14 *
@@ -17,7 +17,7 @@ public class WvpSipDate extends SIPDate { @@ -17,7 +17,7 @@ public class WvpSipDate extends SIPDate {
17 17
18 private Calendar javaCal; 18 private Calendar javaCal;
19 19
20 - public WvpSipDate(long timeMillis) { 20 + public GbSipDate(long timeMillis) {
21 this.javaCal = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault()); 21 this.javaCal = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
22 Date date = new Date(timeMillis); 22 Date date = new Date(timeMillis);
23 this.javaCal.setTime(date); 23 this.javaCal.setTime(date);
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStringMsgParserFactory.java 0 → 100644
  1 +package com.genersoft.iot.vmp.gb28181.bean;
  2 +
  3 +import gov.nist.javax.sip.parser.MessageParser;
  4 +import gov.nist.javax.sip.parser.MessageParserFactory;
  5 +import gov.nist.javax.sip.stack.SIPTransactionStack;
  6 +
  7 +public class GbStringMsgParserFactory implements MessageParserFactory {
  8 +
  9 + /**
  10 + * msg parser is completely stateless, reuse isntance for the whole stack
  11 + * fixes https://github.com/RestComm/jain-sip/issues/92
  12 + */
  13 + private static GBStringMsgParser msgParser = new GBStringMsgParser();
  14 + /*
  15 + * (non-Javadoc)
  16 + * @see gov.nist.javax.sip.parser.MessageParserFactory#createMessageParser(gov.nist.javax.sip.stack.SIPTransactionStack)
  17 + */
  18 + public MessageParser createMessageParser(SIPTransactionStack stack) {
  19 + return msgParser;
  20 + }
  21 +}
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java
@@ -6,7 +6,7 @@ import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; @@ -6,7 +6,7 @@ import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper;
6 import com.genersoft.iot.vmp.gb28181.bean.Device; 6 import com.genersoft.iot.vmp.gb28181.bean.Device;
7 import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo; 7 import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
8 import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; 8 import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
9 -import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; 9 +import com.genersoft.iot.vmp.gb28181.bean.GbSipDate;
10 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; 10 import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
11 import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; 11 import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
12 import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; 12 import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
@@ -145,8 +145,8 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen @@ -145,8 +145,8 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
145 // 添加date头 145 // 添加date头
146 SIPDateHeader dateHeader = new SIPDateHeader(); 146 SIPDateHeader dateHeader = new SIPDateHeader();
147 // 使用自己修改的 147 // 使用自己修改的
148 - WvpSipDate wvpSipDate = new WvpSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis());  
149 - dateHeader.setDate(wvpSipDate); 148 + GbSipDate gbSipDate = new GbSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis());
  149 + dateHeader.setDate(gbSipDate);
150 response.addHeader(dateHeader); 150 response.addHeader(dateHeader);
151 151
152 if (request.getExpires() == null) { 152 if (request.getExpires() == null) {
@@ -218,8 +218,8 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen @@ -218,8 +218,8 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
218 // 添加date头 218 // 添加date头
219 SIPDateHeader dateHeader = new SIPDateHeader(); 219 SIPDateHeader dateHeader = new SIPDateHeader();
220 // 使用自己修改的 220 // 使用自己修改的
221 - WvpSipDate wvpSipDate = new WvpSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis());  
222 - dateHeader.setDate(wvpSipDate); 221 + GbSipDate gbSipDate = new GbSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis());
  222 + dateHeader.setDate(gbSipDate);
223 response.addHeader(dateHeader); 223 response.addHeader(dateHeader);
224 224
225 // 添加Contact头 225 // 添加Contact头
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
@@ -470,7 +470,6 @@ public class DeviceQuery { @@ -470,7 +470,6 @@ public class DeviceQuery {
470 public void getSnap(HttpServletResponse resp, @PathVariable String deviceId, @PathVariable String channelId, @RequestParam(required = false) String mark) { 470 public void getSnap(HttpServletResponse resp, @PathVariable String deviceId, @PathVariable String channelId, @RequestParam(required = false) String mark) {
471 471
472 try { 472 try {
473 -  
474 final InputStream in = Files.newInputStream(new File("snap" + File.separator + deviceId + "_" + channelId + (mark == null? ".jpg": ("_" + mark + ".jpg"))).toPath()); 473 final InputStream in = Files.newInputStream(new File("snap" + File.separator + deviceId + "_" + channelId + (mark == null? ".jpg": ("_" + mark + ".jpg"))).toPath());
475 resp.setContentType(MediaType.IMAGE_PNG_VALUE); 474 resp.setContentType(MediaType.IMAGE_PNG_VALUE);
476 IOUtils.copy(in, resp.getOutputStream()); 475 IOUtils.copy(in, resp.getOutputStream());