Commit 0802677d0b609abc8de0f0d882c6dbf483fc1987
Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0
Showing
9 changed files
with
72 additions
and
71 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java
| @@ -239,58 +239,58 @@ public class DigestServerAuthenticationHelper { | @@ -239,58 +239,58 @@ public class DigestServerAuthenticationHelper { | ||
| 239 | 239 | ||
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | - public static void main(String[] args) throws NoSuchAlgorithmException { | ||
| 243 | - String realm = "3402000000"; | ||
| 244 | - String username = "44010000001180008012"; | ||
| 245 | - | ||
| 246 | - | ||
| 247 | - String nonce = "07cab60999fbf643264ace27d3b7de8b"; | ||
| 248 | - String uri = "sip:34020000002000000001@3402000000"; | ||
| 249 | - // qop 保护质量 包含auth(默认的)和auth-int(增加了报文完整性检测)两种策略 | ||
| 250 | - String qop = "auth"; | ||
| 251 | - | ||
| 252 | - // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 | ||
| 253 | - // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 | ||
| 254 | - //String cNonce = authHeader.getCNonce(); | ||
| 255 | - | ||
| 256 | - // nonce计数器,是一个16进制的数值,表示同一nonce下客户端发送出请求的数量 | ||
| 257 | - int nc = 1; | ||
| 258 | - String ncStr = new DecimalFormat("00000000").format(nc); | ||
| 259 | -// String ncStr = new DecimalFormat("00000000").format(Integer.parseInt(nc + "", 16)); | ||
| 260 | - MessageDigest messageDigest = MessageDigest.getInstance(DEFAULT_ALGORITHM); | ||
| 261 | - String A1 = username + ":" + realm + ":" + "12345678"; | ||
| 262 | - String A2 = "REGISTER" + ":" + uri; | ||
| 263 | - byte mdbytes[] = messageDigest.digest(A1.getBytes()); | ||
| 264 | - String HA1 = toHexString(mdbytes); | ||
| 265 | - System.out.println("A1: " + A1); | ||
| 266 | - System.out.println("A2: " + A2); | ||
| 267 | - | ||
| 268 | - mdbytes = messageDigest.digest(A2.getBytes()); | ||
| 269 | - String HA2 = toHexString(mdbytes); | ||
| 270 | - System.out.println("HA1: " + HA1); | ||
| 271 | - System.out.println("HA2: " + HA2); | ||
| 272 | - String cnonce = "0a4f113b"; | ||
| 273 | - System.out.println("nonce: " + nonce); | ||
| 274 | - System.out.println("nc: " + ncStr); | ||
| 275 | - System.out.println("cnonce: " + cnonce); | ||
| 276 | - System.out.println("qop: " + qop); | ||
| 277 | - String KD = HA1 + ":" + nonce; | ||
| 278 | - | ||
| 279 | - if (qop != null && qop.equals("auth") ) { | ||
| 280 | - if (nc != -1) { | ||
| 281 | - KD += ":" + ncStr; | ||
| 282 | - } | ||
| 283 | - if (cnonce != null) { | ||
| 284 | - KD += ":" + cnonce; | ||
| 285 | - } | ||
| 286 | - KD += ":" + qop; | ||
| 287 | - } | ||
| 288 | - KD += ":" + HA2; | ||
| 289 | - System.out.println("KD: " + KD); | ||
| 290 | - mdbytes = messageDigest.digest(KD.getBytes()); | ||
| 291 | - String mdString = toHexString(mdbytes); | ||
| 292 | - System.out.println("mdString: " + mdString); | ||
| 293 | - String response = "4f0507d4b87cdecff04bdaf4c96348f0"; | ||
| 294 | - System.out.println("response: " + response); | ||
| 295 | - } | 242 | +// public static void main(String[] args) throws NoSuchAlgorithmException { |
| 243 | +// String realm = "3402000000"; | ||
| 244 | +// String username = "44010000001180008012"; | ||
| 245 | + | ||
| 246 | + | ||
| 247 | +// String nonce = "07cab60999fbf643264ace27d3b7de8b"; | ||
| 248 | +// String uri = "sip:34020000002000000001@3402000000"; | ||
| 249 | +// // qop 保护质量 包含auth(默认的)和auth-int(增加了报文完整性检测)两种策略 | ||
| 250 | +// String qop = "auth"; | ||
| 251 | + | ||
| 252 | +// // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 | ||
| 253 | +// // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 | ||
| 254 | +// //String cNonce = authHeader.getCNonce(); | ||
| 255 | + | ||
| 256 | +// // nonce计数器,是一个16进制的数值,表示同一nonce下客户端发送出请求的数量 | ||
| 257 | +// int nc = 1; | ||
| 258 | +// String ncStr = new DecimalFormat("00000000").format(nc); | ||
| 259 | +// // String ncStr = new DecimalFormat("00000000").format(Integer.parseInt(nc + "", 16)); | ||
| 260 | +// MessageDigest messageDigest = MessageDigest.getInstance(DEFAULT_ALGORITHM); | ||
| 261 | +// String A1 = username + ":" + realm + ":" + "12345678"; | ||
| 262 | +// String A2 = "REGISTER" + ":" + uri; | ||
| 263 | +// byte mdbytes[] = messageDigest.digest(A1.getBytes()); | ||
| 264 | +// String HA1 = toHexString(mdbytes); | ||
| 265 | +// System.out.println("A1: " + A1); | ||
| 266 | +// System.out.println("A2: " + A2); | ||
| 267 | + | ||
| 268 | +// mdbytes = messageDigest.digest(A2.getBytes()); | ||
| 269 | +// String HA2 = toHexString(mdbytes); | ||
| 270 | +// System.out.println("HA1: " + HA1); | ||
| 271 | +// System.out.println("HA2: " + HA2); | ||
| 272 | +// String cnonce = "0a4f113b"; | ||
| 273 | +// System.out.println("nonce: " + nonce); | ||
| 274 | +// System.out.println("nc: " + ncStr); | ||
| 275 | +// System.out.println("cnonce: " + cnonce); | ||
| 276 | +// System.out.println("qop: " + qop); | ||
| 277 | +// String KD = HA1 + ":" + nonce; | ||
| 278 | + | ||
| 279 | +// if (qop != null && qop.equals("auth") ) { | ||
| 280 | +// if (nc != -1) { | ||
| 281 | +// KD += ":" + ncStr; | ||
| 282 | +// } | ||
| 283 | +// if (cnonce != null) { | ||
| 284 | +// KD += ":" + cnonce; | ||
| 285 | +// } | ||
| 286 | +// KD += ":" + qop; | ||
| 287 | +// } | ||
| 288 | +// KD += ":" + HA2; | ||
| 289 | +// System.out.println("KD: " + KD); | ||
| 290 | +// mdbytes = messageDigest.digest(KD.getBytes()); | ||
| 291 | +// String mdString = toHexString(mdbytes); | ||
| 292 | +// System.out.println("mdString: " + mdString); | ||
| 293 | +// String response = "4f0507d4b87cdecff04bdaf4c96348f0"; | ||
| 294 | +// System.out.println("response: " + response); | ||
| 295 | +// } | ||
| 296 | } | 296 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.request.impl; | @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.request.impl; | ||
| 2 | 2 | ||
| 3 | import java.io.ByteArrayInputStream; | 3 | import java.io.ByteArrayInputStream; |
| 4 | import java.text.ParseException; | 4 | import java.text.ParseException; |
| 5 | -import java.text.SimpleDateFormat; | ||
| 6 | import java.util.*; | 5 | import java.util.*; |
| 7 | 6 | ||
| 8 | import javax.sip.address.SipURI; | 7 | import javax.sip.address.SipURI; |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
| @@ -17,6 +17,7 @@ import org.springframework.stereotype.Component; | @@ -17,6 +17,7 @@ import org.springframework.stereotype.Component; | ||
| 17 | 17 | ||
| 18 | import java.util.*; | 18 | import java.util.*; |
| 19 | 19 | ||
| 20 | +@SuppressWarnings("unchecked") | ||
| 20 | @Component | 21 | @Component |
| 21 | public class ZLMMediaListManager { | 22 | public class ZLMMediaListManager { |
| 22 | 23 |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| @@ -4,12 +4,10 @@ import com.alibaba.fastjson.JSON; | @@ -4,12 +4,10 @@ import com.alibaba.fastjson.JSON; | ||
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | import com.genersoft.iot.vmp.conf.MediaConfig; | 5 | import com.genersoft.iot.vmp.conf.MediaConfig; |
| 6 | import okhttp3.*; | 6 | import okhttp3.*; |
| 7 | -import org.checkerframework.checker.units.qual.A; | ||
| 8 | import org.jetbrains.annotations.NotNull; | 7 | import org.jetbrains.annotations.NotNull; |
| 9 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
| 10 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | -import org.springframework.beans.factory.annotation.Value; | ||
| 13 | import org.springframework.stereotype.Component; | 11 | import org.springframework.stereotype.Component; |
| 14 | 12 | ||
| 15 | import java.io.*; | 13 | import java.io.*; |
src/main/java/com/genersoft/iot/vmp/onvif/impl/ONVIFServerIMpl.java
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| @@ -96,15 +96,16 @@ public class PlayServiceImpl implements IPlayService { | @@ -96,15 +96,16 @@ public class PlayServiceImpl implements IPlayService { | ||
| 96 | try { | 96 | try { |
| 97 | String classPath = ResourceUtils.getURL("classpath:").getPath(); | 97 | String classPath = ResourceUtils.getURL("classpath:").getPath(); |
| 98 | // System.out.println(classPath); | 98 | // System.out.println(classPath); |
| 99 | - String path = classPath + "static/static/snap/"; | 99 | + // 兼容打包为jar的class路径 |
| 100 | if(classPath.contains("jar")) { | 100 | if(classPath.contains("jar")) { |
| 101 | classPath = classPath.substring(0, classPath.lastIndexOf(".")); | 101 | classPath = classPath.substring(0, classPath.lastIndexOf(".")); |
| 102 | - classPath = classPath.substring(0, classPath.lastIndexOf("/")); | ||
| 103 | - path = classPath + "/snap/"; | 102 | + classPath = classPath.substring(0, classPath.lastIndexOf("/") + 1); |
| 104 | } | 103 | } |
| 105 | - if (path.startsWith("file:")) { | ||
| 106 | - path = path.substring(path.indexOf(":") + 1, path.length()); | 104 | + if (classPath.startsWith("file:")) { |
| 105 | + classPath = classPath.substring(classPath.indexOf(":") + 1, classPath.length()); | ||
| 107 | } | 106 | } |
| 107 | + String path = classPath + "static/static/snap/"; | ||
| 108 | + // 兼容Windows系统路径(去除前面的“/”) | ||
| 108 | if(System.getProperty("os.name").contains("indows")) { | 109 | if(System.getProperty("os.name").contains("indows")) { |
| 109 | path = path.substring(1, path.length()); | 110 | path = path.substring(1, path.length()); |
| 110 | } | 111 | } |
| @@ -116,7 +117,7 @@ public class PlayServiceImpl implements IPlayService { | @@ -116,7 +117,7 @@ public class PlayServiceImpl implements IPlayService { | ||
| 116 | StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData(); | 117 | StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData(); |
| 117 | String streamUrl = streamInfoForSuccess.getFmp4(); | 118 | String streamUrl = streamInfoForSuccess.getFmp4(); |
| 118 | // 请求截图 | 119 | // 请求截图 |
| 119 | - zlmresTfulUtils.getSnap(streamUrl, 5, 1, path, fileName); | 120 | + zlmresTfulUtils.getSnap(streamUrl, 15, 1, path, fileName); |
| 120 | } | 121 | } |
| 121 | } | 122 | } |
| 122 | System.out.println(path); | 123 | System.out.println(path); |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
| @@ -132,15 +132,14 @@ public class DeviceQuery { | @@ -132,15 +132,14 @@ public class DeviceQuery { | ||
| 132 | */ | 132 | */ |
| 133 | @ApiOperation("同步设备通道") | 133 | @ApiOperation("同步设备通道") |
| 134 | @ApiImplicitParams({ | 134 | @ApiImplicitParams({ |
| 135 | - @ApiImplicitParam(name="deviceId", value = "设备id", required = true ,dataTypeClass = String.class), | 135 | + @ApiImplicitParam(name="deviceId", value = "设备id", required = true, dataTypeClass = String.class), |
| 136 | }) | 136 | }) |
| 137 | @PostMapping("/devices/{deviceId}/sync") | 137 | @PostMapping("/devices/{deviceId}/sync") |
| 138 | public DeferredResult<ResponseEntity<Device>> devicesSync(@PathVariable String deviceId){ | 138 | public DeferredResult<ResponseEntity<Device>> devicesSync(@PathVariable String deviceId){ |
| 139 | 139 | ||
| 140 | if (logger.isDebugEnabled()) { | 140 | if (logger.isDebugEnabled()) { |
| 141 | - } | ||
| 142 | logger.debug("设备通道信息同步API调用,deviceId:" + deviceId); | 141 | logger.debug("设备通道信息同步API调用,deviceId:" + deviceId); |
| 143 | - | 142 | + } |
| 144 | Device device = storager.queryVideoDevice(deviceId); | 143 | Device device = storager.queryVideoDevice(deviceId); |
| 145 | cmder.catalogQuery(device, event -> { | 144 | cmder.catalogQuery(device, event -> { |
| 146 | Response response = event.getResponse(); | 145 | Response response = event.getResponse(); |
| @@ -264,7 +263,7 @@ public class DeviceQuery { | @@ -264,7 +263,7 @@ public class DeviceQuery { | ||
| 264 | @ApiImplicitParams({ | 263 | @ApiImplicitParams({ |
| 265 | @ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class), | 264 | @ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class), |
| 266 | @ApiImplicitParam(name = "streamMode", value = "数据流传输模式, 取值:" + | 265 | @ApiImplicitParam(name = "streamMode", value = "数据流传输模式, 取值:" + |
| 267 | - "UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)"), | 266 | + "UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)", dataTypeClass = String.class), |
| 268 | }) | 267 | }) |
| 269 | @PostMapping("/transport/{deviceId}/{streamMode}") | 268 | @PostMapping("/transport/{deviceId}/{streamMode}") |
| 270 | public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ | 269 | public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java
| @@ -56,7 +56,7 @@ public class GbStreamController { | @@ -56,7 +56,7 @@ public class GbStreamController { | ||
| 56 | */ | 56 | */ |
| 57 | @ApiOperation("移除国标关联") | 57 | @ApiOperation("移除国标关联") |
| 58 | @ApiImplicitParams({ | 58 | @ApiImplicitParams({ |
| 59 | - @ApiImplicitParam(name = "gbStreamParam", value = "GbStreamParam", required = true , | 59 | + @ApiImplicitParam(name = "gbStreamParam", value = "GbStreamParam", required = true, |
| 60 | dataTypeClass = GbStreamParam.class), | 60 | dataTypeClass = GbStreamParam.class), |
| 61 | }) | 61 | }) |
| 62 | @DeleteMapping(value = "/del") | 62 | @DeleteMapping(value = "/del") |
| @@ -77,7 +77,7 @@ public class GbStreamController { | @@ -77,7 +77,7 @@ public class GbStreamController { | ||
| 77 | */ | 77 | */ |
| 78 | @ApiOperation("保存国标关联") | 78 | @ApiOperation("保存国标关联") |
| 79 | @ApiImplicitParams({ | 79 | @ApiImplicitParams({ |
| 80 | - @ApiImplicitParam(name = "gbStreamParam", value = "GbStreamParam", required = true , dataTypeClass = GbStreamParam.class), | 80 | + @ApiImplicitParam(name = "gbStreamParam", value = "GbStreamParam", required = true, dataTypeClass = GbStreamParam.class), |
| 81 | }) | 81 | }) |
| 82 | @PostMapping(value = "/add") | 82 | @PostMapping(value = "/add") |
| 83 | @ResponseBody | 83 | @ResponseBody |
src/main/java/com/genersoft/iot/vmp/vmanager/record/RecoderProxyController.java
| @@ -14,6 +14,8 @@ import org.springframework.web.client.RestTemplate; | @@ -14,6 +14,8 @@ import org.springframework.web.client.RestTemplate; | ||
| 14 | 14 | ||
| 15 | import javax.servlet.http.HttpServletRequest; | 15 | import javax.servlet.http.HttpServletRequest; |
| 16 | import javax.servlet.http.HttpServletResponse; | 16 | import javax.servlet.http.HttpServletResponse; |
| 17 | + | ||
| 18 | +import java.io.UnsupportedEncodingException; | ||
| 17 | import java.net.URLDecoder; | 19 | import java.net.URLDecoder; |
| 18 | 20 | ||
| 19 | @RestController | 21 | @RestController |
| @@ -31,7 +33,7 @@ public class RecoderProxyController { | @@ -31,7 +33,7 @@ public class RecoderProxyController { | ||
| 31 | 33 | ||
| 32 | @ResponseBody | 34 | @ResponseBody |
| 33 | @RequestMapping(value = "/**/**/**", produces = "application/json;charset=UTF-8") | 35 | @RequestMapping(value = "/**/**/**", produces = "application/json;charset=UTF-8") |
| 34 | - public Object proxy(HttpServletRequest request, HttpServletResponse response){ | 36 | + public Object proxy(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException{ |
| 35 | 37 | ||
| 36 | 38 | ||
| 37 | String baseRequestURI = request.getRequestURI(); | 39 | String baseRequestURI = request.getRequestURI(); |
| @@ -51,7 +53,7 @@ public class RecoderProxyController { | @@ -51,7 +53,7 @@ public class RecoderProxyController { | ||
| 51 | mediaInfo.getSdpIp(), | 53 | mediaInfo.getSdpIp(), |
| 52 | mediaConfig.getRecordAssistPort(), | 54 | mediaConfig.getRecordAssistPort(), |
| 53 | baseRequestURI.substring(baseRequestURI.indexOf(mediaId) + mediaId.length()), | 55 | baseRequestURI.substring(baseRequestURI.indexOf(mediaId) + mediaId.length()), |
| 54 | - URLDecoder.decode(request.getQueryString()) | 56 | + URLDecoder.decode(request.getQueryString(), "UTF-8") |
| 55 | ); | 57 | ); |
| 56 | // 发送请求 | 58 | // 发送请求 |
| 57 | RestTemplate restTemplate = new RestTemplate(); | 59 | RestTemplate restTemplate = new RestTemplate(); |