录像回放/下载添加 是否使用时间范围限制
This commit is contained in:
parent
eb10b3998a
commit
85ec74771a
@ -4,9 +4,22 @@ import lombok.Data;
|
|||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = "proxy.device")
|
@ConfigurationProperties(prefix = "proxy.device")
|
||||||
public class DeviceProxyConfig {
|
public class DeviceProxyConfig {
|
||||||
|
/**
|
||||||
|
* 通过其他 代理 agent 拉取历史视频 的地址
|
||||||
|
*/
|
||||||
private String url;
|
private String url;
|
||||||
|
/**
|
||||||
|
* 是否只通过代理拉取指定时间范围内的视频查询请求
|
||||||
|
*/
|
||||||
|
private Boolean proxyVideoInTimeRange = true;
|
||||||
|
/**
|
||||||
|
* 代理该时间段内的历史视频查询请求
|
||||||
|
*/
|
||||||
|
private Duration proxyTimeRange = Duration.ofMinutes(3);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package cn.skcks.docking.gb28181.mocking.core.sip.message.processor.invite.request;
|
package cn.skcks.docking.gb28181.mocking.core.sip.message.processor.invite.request;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUnit;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.skcks.docking.gb28181.core.sip.listener.SipListener;
|
import cn.skcks.docking.gb28181.core.sip.listener.SipListener;
|
||||||
import cn.skcks.docking.gb28181.core.sip.message.processor.MessageProcessor;
|
import cn.skcks.docking.gb28181.core.sip.message.processor.MessageProcessor;
|
||||||
import cn.skcks.docking.gb28181.core.sip.message.subscribe.GenericSubscribe;
|
import cn.skcks.docking.gb28181.core.sip.message.subscribe.GenericSubscribe;
|
||||||
|
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.FfmpegConfig;
|
||||||
import cn.skcks.docking.gb28181.mocking.core.sip.message.subscribe.SipSubscribe;
|
import cn.skcks.docking.gb28181.mocking.core.sip.message.subscribe.SipSubscribe;
|
||||||
import cn.skcks.docking.gb28181.mocking.core.sip.response.SipResponseBuilder;
|
import cn.skcks.docking.gb28181.mocking.core.sip.response.SipResponseBuilder;
|
||||||
@ -50,6 +53,8 @@ public class InviteRequestProcessor implements MessageProcessor {
|
|||||||
|
|
||||||
private final FfmpegConfig ffmpegConfig;
|
private final FfmpegConfig ffmpegConfig;
|
||||||
|
|
||||||
|
private final DeviceProxyConfig deviceProxyConfig;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
@ -126,6 +131,11 @@ public class InviteRequestProcessor implements MessageProcessor {
|
|||||||
"Unsupported Media Type");
|
"Unsupported Media Type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SipSender.SendResponse forbidden(SIPRequest request) {
|
||||||
|
return (provider, ip, port) -> SipResponseBuilder.response(request, Response.FORBIDDEN,
|
||||||
|
"Only support playback with " + deviceProxyConfig.getProxyTimeRange().getSeconds() + " secs video");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 视频点播
|
* 视频点播
|
||||||
*
|
*
|
||||||
@ -209,6 +219,19 @@ public class InviteRequestProcessor implements MessageProcessor {
|
|||||||
Date start = new Date(time.getStartTime() * 1000);
|
Date start = new Date(time.getStartTime() * 1000);
|
||||||
Date stop = new Date(time.getStopTime() * 1000);
|
Date stop = new Date(time.getStopTime() * 1000);
|
||||||
log.info("{} ~ {}", start, stop);
|
log.info("{} ~ {}", start, stop);
|
||||||
|
|
||||||
|
String senderIp = request.getLocalAddress().getHostAddress();
|
||||||
|
String transport = request.getTopmostViaHeader().getTransport();
|
||||||
|
if(deviceProxyConfig.getProxyVideoInTimeRange()){
|
||||||
|
long between = DateUtil.between(start, stop, DateUnit.SECOND);
|
||||||
|
long seconds = deviceProxyConfig.getProxyTimeRange().getSeconds();
|
||||||
|
if( between > seconds ){
|
||||||
|
log.info("请求回放/下载时长 {} 大于所设定 支持时长范围 {}",between, seconds);
|
||||||
|
sender.sendResponse(senderIp, transport, forbidden(request));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String channelId = gb28181Description.getOrigin().getUsername();
|
String channelId = gb28181Description.getOrigin().getUsername();
|
||||||
log.info("通道id: {}", channelId);
|
log.info("通道id: {}", channelId);
|
||||||
String address = gb28181Description.getOrigin().getAddress();
|
String address = gb28181Description.getOrigin().getAddress();
|
||||||
@ -216,9 +239,6 @@ public class InviteRequestProcessor implements MessageProcessor {
|
|||||||
Media media = mediaDescription.getMedia();
|
Media media = mediaDescription.getMedia();
|
||||||
int port = media.getMediaPort();
|
int port = media.getMediaPort();
|
||||||
log.info("目标端口号: {}", port);
|
log.info("目标端口号: {}", port);
|
||||||
|
|
||||||
String senderIp = request.getLocalAddress().getHostAddress();
|
|
||||||
String transport = request.getTopmostViaHeader().getTransport();
|
|
||||||
int taskNum = DeviceProxyService.getTaskNum().get();
|
int taskNum = DeviceProxyService.getTaskNum().get();
|
||||||
log.info("当前任务数 {}", taskNum);
|
log.info("当前任务数 {}", taskNum);
|
||||||
if(ffmpegConfig.getTask().getMax() > 0 && taskNum >= ffmpegConfig.getTask().getMax()){
|
if(ffmpegConfig.getTask().getMax() > 0 && taskNum >= ffmpegConfig.getTask().getMax()){
|
||||||
|
Loading…
Reference in New Issue
Block a user