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