Commit 730a64be077b51add311b9d880bb23f5162253ec
1 parent
5ef229f0
优化录像查询,优化注释
Showing
4 changed files
with
40 additions
and
22 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| ... | ... | @@ -188,19 +188,29 @@ public class SIPCommander implements ISIPCommander { |
| 188 | 188 | * @param moveSpeed 镜头移动速度 默认 0XFF (0-255) |
| 189 | 189 | * @param zoomSpeed 镜头缩放速度 默认 0X1 (0-255) |
| 190 | 190 | */ |
| 191 | - public static String frontEndCmdString(int cmdCode, int parameter1, int parameter2, int combineCode2) { | |
| 191 | + | |
| 192 | + /** | |
| 193 | + * 云台指令码计算 | |
| 194 | + * | |
| 195 | + * @param cmdCode 指令码 | |
| 196 | + * @param horizonSpeed 水平移动速度 | |
| 197 | + * @param verticalSpeed 垂直移动速度 | |
| 198 | + * @param zoomSpeed 缩放速度 | |
| 199 | + * @return | |
| 200 | + */ | |
| 201 | + public static String frontEndCmdString(int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed) { | |
| 192 | 202 | StringBuilder builder = new StringBuilder("A50F01"); |
| 193 | 203 | String strTmp; |
| 194 | 204 | strTmp = String.format("%02X", cmdCode); |
| 195 | 205 | builder.append(strTmp, 0, 2); |
| 196 | - strTmp = String.format("%02X", parameter1); | |
| 206 | + strTmp = String.format("%02X", horizonSpeed); | |
| 197 | 207 | builder.append(strTmp, 0, 2); |
| 198 | - strTmp = String.format("%02X", parameter2); | |
| 208 | + strTmp = String.format("%02X", verticalSpeed); | |
| 199 | 209 | builder.append(strTmp, 0, 2); |
| 200 | - strTmp = String.format("%X", combineCode2); | |
| 210 | + strTmp = String.format("%X", zoomSpeed); | |
| 201 | 211 | builder.append(strTmp, 0, 1).append("0"); |
| 202 | 212 | //计算校验码 |
| 203 | - int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + parameter1 + parameter2 + (combineCode2 & 0XF0)) % 0X100; | |
| 213 | + int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + horizonSpeed + verticalSpeed + (zoomSpeed & 0XF0)) % 0X100; | |
| 204 | 214 | strTmp = String.format("%02X", checkCode); |
| 205 | 215 | builder.append(strTmp, 0, 2); |
| 206 | 216 | return builder.toString(); |
| ... | ... | @@ -249,14 +259,14 @@ public class SIPCommander implements ISIPCommander { |
| 249 | 259 | * @param device 控制设备 |
| 250 | 260 | * @param channelId 预览通道 |
| 251 | 261 | * @param cmdCode 指令码 |
| 252 | - * @param parameter1 数据1 | |
| 253 | - * @param parameter2 数据2 | |
| 254 | - * @param combineCode2 组合码2 | |
| 262 | + * @param horizonSpeed 水平移动速度 | |
| 263 | + * @param verticalSpeed 垂直移动速度 | |
| 264 | + * @param zoomSpeed 缩放速度 | |
| 255 | 265 | */ |
| 256 | 266 | @Override |
| 257 | - public boolean frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) { | |
| 267 | + public boolean frontEndCmd(Device device, String channelId, int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed) { | |
| 258 | 268 | try { |
| 259 | - String cmdStr= frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2); | |
| 269 | + String cmdStr= frontEndCmdString(cmdCode, horizonSpeed, verticalSpeed, zoomSpeed); | |
| 260 | 270 | System.out.println("控制字符串:" + cmdStr); |
| 261 | 271 | StringBuffer ptzXml = new StringBuffer(200); |
| 262 | 272 | ptzXml.append("<?xml version=\"1.0\" ?>\r\n"); |
| ... | ... | @@ -701,7 +711,6 @@ public class SIPCommander implements ISIPCommander { |
| 701 | 711 | |
| 702 | 712 | Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), "ViaRecordInfoBranch", "FromRecordInfoTag", null); |
| 703 | 713 | |
| 704 | - | |
| 705 | 714 | transmitRequest(device, request); |
| 706 | 715 | } catch (SipException | ParseException | InvalidArgumentException e) { |
| 707 | 716 | e.printStackTrace(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/ptz/PtzController.java
| ... | ... | @@ -29,15 +29,14 @@ public class PtzController { |
| 29 | 29 | private IVideoManagerStorager storager; |
| 30 | 30 | |
| 31 | 31 | /*** |
| 32 | - * http://localhost:8080/api/ptz/34020000001320000002_34020000001320000008?leftRight=1&upDown=0&inOut=0&moveSpeed=50&zoomSpeed=0 | |
| 33 | - * @param deviceId | |
| 34 | - * @param channelId | |
| 35 | - * @param leftRight | |
| 36 | - * @param upDown | |
| 37 | - * @param inOut | |
| 38 | - * @param moveSpeed | |
| 39 | - * @param zoomSpeed | |
| 40 | - * @return | |
| 32 | + * 云台控制 | |
| 33 | + * @param deviceId 设备id | |
| 34 | + * @param channelId 通道id | |
| 35 | + * @param cmdCode 指令码 | |
| 36 | + * @param horizonSpeed 水平移动速度 | |
| 37 | + * @param verticalSpeed 垂直移动速度 | |
| 38 | + * @param zoomSpeed 缩放速度 | |
| 39 | + * @return String 控制结果 | |
| 41 | 40 | */ |
| 42 | 41 | @PostMapping("/ptz/{deviceId}/{channelId}") |
| 43 | 42 | public ResponseEntity<String> ptz(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed){ | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/record/RecordController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.record; |
| 2 | 2 | |
| 3 | +import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | |
| 3 | 4 | import org.slf4j.Logger; |
| 4 | 5 | import org.slf4j.LoggerFactory; |
| 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -32,7 +33,7 @@ public class RecordController { |
| 32 | 33 | |
| 33 | 34 | @Autowired |
| 34 | 35 | private DeferredResultHolder resultHolder; |
| 35 | - | |
| 36 | + | |
| 36 | 37 | @GetMapping("/record/{deviceId}/{channelId}") |
| 37 | 38 | public DeferredResult<ResponseEntity<RecordInfo>> recordinfo(@PathVariable String deviceId,@PathVariable String channelId, String startTime, String endTime){ |
| 38 | 39 | |
| ... | ... | @@ -42,9 +43,17 @@ public class RecordController { |
| 42 | 43 | |
| 43 | 44 | Device device = storager.queryVideoDevice(deviceId); |
| 44 | 45 | cmder.recordInfoQuery(device, channelId, startTime, endTime); |
| 45 | - DeferredResult<ResponseEntity<RecordInfo>> result = new DeferredResult<ResponseEntity<RecordInfo>>(); | |
| 46 | + // 指定超时时间 1分钟30秒 | |
| 47 | + DeferredResult<ResponseEntity<RecordInfo>> result = new DeferredResult<ResponseEntity<RecordInfo>>(90*1000L); | |
| 46 | 48 | // 录像查询以channelId作为deviceId查询 |
| 47 | 49 | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_RECORDINFO+channelId, result); |
| 50 | + result.onTimeout(()->{ | |
| 51 | + RequestMessage msg = new RequestMessage(); | |
| 52 | + msg.setDeviceId(deviceId); | |
| 53 | + msg.setType(DeferredResultHolder.CALLBACK_CMD_RECORDINFO); | |
| 54 | + msg.setData("timeout"); | |
| 55 | + resultHolder.invokeResult(msg); | |
| 56 | + }); | |
| 48 | 57 | return result; |
| 49 | 58 | } |
| 50 | 59 | } | ... | ... |