Browse Source

优化兼容接口

pull/249/head
648540858 3 years ago
parent
commit
59e369e37d
  1. 33
      src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiCompatibleController.java
  2. 37
      src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java
  3. 2
      src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java

33
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiCompatibleController.java

@ -1,33 +0,0 @@
package com.genersoft.iot.vmp.web.gb28181;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@CrossOrigin
@RestController
public class ApiCompatibleController {
private final static Logger logger = LoggerFactory.getLogger(ApiCompatibleController.class);
@Autowired
private IMediaService mediaService;
@GetMapping(value = "/api/v1/stream_info_by_app_and_stream")
@ResponseBody
public WVPResult<StreamInfo> getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app, @RequestParam String stream){
String localAddr = request.getLocalAddr();
StreamInfo streamINfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, localAddr);
WVPResult<StreamInfo> wvpResult = new WVPResult<>();
wvpResult.setCode(0);
wvpResult.setMsg("success");
wvpResult.setData(streamINfo);
return wvpResult;
}
}

37
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java

@ -45,49 +45,46 @@ public class ApiControlController {
serial, code, command, speed)); serial, code, command, speed));
} }
Device device = storager.queryVideoDevice(serial); Device device = storager.queryVideoDevice(serial);
int leftRight = 0; int cmdCode = 0;
int upDown = 0; switch (command){
int inOut = 0;
switch (command) {
case "left": case "left":
leftRight = 1; cmdCode = 2;
break; break;
case "right": case "right":
leftRight = 2; cmdCode = 1;
break; break;
case "up": case "up":
upDown = 1; cmdCode = 8;
break; break;
case "down": case "down":
upDown = 2; cmdCode = 4;
break; break;
case "upleft": case "upleft":
upDown = 1; cmdCode = 10;
leftRight = 1; break;
case "upright": case "upright":
upDown = 1; cmdCode = 9;
leftRight = 2;
break; break;
case "downleft": case "downleft":
upDown = 2; cmdCode = 6;
leftRight = 1;
break; break;
case "downright": case "downright":
upDown = 2; cmdCode = 5;
leftRight = 2;
break; break;
case "zoomin": case "zoomin":
inOut = 2; cmdCode = 16;
break; break;
case "zoomout": case "zoomout":
inOut = 1; cmdCode = 32;
break; break;
case "stop": case "stop":
cmdCode = 0;
break;
default:
break; break;
} }
// 默认值 50 // 默认值 50
cmder.ptzCmd(device, code, leftRight, upDown, inOut, speed==0 ? 129 : speed, 50); cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
return null; return null;
} }
} }

2
src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java

@ -73,7 +73,7 @@ public class ApiDeviceController {
deviceJsonObject.put("ChannelCount", device.getChannelCount()); deviceJsonObject.put("ChannelCount", device.getChannelCount());
deviceJsonObject.put("RecvStreamIP", ""); deviceJsonObject.put("RecvStreamIP", "");
deviceJsonObject.put("CatalogInterval", 3600); // 通道目录抓取周期 deviceJsonObject.put("CatalogInterval", 3600); // 通道目录抓取周期
deviceJsonObject.put("SubscribeInterval", 0); // 订阅周期(秒), 0 表示后台不周期订阅 deviceJsonObject.put("SubscribeInterval", device.getSubscribeCycleForCatalog()); // 订阅周期(秒), 0 表示后台不周期订阅
deviceJsonObject.put("Online", device.getOnline() == 1); deviceJsonObject.put("Online", device.getOnline() == 1);
deviceJsonObject.put("Password", ""); deviceJsonObject.put("Password", "");
deviceJsonObject.put("MediaTransport", device.getTransport()); deviceJsonObject.put("MediaTransport", device.getTransport());

Loading…
Cancel
Save