Commit 0eee65bc424cbdb348052ba4ef6b91add28bc6a4

Authored by 648540858
1 parent 3f5eba1a

保存拉流代理返回结果添加streamInfo

src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
1 1 package com.genersoft.iot.vmp.service;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
  4 +import com.genersoft.iot.vmp.common.StreamInfo;
4 5 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
5 6 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
  7 +import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
6 8 import com.github.pagehelper.PageInfo;
7 9  
8 10 public interface IStreamProxyService {
... ... @@ -11,7 +13,7 @@ public interface IStreamProxyService {
11 13 * 保存视频代理
12 14 * @param param
13 15 */
14   - String save(StreamProxyItem param);
  16 + WVPResult<StreamInfo> save(StreamProxyItem param);
15 17  
16 18 /**
17 19 * 添加视频代理到zlm
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
1 1 package com.genersoft.iot.vmp.service.impl;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
  4 +import com.genersoft.iot.vmp.common.StreamInfo;
4 5 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
5 6 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
6 7 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
7 8 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
8 9 import com.genersoft.iot.vmp.service.IGbStreamService;
9 10 import com.genersoft.iot.vmp.service.IMediaServerService;
  11 +import com.genersoft.iot.vmp.service.IMediaService;
10 12 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
11 13 import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
12 14 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
13 15 import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
14 16 import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
15 17 import com.genersoft.iot.vmp.service.IStreamProxyService;
  18 +import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
16 19 import com.github.pagehelper.PageInfo;
17 20 import org.slf4j.Logger;
18 21 import org.slf4j.LoggerFactory;
... ... @@ -34,7 +37,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
34 37 private IVideoManagerStorager videoManagerStorager;
35 38  
36 39 @Autowired
37   - private IRedisCatchStorage redisCatchStorage;
  40 + private IMediaService mediaService;
38 41  
39 42 @Autowired
40 43 private ZLMRESTfulUtils zlmresTfulUtils;;
... ... @@ -56,8 +59,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
56 59  
57 60  
58 61 @Override
59   - public String save(StreamProxyItem param) {
  62 + public WVPResult<StreamInfo> save(StreamProxyItem param) {
60 63 MediaServerItem mediaInfo;
  64 + WVPResult<StreamInfo> wvpResult = new WVPResult<>();
  65 + wvpResult.setCode(0);
61 66 if ("auto".equals(param.getMediaServerId())){
62 67 mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
63 68 }else {
... ... @@ -65,7 +70,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
65 70 }
66 71 if (mediaInfo == null) {
67 72 logger.warn("保存代理未找到在线的ZLM...");
68   - return "保存失败";
  73 + wvpResult.setMsg("保存失败");
  74 + return wvpResult;
69 75 }
70 76 String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(),
71 77 param.getStream() );
... ... @@ -83,6 +89,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
83 89 result.append(", 但是启用失败,请检查流地址是否可用");
84 90 param.setEnable(false);
85 91 videoManagerStorager.updateStreamProxy(param);
  92 + }else {
  93 + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
  94 + mediaInfo, param.getApp(), param.getStream(), null);
  95 + wvpResult.setData(streamInfo);
86 96 }
87 97 }
88 98 }
... ... @@ -97,6 +107,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
97 107 result.append(", 但是启用失败,请检查流地址是否可用");
98 108 param.setEnable(false);
99 109 videoManagerStorager.updateStreamProxy(param);
  110 + }else {
  111 + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
  112 + mediaInfo, param.getApp(), param.getStream(), null);
  113 + wvpResult.setData(streamInfo);
100 114 }
101 115 }
102 116 }else {
... ... @@ -113,7 +127,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
113 127 result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败");
114 128 }
115 129 }
116   - return result.toString();
  130 + wvpResult.setMsg(result.toString());
  131 + return wvpResult;
117 132 }
118 133  
119 134 @Override
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java
1 1 package com.genersoft.iot.vmp.vmanager.streamProxy;
2 2  
3 3 import com.alibaba.fastjson.JSONObject;
  4 +import com.genersoft.iot.vmp.common.StreamInfo;
4 5 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
5 6 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
6 7 import com.genersoft.iot.vmp.service.IMediaServerService;
  8 +import com.genersoft.iot.vmp.service.IMediaService;
7 9 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
8 10 import com.genersoft.iot.vmp.service.IStreamProxyService;
9 11 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
... ... @@ -68,10 +70,7 @@ public class StreamProxyController {
68 70 public WVPResult save(@RequestBody StreamProxyItem param){
69 71 logger.info("添加代理: " + JSONObject.toJSONString(param));
70 72 if (StringUtils.isEmpty(param.getMediaServerId())) param.setMediaServerId("auto");
71   - String msg = streamProxyService.save(param);
72   - WVPResult<Object> result = new WVPResult<>();
73   - result.setCode(0);
74   - result.setMsg(msg);
  73 + WVPResult<StreamInfo> result = streamProxyService.save(param);
75 74 return result;
76 75 }
77 76  
... ...
web_src/src/components/dialog/StreamProxyEdit.vue
... ... @@ -160,7 +160,7 @@ export default {
160 160 type: "default",
161 161 app: null,
162 162 stream: null,
163   - url: "rtmp://58.200.131.2/livetv/cctv5hd",
  163 + url: "",
164 164 src_url: null,
165 165 timeout_ms: null,
166 166 ffmpeg_cmd_key: null,
... ...