调整
This commit is contained in:
parent
cbba1c7be7
commit
a5faf10138
@ -85,14 +85,6 @@ public class VideoController {
|
|||||||
return gb28181DownloadService.realtimeVideoUrl(req.getDeviceCode());
|
return gb28181DownloadService.realtimeVideoUrl(req.getDeviceCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "续签实时视频 +60s")
|
|
||||||
@GetMapping(value = "/device/realtime/renew")
|
|
||||||
@ResponseBody
|
|
||||||
public JsonResponse<Void> renew(@ParameterObject RealtimeVideoReq req) {
|
|
||||||
gb28181DownloadService.renewRealtimeVideoUrl(req.getDeviceCode());
|
|
||||||
return JsonResponse.success(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "关闭实时视频")
|
@Operation(summary = "关闭实时视频")
|
||||||
@GetMapping(value = "/device/realtime/close")
|
@GetMapping(value = "/device/realtime/close")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
@ -81,7 +81,6 @@ public class Gb28181DownloadService {
|
|||||||
private final WvpProxyConfig wvpProxyConfig;
|
private final WvpProxyConfig wvpProxyConfig;
|
||||||
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
|
private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
|
||||||
private final ConcurrentMap<String, DeferredResult<JsonResponse<String>>> requestMap = new ConcurrentHashMap<>();
|
private final ConcurrentMap<String, DeferredResult<JsonResponse<String>>> requestMap = new ConcurrentHashMap<>();
|
||||||
private final ConcurrentMap<String, ScheduledFuture<?>> realtimeMap = new ConcurrentHashMap<>();
|
|
||||||
private final ConcurrentMap<String, VideoInfo> realtimeVideoInfoMap = new ConcurrentHashMap<>();
|
private final ConcurrentMap<String, VideoInfo> realtimeVideoInfoMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -249,8 +248,6 @@ public class Gb28181DownloadService {
|
|||||||
log.info("获取媒体信息 {}", videoInfo);
|
log.info("获取媒体信息 {}", videoInfo);
|
||||||
String cacheKey = CacheUtil.getKey(docking.getGbDeviceId(), device.getGbDeviceChannelId());
|
String cacheKey = CacheUtil.getKey(docking.getGbDeviceId(), device.getGbDeviceChannelId());
|
||||||
realtimeVideoInfoMap.put(cacheKey, videoInfo);
|
realtimeVideoInfoMap.put(cacheKey, videoInfo);
|
||||||
String existCallId = RedisUtil.StringOps.get(cacheKey);
|
|
||||||
autoCloseRealtimeVideo(docking,device,videoInfo,cacheKey,existCallId);
|
|
||||||
String url = StringUtils.isNotBlank(proxySipConfig.getProxyMediaUrl()) ?
|
String url = StringUtils.isNotBlank(proxySipConfig.getProxyMediaUrl()) ?
|
||||||
StringUtils.replace(videoInfo.getUrl(), zlmMediaConfig.getUrl(), proxySipConfig.getProxyMediaUrl()):
|
StringUtils.replace(videoInfo.getUrl(), zlmMediaConfig.getUrl(), proxySipConfig.getProxyMediaUrl()):
|
||||||
videoInfo.getUrl();
|
videoInfo.getUrl();
|
||||||
@ -260,45 +257,9 @@ public class Gb28181DownloadService {
|
|||||||
return result;
|
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) {
|
private void closeExistRequest(String deviceCode, WvpProxyDevice device, WvpProxyDocking docking) {
|
||||||
requestMap.computeIfPresent(deviceCode,(key,requestResult)->{
|
requestMap.computeIfPresent(deviceCode,(key,requestResult)->{
|
||||||
|
log.info("关闭已存在的视频请求 {}", deviceCode);
|
||||||
if(!requestResult.hasResult()){
|
if(!requestResult.hasResult()){
|
||||||
requestResult.setResult(JsonResponse.error("同一设备重复请求, 本次请求结束"));
|
requestResult.setResult(JsonResponse.error("同一设备重复请求, 本次请求结束"));
|
||||||
String cacheKey = CacheUtil.getKey(docking.getGbDeviceId(), device.getGbDeviceChannelId());
|
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){
|
public void closeRealtimeVideoNow(String deviceCode){
|
||||||
WvpProxyDevice device = deviceService.getDeviceByDeviceCode(deviceCode).orElse(null);
|
WvpProxyDevice device = deviceService.getDeviceByDeviceCode(deviceCode).orElse(null);
|
||||||
if(device == null){
|
if(device == null){
|
||||||
@ -337,10 +290,6 @@ public class Gb28181DownloadService {
|
|||||||
String existCallId = RedisUtil.StringOps.get(cacheKey);
|
String existCallId = RedisUtil.StringOps.get(cacheKey);
|
||||||
realtimeVideoInfoMap.computeIfPresent(cacheKey, (key, videoInfo) -> {
|
realtimeVideoInfoMap.computeIfPresent(cacheKey, (key, videoInfo) -> {
|
||||||
closeRealtimeVideoNow(docking,device,videoInfo,cacheKey,existCallId);
|
closeRealtimeVideoNow(docking,device,videoInfo,cacheKey,existCallId);
|
||||||
realtimeMap.computeIfPresent(cacheKey,(k, scheduledFuture)->{
|
|
||||||
scheduledFuture.cancel(true);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user