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));
}
Device device = storager.queryVideoDevice(serial);
int leftRight = 0;
int upDown = 0;
int inOut = 0;
switch (command) {
int cmdCode = 0;
switch (command){
case "left":
leftRight = 1;
cmdCode = 2;
break;
case "right":
leftRight = 2;
cmdCode = 1;
break;
case "up":
upDown = 1;
cmdCode = 8;
break;
case "down":
upDown = 2;
cmdCode = 4;
break;
case "upleft":
upDown = 1;
leftRight = 1;
cmdCode = 10;
break;
case "upright":
upDown = 1;
leftRight = 2;
cmdCode = 9;
break;
case "downleft":
upDown = 2;
leftRight = 1;
cmdCode = 6;
break;
case "downright":
upDown = 2;
leftRight = 2;
cmdCode = 5;
break;
case "zoomin":
inOut = 2;
cmdCode = 16;
break;
case "zoomout":
inOut = 1;
cmdCode = 32;
break;
case "stop":
cmdCode = 0;
break;
default:
break;
}
// 默认值 50
cmder.ptzCmd(device, code, leftRight, upDown, inOut, speed==0 ? 129 : speed, 50);
cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed);
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("RecvStreamIP", "");
deviceJsonObject.put("CatalogInterval", 3600); // 通道目录抓取周期
deviceJsonObject.put("SubscribeInterval", 0); // 订阅周期(秒), 0 表示后台不周期订阅
deviceJsonObject.put("SubscribeInterval", device.getSubscribeCycleForCatalog()); // 订阅周期(秒), 0 表示后台不周期订阅
deviceJsonObject.put("Online", device.getOnline() == 1);
deviceJsonObject.put("Password", "");
deviceJsonObject.put("MediaTransport", device.getTransport());

Loading…
Cancel
Save