Commit 59e369e37d52f8822b1abfe8994bf8ff7346c6d4
1 parent
e1920093
优化兼容接口
Showing
3 changed files
with
18 additions
and
54 deletions
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiCompatibleController.java deleted
100644 → 0
| 1 | -package com.genersoft.iot.vmp.web.gb28181; | |
| 2 | - | |
| 3 | -import com.genersoft.iot.vmp.common.StreamInfo; | |
| 4 | -import com.genersoft.iot.vmp.service.IMediaService; | |
| 5 | -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | |
| 6 | -import org.slf4j.Logger; | |
| 7 | -import org.slf4j.LoggerFactory; | |
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | -import org.springframework.web.bind.annotation.*; | |
| 10 | - | |
| 11 | -import javax.servlet.http.HttpServletRequest; | |
| 12 | - | |
| 13 | -@CrossOrigin | |
| 14 | -@RestController | |
| 15 | -public class ApiCompatibleController { | |
| 16 | - | |
| 17 | - private final static Logger logger = LoggerFactory.getLogger(ApiCompatibleController.class); | |
| 18 | - | |
| 19 | - @Autowired | |
| 20 | - private IMediaService mediaService; | |
| 21 | - | |
| 22 | - @GetMapping(value = "/api/v1/stream_info_by_app_and_stream") | |
| 23 | - @ResponseBody | |
| 24 | - public WVPResult<StreamInfo> getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app, @RequestParam String stream){ | |
| 25 | - String localAddr = request.getLocalAddr(); | |
| 26 | - StreamInfo streamINfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, localAddr); | |
| 27 | - WVPResult<StreamInfo> wvpResult = new WVPResult<>(); | |
| 28 | - wvpResult.setCode(0); | |
| 29 | - wvpResult.setMsg("success"); | |
| 30 | - wvpResult.setData(streamINfo); | |
| 31 | - return wvpResult; | |
| 32 | - } | |
| 33 | -} |
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
| ... | ... | @@ -45,49 +45,46 @@ public class ApiControlController { |
| 45 | 45 | serial, code, command, speed)); |
| 46 | 46 | } |
| 47 | 47 | Device device = storager.queryVideoDevice(serial); |
| 48 | - int leftRight = 0; | |
| 49 | - int upDown = 0; | |
| 50 | - int inOut = 0; | |
| 51 | - switch (command) { | |
| 48 | + int cmdCode = 0; | |
| 49 | + switch (command){ | |
| 52 | 50 | case "left": |
| 53 | - leftRight = 1; | |
| 51 | + cmdCode = 2; | |
| 54 | 52 | break; |
| 55 | 53 | case "right": |
| 56 | - leftRight = 2; | |
| 54 | + cmdCode = 1; | |
| 57 | 55 | break; |
| 58 | 56 | case "up": |
| 59 | - upDown = 1; | |
| 57 | + cmdCode = 8; | |
| 60 | 58 | break; |
| 61 | 59 | case "down": |
| 62 | - upDown = 2; | |
| 60 | + cmdCode = 4; | |
| 63 | 61 | break; |
| 64 | 62 | case "upleft": |
| 65 | - upDown = 1; | |
| 66 | - leftRight = 1; | |
| 63 | + cmdCode = 10; | |
| 64 | + break; | |
| 67 | 65 | case "upright": |
| 68 | - upDown = 1; | |
| 69 | - leftRight = 2; | |
| 66 | + cmdCode = 9; | |
| 70 | 67 | break; |
| 71 | 68 | case "downleft": |
| 72 | - upDown = 2; | |
| 73 | - leftRight = 1; | |
| 69 | + cmdCode = 6; | |
| 74 | 70 | break; |
| 75 | 71 | case "downright": |
| 76 | - upDown = 2; | |
| 77 | - leftRight = 2; | |
| 72 | + cmdCode = 5; | |
| 78 | 73 | break; |
| 79 | 74 | case "zoomin": |
| 80 | - inOut = 2; | |
| 75 | + cmdCode = 16; | |
| 81 | 76 | break; |
| 82 | 77 | case "zoomout": |
| 83 | - inOut = 1; | |
| 78 | + cmdCode = 32; | |
| 84 | 79 | break; |
| 85 | 80 | case "stop": |
| 81 | + cmdCode = 0; | |
| 82 | + break; | |
| 83 | + default: | |
| 86 | 84 | break; |
| 87 | - | |
| 88 | 85 | } |
| 89 | 86 | // 默认值 50 |
| 90 | - cmder.ptzCmd(device, code, leftRight, upDown, inOut, speed==0 ? 129 : speed, 50); | |
| 87 | + cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed); | |
| 91 | 88 | return null; |
| 92 | 89 | } |
| 93 | 90 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java
| ... | ... | @@ -73,7 +73,7 @@ public class ApiDeviceController { |
| 73 | 73 | deviceJsonObject.put("ChannelCount", device.getChannelCount()); |
| 74 | 74 | deviceJsonObject.put("RecvStreamIP", ""); |
| 75 | 75 | deviceJsonObject.put("CatalogInterval", 3600); // 通道目录抓取周期 |
| 76 | - deviceJsonObject.put("SubscribeInterval", 0); // 订阅周期(秒), 0 表示后台不周期订阅 | |
| 76 | + deviceJsonObject.put("SubscribeInterval", device.getSubscribeCycleForCatalog()); // 订阅周期(秒), 0 表示后台不周期订阅 | |
| 77 | 77 | deviceJsonObject.put("Online", device.getOnline() == 1); |
| 78 | 78 | deviceJsonObject.put("Password", ""); |
| 79 | 79 | deviceJsonObject.put("MediaTransport", device.getTransport()); | ... | ... |