From 838efa92e2d8b1cf477ae358f3be24e2b5d04c15 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Tue, 6 Feb 2024 16:10:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE=20?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E6=97=B6=E9=97=B4=E8=8C=83=E5=9B=B4=E7=9A=84?= =?UTF-8?q?=20recordInfo=20=E6=9F=A5=E8=AF=A2,=20=E9=A2=84=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E8=A7=86=E9=A2=91=E6=96=87=E4=BB=B6=E5=88=B0=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=8C=87=E5=AE=9A=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/device/DeviceProxyService.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 f4cb15b..cff3854 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 @@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.URLUtil; +import cn.skcks.docking.gb28181.common.json.JsonResponse; import cn.skcks.docking.gb28181.common.redis.RedisUtil; import cn.skcks.docking.gb28181.common.xml.XmlUtils; import cn.skcks.docking.gb28181.core.sip.gb28181.cache.CacheUtil; @@ -23,6 +24,7 @@ import cn.skcks.docking.gb28181.media.dto.rtp.StopSendRtp; import cn.skcks.docking.gb28181.media.dto.status.ResponseStatus; import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService; import cn.skcks.docking.gb28181.mocking.config.sip.DeviceProxyConfig; +import cn.skcks.docking.gb28181.mocking.config.sip.FfmpegConfig; import cn.skcks.docking.gb28181.mocking.config.sip.ZlmHookConfig; import cn.skcks.docking.gb28181.mocking.config.sip.ZlmRtmpConfig; import cn.skcks.docking.gb28181.mocking.core.sip.message.processor.message.request.notify.dto.MediaStatusRequestDTO; @@ -30,6 +32,7 @@ import cn.skcks.docking.gb28181.mocking.core.sip.message.subscribe.SipSubscribe; import cn.skcks.docking.gb28181.mocking.core.sip.request.SipRequestBuilder; import cn.skcks.docking.gb28181.mocking.core.sip.response.SipResponseBuilder; import cn.skcks.docking.gb28181.mocking.core.sip.sender.SipSender; +import cn.skcks.docking.gb28181.mocking.core.sip.service.VideoCacheManager; import cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.model.MockingDevice; import cn.skcks.docking.gb28181.mocking.service.ffmpeg.FfmpegSupportService; import cn.skcks.docking.gb28181.mocking.service.zlm.hook.ZlmStreamChangeHookService; @@ -89,12 +92,15 @@ public class DeviceProxyService { private final ZlmMediaConfig zlmMediaConfig; private final ZlmStreamChangeHookService zlmStreamChangeHookService; private final ZlmRtmpConfig zlmRtmpConfig; + private final VideoCacheManager videoCacheManager; private final String DEFAULT_ZLM_APP = "live"; private final String ZLM_FFMPEG_PROXY_APP = "ffmpeg_proxy"; private final ZlmStreamNoneReaderHookService zlmStreamNoneReaderHookService; + private final FfmpegConfig ffmpegConfig; + ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); public interface TaskProcessor { @@ -491,7 +497,19 @@ public class DeviceProxyService { } } + @SneakyThrows private String getProxyUrl(MockingDevice device, Date startTime, Date endTime){ + if(proxyConfig.getPreDownloadForRecordInfo().getEnable() && !ffmpegConfig.getUseZlmFfmpeg()){ + CompletableFuture> task = videoCacheManager.get(device.getDeviceCode(), startTime, endTime); + if(task != null){ + if(task.isDone()){ + String file = task.get().getData(); + log.info("本地视频已缓存, 将从本地缓存推流, 缓存文件 => {}", file); + return file; + } + } + } + String fromUrl = URLUtil.completeUrl(proxyConfig.getUrl(), "/video"); HashMap map = new HashMap<>(3); String deviceCode = device.getDeviceCode();