保存拉流代理返回结果添加streamInfo
This commit is contained in:
parent
3f5eba1a60
commit
0eee65bc42
@ -1,8 +1,10 @@
|
|||||||
package com.genersoft.iot.vmp.service;
|
package com.genersoft.iot.vmp.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
public interface IStreamProxyService {
|
public interface IStreamProxyService {
|
||||||
@ -11,7 +13,7 @@ public interface IStreamProxyService {
|
|||||||
* 保存视频代理
|
* 保存视频代理
|
||||||
* @param param
|
* @param param
|
||||||
*/
|
*/
|
||||||
String save(StreamProxyItem param);
|
WVPResult<StreamInfo> save(StreamProxyItem param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加视频代理到zlm
|
* 添加视频代理到zlm
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
package com.genersoft.iot.vmp.service.impl;
|
package com.genersoft.iot.vmp.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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.gb28181.bean.GbStream;
|
||||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
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.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||||
import com.genersoft.iot.vmp.service.IGbStreamService;
|
import com.genersoft.iot.vmp.service.IGbStreamService;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
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.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||||
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
|
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
|
||||||
import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
|
import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
|
||||||
import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
|
import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
|
||||||
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
||||||
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -34,7 +37,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||||||
private IVideoManagerStorager videoManagerStorager;
|
private IVideoManagerStorager videoManagerStorager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRedisCatchStorage redisCatchStorage;
|
private IMediaService mediaService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ZLMRESTfulUtils zlmresTfulUtils;;
|
private ZLMRESTfulUtils zlmresTfulUtils;;
|
||||||
@ -56,8 +59,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String save(StreamProxyItem param) {
|
public WVPResult<StreamInfo> save(StreamProxyItem param) {
|
||||||
MediaServerItem mediaInfo;
|
MediaServerItem mediaInfo;
|
||||||
|
WVPResult<StreamInfo> wvpResult = new WVPResult<>();
|
||||||
|
wvpResult.setCode(0);
|
||||||
if ("auto".equals(param.getMediaServerId())){
|
if ("auto".equals(param.getMediaServerId())){
|
||||||
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
|
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
|
||||||
}else {
|
}else {
|
||||||
@ -65,7 +70,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||||||
}
|
}
|
||||||
if (mediaInfo == null) {
|
if (mediaInfo == null) {
|
||||||
logger.warn("保存代理未找到在线的ZLM...");
|
logger.warn("保存代理未找到在线的ZLM...");
|
||||||
return "保存失败";
|
wvpResult.setMsg("保存失败");
|
||||||
|
return wvpResult;
|
||||||
}
|
}
|
||||||
String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(),
|
String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(),
|
||||||
param.getStream() );
|
param.getStream() );
|
||||||
@ -83,6 +89,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||||||
result.append(", 但是启用失败,请检查流地址是否可用");
|
result.append(", 但是启用失败,请检查流地址是否可用");
|
||||||
param.setEnable(false);
|
param.setEnable(false);
|
||||||
videoManagerStorager.updateStreamProxy(param);
|
videoManagerStorager.updateStreamProxy(param);
|
||||||
|
}else {
|
||||||
|
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
|
||||||
|
mediaInfo, param.getApp(), param.getStream(), null);
|
||||||
|
wvpResult.setData(streamInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,6 +107,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||||||
result.append(", 但是启用失败,请检查流地址是否可用");
|
result.append(", 但是启用失败,请检查流地址是否可用");
|
||||||
param.setEnable(false);
|
param.setEnable(false);
|
||||||
videoManagerStorager.updateStreamProxy(param);
|
videoManagerStorager.updateStreamProxy(param);
|
||||||
|
}else {
|
||||||
|
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
|
||||||
|
mediaInfo, param.getApp(), param.getStream(), null);
|
||||||
|
wvpResult.setData(streamInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
@ -113,7 +127,8 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
|||||||
result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败");
|
result.append(", 关联国标平台[ " + param.getPlatformGbId() + " ]失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.toString();
|
wvpResult.setMsg(result.toString());
|
||||||
|
return wvpResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.genersoft.iot.vmp.vmanager.streamProxy;
|
package com.genersoft.iot.vmp.vmanager.streamProxy;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
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.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||||
import com.genersoft.iot.vmp.service.IMediaServerService;
|
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.IRedisCatchStorage;
|
||||||
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
import com.genersoft.iot.vmp.service.IStreamProxyService;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
@ -68,10 +70,7 @@ public class StreamProxyController {
|
|||||||
public WVPResult save(@RequestBody StreamProxyItem param){
|
public WVPResult save(@RequestBody StreamProxyItem param){
|
||||||
logger.info("添加代理: " + JSONObject.toJSONString(param));
|
logger.info("添加代理: " + JSONObject.toJSONString(param));
|
||||||
if (StringUtils.isEmpty(param.getMediaServerId())) param.setMediaServerId("auto");
|
if (StringUtils.isEmpty(param.getMediaServerId())) param.setMediaServerId("auto");
|
||||||
String msg = streamProxyService.save(param);
|
WVPResult<StreamInfo> result = streamProxyService.save(param);
|
||||||
WVPResult<Object> result = new WVPResult<>();
|
|
||||||
result.setCode(0);
|
|
||||||
result.setMsg(msg);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ export default {
|
|||||||
type: "default",
|
type: "default",
|
||||||
app: null,
|
app: null,
|
||||||
stream: null,
|
stream: null,
|
||||||
url: "rtmp://58.200.131.2/livetv/cctv5hd",
|
url: "",
|
||||||
src_url: null,
|
src_url: null,
|
||||||
timeout_ms: null,
|
timeout_ms: null,
|
||||||
ffmpeg_cmd_key: null,
|
ffmpeg_cmd_key: null,
|
||||||
|
Loading…
Reference in New Issue
Block a user