DeviceProxyService 调整

This commit is contained in:
shikong 2024-03-14 10:53:57 +08:00
parent 28dfe97a5a
commit 39af43f7aa

View File

@ -198,9 +198,12 @@ public class DeviceProxyService {
public TaskProcessor playbackTask(){
return (Runnable sendOkResponse, SIPRequest request,String callId,String fromUrl, String toAddr,int toPort, MockingDevice device, String key, long time,String ssrc) -> {
scheduledExecutorService.schedule(() -> {
trying(request);
sendOkResponse.run();
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
log.error("{}", e.getMessage());
}
String ackKey = GenericSubscribe.Helper.getKey(Request.ACK, callId);
subscribe.getAckSubscribe().addPublisher(ackKey, 1, TimeUnit.MINUTES);
subscribe.getAckSubscribe().addSubscribe(ackKey, new Flow.Subscriber<>() {
@ -230,12 +233,13 @@ public class DeviceProxyService {
callbackTask.put(device.getDeviceCode(), executor);
executeResultHandler.waitFor();
} catch (Exception e) {
sendBye(request,device,"");
sendBye(request, device, "");
log.error("{}", e.getMessage());
}
}
});
}, 1, TimeUnit.SECONDS);
trying(request);
sendOkResponse.run();
};
}
@ -247,8 +251,6 @@ public class DeviceProxyService {
log.error("{}", e.getMessage());
}
trying(request);
sendOkResponse.run();
String ackKey = GenericSubscribe.Helper.getKey(Request.ACK, callId);
subscribe.getAckSubscribe().addPublisher(ackKey, 1, TimeUnit.MINUTES);
subscribe.getAckSubscribe().addSubscribe(ackKey, new Flow.Subscriber<>() {
@ -271,9 +273,9 @@ public class DeviceProxyService {
Flow.Subscriber<SIPRequest> task = ffmpegTask(request, downloadTask, callId, key, device);
try {
FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key);
if(!ffmpegConfig.getRtp().getUseRtpToDownload()){
if (!ffmpegConfig.getRtp().getUseRtpToDownload()) {
String zlmRtpUrl = getZlmRtmpUrl(DEFAULT_ZLM_APP, callId);
scheduledExecutorService.submit(()->{
scheduledExecutorService.submit(() -> {
try {
requestZlmPushStream(request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc);
} catch (Exception e) {
@ -297,7 +299,8 @@ public class DeviceProxyService {
}
}
});
trying(request);
sendOkResponse.run();
};
}