| | |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.github.pagehelper.PageInfo; |
| | | import io.swagger.annotations.*; |
| | | import org.slf4j.Logger; |
| | |
| | | |
| | | @Autowired |
| | | private IVideoManagerStorager storager; |
| | | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | @Autowired |
| | | private SIPCommander cmder; |
| | |
| | | */ |
| | | @ApiOperation("同步设备通道") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name="deviceId", value = "设备id", required = true ,dataTypeClass = String.class), |
| | | @ApiImplicitParam(name="deviceId", value = "设备id", required = true, dataTypeClass = String.class), |
| | | }) |
| | | @PostMapping("/devices/{deviceId}/sync") |
| | | public DeferredResult<ResponseEntity<Device>> devicesSync(@PathVariable String deviceId){ |
| | | |
| | | if (logger.isDebugEnabled()) { |
| | | } |
| | | logger.debug("设备通道信息同步API调用,deviceId:" + deviceId); |
| | | |
| | | } |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | cmder.catalogQuery(device, event -> { |
| | | Response response = event.getResponse(); |
| | |
| | | msg.setData(String.format("同步通道失败,错误码: %s, %s", response.getStatusCode(), response.getReasonPhrase())); |
| | | resultHolder.invokeResult(msg); |
| | | }); |
| | | DeferredResult<ResponseEntity<Device>> result = new DeferredResult<ResponseEntity<Device>>(2*1000L); |
| | | DeferredResult<ResponseEntity<Device>> result = new DeferredResult<ResponseEntity<Device>>(15*1000L); |
| | | result.onTimeout(()->{ |
| | | logger.warn(String.format("设备通道信息同步超时")); |
| | | // 释放rtpserver |
| | |
| | | if (offLineDetector.isOnline(deviceId)) { |
| | | return new ResponseEntity<String>("不允许删除在线设备!", HttpStatus.NOT_ACCEPTABLE); |
| | | } |
| | | // 清除redis记录 |
| | | boolean isSuccess = storager.delete(deviceId); |
| | | if (isSuccess) { |
| | | redisCatchStorage.clearCatchByDeviceId(deviceId); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("deviceId", deviceId); |
| | | return new ResponseEntity<>(json.toString(),HttpStatus.OK); |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "streamMode", value = "数据流传输模式, 取值:" + |
| | | "UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)"), |
| | | "UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)", dataTypeClass = String.class), |
| | | }) |
| | | @PostMapping("/transport/{deviceId}/{streamMode}") |
| | | public ResponseEntity<PageInfo> updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ |