Commit 020f9ea8a05165979afe6a1736abcce29ed6a2f8
Merge branch 'wvp-28181-2.0'
# Conflicts: # src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
Showing
6 changed files
with
59 additions
and
23 deletions
src/main/java/com/genersoft/iot/vmp/service/IPlayService.java
| ... | ... | @@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.service.bean.InviteTimeOutCallback; |
| 12 | 12 | import com.genersoft.iot.vmp.service.bean.PlayBackCallback; |
| 13 | 13 | import com.genersoft.iot.vmp.service.bean.SSRCInfo; |
| 14 | 14 | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.AudioBroadcastEvent; |
| 15 | +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | |
| 15 | 16 | import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; |
| 16 | 17 | import org.springframework.http.ResponseEntity; |
| 17 | 18 | import org.springframework.web.context.request.async.DeferredResult; |
| ... | ... | @@ -32,13 +33,13 @@ public interface IPlayService { |
| 32 | 33 | |
| 33 | 34 | void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString); |
| 34 | 35 | |
| 35 | - DeferredResult<String> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); | |
| 36 | - DeferredResult<String> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); | |
| 36 | + DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); | |
| 37 | + DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); | |
| 37 | 38 | |
| 38 | 39 | void zlmServerOffline(String mediaServerId); |
| 39 | 40 | |
| 40 | - DeferredResult<String> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); | |
| 41 | - DeferredResult<String> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); | |
| 41 | + DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); | |
| 42 | + DeferredResult<WVPResult<StreamInfo>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack); | |
| 42 | 43 | |
| 43 | 44 | StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream); |
| 44 | 45 | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackResult.java
| ... | ... | @@ -12,6 +12,8 @@ import java.util.EventObject; |
| 12 | 12 | */ |
| 13 | 13 | public class PlayBackResult<T> { |
| 14 | 14 | private int code; |
| 15 | + | |
| 16 | + private String msg; | |
| 15 | 17 | private T data; |
| 16 | 18 | private MediaServerItem mediaServerItem; |
| 17 | 19 | private JSONObject response; |
| ... | ... | @@ -56,4 +58,12 @@ public class PlayBackResult<T> { |
| 56 | 58 | public void setEvent(SipSubscribe.EventResult<EventObject> event) { |
| 57 | 59 | this.event = event; |
| 58 | 60 | } |
| 61 | + | |
| 62 | + public String getMsg() { | |
| 63 | + return msg; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public void setMsg(String msg) { | |
| 67 | + this.msg = msg; | |
| 68 | + } | |
| 59 | 69 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
| ... | ... | @@ -410,7 +410,7 @@ public class PlayServiceImpl implements IPlayService { |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | @Override |
| 413 | - public DeferredResult<String> playBack(String deviceId, String channelId, String startTime, | |
| 413 | + public DeferredResult<WVPResult<StreamInfo>> playBack(String deviceId, String channelId, String startTime, | |
| 414 | 414 | String endTime,InviteStreamCallback inviteStreamCallback, |
| 415 | 415 | PlayBackCallback callback) { |
| 416 | 416 | Device device = storager.queryVideoDevice(deviceId); |
| ... | ... | @@ -424,7 +424,7 @@ public class PlayServiceImpl implements IPlayService { |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | @Override |
| 427 | - public DeferredResult<String> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, | |
| 427 | + public DeferredResult<WVPResult<StreamInfo>> playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, | |
| 428 | 428 | String deviceId, String channelId, String startTime, |
| 429 | 429 | String endTime, InviteStreamCallback infoCallBack, |
| 430 | 430 | PlayBackCallback playBackCallback) { |
| ... | ... | @@ -437,7 +437,7 @@ public class PlayServiceImpl implements IPlayService { |
| 437 | 437 | if (device == null) { |
| 438 | 438 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在"); |
| 439 | 439 | } |
| 440 | - DeferredResult<String> result = new DeferredResult<>(30000L); | |
| 440 | + DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(30000L); | |
| 441 | 441 | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid, result); |
| 442 | 442 | RequestMessage requestMessage = new RequestMessage(); |
| 443 | 443 | requestMessage.setId(uuid); |
| ... | ... | @@ -446,7 +446,8 @@ public class PlayServiceImpl implements IPlayService { |
| 446 | 446 | String playBackTimeOutTaskKey = UUID.randomUUID().toString(); |
| 447 | 447 | dynamicTask.startDelay(playBackTimeOutTaskKey, ()->{ |
| 448 | 448 | logger.warn(String.format("设备回放超时,deviceId:%s ,channelId:%s", deviceId, channelId)); |
| 449 | - playBackResult.setCode(-1); | |
| 449 | + playBackResult.setCode(ErrorCode.ERROR100.getCode()); | |
| 450 | + playBackResult.setMsg("回放超时"); | |
| 450 | 451 | playBackResult.setData(requestMessage); |
| 451 | 452 | SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); |
| 452 | 453 | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 |
| ... | ... | @@ -461,6 +462,8 @@ public class PlayServiceImpl implements IPlayService { |
| 461 | 462 | cmder.streamByeCmd(device.getDeviceId(), channelId, ssrcInfo.getStream(), null); |
| 462 | 463 | // 回复之前所有的点播请求 |
| 463 | 464 | playBackCallback.call(playBackResult); |
| 465 | + result.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "回放超时")); | |
| 466 | + resultHolder.exist(DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId, uuid); | |
| 464 | 467 | }, userSetting.getPlayTimeout()); |
| 465 | 468 | |
| 466 | 469 | cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack, |
| ... | ... | @@ -470,14 +473,16 @@ public class PlayServiceImpl implements IPlayService { |
| 470 | 473 | StreamInfo streamInfo = onPublishHandler(inviteStreamInfo.getMediaServerItem(), inviteStreamInfo.getResponse(), deviceId, channelId); |
| 471 | 474 | if (streamInfo == null) { |
| 472 | 475 | logger.warn("设备回放API调用失败!"); |
| 473 | - playBackResult.setCode(-1); | |
| 476 | + playBackResult.setCode(ErrorCode.ERROR100.getCode()); | |
| 477 | + playBackResult.setMsg("设备回放API调用失败!"); | |
| 474 | 478 | playBackCallback.call(playBackResult); |
| 475 | 479 | return; |
| 476 | 480 | } |
| 477 | 481 | redisCatchStorage.startPlayback(streamInfo, inviteStreamInfo.getCallId()); |
| 478 | 482 | WVPResult<StreamInfo> success = WVPResult.success(streamInfo); |
| 479 | 483 | requestMessage.setData(success); |
| 480 | - playBackResult.setCode(0); | |
| 484 | + playBackResult.setCode(ErrorCode.SUCCESS.getCode()); | |
| 485 | + playBackResult.setMsg(ErrorCode.SUCCESS.getMsg()); | |
| 481 | 486 | playBackResult.setData(requestMessage); |
| 482 | 487 | playBackResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); |
| 483 | 488 | playBackResult.setResponse(inviteStreamInfo.getResponse()); |
| ... | ... | @@ -485,7 +490,8 @@ public class PlayServiceImpl implements IPlayService { |
| 485 | 490 | }, event -> { |
| 486 | 491 | dynamicTask.stop(playBackTimeOutTaskKey); |
| 487 | 492 | requestMessage.setData(WVPResult.fail(ErrorCode.ERROR100.getCode(), String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg))); |
| 488 | - playBackResult.setCode(-1); | |
| 493 | + playBackResult.setCode(ErrorCode.ERROR100.getCode()); | |
| 494 | + playBackResult.setMsg(String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg)); | |
| 489 | 495 | playBackResult.setData(requestMessage); |
| 490 | 496 | playBackResult.setEvent(event); |
| 491 | 497 | playBackCallback.call(playBackResult); |
| ... | ... | @@ -495,7 +501,7 @@ public class PlayServiceImpl implements IPlayService { |
| 495 | 501 | } |
| 496 | 502 | |
| 497 | 503 | @Override |
| 498 | - public DeferredResult<String> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { | |
| 504 | + public DeferredResult<WVPResult<StreamInfo>> download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { | |
| 499 | 505 | Device device = storager.queryVideoDevice(deviceId); |
| 500 | 506 | if (device == null) { |
| 501 | 507 | return null; |
| ... | ... | @@ -507,13 +513,13 @@ public class PlayServiceImpl implements IPlayService { |
| 507 | 513 | } |
| 508 | 514 | |
| 509 | 515 | @Override |
| 510 | - public DeferredResult<String> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { | |
| 516 | + public DeferredResult<WVPResult<StreamInfo>> download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) { | |
| 511 | 517 | if (mediaServerItem == null || ssrcInfo == null) { |
| 512 | 518 | return null; |
| 513 | 519 | } |
| 514 | 520 | String uuid = UUID.randomUUID().toString(); |
| 515 | 521 | String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId; |
| 516 | - DeferredResult<String> result = new DeferredResult<>(30000L); | |
| 522 | + DeferredResult<WVPResult<StreamInfo>> result = new DeferredResult<>(30000L); | |
| 517 | 523 | Device device = storager.queryVideoDevice(deviceId); |
| 518 | 524 | if (device == null) { |
| 519 | 525 | throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "不存在"); |
| ... | ... | @@ -533,7 +539,8 @@ public class PlayServiceImpl implements IPlayService { |
| 533 | 539 | logger.warn(String.format("录像下载请求超时,deviceId:%s ,channelId:%s", deviceId, channelId)); |
| 534 | 540 | wvpResult.setCode(ErrorCode.ERROR100.getCode()); |
| 535 | 541 | wvpResult.setMsg("录像下载请求超时"); |
| 536 | - downloadResult.setCode(-1); | |
| 542 | + downloadResult.setCode(ErrorCode.ERROR100.getCode()); | |
| 543 | + downloadResult.setMsg("录像下载请求超时"); | |
| 537 | 544 | hookCallBack.call(downloadResult); |
| 538 | 545 | SIPDialog dialog = streamSession.getDialogByStream(deviceId, channelId, ssrcInfo.getStream()); |
| 539 | 546 | // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 |
| ... | ... | @@ -568,13 +575,15 @@ public class PlayServiceImpl implements IPlayService { |
| 568 | 575 | wvpResult.setCode(ErrorCode.SUCCESS.getCode()); |
| 569 | 576 | wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); |
| 570 | 577 | wvpResult.setData(streamInfo); |
| 571 | - downloadResult.setCode(0); | |
| 578 | + downloadResult.setCode(ErrorCode.SUCCESS.getCode()); | |
| 579 | + downloadResult.setMsg(ErrorCode.SUCCESS.getMsg()); | |
| 572 | 580 | downloadResult.setMediaServerItem(inviteStreamInfo.getMediaServerItem()); |
| 573 | 581 | downloadResult.setResponse(inviteStreamInfo.getResponse()); |
| 574 | 582 | hookCallBack.call(downloadResult); |
| 575 | 583 | }, event -> { |
| 576 | 584 | dynamicTask.stop(downLoadTimeOutTaskKey); |
| 577 | - downloadResult.setCode(-1); | |
| 585 | + downloadResult.setCode(ErrorCode.ERROR100.getCode()); | |
| 586 | + downloadResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg)); | |
| 578 | 587 | wvpResult.setCode(ErrorCode.ERROR100.getCode()); |
| 579 | 588 | wvpResult.setMsg(String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg)); |
| 580 | 589 | downloadResult.setEvent(event); | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java
| ... | ... | @@ -3,9 +3,11 @@ package com.genersoft.iot.vmp.vmanager.gb28181.playback; |
| 3 | 3 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 4 | 4 | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 6 | +import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | |
| 6 | 7 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 7 | 8 | import com.genersoft.iot.vmp.service.IPlayService; |
| 8 | 9 | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| 10 | +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; | |
| 9 | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | 12 | import io.swagger.v3.oas.annotations.Parameter; |
| 11 | 13 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -57,8 +59,8 @@ public class PlaybackController { |
| 57 | 59 | @Parameter(name = "startTime", description = "开始时间", required = true) |
| 58 | 60 | @Parameter(name = "endTime", description = "结束时间", required = true) |
| 59 | 61 | @GetMapping("/start/{deviceId}/{channelId}") |
| 60 | - public DeferredResult<String> play(@PathVariable String deviceId, @PathVariable String channelId, | |
| 61 | - String startTime,String endTime) { | |
| 62 | + public DeferredResult<WVPResult<StreamInfo>> play(@PathVariable String deviceId, @PathVariable String channelId, | |
| 63 | + String startTime, String endTime) { | |
| 62 | 64 | |
| 63 | 65 | if (logger.isDebugEnabled()) { |
| 64 | 66 | logger.debug(String.format("设备回放 API调用,deviceId:%s ,channelId:%s", deviceId, channelId)); |
| ... | ... | @@ -66,7 +68,15 @@ public class PlaybackController { |
| 66 | 68 | |
| 67 | 69 | |
| 68 | 70 | return playService.playBack(deviceId, channelId, startTime, endTime, null, |
| 69 | - playBackResult->resultHolder.invokeResult(playBackResult.getData())); | |
| 71 | + playBackResult->{ | |
| 72 | + if (playBackResult.getCode() != ErrorCode.SUCCESS.getCode()) { | |
| 73 | + RequestMessage data = playBackResult.getData(); | |
| 74 | + data.setData(WVPResult.fail(playBackResult.getCode(), playBackResult.getMsg())); | |
| 75 | + resultHolder.invokeResult(data); | |
| 76 | + }else { | |
| 77 | + resultHolder.invokeResult(playBackResult.getData()); | |
| 78 | + } | |
| 79 | + }); | |
| 70 | 80 | } |
| 71 | 81 | |
| 72 | 82 | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java
| ... | ... | @@ -110,14 +110,14 @@ public class GBRecordController { |
| 110 | 110 | @Parameter(name = "endTime", description = "结束时间", required = true) |
| 111 | 111 | @Parameter(name = "downloadSpeed", description = "下载倍速", required = true) |
| 112 | 112 | @GetMapping("/download/start/{deviceId}/{channelId}") |
| 113 | - public DeferredResult<String> download(@PathVariable String deviceId, @PathVariable String channelId, | |
| 113 | + public DeferredResult<WVPResult<StreamInfo>> download(@PathVariable String deviceId, @PathVariable String channelId, | |
| 114 | 114 | String startTime, String endTime, String downloadSpeed) { |
| 115 | 115 | |
| 116 | 116 | if (logger.isDebugEnabled()) { |
| 117 | 117 | logger.debug(String.format("历史媒体下载 API调用,deviceId:%s,channelId:%s,downloadSpeed:%s", deviceId, channelId, downloadSpeed)); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - DeferredResult<String> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{ | |
| 120 | + DeferredResult<WVPResult<StreamInfo>> result = playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), null, hookCallBack->{ | |
| 121 | 121 | resultHolder.invokeResult(hookCallBack.getData()); |
| 122 | 122 | }); |
| 123 | 123 | ... | ... |
web_src/src/components/dialog/devicePlayer.vue
| ... | ... | @@ -582,10 +582,10 @@ export default { |
| 582 | 582 | url: '/api/gb_record/query/' + this.deviceId + '/' + this.channelId + '?startTime=' + startTime + '&endTime=' + endTime |
| 583 | 583 | }).then(function (res) { |
| 584 | 584 | console.log(res) |
| 585 | + that.recordsLoading = false; | |
| 585 | 586 | if(res.data.code === 0) { |
| 586 | 587 | // 处理时间信息 |
| 587 | 588 | that.videoHistory.searchHistoryResult = res.data.data.recordList; |
| 588 | - that.recordsLoading = false; | |
| 589 | 589 | }else { |
| 590 | 590 | this.$message({ |
| 591 | 591 | showClose: true, |
| ... | ... | @@ -631,6 +631,12 @@ export default { |
| 631 | 631 | that.mediaServerId = that.streamInfo.mediaServerId; |
| 632 | 632 | that.ssrc = that.streamInfo.ssrc; |
| 633 | 633 | that.videoUrl = that.getUrlByStreamInfo(); |
| 634 | + }else { | |
| 635 | + that.$message({ | |
| 636 | + showClose: true, | |
| 637 | + message: res.data.msg, | |
| 638 | + type: "error", | |
| 639 | + }); | |
| 634 | 640 | } |
| 635 | 641 | that.recordPlay = true; |
| 636 | 642 | }); | ... | ... |