优化拉流代理保存

pull/957/head
tonyjianhua 2023-07-19 13:33:53 +08:00
parent 19533c8f4d
commit 41d9c347bf
1 changed files with 22 additions and 20 deletions

View File

@ -161,6 +161,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
return; return;
} }
if (param.isEnable()) {
String talkKey = UUID.randomUUID().toString(); String talkKey = UUID.randomUUID().toString();
dynamicTask.startCron(talkKey, ()->{ dynamicTask.startCron(talkKey, ()->{
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false); StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false);
@ -178,8 +179,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
callback.run(ErrorCode.ERROR100.getCode(), "超时", null); callback.run(ErrorCode.ERROR100.getCode(), "超时", null);
} }
}, 5000); }, 5000);
if (param.isEnable()) {
JSONObject jsonObject = addStreamProxyToZlm(param); JSONObject jsonObject = addStreamProxyToZlm(param);
if (jsonObject != null && jsonObject.getInteger("code") == 0) { if (jsonObject != null && jsonObject.getInteger("code") == 0) {
dynamicTask.stop(talkKey); dynamicTask.stop(talkKey);
@ -196,13 +195,16 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
} }
if (jsonObject == null){ if (jsonObject == null){
callback.run(ErrorCode.ERROR100.getCode(), "记录已保存,启用失败", null); callback.run(ErrorCode.ERROR100.getCode(), "记录已保存,启用失败", null);
return;
}else { }else {
callback.run(ErrorCode.ERROR100.getCode(), jsonObject.getString("msg"), null); callback.run(ErrorCode.ERROR100.getCode(), jsonObject.getString("msg"), null);
return;
} }
} }
} }
else{
StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
mediaInfo, param.getApp(), param.getStream(), null, null);
callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
}
} }
private String getSchemaFromFFmpegCmd(String ffmpegCmd) { private String getSchemaFromFFmpegCmd(String ffmpegCmd) {