策略配置文件增加注释与使用Lombok

This commit is contained in:
648540858
2024-10-30 15:19:17 +08:00
parent b759bdcccd
commit 396961ea20
9 changed files with 143 additions and 309 deletions

View File

@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.conf;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@@ -13,326 +14,160 @@ import java.util.List;
@Component
@ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true)
@Order(0)
@Data
public class UserSetting {
/**
* 是否保存位置的历史记录(轨迹)
*/
private Boolean savePositionHistory = Boolean.FALSE;
/**
* 是否开始自动点播: 请求流为未拉起的流时,自动开启点播, 需要rtp.enable=true
*/
private Boolean autoApplyPlay = Boolean.FALSE;
/**
* [可选] 部分设备需要扩展SDP需要打开此设置,一般设备无需打开
*/
private Boolean seniorSdp = Boolean.FALSE;
/**
* 点播/录像回放 等待超时时间,单位:毫秒
*/
private Integer playTimeout = 10000;
/**
* 上级点播等待超时时间,单位:毫秒
*/
private int platformPlayTimeout = 20000;
/**
* 是否开启接口鉴权
*/
private Boolean interfaceAuthentication = Boolean.TRUE;
private Boolean recordPushLive = Boolean.TRUE;
private Boolean recordSip = Boolean.TRUE;
private Boolean logInDatabase = Boolean.FALSE;
private Boolean usePushingAsStatus = Boolean.FALSE;
private Boolean useSourceIpAsStreamIp = Boolean.FALSE;
private Boolean sipUseSourceIpAsRemoteAddress = Boolean.FALSE;
private Boolean streamOnDemand = Boolean.TRUE;
private Boolean pushAuthority = Boolean.TRUE;
private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
private Boolean sipLog = Boolean.FALSE;
private Boolean sqlLog = Boolean.FALSE;
private Boolean sendToPlatformsWhenIdLost = Boolean.FALSE;
private Boolean refuseChannelStatusChannelFormNotify = Boolean.FALSE;
private Boolean deviceStatusNotify = Boolean.TRUE;
private Boolean useCustomSsrcForParentInvite = Boolean.TRUE;
private Boolean docEnable = Boolean.TRUE;
private String serverId = "000000";
private String thirdPartyGBIdReg = "[\\s\\S]*";
private String broadcastForPlatform = "UDP";
private String civilCodeFile = "classpath:civilCode.csv";
/**
* 接口鉴权例外的接口, 即不进行接口鉴权的接口,尽量详细书写,尽量不用/**,至少两级目录
*/
private List<String> interfaceAuthenticationExcludes = new ArrayList<>();
/**
* 推流直播是否录制
*/
private Boolean recordPushLive = Boolean.TRUE;
/**
* 国标是否录制
*/
private Boolean recordSip = Boolean.TRUE;
/**
* 使用推流状态作为推流通道状态
*/
private Boolean usePushingAsStatus = Boolean.FALSE;
/**
* 使用来源请求ip作为streamIp,当且仅当你只有zlm节点它与wvp在一起的情况下开启
*/
private Boolean useSourceIpAsStreamIp = Boolean.FALSE;
/**
* 是否使用设备来源Ip作为回复IP 不设置则为 false
*/
private Boolean sipUseSourceIpAsRemoteAddress = Boolean.FALSE;
/**
* 国标点播 按需拉流, true有人观看拉流无人观看释放 false拉起后不自动释放
*/
private Boolean streamOnDemand = Boolean.TRUE;
/**
* 推流鉴权, 默认开启
*/
private Boolean pushAuthority = Boolean.TRUE;
/**
* 设备上线时是否自动同步通道
*/
private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
/**
* 是否开启sip日志
*/
private Boolean sipLog = Boolean.FALSE;
/**
* 是否开启mybatis-sql日志
*/
private Boolean sqlLog = Boolean.FALSE;
/**
* 消息通道功能-缺少国标ID是否给所有上级发送消息
*/
private Boolean sendToPlatformsWhenIdLost = Boolean.FALSE;
/**
* 保持通道状态不接受notify通道状态变化 兼容海康平台发送错误消息
*/
private Boolean refuseChannelStatusChannelFormNotify = Boolean.FALSE;
/**
* 设备/通道状态变化时发送消息
*/
private Boolean deviceStatusNotify = Boolean.TRUE;
/**
* 上级平台点播时不使用上级平台指定的ssrc使用自定义的ssrc参考国标文档-点播外域设备媒体流SSRC处理方式
*/
private Boolean useCustomSsrcForParentInvite = Boolean.TRUE;
/**
* 开启接口文档页面。 默认开启生产环境建议关闭遇到swagger相关的漏洞时也可以关闭
*/
private Boolean docEnable = Boolean.TRUE;
/**
* 服务ID不写则为000000
*/
private String serverId = "000000";
/**
* 国标级联语音喊话发流模式 * UDP:udp传输 TCP-ACTIVEtcp主动模式 TCP-PASSIVEtcp被动模式
*/
private String broadcastForPlatform = "UDP";
/**
* 行政区划信息文件,系统启动时会加载到系统里
*/
private String civilCodeFile = "classpath:civilCode.csv";
/**
* 跨域配置,不配置此项则允许所有跨域请求,配置后则只允许配置的页面的地址请求, 可以配置多个
*/
private List<String> allowedOrigins = new ArrayList<>();
/**
* 设置notify缓存队列最大长度超过此长度的数据将返回486 BUSY_HERE消息丢弃, 默认100000
*/
private int maxNotifyCountQueue = 100000;
/**
* 国标级联离线后多久重试一次注册
*/
private int registerAgainAfterTime = 60;
/**
* 国标续订方式true为续订每次注册在同一个会话里false为重新注册每次使用新的会话
*/
private boolean registerKeepIntDialog = false;
/**
* # 国标设备离线后的上线策略,
* # 0 国标标准实现,设备离线后不回复心跳,直到设备重新注册上线,
* # 1默认 对于离线设备,收到心跳就把设备设置为上线,并更新注册时间为上次这次心跳的时间。防止过期时间判断异常
*/
private int gbDeviceOnline = 1;
public Boolean getSavePositionHistory() {
return savePositionHistory;
}
public Boolean isSavePositionHistory() {
return savePositionHistory;
}
public Boolean isAutoApplyPlay() {
return autoApplyPlay;
}
public Boolean isSeniorSdp() {
return seniorSdp;
}
public Integer getPlayTimeout() {
return playTimeout;
}
public Boolean isInterfaceAuthentication() {
return interfaceAuthentication;
}
public Boolean isRecordPushLive() {
return recordPushLive;
}
public List<String> getInterfaceAuthenticationExcludes() {
return interfaceAuthenticationExcludes;
}
public void setSavePositionHistory(Boolean savePositionHistory) {
this.savePositionHistory = savePositionHistory;
}
public void setAutoApplyPlay(Boolean autoApplyPlay) {
this.autoApplyPlay = autoApplyPlay;
}
public void setSeniorSdp(Boolean seniorSdp) {
this.seniorSdp = seniorSdp;
}
public void setPlayTimeout(Integer playTimeout) {
this.playTimeout = playTimeout;
}
public void setInterfaceAuthentication(boolean interfaceAuthentication) {
this.interfaceAuthentication = interfaceAuthentication;
}
public void setRecordPushLive(Boolean recordPushLive) {
this.recordPushLive = recordPushLive;
}
public void setInterfaceAuthenticationExcludes(List<String> interfaceAuthenticationExcludes) {
this.interfaceAuthenticationExcludes = interfaceAuthenticationExcludes;
}
public Boolean getLogInDatabase() {
return logInDatabase;
}
public void setLogInDatabase(Boolean logInDatabase) {
this.logInDatabase = logInDatabase;
}
public String getServerId() {
return serverId;
}
public void setServerId(String serverId) {
this.serverId = serverId;
}
public String getThirdPartyGBIdReg() {
return thirdPartyGBIdReg;
}
public void setThirdPartyGBIdReg(String thirdPartyGBIdReg) {
this.thirdPartyGBIdReg = thirdPartyGBIdReg;
}
public Boolean getRecordSip() {
return recordSip;
}
public void setRecordSip(Boolean recordSip) {
this.recordSip = recordSip;
}
public int getPlatformPlayTimeout() {
return platformPlayTimeout;
}
public void setPlatformPlayTimeout(int platformPlayTimeout) {
this.platformPlayTimeout = platformPlayTimeout;
}
public Boolean isUsePushingAsStatus() {
return usePushingAsStatus;
}
public void setUsePushingAsStatus(Boolean usePushingAsStatus) {
this.usePushingAsStatus = usePushingAsStatus;
}
public Boolean getStreamOnDemand() {
return streamOnDemand;
}
public void setStreamOnDemand(Boolean streamOnDemand) {
this.streamOnDemand = streamOnDemand;
}
public Boolean getUseSourceIpAsStreamIp() {
return useSourceIpAsStreamIp;
}
public void setUseSourceIpAsStreamIp(Boolean useSourceIpAsStreamIp) {
this.useSourceIpAsStreamIp = useSourceIpAsStreamIp;
}
public Boolean getPushAuthority() {
return pushAuthority;
}
public void setPushAuthority(Boolean pushAuthority) {
this.pushAuthority = pushAuthority;
}
public Boolean getSyncChannelOnDeviceOnline() {
return syncChannelOnDeviceOnline;
}
public void setSyncChannelOnDeviceOnline(Boolean syncChannelOnDeviceOnline) {
this.syncChannelOnDeviceOnline = syncChannelOnDeviceOnline;
}
public String getBroadcastForPlatform() {
return broadcastForPlatform;
}
public void setBroadcastForPlatform(String broadcastForPlatform) {
this.broadcastForPlatform = broadcastForPlatform;
}
public Boolean getSipUseSourceIpAsRemoteAddress() {
return sipUseSourceIpAsRemoteAddress;
}
public void setSipUseSourceIpAsRemoteAddress(Boolean sipUseSourceIpAsRemoteAddress) {
this.sipUseSourceIpAsRemoteAddress = sipUseSourceIpAsRemoteAddress;
}
public Boolean getSipLog() {
return sipLog;
}
public void setSipLog(Boolean sipLog) {
this.sipLog = sipLog;
}
public List<String> getAllowedOrigins() {
return allowedOrigins;
}
public void setAllowedOrigins(List<String> allowedOrigins) {
this.allowedOrigins = allowedOrigins;
}
public Boolean getSendToPlatformsWhenIdLost() {
return sendToPlatformsWhenIdLost;
}
public void setSendToPlatformsWhenIdLost(Boolean sendToPlatformsWhenIdLost) {
this.sendToPlatformsWhenIdLost = sendToPlatformsWhenIdLost;
}
public Boolean getRefuseChannelStatusChannelFormNotify() {
return refuseChannelStatusChannelFormNotify;
}
public void setRefuseChannelStatusChannelFormNotify(Boolean refuseChannelStatusChannelFormNotify) {
this.refuseChannelStatusChannelFormNotify = refuseChannelStatusChannelFormNotify;
}
public int getMaxNotifyCountQueue() {
return maxNotifyCountQueue;
}
public void setMaxNotifyCountQueue(int maxNotifyCountQueue) {
this.maxNotifyCountQueue = maxNotifyCountQueue;
}
public Boolean getDeviceStatusNotify() {
return deviceStatusNotify;
}
public void setDeviceStatusNotify(Boolean deviceStatusNotify) {
this.deviceStatusNotify = deviceStatusNotify;
}
public Boolean getUseCustomSsrcForParentInvite() {
return useCustomSsrcForParentInvite;
}
public void setUseCustomSsrcForParentInvite(Boolean useCustomSsrcForParentInvite) {
this.useCustomSsrcForParentInvite = useCustomSsrcForParentInvite;
}
public Boolean getSqlLog() {
return sqlLog;
}
public void setSqlLog(Boolean sqlLog) {
this.sqlLog = sqlLog;
}
public String getCivilCodeFile() {
return civilCodeFile;
}
public void setCivilCodeFile(String civilCodeFile) {
this.civilCodeFile = civilCodeFile;
}
public int getRegisterAgainAfterTime() {
return registerAgainAfterTime;
}
public void setRegisterAgainAfterTime(int registerAgainAfterTime) {
this.registerAgainAfterTime = registerAgainAfterTime;
}
public boolean isRegisterKeepIntDialog() {
return registerKeepIntDialog;
}
public void setRegisterKeepIntDialog(boolean registerKeepIntDialog) {
this.registerKeepIntDialog = registerKeepIntDialog;
}
public Boolean getDocEnable() {
return docEnable;
}
public void setDocEnable(Boolean docEnable) {
this.docEnable = docEnable;
}
public int getGbDeviceOnline() {
return gbDeviceOnline;
}
public void setGbDeviceOnline(int gbDeviceOnline) {
this.gbDeviceOnline = gbDeviceOnline;
}
}

View File

@@ -44,7 +44,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
return;
}
if (!userSetting.isInterfaceAuthentication()) {
if (!userSetting.getInterfaceAuthentication()) {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(null, null, new ArrayList<>() );
SecurityContextHolder.getContext().setAuthentication(token);
chain.doFilter(request, response);

View File

@@ -62,7 +62,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
**/
@Override
public void configure(WebSecurity web) {
if (userSetting.isInterfaceAuthentication()) {
if (userSetting.getInterfaceAuthentication()) {
ArrayList<String> matchers = new ArrayList<>();
matchers.add("/");
matchers.add("/#/**");

View File

@@ -469,7 +469,6 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
if (CollectionUtils.isEmpty(deviceChannelList)) {
return false;
}
System.out.println("size: " + deviceChannelList.size());
List<DeviceChannel> allChannels = channelMapper.queryAllChannelsForRefresh(deviceDbId);
Map<String,DeviceChannel> allChannelMap = new HashMap<>();
if (!allChannels.isEmpty()) {

View File

@@ -281,7 +281,7 @@ public class SIPCommander implements ISIPCommander {
content.append("c=IN IP4 " + sdpIp + "\r\n");
content.append("t=0 0\r\n");
if (userSetting.isSeniorSdp()) {
if (userSetting.getSeniorSdp()) {
if ("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) {
content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n");
} else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) {
@@ -383,7 +383,7 @@ public class SIPCommander implements ISIPCommander {
String streamMode = device.getStreamMode();
if (userSetting.isSeniorSdp()) {
if (userSetting.getSeniorSdp()) {
if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) {
content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n");
} else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) {
@@ -472,7 +472,7 @@ public class SIPCommander implements ISIPCommander {
String streamMode = device.getStreamMode().toUpperCase();
if (userSetting.isSeniorSdp()) {
if (userSetting.getSeniorSdp()) {
if ("TCP-PASSIVE".equals(streamMode)) {
content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n");
} else if ("TCP-ACTIVE".equals(streamMode)) {

View File

@@ -209,7 +209,7 @@ public class ZLMHttpHookListener {
MediaServer mediaServer = mediaServerService.getOne(param.getMediaServerId());
if (!userSetting.isAutoApplyPlay() || mediaServer == null) {
if (!userSetting.getAutoApplyPlay() || mediaServer == null) {
return HookResult.SUCCESS();
}
MediaNotFoundEvent mediaNotFoundEvent = MediaNotFoundEvent.getInstance(this, param, mediaServer);

View File

@@ -123,7 +123,7 @@ public class MediaServiceImpl implements IMediaService {
if ("rtp".equals(app)) {
result.setEnable_mp4(userSetting.getRecordSip());
} else {
result.setEnable_mp4(userSetting.isRecordPushLive());
result.setEnable_mp4(userSetting.getRecordPushLive());
}
// 国标流
if ("rtp".equals(app)) {

View File

@@ -100,7 +100,7 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
@Override
public void run(ApplicationArguments args) throws Exception {
if (userSetting.isUsePushingAsStatus()) {
if (userSetting.getUsePushingAsStatus()) {
return;
}
// 查询是否存在推流设备,没有则不发送

View File

@@ -284,7 +284,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
mediaServerService.closeStreams(mediaServer, streamPush.getApp(), streamPush.getStream());
}
streamPush.setPushing(false);
if (userSetting.isUsePushingAsStatus()) {
if (userSetting.getUsePushingAsStatus()) {
CommonGBChannel commonGBChannel = streamPush.buildCommonGBChannel();
if (commonGBChannel != null) {
gbChannelService.offline(commonGBChannel);
@@ -474,7 +474,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
@Override
public ResourceBaseInfo getOverview() {
int total = streamPushMapper.getAllCount();
int online = streamPushMapper.getAllPushing(userSetting.isUsePushingAsStatus());
int online = streamPushMapper.getAllPushing(userSetting.getUsePushingAsStatus());
return new ResourceBaseInfo(total, online);
}
@@ -500,7 +500,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
@Transactional
public void updatePushStatus(StreamPush streamPush, boolean pushIng) {
streamPush.setPushing(pushIng);
if (userSetting.isUsePushingAsStatus()) {
if (userSetting.getUsePushingAsStatus()) {
streamPush.setGbStatus(pushIng?"ON":"OFF");
}
streamPush.setPushTime(DateUtil.getNow());
@@ -508,7 +508,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
if (ObjectUtils.isEmpty(streamPush.getGbDeviceId())) {
return;
}
if (userSetting.isUsePushingAsStatus()) {
if (userSetting.getUsePushingAsStatus()) {
if ("ON".equalsIgnoreCase(streamPush.getGbStatus()) ) {
gbChannelService.online(streamPush.buildCommonGBChannel());
}else {