优化地图信息窗口逻辑,修复拉流代理播放
This commit is contained in:
@@ -588,11 +588,6 @@ public class ZLMRESTfulUtils {
|
||||
}
|
||||
|
||||
public ZLMResult<StreamProxyResult> addStreamProxy(MediaServer mediaServer, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type, Integer timeOut) {
|
||||
try {
|
||||
url = URLEncoder.encode(url, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(),"url编码失败");
|
||||
}
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("vhost", "__defaultVhost__");
|
||||
param.put("app", app);
|
||||
|
||||
@@ -282,12 +282,7 @@ public class MediaServiceImpl implements IMediaService {
|
||||
// 拉流代理
|
||||
StreamProxy streamProxy = streamProxyService.getStreamProxyByAppAndStream(app, stream);
|
||||
if (streamProxy != null) {
|
||||
if (streamProxy.isEnableRemoveNoneReader()) {
|
||||
// 无人观看自动移除
|
||||
streamProxyService.delteByAppAndStream(app, stream);
|
||||
log.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", app, stream, streamProxy.getSrcUrl());
|
||||
return true;
|
||||
} else if (streamProxy.isEnableDisableNoneReader()) {
|
||||
if (streamProxy.isEnableDisableNoneReader()) {
|
||||
// 无人观看停用
|
||||
// 修改数据
|
||||
streamProxyService.stopByAppAndStream(app, stream);
|
||||
|
||||
@@ -60,9 +60,6 @@ public class StreamProxy extends CommonGBChannel {
|
||||
@Schema(description = "是否启用MP4")
|
||||
private boolean enableMp4;
|
||||
|
||||
@Schema(description = "是否 无人观看时删除")
|
||||
private boolean enableRemoveNoneReader;
|
||||
|
||||
@Schema(description = "是否 无人观看时自动停用")
|
||||
private boolean enableDisableNoneReader;
|
||||
|
||||
|
||||
@@ -46,9 +46,6 @@ public class StreamProxyParam {
|
||||
@Schema(description = "是否启用MP4")
|
||||
private boolean enableMp4;
|
||||
|
||||
@Schema(description = "是否 无人观看时删除")
|
||||
private boolean enableRemoveNoneReader;
|
||||
|
||||
@Schema(description = "是否 无人观看时自动停用")
|
||||
private boolean enableDisableNoneReader;
|
||||
|
||||
@@ -65,7 +62,6 @@ public class StreamProxyParam {
|
||||
streamProxy.setEnable(enable);
|
||||
streamProxy.setEnableAudio(enableAudio);
|
||||
streamProxy.setEnableMp4(enableMp4);
|
||||
streamProxy.setEnableRemoveNoneReader(enableRemoveNoneReader);
|
||||
streamProxy.setEnableDisableNoneReader(enableDisableNoneReader);
|
||||
streamProxy.setFfmpegCmdKey(ffmpegCmdKey);
|
||||
streamProxy.setGbName(name);
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
|
||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxyParam;
|
||||
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyPlayService;
|
||||
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
@@ -21,6 +20,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -28,7 +28,6 @@ import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
@@ -89,54 +88,6 @@ public class StreamProxyController {
|
||||
return streamProxyService.getStreamProxyByAppAndStream(app, stream);
|
||||
}
|
||||
|
||||
@Operation(summary = "保存代理(已存在会覆盖)", security = @SecurityRequirement(name = JwtUtils.HEADER), parameters = {
|
||||
@Parameter(name = "param", description = "代理参数", required = true),
|
||||
})
|
||||
@PostMapping(value = "/save")
|
||||
@ResponseBody
|
||||
public DeferredResult<WVPResult<StreamContent>> save(HttpServletRequest request, @RequestBody StreamProxyParam param){
|
||||
log.info("添加代理: " + JSONObject.toJSONString(param));
|
||||
if (ObjectUtils.isEmpty(param.getMediaServerId())) {
|
||||
param.setMediaServerId("auto");
|
||||
}
|
||||
if (ObjectUtils.isEmpty(param.getType())) {
|
||||
param.setType("default");
|
||||
}
|
||||
DeferredResult<WVPResult<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
|
||||
ErrorCallback<StreamInfo> callback = (code, msg, streamInfo) -> {
|
||||
if (code == InviteErrorCode.SUCCESS.getCode()) {
|
||||
WVPResult<StreamContent> wvpResult = WVPResult.success();
|
||||
if (streamInfo != null) {
|
||||
if (userSetting.getUseSourceIpAsStreamIp()) {
|
||||
streamInfo=streamInfo.clone();//深拷贝
|
||||
String host;
|
||||
try {
|
||||
URL url=new URL(request.getRequestURL().toString());
|
||||
host=url.getHost();
|
||||
} catch (MalformedURLException e) {
|
||||
host=request.getLocalAddr();
|
||||
}
|
||||
streamInfo.changeStreamIp(host);
|
||||
}
|
||||
if (!ObjectUtils.isEmpty(streamInfo.getMediaServer().getTranscodeSuffix())
|
||||
&& !"null".equalsIgnoreCase(streamInfo.getMediaServer().getTranscodeSuffix())) {
|
||||
streamInfo.setStream(streamInfo.getStream() + "_" + streamInfo.getMediaServer().getTranscodeSuffix());
|
||||
}
|
||||
wvpResult.setData(new StreamContent(streamInfo));
|
||||
}else {
|
||||
wvpResult.setCode(code);
|
||||
wvpResult.setMsg(msg);
|
||||
}
|
||||
|
||||
result.setResult(wvpResult);
|
||||
}else {
|
||||
result.setResult(WVPResult.fail(code, msg));
|
||||
}
|
||||
};
|
||||
streamProxyService.save(param, callback);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "新增代理", security = @SecurityRequirement(name = JwtUtils.HEADER), parameters = {
|
||||
@Parameter(name = "param", description = "代理参数", required = true),
|
||||
})
|
||||
|
||||
@@ -13,10 +13,10 @@ public interface StreamProxyMapper {
|
||||
|
||||
@Insert("INSERT INTO wvp_stream_proxy (type, app, stream,relates_media_server_id, src_url, " +
|
||||
"timeout, ffmpeg_cmd_key, rtsp_type, enable_audio, enable_mp4, enable, pulling, " +
|
||||
"enable_remove_none_reader, enable_disable_none_reader, server_id, create_time) VALUES" +
|
||||
"enable_disable_none_reader, server_id, create_time) VALUES" +
|
||||
"(#{type}, #{app}, #{stream}, #{relatesMediaServerId}, #{srcUrl}, " +
|
||||
"#{timeout}, #{ffmpegCmdKey}, #{rtspType}, #{enableAudio}, #{enableMp4}, #{enable}, #{pulling}, " +
|
||||
"#{enableRemoveNoneReader}, #{enableDisableNoneReader}, #{serverId}, #{createTime} )")
|
||||
"#{enableDisableNoneReader}, #{serverId}, #{createTime} )")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
int add(StreamProxy streamProxyDto);
|
||||
|
||||
@@ -32,7 +32,6 @@ public interface StreamProxyMapper {
|
||||
"enable_audio=#{enableAudio}, " +
|
||||
"enable=#{enable}, " +
|
||||
"pulling=#{pulling}, " +
|
||||
"enable_remove_none_reader=#{enableRemoveNoneReader}, " +
|
||||
"enable_disable_none_reader=#{enableDisableNoneReader}, " +
|
||||
"enable_mp4=#{enableMp4} " +
|
||||
"WHERE id=#{id}")
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
|
||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxyParam;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
@@ -12,12 +11,6 @@ import java.util.Map;
|
||||
|
||||
public interface IStreamProxyService {
|
||||
|
||||
/**
|
||||
* 保存视频代理
|
||||
* @param param
|
||||
*/
|
||||
void save(StreamProxyParam param, ErrorCallback<StreamInfo> callback);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.genersoft.iot.vmp.media.zlm.dto.hook.OriginType;
|
||||
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
|
||||
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxyParam;
|
||||
import com.genersoft.iot.vmp.streamProxy.dao.StreamProxyMapper;
|
||||
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyPlayService;
|
||||
import com.genersoft.iot.vmp.streamProxy.service.IStreamProxyService;
|
||||
@@ -137,35 +136,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(StreamProxyParam param, ErrorCallback<StreamInfo> callback) {
|
||||
// 兼容旧接口
|
||||
StreamProxy streamProxyInDb = getStreamProxyByAppAndStream(param.getApp(), param.getStream());
|
||||
if (streamProxyInDb != null && streamProxyInDb.getPulling() != null && streamProxyInDb.getPulling()) {
|
||||
playService.stopProxy(streamProxyInDb);
|
||||
}
|
||||
if (param.getMediaServerId().equals("auto")) {
|
||||
param.setMediaServerId(null);
|
||||
}
|
||||
StreamProxy streamProxy = param.buildStreamProxy(userSetting.getServerId());
|
||||
|
||||
if (streamProxyInDb == null) {
|
||||
add(streamProxy);
|
||||
} else {
|
||||
try {
|
||||
playService.stopProxy(streamProxyInDb);
|
||||
} catch (ControllerException ignored) {
|
||||
}
|
||||
streamProxyMapper.delete(streamProxyInDb.getId());
|
||||
add(streamProxy);
|
||||
}
|
||||
|
||||
if (param.isEnable()) {
|
||||
playService.startProxy(streamProxy, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void add(StreamProxy streamProxy) {
|
||||
@@ -329,11 +299,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
streamProxy.setGbStatus("OFF");
|
||||
channelListForOffline.add(streamProxy.buildCommonGBChannel());
|
||||
}
|
||||
// 移除开启了无人观看自动移除的流
|
||||
if (streamProxy.getGbDeviceId() == null && streamProxy.isEnableRemoveNoneReader()) {
|
||||
streamProxiesForRemove.add(streamProxy);
|
||||
streamProxyMapForDb.remove(streamProxy.getApp() + streamProxy.getStream());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!channelListForOffline.isEmpty()) {
|
||||
@@ -360,7 +325,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
if (streamProxies.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<StreamProxy> streamProxiesForRemove = new ArrayList<>();
|
||||
List<StreamProxy> streamProxiesForSendMessage = new ArrayList<>();
|
||||
List<CommonGBChannel> channelListForOffline = new ArrayList<>();
|
||||
|
||||
@@ -368,18 +332,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||
if (streamProxy.getGbId() > 0 && "ON".equalsIgnoreCase(streamProxy.getGbStatus())) {
|
||||
channelListForOffline.add(streamProxy.buildCommonGBChannel());
|
||||
}
|
||||
if (streamProxy.getGbId() == 0 && streamProxy.isEnableRemoveNoneReader()) {
|
||||
streamProxiesForRemove.add(streamProxy);
|
||||
}
|
||||
if ("ON".equalsIgnoreCase(streamProxy.getGbStatus())) {
|
||||
streamProxiesForSendMessage.add(streamProxy);
|
||||
}
|
||||
}
|
||||
if (!streamProxiesForRemove.isEmpty()) {
|
||||
// 移除开启了无人观看自动移除的流
|
||||
streamProxyMapper.deleteByList(streamProxiesForRemove);
|
||||
}
|
||||
if (!streamProxiesForRemove.isEmpty()) {
|
||||
if (!channelListForOffline.isEmpty()) {
|
||||
// 修改国标关联的国标通道的状态
|
||||
gbChannelService.offline(channelListForOffline);
|
||||
}
|
||||
|
||||
@@ -351,6 +351,17 @@ public class CameraChannelService implements CommandLineRunner {
|
||||
*/
|
||||
private List<CameraChannel> addIconPathAndPositionForCameraChannelList(List<CameraChannel> channels, String geoCoordSys) {
|
||||
// 读取redis 图标信息
|
||||
/*
|
||||
{
|
||||
"brand": "三永",
|
||||
"createdTime": 1715845840000,
|
||||
"displayInSelect": true,
|
||||
"id": 12,
|
||||
"imagesPath": "images/lt132",
|
||||
"machineName": "图传对讲单兵",
|
||||
"machineType": "LT132"
|
||||
},
|
||||
*/
|
||||
JSONArray jsonArray = (JSONArray) redisTemplate.opsForValue().get("machineInfo");
|
||||
Map<String, String> pathMap = new HashMap<>();
|
||||
if (jsonArray != null && !jsonArray.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user