From 20082441ef5f6d62b93d572cc5dfebb3616bea9a Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 24 十一月 2021 15:09:43 +0800 Subject: [PATCH] 拉流代理接口添加无人观看则自动移除参数,拉流代理返回值增加流地址信息 --- src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index bbcad1c..3ffc68e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -1,18 +1,21 @@ package com.genersoft.iot.vmp.service.impl; import com.alibaba.fastjson.JSONObject; +import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.service.IGbStreamService; 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.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; import com.genersoft.iot.vmp.service.IStreamProxyService; +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +37,7 @@ private IVideoManagerStorager videoManagerStorager; @Autowired - private IRedisCatchStorage redisCatchStorage; + private IMediaService mediaService; @Autowired private ZLMRESTfulUtils zlmresTfulUtils;; @@ -56,8 +59,10 @@ @Override - public String save(StreamProxyItem param) { + public WVPResult<StreamInfo> save(StreamProxyItem param) { MediaServerItem mediaInfo; + WVPResult<StreamInfo> wvpResult = new WVPResult<>(); + wvpResult.setCode(0); if ("auto".equals(param.getMediaServerId())){ mediaInfo = mediaServerService.getMediaServerForMinimumLoad(); }else { @@ -65,7 +70,8 @@ } if (mediaInfo == null) { logger.warn("淇濆瓨浠g悊鏈壘鍒板湪绾跨殑ZLM..."); - return "淇濆瓨澶辫触"; + wvpResult.setMsg("淇濆瓨澶辫触"); + return wvpResult; } String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(), param.getStream() ); @@ -83,6 +89,10 @@ result.append(", 浣嗘槸鍚敤澶辫触锛岃妫�鏌ユ祦鍦板潃鏄惁鍙敤"); param.setEnable(false); videoManagerStorager.updateStreamProxy(param); + }else { + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream( + mediaInfo, param.getApp(), param.getStream(), null); + wvpResult.setData(streamInfo); } } } @@ -97,6 +107,10 @@ result.append(", 浣嗘槸鍚敤澶辫触锛岃妫�鏌ユ祦鍦板潃鏄惁鍙敤"); param.setEnable(false); videoManagerStorager.updateStreamProxy(param); + }else { + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream( + mediaInfo, param.getApp(), param.getStream(), null); + wvpResult.setData(streamInfo); } } }else { @@ -113,7 +127,8 @@ result.append(", 鍏宠仈鍥芥爣骞冲彴[ " + param.getPlatformGbId() + " ]澶辫触"); } } - return result.toString(); + wvpResult.setMsg(result.toString()); + return wvpResult; } @Override @@ -213,4 +228,10 @@ return result; } + + + @Override + public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) { + return videoManagerStorager.getStreamProxyByAppAndStream(app, streamId); + } } -- Gitblit v1.8.0