From 8c581b7eead45b41a153d4d662034e10f19c3d19 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Sun, 8 Oct 2023 10:53:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=BD=BF=E7=94=A8=20zlmStrea?= =?UTF-8?q?mProxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mocking/config/sip/ZlmHookConfig.java | 1 - .../service/device/DeviceProxyService.java | 47 +++++-------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmHookConfig.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmHookConfig.java index 75547a0..003b7e3 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmHookConfig.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmHookConfig.java @@ -13,5 +13,4 @@ public class ZlmHookConfig { private String hook; private Duration delay = Duration.ofMillis(100); private Duration fixed = Duration.ofSeconds(30); - private Boolean proxy = true; } 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 df234f0..44658b4 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 @@ -11,7 +11,6 @@ import cn.skcks.docking.gb28181.core.sip.gb28181.sdp.GB28181Description; import cn.skcks.docking.gb28181.core.sip.message.subscribe.GenericSubscribe; import cn.skcks.docking.gb28181.core.sip.utils.SipUtil; import cn.skcks.docking.gb28181.media.config.ZlmMediaConfig; -import cn.skcks.docking.gb28181.media.dto.proxy.AddStreamProxy; import cn.skcks.docking.gb28181.media.dto.rtp.StartSendRtp; import cn.skcks.docking.gb28181.media.dto.rtp.StartSendRtpResp; import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService; @@ -108,23 +107,12 @@ public class DeviceProxyService { zlmStreamChangeHookService.getUnregistHandler().put(callId,()->{ sendBye(request,device,key); }); - if(zlmHookConfig.getProxy()){ - AddStreamProxy addStreamProxy = AddStreamProxy.builder() - .app("live") - .stream(callId) - .url(fromUrl) - .timeoutSec(30.0) - .build(); - zlmMediaService.addStreamProxy(addStreamProxy); - scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS); - } else { - FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); - String zlmRtpUrl = "rtmp://" + zlmMediaConfig.getIp() + ":" + zlmRtmpConfig.getPort() + "/live/" + callId; - Executor executor = pushRtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); - scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS); - callbackTask.put(device.getDeviceCode(), executor); - executeResultHandler.waitFor(); - } + FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); + String zlmRtpUrl = "rtmp://" + zlmMediaConfig.getIp() + ":" + zlmRtmpConfig.getPort() + "/live/" + callId; + Executor executor = pushRtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); + scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS); + callbackTask.put(device.getDeviceCode(), executor); + executeResultHandler.waitFor(); } catch (Exception e) { throw new RuntimeException(e); } @@ -159,23 +147,12 @@ public class DeviceProxyService { zlmStreamChangeHookService.getUnregistHandler().put(callId,()->{ sendBye(request,device,key); }); - if(zlmHookConfig.getProxy()){ - AddStreamProxy addStreamProxy = AddStreamProxy.builder() - .app("live") - .stream(callId) - .url(fromUrl) - .timeoutSec(30.0) - .build(); - zlmMediaService.addStreamProxy(addStreamProxy); - scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS); - } else { - FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); - String zlmRtpUrl = "rtmp://" + zlmMediaConfig.getIp() + ":" + zlmRtmpConfig.getPort() + "/live/" + callId; - Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); - scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS); - downloadTask.put(device.getDeviceCode(), executor); - executeResultHandler.waitFor(); - } + FfmpegExecuteResultHandler executeResultHandler = mediaStatus(request, device, key); + String zlmRtpUrl = "rtmp://" + zlmMediaConfig.getIp() + ":" + zlmRtmpConfig.getPort() + "/live/" + callId; + Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); + scheduledExecutorService.schedule(subscriber::onComplete, time + 60, TimeUnit.SECONDS); + downloadTask.put(device.getDeviceCode(), executor); + executeResultHandler.waitFor(); } catch (Exception e) { throw new RuntimeException(e); }