From c280b5f40d93b946c7825df19a2f5be2175cfbb4 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Tue, 23 Jan 2024 15:31:34 +0800 Subject: [PATCH] =?UTF-8?q?ffmpeg=20=E5=A4=B1=E8=B4=A5=E6=97=B6=20?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=20trying=20=E4=BF=9D=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mocking/service/device/DeviceProxyService.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java index c205f21..be83237 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java @@ -170,7 +170,7 @@ public class DeviceProxyService { Flow.Subscriber task = ffmpegTask(request, callbackTask, callId, key, device); try { String zlmRtpUrl = requestZlmPushStream(schedule, sendOkResponse, request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc); - FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); + FfmpegExecuteResultHandler executeResultHandler = mediaStatus(schedule,request, device, key); Executor executor = pushRtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); scheduledExecutorService.schedule(task::onComplete, time + 60, TimeUnit.SECONDS); callbackTask.put(device.getDeviceCode(), executor); @@ -189,7 +189,7 @@ public class DeviceProxyService { Flow.Subscriber task = ffmpegTask(request, downloadTask, callId, key, device); try { String zlmRtpUrl = requestZlmPushStream(schedule, sendOkResponse, request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc); - FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); + FfmpegExecuteResultHandler executeResultHandler = mediaStatus(schedule, request, device, key); Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); scheduledExecutorService.schedule(task::onComplete, time + 60, TimeUnit.SECONDS); downloadTask.put(device.getDeviceCode(), executor); @@ -524,11 +524,14 @@ public class DeviceProxyService { @Setter(AccessLevel.PRIVATE) private boolean hasResult = false; + private final ScheduledFuture tryingSchedule; private final SIPRequest request; private final MockingDevice device; private final String key; private void close(){ + tryingSchedule.cancel(true); + CallIdHeader requestCallId = request.getCallId(); String callId = requestCallId.getCallId(); callbackTask.remove(callId); @@ -575,18 +578,16 @@ public class DeviceProxyService { mediaStatus(); } - @SneakyThrows @Override public void onProcessFailed(ExecuteException e) { hasResult = true; log.error("ffmpeg 执行失败", e); close(); - throw e; } } - public FfmpegExecuteResultHandler mediaStatus(SIPRequest request, MockingDevice device,String key){ - return new FfmpegExecuteResultHandler(request,device,key); + public FfmpegExecuteResultHandler mediaStatus(ScheduledFuture tryingSchedule,SIPRequest request, MockingDevice device,String key){ + return new FfmpegExecuteResultHandler(tryingSchedule,request,device,key); } /**