Commit e960720298bdb3e09695cfbcf2a3e990eff24d0a
1 parent
518f0b02
通过重写的方式解决与国标时间格式不一致的问题, 不需要修改jar包了。
Showing
5 changed files
with
86 additions
and
5 deletions
libs/jain-sip-ri-1.3.0-92.jar deleted
100644 → 0
No preview for this file type
pom.xml
| ... | ... | @@ -126,13 +126,22 @@ |
| 126 | 126 | </dependency> |
| 127 | 127 | |
| 128 | 128 | <!-- sip协议栈 --> |
| 129 | +<!-- <dependency>--> | |
| 130 | +<!-- <groupId>javax.sip</groupId>--> | |
| 131 | +<!-- <artifactId>jain-sip-ri</artifactId>--> | |
| 132 | +<!-- <version>1.3.0-92</version>--> | |
| 133 | +<!-- <scope>system</scope>--> | |
| 134 | +<!-- <systemPath>${pom.basedir}/libs/jain-sip-ri-1.3.0-92.jar</systemPath>--> | |
| 135 | +<!-- </dependency>--> | |
| 136 | + | |
| 137 | + <!-- https://mvnrepository.com/artifact/javax.sip/jain-sip-ri --> | |
| 129 | 138 | <dependency> |
| 130 | 139 | <groupId>javax.sip</groupId> |
| 131 | 140 | <artifactId>jain-sip-ri</artifactId> |
| 132 | - <version>1.3.0-92</version> | |
| 133 | - <scope>system</scope> | |
| 134 | - <systemPath>${pom.basedir}/libs/jain-sip-ri-1.3.0-92.jar</systemPath> | |
| 141 | + <version>1.3.0-91</version> | |
| 135 | 142 | </dependency> |
| 143 | + | |
| 144 | + | |
| 136 | 145 | <dependency> |
| 137 | 146 | <groupId>log4j</groupId> |
| 138 | 147 | <artifactId>log4j</artifactId> | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.bean; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import gov.nist.javax.sip.header.SIPDate; | |
| 5 | + | |
| 4 | 6 | import java.util.List; |
| 5 | 7 | |
| 6 | 8 | /** |
| ... | ... | @@ -49,4 +51,5 @@ public class RecordInfo { |
| 49 | 51 | public void setRecordList(List<RecordItem> recordList) { |
| 50 | 52 | this.recordList = recordList; |
| 51 | 53 | } |
| 54 | + | |
| 52 | 55 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/WvpSipDate.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.gb28181.bean; | |
| 2 | + | |
| 3 | +import gov.nist.javax.sip.header.SIPDate; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 重写jain sip的SIPDate解决与国标时间格式不一致的问题 | |
| 7 | + */ | |
| 8 | +public class WvpSipDate extends SIPDate { | |
| 9 | + | |
| 10 | + public WvpSipDate(long timeMillis) { | |
| 11 | + super(timeMillis); | |
| 12 | + } | |
| 13 | + | |
| 14 | + @Override | |
| 15 | + public StringBuilder encode(StringBuilder var1) { | |
| 16 | + String var2; | |
| 17 | + if (this.month < 9) { | |
| 18 | + var2 = "0" + (this.month + 1); | |
| 19 | + } else { | |
| 20 | + var2 = "" + (this.month + 1); | |
| 21 | + } | |
| 22 | + | |
| 23 | + String var3; | |
| 24 | + if (this.day < 10) { | |
| 25 | + var3 = "0" + this.day; | |
| 26 | + } else { | |
| 27 | + var3 = "" + this.day; | |
| 28 | + } | |
| 29 | + | |
| 30 | + String var4; | |
| 31 | + if (this.hour < 10) { | |
| 32 | + var4 = "0" + this.hour; | |
| 33 | + } else { | |
| 34 | + var4 = "" + this.hour; | |
| 35 | + } | |
| 36 | + | |
| 37 | + String var5; | |
| 38 | + if (this.minute < 10) { | |
| 39 | + var5 = "0" + this.minute; | |
| 40 | + } else { | |
| 41 | + var5 = "" + this.minute; | |
| 42 | + } | |
| 43 | + | |
| 44 | + String var6; | |
| 45 | + if (this.second < 10) { | |
| 46 | + var6 = "0" + this.second; | |
| 47 | + } else { | |
| 48 | + var6 = "" + this.second; | |
| 49 | + } | |
| 50 | + | |
| 51 | + int var8 = this.getJavaCal().get(14); | |
| 52 | + String var7; | |
| 53 | + if (var8 < 10) { | |
| 54 | + var7 = "00" + var8; | |
| 55 | + } else if (var8 < 100) { | |
| 56 | + var7 = "0" + var8; | |
| 57 | + } else { | |
| 58 | + var7 = "" + var8; | |
| 59 | + } | |
| 60 | + | |
| 61 | + return var1.append(this.year).append("-").append(var2).append("-").append(var3).append("T").append(var4).append(":").append(var5).append(":").append(var6).append(".").append(var7); | |
| 62 | + } | |
| 63 | +} | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
| ... | ... | @@ -16,6 +16,8 @@ import javax.sip.header.ViaHeader; |
| 16 | 16 | import javax.sip.message.Request; |
| 17 | 17 | import javax.sip.message.Response; |
| 18 | 18 | |
| 19 | +import com.genersoft.iot.vmp.gb28181.bean.WvpSipDate; | |
| 20 | +import gov.nist.javax.sip.header.SIPDateHeader; | |
| 19 | 21 | import org.slf4j.Logger; |
| 20 | 22 | import org.slf4j.LoggerFactory; |
| 21 | 23 | import org.springframework.util.StringUtils; |
| ... | ... | @@ -25,7 +27,6 @@ import com.genersoft.iot.vmp.conf.SipConfig; |
| 25 | 27 | import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; |
| 26 | 28 | import com.genersoft.iot.vmp.gb28181.auth.RegisterLogicHandler; |
| 27 | 29 | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| 28 | -import com.genersoft.iot.vmp.gb28181.bean.Host; | |
| 29 | 30 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 30 | 31 | import com.genersoft.iot.vmp.gb28181.transmit.request.SIPRequestAbstractProcessor; |
| 31 | 32 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| ... | ... | @@ -88,7 +89,12 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor { |
| 88 | 89 | else if (passwordCorrect) { |
| 89 | 90 | response = getMessageFactory().createResponse(Response.OK, request); |
| 90 | 91 | // 添加date头 |
| 91 | - response.addHeader(getHeaderFactory().createDateHeader(Calendar.getInstance(Locale.ENGLISH))); | |
| 92 | + SIPDateHeader dateHeader = new SIPDateHeader(); | |
| 93 | + // 使用自己修改的 | |
| 94 | + WvpSipDate wvpSipDate = new WvpSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis()); | |
| 95 | + dateHeader.setDate(wvpSipDate); | |
| 96 | + response.addHeader(dateHeader); | |
| 97 | + | |
| 92 | 98 | ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(Expires.NAME); |
| 93 | 99 | // 添加Contact头 |
| 94 | 100 | response.addHeader(request.getHeader(ContactHeader.NAME)); | ... | ... |