From 8f77d0c25cdd37d4cc96c923b46ae28607bae51d Mon Sep 17 00:00:00 2001 From: jiang <893224616@qq.com> Date: 星期四, 18 八月 2022 16:17:23 +0800 Subject: [PATCH] 根据redis消息更新推流列表 --- src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 106 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java index 0c34f74..c978ae6 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java @@ -3,13 +3,20 @@ import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelReader; import com.alibaba.excel.read.metadata.ReadSheet; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.conf.security.SecurityUtils; +import com.genersoft.iot.vmp.conf.security.dto.LoginUser; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; +import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.IMediaServerService; +import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.impl.StreamPushUploadFileHandler; +import com.genersoft.iot.vmp.vmanager.bean.BatchGBStreamParam; import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; @@ -29,6 +36,7 @@ import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; @@ -52,6 +60,12 @@ @Autowired private DeferredResultHolder resultHolder; + + @Autowired + private IMediaService mediaService; + + @Autowired + private UserSetting userSetting; @ApiOperation("鎺ㄦ祦鍒楄〃鏌ヨ") @ApiImplicitParams({ @@ -116,13 +130,32 @@ }) @PostMapping(value = "/stop") @ResponseBody - public Object removeFormGB(@RequestParam(required = true)String app, @RequestParam(required = true)String streamId){ + public Object stop(String app, String streamId){ if (streamPushService.stop(app, streamId)){ return "success"; }else { return "fail"; } } + + @ApiOperation("涓澶氫釜鎺ㄦ祦") + @ApiImplicitParams({ + @ApiImplicitParam(name = "app", value = "搴旂敤鍚�", required = true, dataTypeClass = String.class), + @ApiImplicitParam(name = "streamId", value = "娴両D", required = true, dataTypeClass = String.class), + }) + @DeleteMapping(value = "/batchStop") + @ResponseBody + public Object batchStop(@RequestBody BatchGBStreamParam batchGBStreamParam){ + if (batchGBStreamParam.getGbStreams().size() == 0) { + return "fail"; + } + if (streamPushService.batchStop(batchGBStreamParam.getGbStreams())){ + return "success"; + }else { + return "fail"; + } + } + @PostMapping(value = "upload") @ResponseBody public DeferredResult<ResponseEntity<WVPResult<Object>>> uploadChannelFile(@RequestParam(value = "file") MultipartFile file){ @@ -148,16 +181,6 @@ result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult)); return result; } -// if (!file.getContentType().endsWith(".xls") -// && !file.getContentType().endsWith(".csv") -// && !file.getContentType().endsWith(".xlsx") ) { -// logger.warn("閫氶亾瀵煎叆鏂囦欢绫诲瀷閿欒: {}",file.getContentType() ); -// WVPResult<Object> wvpResult = new WVPResult<>(); -// wvpResult.setCode(-1); -// wvpResult.setMsg("鏂囦欢绫诲瀷閿欒锛岃浣跨敤"); -// result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult)); -// return result; -// } // 鍚屾椂鍙鐞嗕竴涓枃浠� if (resultHolder.exist(key, null)) { logger.warn("宸叉湁瀵煎叆浠诲姟姝e湪鎵ц"); @@ -227,5 +250,77 @@ return result; } + /** + * 鑾峰彇鎺ㄦ祦鎾斁鍦板潃 + * @param app 搴旂敤鍚� + * @param stream 娴乮d + * @return + */ + @ApiOperation("鑾峰彇鎺ㄦ祦鎾斁鍦板潃") + @ApiImplicitParams({ + @ApiImplicitParam(name = "app", value = "搴旂敤鍚�", dataTypeClass = String.class), + @ApiImplicitParam(name = "stream", value = "娴乮d", dataTypeClass = String.class), + @ApiImplicitParam(name = "mediaServerId", value = "濯掍綋鏈嶅姟鍣╥d", dataTypeClass = String.class, required = false), + }) + @GetMapping(value = "/getPlayUrl") + @ResponseBody + public WVPResult<StreamInfo> getPlayUrl(@RequestParam String app,@RequestParam String stream, + @RequestParam(required = false) String mediaServerId){ + boolean authority = false; + // 鏄惁鐧婚檰鐢ㄦ埛, 鐧婚檰鐢ㄦ埛杩斿洖瀹屾暣淇℃伅 + LoginUser userInfo = SecurityUtils.getUserInfo(); + if (userInfo!= null) { + authority = true; + } + WVPResult<StreamInfo> result = new WVPResult<>(); + StreamPushItem push = streamPushService.getPush(app, stream); + if (push != null && !push.isSelf()) { + result.setCode(-1); + result.setMsg("鏉ヨ嚜鍏朵粬骞冲彴鐨勬帹娴佷俊鎭�"); + return result; + } + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority); + if (streamInfo != null){ + result.setCode(0); + result.setMsg("success"); + result.setData(streamInfo); + }else { + result.setCode(-1); + result.setMsg("鑾峰彇鎾斁鍦板潃澶辫触"); + } + return result; + } + + /** + * 鑾峰彇鎺ㄦ祦鎾斁鍦板潃 + * @param stream 鎺ㄦ祦淇℃伅 + * @return + */ + @ApiOperation("鑾峰彇鎺ㄦ祦鎾斁鍦板潃") + @ApiImplicitParams({ + @ApiImplicitParam(name = "stream", value = "鎺ㄦ祦淇℃伅", dataTypeClass = StreamPushItem.class), + }) + @PostMapping(value = "/add") + @ResponseBody + public WVPResult<StreamInfo> add(@RequestBody StreamPushItem stream){ + if (StringUtils.isEmpty(stream.getGbId())) { + + return new WVPResult<>(400, "鍥芥爣ID涓嶅彲涓虹┖", null); + } + if (StringUtils.isEmpty(stream.getApp()) && StringUtils.isEmpty(stream.getStream())) { + return new WVPResult<>(400, "app鎴杝tream涓嶅彲涓虹┖", null); + } + stream.setStatus(false); + stream.setPushIng(false); + stream.setAliveSecond(0L); + stream.setTotalReaderCount("0"); + boolean result = streamPushService.add(stream); + + if (result) { + return new WVPResult<>(0, "success", null); + }else { + return new WVPResult<>(-1, "fail", null); + } + } } -- Gitblit v1.8.0