From 28d47f89b436bef7138d1f187839f2aa8e892596 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Sun, 1 Oct 2023 03:30:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=BA=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E7=9A=84zlm=20=E6=9C=8D=E5=8A=A1=20=E5=B9=B6?= =?UTF-8?q?=20hook=20=E8=A7=86=E9=A2=91=20=E5=85=88=20ffmpeg=20=E6=8E=A8?= =?UTF-8?q?=E6=B5=81=E5=88=B0=20zlm=20=E5=86=8D=E7=94=B1zlm=E6=90=BA?= =?UTF-8?q?=E5=B8=A6=20ssrc=20=E6=8E=A8=E6=B5=81=E5=88=B0=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=20=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/device/DeviceProxyService.java | 24 +++++++++---------- .../zlm/hook/ZlmStreamChangeHookService.java | 2 +- 2 files changed, 13 insertions(+), 13 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 9e18111..7b3765a 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 @@ -80,12 +80,6 @@ public class DeviceProxyService { Flow.Subscriber subscriber = byeSubscriber(key, device, callbackTask); subscribe.getByeSubscribe().addSubscribe(key, subscriber); taskNum.getAndIncrement(); - FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); - OpenRtpServerResp openRtpServerResp = zlmMediaService.openRtpServer(new OpenRtpServer(0, 0, key)); - log.info("openRtpServerResp {}",openRtpServerResp); - Integer port = openRtpServerResp.getPort(); - String zlmRtpUrl = "rtp://" + zlmMediaConfig.getIp() + ":" + port; - Executor executor = pushRtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); zlmStreamChangeHookService.handlerMap.put(key,()->{ StartSendRtp startSendRtp = new StartSendRtp(); startSendRtp.setApp("rtp"); @@ -98,6 +92,12 @@ public class DeviceProxyService { StartSendRtpResp startSendRtpResp = zlmMediaService.startSendRtp(startSendRtp); log.info("startSendRtpResp {}",startSendRtpResp); }); + FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); + OpenRtpServerResp openRtpServerResp = zlmMediaService.openRtpServer(new OpenRtpServer(0, 0, key)); + log.info("openRtpServerResp {}",openRtpServerResp); + Integer port = openRtpServerResp.getPort(); + String zlmRtpUrl = "rtp://" + zlmMediaConfig.getIp() + ":" + port; + Executor executor = pushRtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS); callbackTask.put(device.getDeviceCode(), executor); executeResultHandler.waitFor(); @@ -112,11 +112,6 @@ public class DeviceProxyService { Flow.Subscriber subscriber = byeSubscriber(key, device, downloadTask); subscribe.getByeSubscribe().addSubscribe(key, subscriber); taskNum.getAndIncrement(); - FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); - OpenRtpServerResp openRtpServerResp = zlmMediaService.openRtpServer(new OpenRtpServer(0, 0, key)); - Integer port = openRtpServerResp.getPort(); - String zlmRtpUrl = "rtp://" + zlmMediaConfig.getIp() + ":" + port; - Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); zlmStreamChangeHookService.handlerMap.put(key,()->{ StartSendRtp startSendRtp = new StartSendRtp(); startSendRtp.setApp("rtp"); @@ -129,8 +124,13 @@ public class DeviceProxyService { StartSendRtpResp startSendRtpResp = zlmMediaService.startSendRtp(startSendRtp); log.info("startSendRtpResp {}",startSendRtpResp); }); - downloadTask.put(device.getDeviceCode(), executor); + FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); + OpenRtpServerResp openRtpServerResp = zlmMediaService.openRtpServer(new OpenRtpServer(0, 0, key)); + Integer port = openRtpServerResp.getPort(); + String zlmRtpUrl = "rtp://" + zlmMediaConfig.getIp() + ":" + port; + Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS); + downloadTask.put(device.getDeviceCode(), executor); executeResultHandler.waitFor(); }; } diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/zlm/hook/ZlmStreamChangeHookService.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/zlm/hook/ZlmStreamChangeHookService.java index 911c72c..b73f5a1 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/zlm/hook/ZlmStreamChangeHookService.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/zlm/hook/ZlmStreamChangeHookService.java @@ -16,7 +16,7 @@ public class ZlmStreamChangeHookService { public ConcurrentMap handlerMap = new ConcurrentHashMap<>(); - synchronized public void processEvent(String streamId, Boolean regist){ + public void processEvent(String streamId, Boolean regist){ if(!regist){ return; }