修复旧版本拉流代理的兼容接口

pull/1642/head
648540858 2024-09-18 14:32:40 +08:00
parent 0c642f3b58
commit c4076ed393
4 changed files with 44 additions and 25 deletions

View File

@ -37,7 +37,9 @@ public class SipSubscribe {
// @Scheduled(fixedRate= 100 * 60 * 60 )
@Scheduled(cron="0 0/5 * * * ?") //每5分钟执行一次
public void execute(){
if(log.isDebugEnabled()){
log.info("[定时任务] 清理过期的SIP订阅信息");
}
Instant instant = Instant.now().minusMillis(TimeUnit.MINUTES.toMillis(5));
@ -53,11 +55,13 @@ public class SipSubscribe {
errorTimeSubscribes.remove(key);
}
}
if(log.isDebugEnabled()){
log.debug("okTimeSubscribes.size:{}",okTimeSubscribes.size());
log.debug("okSubscribes.size:{}",okSubscribes.size());
log.debug("errorTimeSubscribes.size:{}",errorTimeSubscribes.size());
log.debug("errorSubscribes.size:{}",errorSubscribes.size());
}
}
public interface Event { void response(EventResult eventResult);
}

View File

@ -16,6 +16,9 @@ public class StreamProxyParam {
@Schema(description = "应用名")
private String app;
@Schema(description = "名称")
private String name;
@Schema(description = "流ID")
private String stream;
@ -64,7 +67,7 @@ public class StreamProxyParam {
streamProxy.setEnableRemoveNoneReader(enableRemoveNoneReader);
streamProxy.setEnableDisableNoneReader(enableDisableNoneReader);
streamProxy.setFfmpegCmdKey(ffmpegCmdKey);
streamProxy.setGbName(name);
return streamProxy;
}

View File

@ -87,7 +87,7 @@ public interface IStreamProxyService {
*/
ResourceBaseInfo getOverview();
StreamInfo add(StreamProxy streamProxy);
void add(StreamProxy streamProxy);
StreamProxy getStreamProxy(int id);

View File

@ -140,21 +140,35 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
public StreamInfo save(StreamProxyParam param) {
// 兼容旧接口
StreamProxy streamProxyInDb = getStreamProxyByAppAndStream(param.getApp(), param.getStream());
if (streamProxyInDb != null && streamProxyInDb.getPulling()) {
if (streamProxyInDb != null && streamProxyInDb.getPulling() != null && streamProxyInDb.getPulling()) {
playService.stopProxy(streamProxyInDb);
}
if (param.getMediaServerId().equals("auto")) {
param.setMediaServerId(null);
}
StreamProxy streamProxy = param.buildStreamProxy();
if (streamProxyInDb == null) {
return add(param.buildStreamProxy());
add(streamProxy);
} else {
try {
playService.stopProxy(streamProxyInDb);
} catch (ControllerException ignored) {
}
streamProxyMapper.delete(streamProxyInDb.getId());
return add(param.buildStreamProxy());
add(streamProxy);
}
if (param.isEnable()) {
return playService.startProxy(streamProxy);
} else {
return null;
}
}
@Override
@Transactional
public StreamInfo add(StreamProxy streamProxy) {
public void add(StreamProxy streamProxy) {
StreamProxy streamProxyInDb = streamProxyMapper.selectOneByAppAndStream(streamProxy.getApp(), streamProxy.getStream());
if (streamProxyInDb != null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "APP+STREAM已经存在");
@ -166,7 +180,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
streamProxy.setUpdateTime(DateUtil.getNow());
streamProxyMapper.add(streamProxy);
streamProxy.setStreamProxyId(streamProxy.getId());
return null;
}
@Override
@ -258,7 +271,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
}
@Override
public Map<String, String> getFFmpegCMDs(MediaServer mediaServer) {
return mediaServerService.getFFmpegCMDs(mediaServer);