Merge branch 'wvp-28181-2.0'
# Conflicts:
# src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
| | |
| | | import com.genersoft.iot.vmp.service.bean.PlayBackCallback; |
| | | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| | | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.context.request.async.DeferredResult; |
| | |
| | | |
| | | void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString); |
| | | |
| | | DeferredResult<String> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| | | DeferredResult<String> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| | | DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| | | DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| | | |
| | | void zlmServerOffline(String mediaServerId); |
| | | |
| | | DeferredResult<String> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| | | DeferredResult<String> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| | | DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); |
| | | DeferredResult<WVPResult<StreamInfo>> 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); |
| | | |
| | |
| | | */ |
| | | public class PlayBackResult<T> { |
| | | private int code; |
| | | |
| | | private String msg; |
| | | private T data; |
| | | private MediaServerItem mediaServerItem; |
| | | private JSONObject response; |
| | |
| | | public void setEvent(SipSubscribe.EventResult<EventObject> event) { |
| | | this.event = event; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public void setMsg(String msg) { |
| | | this.msg = msg; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DeferredResult<String> playBack(String deviceId, String channelId, String startTime, |
| | | public DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime, |
| | | String endTime,InviteStreamCallback inviteStreamCallback, |
| | | PlayBackCallback callback) { |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DeferredResult<String> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, |
| | | public DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, |
| | | String deviceId, String channelId, String startTime, |
| | | String endTime, InviteStreamCallback infoCallBack, |
| | | PlayBackCallback playBackCallback) { |
| | |
| | | if (device == null) { |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在"); |
| | | } |
| | | DeferredResult<String> result = new DeferredResult<>(30000L); |
| | | DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(30000L); |
| | | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid, result); |
| | | RequestMessage requestMessage = new RequestMessage(); |
| | | requestMessage.setId(uuid); |
| | |
| | | String playBackTimeOutTaskKey = UUID.randomUUID().toString(); |
| | | dynamicTask.startDelay(playBackTimeOutTaskKey, ()->{ |
| | | logger.warn(String.format("设备回放超时,deviceId:%s ,channelId:%s", deviceId, channelId)); |
| | | playBackResult.setCode(-1); |
| | | playBackResult.setCode(ErrorCode.ERROR100.getCode()); |
| | | playBackResult.setMsg("回放超时"); |
| | | playBackResult.setData(requestMessage); |
| | | SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); |
| | | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 |
| | |
| | | cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); |
| | | // 回复之前所有的点播请求 |
| | | playBackCallback.call(playBackResult); |
| | | result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "回放超时")); |
| | | resultHolder.exist(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid); |
| | | }, userSetting.getPlayTimeout()); |
| | | |
| | | cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack, |
| | |
| | | StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); |
| | | if (streamInfo == null) { |
| | | logger.warn("设备回放API调用失败!"); |
| | | playBackResult.setCode(-1); |
| | | playBackResult.setCode(ErrorCode.ERROR100.getCode()); |
| | | playBackResult.setMsg("设备回放API调用失败!"); |
| | | playBackCallback.call(playBackResult); |
| | | return; |
| | | } |
| | | redisCatchStorage.startPlayback(streamInfo, inviteStreamInfo.getCallId()); |
| | | WVPResult<StreamInfo> success = WVPResult.success(streamInfo); |
| | | requestMessage.setData(success); |
| | | playBackResult.setCode(0); |
| | | playBackResult.setCode(ErrorCode.SUCCESS.getCode()); |
| | | playBackResult.setMsg(ErrorCode.SUCCESS.getMsg()); |
| | | playBackResult.setData(requestMessage); |
| | | playBackResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); |
| | | playBackResult.setResponse(inviteStreamInfo.getResponse()); |
| | |
| | | }, event -> { |
| | | dynamicTask.stop(playBackTimeOutTaskKey); |
| | | requestMessage.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg))); |
| | | playBackResult.setCode(-1); |
| | | playBackResult.setCode(ErrorCode.ERROR100.getCode()); |
| | | playBackResult.setMsg(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg)); |
| | | playBackResult.setData(requestMessage); |
| | | playBackResult.setEvent(event); |
| | | playBackCallback.call(playBackResult); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DeferredResult<String> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { |
| | | public DeferredResult<WVPResult<StreamInfo>> 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; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DeferredResult<String> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { |
| | | public DeferredResult<WVPResult<StreamInfo>> 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<String> result = new DeferredResult<>(30000L); |
| | | DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(30000L); |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | if (device == null) { |
| | | throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "不存在"); |
| | |
| | | logger.warn(String.format("录像下载请求超时,deviceId:%s ,channelId:%s", deviceId, channelId)); |
| | | wvpResult.setCode(ErrorCode.ERROR100.getCode()); |
| | | wvpResult.setMsg("录像下载请求超时"); |
| | | downloadResult.setCode(-1); |
| | | downloadResult.setCode(ErrorCode.ERROR100.getCode()); |
| | | downloadResult.setMsg("录像下载请求超时"); |
| | | hookCallBack.call(downloadResult); |
| | | SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); |
| | | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 |
| | |
| | | wvpResult.setCode(ErrorCode.SUCCESS.getCode()); |
| | | wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); |
| | | wvpResult.setData(streamInfo); |
| | | downloadResult.setCode(0); |
| | | downloadResult.setCode(ErrorCode.SUCCESS.getCode()); |
| | | downloadResult.setMsg(ErrorCode.SUCCESS.getMsg()); |
| | | downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); |
| | | downloadResult.setResponse(inviteStreamInfo.getResponse()); |
| | | hookCallBack.call(downloadResult); |
| | | }, event -> { |
| | | dynamicTask.stop(downLoadTimeOutTaskKey); |
| | | downloadResult.setCode(-1); |
| | | downloadResult.setCode(ErrorCode.ERROR100.getCode()); |
| | | downloadResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg)); |
| | | wvpResult.setCode(ErrorCode.ERROR100.getCode()); |
| | | wvpResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg)); |
| | | downloadResult.setEvent(event); |
| | |
| | | import com.genersoft.iot.vmp.common.StreamInfo; |
| | | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| | | 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.WVPResult; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | @Parameter(name = "startTime", description = "开始时间", required = true) |
| | | @Parameter(name = "endTime", description = "结束时间", required = true) |
| | | @GetMapping("/start/{deviceId}/{channelId}") |
| | | public DeferredResult<String> play(@PathVariable String deviceId, @PathVariable String channelId, |
| | | String startTime,String endTime) { |
| | | public DeferredResult<WVPResult<StreamInfo>> 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)); |
| | |
| | | |
| | | |
| | | return playService.playBack(deviceId, channelId, startTime, endTime, null, |
| | | playBackResult->resultHolder.invokeResult(playBackResult.getData())); |
| | | playBackResult->{ |
| | | if (playBackResult.getCode() != ErrorCode.SUCCESS.getCode()) { |
| | | RequestMessage data = playBackResult.getData(); |
| | | data.setData(WVPResult.fail(playBackResult.getCode(), playBackResult.getMsg())); |
| | | resultHolder.invokeResult(data); |
| | | }else { |
| | | resultHolder.invokeResult(playBackResult.getData()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | @Parameter(name = "endTime", description = "结束时间", required = true) |
| | | @Parameter(name = "downloadSpeed", description = "下载倍速", required = true) |
| | | @GetMapping("/download/start/{deviceId}/{channelId}") |
| | | public DeferredResult<String> download(@PathVariable String deviceId, @PathVariable String channelId, |
| | | public DeferredResult<WVPResult<StreamInfo>> 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<String> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{ |
| | | DeferredResult<WVPResult<StreamInfo>> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{ |
| | | resultHolder.invokeResult(hookCallBack.getData()); |
| | | }); |
| | | |
| | |
| | | url: '/api/gb_record/query/' + this.deviceId + '/' + this.channelId + '?startTime=' + startTime + '&endTime=' + endTime |
| | | }).then(function (res) { |
| | | console.log(res) |
| | | that.recordsLoading = false; |
| | | if(res.data.code === 0) { |
| | | // 处理时间信息 |
| | | that.videoHistory.searchHistoryResult = res.data.data.recordList; |
| | | that.recordsLoading = false; |
| | | }else { |
| | | this.$message({ |
| | | showClose: true, |
| | |
| | | that.mediaServerId = that.streamInfo.mediaServerId; |
| | | that.ssrc = that.streamInfo.ssrc; |
| | | that.videoUrl = that.getUrlByStreamInfo(); |
| | | }else { |
| | | that.$message({ |
| | | showClose: true, |
| | | message: res.data.msg, |
| | | type: "error", |
| | | }); |
| | | } |
| | | that.recordPlay = true; |
| | | }); |