648540858
2022-11-08 96bb3814f65edb36327eb02f2ea1beed30f06dfc
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson2.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
@@ -37,6 +38,8 @@
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.springframework.web.context.request.async.DeferredResult;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
@@ -78,18 +81,25 @@
   @Autowired
   private IMediaServerService mediaServerService;
   @Autowired
   private UserSetting userSetting;
   @Operation(summary = "开始点播")
   @Parameter(name = "deviceId", description = "设备国标编号", required = true)
   @Parameter(name = "channelId", description = "通道国标编号", required = true)
   @GetMapping("/start/{deviceId}/{channelId}")
   public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId,
                                          @PathVariable String channelId) {
   public DeferredResult<WVPResult<StreamInfo>> play(HttpServletRequest request, @PathVariable String deviceId,
                                         @PathVariable String channelId) {
      // 获取可用的zlm
      Device device = storager.queryVideoDevice(deviceId);
      MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device);
      PlayResult playResult = playService.play(newMediaServerItem, deviceId, channelId, null, null, null);
      playResult.getResult().onCompletion(()->{
         WVPResult<StreamInfo> result = (WVPResult<StreamInfo>)playResult.getResult().getResult();
         result.getData().channgeStreamIp(request.getLocalAddr());
         playResult.getResult().setResult(result);
      });
      return playResult.getResult();
   }