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