diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java index 8b3984fcb..ba04d466a 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java @@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback; import com.genersoft.iot.vmp.service.bean.PlayBackCallback; import com.genersoft.iot.vmp.service.bean.SSRCInfo; +import com.genersoft.iot.vmp.vmanager.bean.StreamContent; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.springframework.web.context.request.async.DeferredResult; @@ -35,15 +36,15 @@ public interface IPlayService { void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString); - DeferredResult> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); - DeferredResult> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); + DeferredResult> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); + DeferredResult> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); void zlmServerOffline(String mediaServerId); - DeferredResult> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); - DeferredResult> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); + DeferredResult> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); + DeferredResult> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); - StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream); + StreamContent getDownLoadInfo(String deviceId, String channelId, String stream); void zlmServerOnline(String mediaServerId); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index a2b879451..69405923a 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -35,6 +35,7 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.redis.RedisUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.bean.StreamContent; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -427,9 +428,9 @@ public class PlayServiceImpl implements IPlayService { } @Override - public DeferredResult> playBack(String deviceId, String channelId, String startTime, - String endTime, InviteStreamCallback inviteStreamCallback, - PlayBackCallback callback) { + public DeferredResult> playBack(String deviceId, String channelId, String startTime, + String endTime, InviteStreamCallback inviteStreamCallback, + PlayBackCallback callback) { Device device = storager.queryVideoDevice(deviceId); if (device == null) { return null; @@ -441,7 +442,7 @@ public class PlayServiceImpl implements IPlayService { } @Override - public DeferredResult> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, + public DeferredResult> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback) { @@ -454,8 +455,8 @@ public class PlayServiceImpl implements IPlayService { if (device == null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在"); } - DeferredResult> result = new DeferredResult<>(30000L); - resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid, result); + DeferredResult> result = new DeferredResult<>(30000L); + resultHolder.put(key, uuid, result); RequestMessage requestMessage = new RequestMessage(); requestMessage.setId(uuid); requestMessage.setKey(key); @@ -481,7 +482,7 @@ public class PlayServiceImpl implements IPlayService { // 回复之前所有的点播请求 playBackCallback.call(playBackResult); result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "回放超时")); - resultHolder.exist(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid); + resultHolder.exist(key, uuid); }, userSetting.getPlayTimeout()); SipSubscribe.Event errorEvent = event -> { @@ -507,7 +508,7 @@ public class PlayServiceImpl implements IPlayService { return; } redisCatchStorage.startPlayback(streamInfo, inviteStreamInfo.getCallId()); - WVPResult success = WVPResult.success(streamInfo); + WVPResult success = WVPResult.success(new StreamContent(streamInfo)); requestMessage.setData(success); playBackResult.setCode(ErrorCode.SUCCESS.getCode()); playBackResult.setMsg(ErrorCode.SUCCESS.getMsg()); @@ -584,7 +585,7 @@ public class PlayServiceImpl implements IPlayService { @Override - public DeferredResult> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { + public DeferredResult> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { Device device = storager.queryVideoDevice(deviceId); if (device == null) { return null; @@ -596,13 +597,13 @@ public class PlayServiceImpl implements IPlayService { } @Override - public DeferredResult> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { + public DeferredResult> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { if (mediaServerItem == null || ssrcInfo == null) { return null; } String uuid = UUID.randomUUID().toString(); String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId; - DeferredResult> result = new DeferredResult<>(30000L); + DeferredResult> result = new DeferredResult<>(30000L); Device device = storager.queryVideoDevice(deviceId); if (device == null) { throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "不存在"); @@ -612,7 +613,7 @@ public class PlayServiceImpl implements IPlayService { RequestMessage requestMessage = new RequestMessage(); requestMessage.setId(uuid); requestMessage.setKey(key); - WVPResult wvpResult = new WVPResult<>(); + WVPResult wvpResult = new WVPResult<>(); requestMessage.setData(wvpResult); PlayBackResult downloadResult = new PlayBackResult<>(); downloadResult.setData(requestMessage); @@ -662,7 +663,7 @@ public class PlayServiceImpl implements IPlayService { redisCatchStorage.startDownload(streamInfo, inviteStreamInfo.getCallId()); wvpResult.setCode(ErrorCode.SUCCESS.getCode()); wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); - wvpResult.setData(streamInfo); + wvpResult.setData(new StreamContent(streamInfo)); downloadResult.setCode(ErrorCode.SUCCESS.getCode()); downloadResult.setMsg(ErrorCode.SUCCESS.getMsg()); downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); @@ -680,11 +681,11 @@ public class PlayServiceImpl implements IPlayService { } @Override - public StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream) { + public StreamContent getDownLoadInfo(String deviceId, String channelId, String stream) { StreamInfo streamInfo = redisCatchStorage.queryDownload(deviceId, channelId, stream, null); if (streamInfo != null) { if (streamInfo.getProgress() == 1) { - return streamInfo; + return new StreamContent(streamInfo); } // 获取当前已下载时长 @@ -716,7 +717,7 @@ public class PlayServiceImpl implements IPlayService { } } } - return streamInfo; + return new StreamContent(streamInfo); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java index 696fae0ed..c511b6f2b 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java @@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.bean.StreamContent; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -68,8 +69,8 @@ public class PlaybackController { @Parameter(name = "startTime", description = "开始时间", required = true) @Parameter(name = "endTime", description = "结束时间", required = true) @GetMapping("/start/{deviceId}/{channelId}") - public DeferredResult> play(@PathVariable String deviceId, @PathVariable String channelId, - String startTime, String endTime) { + public DeferredResult> play(@PathVariable String deviceId, @PathVariable String channelId, + String startTime, String endTime) { if (logger.isDebugEnabled()) { logger.debug(String.format("设备回放 API调用,deviceId:%s ,channelId:%s", deviceId, channelId)); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java index 6625ba456..8758763b0 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; +import com.genersoft.iot.vmp.vmanager.bean.StreamContent; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import io.swagger.v3.oas.annotations.Operation; @@ -121,14 +122,14 @@ public class GBRecordController { @Parameter(name = "endTime", description = "结束时间", required = true) @Parameter(name = "downloadSpeed", description = "下载倍速", required = true) @GetMapping("/download/start/{deviceId}/{channelId}") - public DeferredResult> download(@PathVariable String deviceId, @PathVariable String channelId, - String startTime, String endTime, String downloadSpeed) { + public DeferredResult> download(@PathVariable String deviceId, @PathVariable String channelId, + String startTime, String endTime, String downloadSpeed) { if (logger.isDebugEnabled()) { logger.debug(String.format("历史媒体下载 API调用,deviceId:%s,channelId:%s,downloadSpeed:%s", deviceId, channelId, downloadSpeed)); } - DeferredResult> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{ + DeferredResult> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{ resultHolder.invokeResult(hookCallBack.getData()); }); @@ -168,7 +169,7 @@ public class GBRecordController { @Parameter(name = "channelId", description = "通道国标编号", required = true) @Parameter(name = "stream", description = "流ID", required = true) @GetMapping("/download/progress/{deviceId}/{channelId}/{stream}") - public StreamInfo getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) { + public StreamContent getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) { return playService.getDownLoadInfo(deviceId, channelId, stream); } } diff --git a/web_src/src/components/live.vue b/web_src/src/components/live.vue index fcf1d59e6..4a7af491e 100644 --- a/web_src/src/components/live.vue +++ b/web_src/src/components/live.vue @@ -140,9 +140,9 @@ export default { if (res.data.code === 0 && res.data.data) { let videoUrl; if (location.protocol === "https:") { - videoUrl = res.data.data.wss_flv.url; + videoUrl = res.data.data.wss_flv; } else { - videoUrl = res.data.data.ws_flv.url; + videoUrl = res.data.data.ws_flv; } itemData.playUrl = videoUrl; that.setPlayUrl(videoUrl, idxTmp);