diff --git a/src/main/java/com/genersoft/iot/vmp/media/IMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/IMediaNodeServerService.java index c72c7e23..992379d6 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/IMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/IMediaNodeServerService.java @@ -10,9 +10,9 @@ public interface IMediaNodeServerService { void closeRtpServer(MediaServerItem mediaServerItem, String streamId, CommonCallback callback); - void closeStreams(MediaServerItem mediaServerItem, String rtp, String streamId); + void closeStreams(MediaServerItem mediaServerItem, String app, String stream); - Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc); + Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String stream, String ssrc); boolean checkNodeId(MediaServerItem mediaServerItem); diff --git a/src/main/java/com/genersoft/iot/vmp/media/abl/ABLMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/abl/ABLMediaNodeServerService.java index 6e86153d..0c65b2fc 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/abl/ABLMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/abl/ABLMediaNodeServerService.java @@ -1,8 +1,45 @@ package com.genersoft.iot.vmp.media.abl; +import com.genersoft.iot.vmp.common.CommonCallback; import com.genersoft.iot.vmp.media.IMediaNodeServerService; +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import org.springframework.stereotype.Service; @Service("abl") public class ABLMediaNodeServerService implements IMediaNodeServerService { + + @Override + public int createRTPServer(MediaServerItem mediaServerItem, String streamId, long ssrc, Integer port, Boolean onlyAuto, Boolean reUsePort, Integer tcpMode) { + return 0; + } + + @Override + public void closeRtpServer(MediaServerItem mediaServerItem, String streamId) { + + } + + @Override + public void closeRtpServer(MediaServerItem mediaServerItem, String streamId, CommonCallback callback) { + + } + + @Override + public void closeStreams(MediaServerItem mediaServerItem, String rtp, String streamId) { + + } + + @Override + public Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc) { + return null; + } + + @Override + public boolean checkNodeId(MediaServerItem mediaServerItem) { + return false; + } + + @Override + public void online(MediaServerItem mediaServerItem) { + + } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/media/impl/MediaServerServiceImpl.java index 4e8ed274..4a03f1ea 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/media/impl/MediaServerServiceImpl.java @@ -352,6 +352,9 @@ public class MediaServerServiceImpl implements IMediaServerService { logger.info("[添加媒体节点] 失败, mediaServerItem的类型:为空"); return; } + if (mediaServerMapper.queryOne(mediaServerItem.getId()) != null) { + throw new ControllerException(ErrorCode.ERROR100.getCode(),"保存失败,媒体服务ID [ " + mediaServerItem.getId() + " ] 已存在,请修改媒体服务器配置"); + } IMediaNodeServerService mediaNodeServerService = nodeServerServiceMap.get(mediaServerItem.getType()); if (mediaNodeServerService == null) { logger.info("[添加媒体节点] 失败, mediaServerItem的类型: {},未找到对应的实现类", mediaServerItem.getType()); diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java index 4b9013cf..7694967b 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java @@ -1,9 +1,71 @@ package com.genersoft.iot.vmp.media.zlm; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.genersoft.iot.vmp.common.CommonCallback; import com.genersoft.iot.vmp.media.IMediaNodeServerService; +import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; @Service("zlm") public class ZLMMediaNodeServerService implements IMediaNodeServerService { + + @Autowired + private ZLMRESTfulUtils zlmresTfulUtils; + + @Autowired + private ZLMServerFactory zlmServerFactory; + + @Override + public int createRTPServer(MediaServerItem mediaServerItem, String streamId, long ssrc, Integer port, Boolean onlyAuto, Boolean reUsePort, Integer tcpMode) { + return zlmServerFactory.createRTPServer(mediaServerItem, streamId, ssrc, port, onlyAuto, reUsePort, tcpMode);; + } + + @Override + public void closeRtpServer(MediaServerItem mediaServerItem, String streamId) { + zlmresTfulUtils.closeStreams(mediaServerItem, "rtp", streamId); + } + + @Override + public void closeRtpServer(MediaServerItem mediaServerItem, String streamId, CommonCallback callback) { + zlmServerFactory.closeRtpServer(mediaServerItem, streamId, callback); + } + + @Override + public void closeStreams(MediaServerItem mediaServerItem, String app, String stream) { + zlmresTfulUtils.closeStreams(mediaServerItem, app, stream); + } + + @Override + public Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc) { + return zlmServerFactory.updateRtpServerSSRC(mediaServerItem, streamId, ssrc); + } + + @Override + public boolean checkNodeId(MediaServerItem mediaServerItem) { + if (mediaServerItem == null) { + return false; + } + JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); + if (responseJSON != null) { + JSONArray data = responseJSON.getJSONArray("data"); + if (data != null && !data.isEmpty()) { + ZLMServerConfig zlmServerConfig= JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); + return zlmServerConfig.getGeneralMediaServerId().equals(mediaServerItem.getId()); + }else { + return false; + } + + }else { + return false; + } + } + + @Override + public void online(MediaServerItem mediaServerItem) { + + } }