From 39467e9cfbb115eb25fca20165c0ec8bb0bf0a93 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Sun, 25 Feb 2024 03:30:25 +0800 Subject: [PATCH] =?UTF-8?q?zlm=20=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E8=BE=83=E4=B9=85=20=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=85=A8=E9=80=9F=E6=8E=A8=E6=B5=81=E6=97=B6=20=E4=BB=8E=20rtm?= =?UTF-8?q?p=20=E8=BD=AC=E6=8E=A8=20rtp=20=E6=9C=9F=E9=97=B4=20=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=20=E5=A4=A7=E9=87=8F=E6=95=B0=E6=8D=AE=20=E6=95=85?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E9=87=87=E7=94=A8=E6=9A=B4=E5=8A=9B=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E4=BB=A5=E6=9C=80=E5=BF=AB=E9=80=9F=E5=BA=A6=E5=90=AF?= =?UTF-8?q?=E5=8A=A8rtp=E8=BD=AC=E6=8E=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/device/DeviceProxyService.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 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 82eb82e..d59052d 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 @@ -114,11 +114,11 @@ public class DeviceProxyService { .retryIfException() .retryIfRuntimeException() // 重试间隔 - .withWaitStrategy(WaitStrategies.fixedWait(3, TimeUnit.SECONDS)) + .withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.MILLISECONDS)) // 重试次数 - .withStopStrategy(StopStrategies.stopAfterAttempt(3)) + .withStopStrategy(StopStrategies.stopAfterAttempt(1000)) .build(); - zlmStreamChangeHookService.getRegistHandler(DEFAULT_ZLM_APP).put(callId,()->{ + // zlmStreamChangeHookService.getRegistHandler(DEFAULT_ZLM_APP).put(callId,()->{ try { retryer.call(()->{ StartSendRtp startSendRtp = new StartSendRtp(); @@ -139,7 +139,7 @@ public class DeviceProxyService { .ifPresent(ZlmStreamChangeHookService.ZlmStreamChangeHookHandler::handler); throw new RuntimeException(e); } - }); + // }); // }); zlmStreamChangeHookService.getUnregistHandler(DEFAULT_ZLM_APP).put(callId,()->{ @@ -234,9 +234,16 @@ public class DeviceProxyService { Flow.Subscriber task = ffmpegTask(request, downloadTask, callId, key, device); try { String zlmRtpUrl = getZlmRtmpUrl(DEFAULT_ZLM_APP, callId); + scheduledExecutorService.submit(()->{ + try { + requestZlmPushStream(request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); - requestZlmPushStream(request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc); + scheduledExecutorService.schedule(task::onComplete, time + 60, TimeUnit.SECONDS); downloadTask.put(device.getDeviceCode(), executor); executeResultHandler.waitFor();