From a5faf10138b3cf02fb5b8377ceff99e3fcb914c5 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Thu, 14 Dec 2023 16:47:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wvp/api/video/VideoController.java | 8 --- .../gb28181/Gb28181DownloadService.java | 53 +------------------ 2 files changed, 1 insertion(+), 60 deletions(-) diff --git a/gb28181-wvp-proxy-api/src/main/java/cn/skcks/docking/gb28181/wvp/api/video/VideoController.java b/gb28181-wvp-proxy-api/src/main/java/cn/skcks/docking/gb28181/wvp/api/video/VideoController.java index ad7eb18..4969b7c 100644 --- a/gb28181-wvp-proxy-api/src/main/java/cn/skcks/docking/gb28181/wvp/api/video/VideoController.java +++ b/gb28181-wvp-proxy-api/src/main/java/cn/skcks/docking/gb28181/wvp/api/video/VideoController.java @@ -85,14 +85,6 @@ public class VideoController { return gb28181DownloadService.realtimeVideoUrl(req.getDeviceCode()); } - @Operation(summary = "续签实时视频 +60s") - @GetMapping(value = "/device/realtime/renew") - @ResponseBody - public JsonResponse renew(@ParameterObject RealtimeVideoReq req) { - gb28181DownloadService.renewRealtimeVideoUrl(req.getDeviceCode()); - return JsonResponse.success(null); - } - @Operation(summary = "关闭实时视频") @GetMapping(value = "/device/realtime/close") @ResponseBody diff --git a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java index a3e973d..a671410 100644 --- a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java +++ b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java @@ -81,7 +81,6 @@ public class Gb28181DownloadService { private final WvpProxyConfig wvpProxyConfig; private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); private final ConcurrentMap>> requestMap = new ConcurrentHashMap<>(); - private final ConcurrentMap> realtimeMap = new ConcurrentHashMap<>(); private final ConcurrentMap realtimeVideoInfoMap = new ConcurrentHashMap<>(); @Getter @@ -249,8 +248,6 @@ public class Gb28181DownloadService { log.info("获取媒体信息 {}", videoInfo); String cacheKey = CacheUtil.getKey(docking.getGbDeviceId(), device.getGbDeviceChannelId()); realtimeVideoInfoMap.put(cacheKey, videoInfo); - String existCallId = RedisUtil.StringOps.get(cacheKey); - autoCloseRealtimeVideo(docking,device,videoInfo,cacheKey,existCallId); String url = StringUtils.isNotBlank(proxySipConfig.getProxyMediaUrl()) ? StringUtils.replace(videoInfo.getUrl(), zlmMediaConfig.getUrl(), proxySipConfig.getProxyMediaUrl()): videoInfo.getUrl(); @@ -260,45 +257,9 @@ public class Gb28181DownloadService { return result; } - public void renewRealtimeVideoUrl(String deviceCode){ - WvpProxyDevice device = deviceService.getDeviceByDeviceCode(deviceCode).orElse(null); - if(device == null){ - return; - } - WvpProxyDocking docking = dockingService.getDeviceByDeviceCode(device.getGbDeviceId()).orElse(null); - if(docking == null){ - return; - } - - String cacheKey = CacheUtil.getKey(docking.getGbDeviceId(), device.getGbDeviceChannelId()); - realtimeMap.computeIfPresent(cacheKey,(key, scheduledFuture) -> { - scheduledFuture.cancel(true); - return null; - }); - - autoCloseRealtimeVideo(deviceCode); - } - - public void autoCloseRealtimeVideo(String deviceCode){ - WvpProxyDevice device = deviceService.getDeviceByDeviceCode(deviceCode).orElse(null); - if(device == null){ - return; - } - WvpProxyDocking docking = dockingService.getDeviceByDeviceCode(device.getGbDeviceId()).orElse(null); - if(docking == null){ - return; - } - - String cacheKey = CacheUtil.getKey(docking.getGbDeviceId(), device.getGbDeviceChannelId()); - String existCallId = RedisUtil.StringOps.get(cacheKey); - realtimeVideoInfoMap.computeIfPresent(cacheKey, (key, videoInfo) -> { - autoCloseRealtimeVideo(docking,device,videoInfo,cacheKey,existCallId); - return videoInfo; - }); - } - private void closeExistRequest(String deviceCode, WvpProxyDevice device, WvpProxyDocking docking) { requestMap.computeIfPresent(deviceCode,(key,requestResult)->{ + log.info("关闭已存在的视频请求 {}", deviceCode); if(!requestResult.hasResult()){ requestResult.setResult(JsonResponse.error("同一设备重复请求, 本次请求结束")); String cacheKey = CacheUtil.getKey(docking.getGbDeviceId(), device.getGbDeviceChannelId()); @@ -315,14 +276,6 @@ public class Gb28181DownloadService { }); } - public void autoCloseRealtimeVideo(WvpProxyDocking docking, WvpProxyDevice device, Gb28181DownloadService.VideoInfo videoInfo, String cacheKey, String existCallId){ - ScheduledFuture schedule = scheduledExecutorService.schedule(() -> { - closeRealtimeVideoNow(docking, device, videoInfo, cacheKey, existCallId); - }, 60, TimeUnit.SECONDS); - - realtimeMap.put(cacheKey,schedule); - } - public void closeRealtimeVideoNow(String deviceCode){ WvpProxyDevice device = deviceService.getDeviceByDeviceCode(deviceCode).orElse(null); if(device == null){ @@ -337,10 +290,6 @@ public class Gb28181DownloadService { String existCallId = RedisUtil.StringOps.get(cacheKey); realtimeVideoInfoMap.computeIfPresent(cacheKey, (key, videoInfo) -> { closeRealtimeVideoNow(docking,device,videoInfo,cacheKey,existCallId); - realtimeMap.computeIfPresent(cacheKey,(k, scheduledFuture)->{ - scheduledFuture.cancel(true); - return null; - }); return null; }); }