648540858
2022-03-14 bde0e13682ed75d2e8c0cb8a1fd6a96bb92f1dd8
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/DownloadController.java
@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.vmanager.gb28181.playback;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
@@ -76,7 +77,7 @@
      if (logger.isDebugEnabled()) {
         logger.debug(String.format("历史媒体下载 API调用,deviceId:%s,channelId:%s,downloadSpeed:%s", deviceId, channelId, downloadSpeed));
      }
      String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
      String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId;
      String uuid = UUID.randomUUID().toString();
      DeferredResult<ResponseEntity<String>> result = new DeferredResult<ResponseEntity<String>>(30000L);
      // 超时处理
@@ -88,16 +89,11 @@
         msg.setData("Timeout");
         resultHolder.invokeAllResult(msg);
      });
      resultHolder.put(key, uuid, result);
      if(resultHolder.exist(key, null)) {
         return result;
      }
      resultHolder.put(key, uuid, result);
      Device device = storager.queryVideoDevice(deviceId);
      StreamInfo streamInfo = redisCatchStorage.queryPlaybackByDevice(deviceId, channelId);
      if (streamInfo != null) {
         // 停止之前的下载
         cmder.streamByeCmd(deviceId, channelId);
      }
      MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
      if (newMediaServerItem == null) {
@@ -112,9 +108,9 @@
      SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, true);
      cmder.downloadStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, (MediaServerItem mediaServerItem, JSONObject response) -> {
         logger.info("收到订阅消息: " + response.toJSONString());
         playService.onPublishHandlerForPlayBack(mediaServerItem, response, deviceId, channelId, uuid.toString());
      cmder.downloadStreamCmd(newMediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, (InviteStreamInfo inviteStreamInfo) -> {
         logger.info("收到订阅消息: " + inviteStreamInfo.getResponse().toJSONString());
         playService.onPublishHandlerForDownload(inviteStreamInfo, deviceId, channelId, uuid);
      }, event -> {
         RequestMessage msg = new RequestMessage();
         msg.setId(uuid);
@@ -130,11 +126,12 @@
   @ApiImplicitParams({
         @ApiImplicitParam(name = "deviceId", value = "设备ID", dataTypeClass = String.class),
         @ApiImplicitParam(name = "channelId", value = "通道ID", dataTypeClass = String.class),
         @ApiImplicitParam(name = "stream", value = "流ID", dataTypeClass = String.class),
   })
   @GetMapping("/stop/{deviceId}/{channelId}")
   public ResponseEntity<String> playStop(@PathVariable String deviceId, @PathVariable String channelId) {
   @GetMapping("/stop/{deviceId}/{channelId}/{stream}")
   public ResponseEntity<String> playStop(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) {
      cmder.streamByeCmd(deviceId, channelId);
      cmder.streamByeCmd(deviceId, channelId, stream, null);
      if (logger.isDebugEnabled()) {
         logger.debug(String.format("设备历史媒体下载停止 API调用,deviceId/channelId:%s_%s", deviceId, channelId));