Commit 41d9c347bf648a49fc11fbd4c451298f164230ec

Authored by tonyjianhua
1 parent 19533c8f

优化拉流代理保存

src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
@@ -161,25 +161,24 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -161,25 +161,24 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
161 return; 161 return;
162 } 162 }
163 163
164 - String talkKey = UUID.randomUUID().toString();  
165 - dynamicTask.startCron(talkKey, ()->{  
166 - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false);  
167 - if (streamInfo != null) {  
168 - callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);  
169 - }  
170 - }, 1000);  
171 - String delayTalkKey = UUID.randomUUID().toString();  
172 - dynamicTask.startDelay(delayTalkKey, ()->{  
173 - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false);  
174 - if (streamInfo != null) {  
175 - callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);  
176 - }else {  
177 - dynamicTask.stop(talkKey);  
178 - callback.run(ErrorCode.ERROR100.getCode(), "超时", null);  
179 - }  
180 - }, 5000);  
181 -  
182 if (param.isEnable()) { 164 if (param.isEnable()) {
  165 + String talkKey = UUID.randomUUID().toString();
  166 + dynamicTask.startCron(talkKey, ()->{
  167 + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false);
  168 + if (streamInfo != null) {
  169 + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
  170 + }
  171 + }, 1000);
  172 + String delayTalkKey = UUID.randomUUID().toString();
  173 + dynamicTask.startDelay(delayTalkKey, ()->{
  174 + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false);
  175 + if (streamInfo != null) {
  176 + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
  177 + }else {
  178 + dynamicTask.stop(talkKey);
  179 + callback.run(ErrorCode.ERROR100.getCode(), "超时", null);
  180 + }
  181 + }, 5000);
183 JSONObject jsonObject = addStreamProxyToZlm(param); 182 JSONObject jsonObject = addStreamProxyToZlm(param);
184 if (jsonObject != null && jsonObject.getInteger("code") == 0) { 183 if (jsonObject != null && jsonObject.getInteger("code") == 0) {
185 dynamicTask.stop(talkKey); 184 dynamicTask.stop(talkKey);
@@ -196,13 +195,16 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @@ -196,13 +195,16 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
196 } 195 }
197 if (jsonObject == null){ 196 if (jsonObject == null){
198 callback.run(ErrorCode.ERROR100.getCode(), "记录已保存,启用失败", null); 197 callback.run(ErrorCode.ERROR100.getCode(), "记录已保存,启用失败", null);
199 - return;  
200 }else { 198 }else {
201 callback.run(ErrorCode.ERROR100.getCode(), jsonObject.getString("msg"), null); 199 callback.run(ErrorCode.ERROR100.getCode(), jsonObject.getString("msg"), null);
202 - return;  
203 } 200 }
204 } 201 }
205 } 202 }
  203 + else{
  204 + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(
  205 + mediaInfo, param.getApp(), param.getStream(), null, null);
  206 + callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo);
  207 + }
206 } 208 }
207 209
208 private String getSchemaFromFFmpegCmd(String ffmpegCmd) { 210 private String getSchemaFromFFmpegCmd(String ffmpegCmd) {