实现部分优化后的接口

pull/1411/head
648540858 2024-03-18 23:56:27 +08:00
parent 1768565ce0
commit 620a4803da
4 changed files with 104 additions and 2 deletions

View File

@ -10,9 +10,9 @@ public interface IMediaNodeServerService {
void closeRtpServer(MediaServerItem mediaServerItem, String streamId, CommonCallback<Boolean> 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);

View File

@ -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<Boolean> 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) {
}
}

View File

@ -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());

View File

@ -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<Boolean> 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) {
}
}