From 560165b6679f96f04cd3f8f6d5709b1214afddfb Mon Sep 17 00:00:00 2001 From: wangyimeng <421132955@qq.com> Date: 星期六, 26 二月 2022 11:14:56 +0800 Subject: [PATCH] 增加拉流代理修改功能 --- src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java | 79 +++++++++++++++++++++++++++++++++++---- 1 files changed, 70 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java index 8914fc1..5f02b2a 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java @@ -1,9 +1,14 @@ package com.genersoft.iot.vmp.vmanager.streamProxy; import com.alibaba.fastjson.JSONObject; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; +import com.genersoft.iot.vmp.service.IMediaServerService; +import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.service.IStreamProxyService; +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -13,8 +18,10 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; +@SuppressWarnings("rawtypes") /** * 鎷夋祦浠g悊鎺ュ彛 */ @@ -28,6 +35,10 @@ @Autowired private IRedisCatchStorage redisCatchStorage; + + + @Autowired + private IMediaServerService mediaServerService; @Autowired private IStreamProxyService streamProxyService; @@ -56,23 +67,73 @@ }) @PostMapping(value = "/save") @ResponseBody - public Object save(@RequestBody StreamProxyItem param){ + public WVPResult save(@RequestBody StreamProxyItem param){ logger.info("娣诲姞浠g悊锛� " + JSONObject.toJSONString(param)); - streamProxyService.save(param); - return "success"; + if (StringUtils.isEmpty(param.getMediaServerId())) param.setMediaServerId("auto"); + if (StringUtils.isEmpty(param.getType())) param.setType("default"); + if (StringUtils.isEmpty(param.getGbId())) param.setGbId(null); + WVPResult<StreamInfo> result = streamProxyService.save(param); + return result; + } + @ApiOperation("淇敼浠g悊") + @ApiImplicitParams({ + @ApiImplicitParam(name = "param", value = "浠g悊鍙傛暟", dataTypeClass = StreamProxyItem.class), + }) + @PostMapping(value = "/update") + @ResponseBody + public WVPResult update(@RequestBody StreamProxyItem param){ + logger.info("淇敼浠g悊锛� " + JSONObject.toJSONString(param)); + WVPResult<StreamInfo> result = new WVPResult<>(); + if(StringUtils.isEmpty(param.getApp())||StringUtils.isEmpty(param.getStream())){ + result.setCode(400); + result.setMsg("app涓嶈兘涓簄ull涓攕tream涓嶈兘涓簄ull锛岃妫�鏌ュ叿浣撳弬鏁帮紒"); + return result; + } + streamProxyService.del(param.getApp(), param.getStream()); + if (StringUtils.isEmpty(param.getMediaServerId())) param.setMediaServerId("auto"); + if (StringUtils.isEmpty(param.getType())) param.setType("default"); + if (StringUtils.isEmpty(param.getGbId())) param.setGbId(null); + param.setEnable(false); + result = streamProxyService.save(param); + return result; + } + @ApiOperation("鑾峰彇ffmpeg.cmd妯℃澘") + @GetMapping(value = "/ffmpeg_cmd/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "mediaServerId", value = "娴佸獟浣揑D", dataTypeClass = String.class), + }) + @ResponseBody + public WVPResult getFFmpegCMDs(@RequestParam String mediaServerId){ + logger.debug("鑾峰彇鑺傜偣[ {} ]ffmpeg.cmd妯℃澘", mediaServerId ); + + MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); + JSONObject data = streamProxyService.getFFmpegCMDs(mediaServerItem); + WVPResult<JSONObject> result = new WVPResult<>(); + result.setCode(0); + result.setMsg("success"); + result.setData(data); + return result; } @ApiOperation("绉婚櫎浠g悊") @ApiImplicitParams({ - @ApiImplicitParam(name = "app", value = "搴旂敤鍚�", dataTypeClass = String.class), - @ApiImplicitParam(name = "stream", value = "娴両D", dataTypeClass = String.class), + @ApiImplicitParam(name = "app", value = "搴旂敤鍚�", required = true, dataTypeClass = String.class), + @ApiImplicitParam(name = "stream", value = "娴両D", required = true, dataTypeClass = String.class), }) @DeleteMapping(value = "/del") @ResponseBody - public Object del(String app, String stream){ + public WVPResult del(@RequestParam String app, @RequestParam String stream){ logger.info("绉婚櫎浠g悊锛� " + app + "/" + stream); - streamProxyService.del(app, stream); - return "success"; + WVPResult<Object> result = new WVPResult<>(); + if (app == null || stream == null) { + result.setCode(400); + result.setMsg(app == null ?"app涓嶈兘涓簄ull":"stream涓嶈兘涓簄ull"); + }else { + streamProxyService.del(app, stream); + result.setCode(0); + result.setMsg("success"); + } + return result; } @ApiOperation("鍚敤浠g悊") @@ -85,7 +146,7 @@ public Object start(String app, String stream){ logger.info("鍚敤浠g悊锛� " + app + "/" + stream); boolean result = streamProxyService.start(app, stream); - return "success"; + return result?"success":"fail"; } @ApiOperation("鍋滅敤浠g悊") -- Gitblit v1.8.0