|  |  | 
 |  |  | 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 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") | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private IRedisCatchStorage redisCatchStorage; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private IMediaServerService mediaServerService; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private IStreamProxyService streamProxyService; | 
 |  |  | 
 |  |  |     @ResponseBody | 
 |  |  |     public WVPResult save(@RequestBody StreamProxyItem param){ | 
 |  |  |         logger.info("添加代理: " + JSONObject.toJSONString(param)); | 
 |  |  |         String msg = streamProxyService.save(param); | 
 |  |  |         WVPResult<Object> result = new WVPResult<>(); | 
 |  |  |         result.setCode(0); | 
 |  |  |         result.setMsg(msg); | 
 |  |  |         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("获取ffmpeg.cmd模板") | 
 |  |  |     @GetMapping(value = "/ffmpeg_cmd/list") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "mediaServerId", value = "流媒体ID", dataTypeClass = String.class), | 
 |  |  |     }) | 
 |  |  |     @ResponseBody | 
 |  |  |     public WVPResult getFFmpegCMDs(){ | 
 |  |  |         logger.debug("获取ffmpeg.cmd模板:" ); | 
 |  |  |         JSONObject data = streamProxyService.getFFmpegCMDs(); | 
 |  |  |     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"); | 
 |  |  | 
 |  |  |  | 
 |  |  |     @ApiOperation("移除代理") | 
 |  |  |     @ApiImplicitParams({ | 
 |  |  |             @ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class), | 
 |  |  |             @ApiImplicitParam(name = "stream", value = "流ID", dataTypeClass = String.class), | 
 |  |  |             @ApiImplicitParam(name = "app", value = "应用名", required = true, dataTypeClass = String.class), | 
 |  |  |             @ApiImplicitParam(name = "stream", value = "流ID", required = true, dataTypeClass = String.class), | 
 |  |  |     }) | 
 |  |  |     @DeleteMapping(value = "/del") | 
 |  |  |     @ResponseBody | 
 |  |  |     public WVPResult del(String app, String stream){ | 
 |  |  |     public WVPResult del(@RequestParam String app, @RequestParam String stream){ | 
 |  |  |         logger.info("移除代理: " + app + "/" + stream); | 
 |  |  |         WVPResult<Object> result = new WVPResult<>(); | 
 |  |  |         if (app == null || stream == null) { |