Merge branch 'master' into dev/设备和平台使用不同的优化策略

This commit is contained in:
lin
2025-06-03 11:31:38 +08:00
9 changed files with 35 additions and 36 deletions

View File

@@ -132,7 +132,7 @@ https://gitee.com/pan648540858/wvp-GB28181-pro.git
- [X] 支持ONVIF协议设备检索支持点播云台控制国标级联点播自动点播等。
- [X] 支持部标1078+808协议支持点播云台控制录像回放位置上报自动点播等。
- [X] 支持国标28181-2022协议支持巡航轨迹查询PTZ精准控制存储卡格式化设备软件升级OSD配置h265+aac支持辅码流录像倒放等。
- [X] 支持国网B接口协议。支持注册获取资源预览
- [X] 支持国网B接口协议。支持注册获取资源预览, 云台控制,预置位控制等,可免费定制支持语音对讲、录像回放和抓拍图像。
# 授权协议

View File

@@ -147,7 +147,7 @@ public interface DeviceMapper {
", subscribe_cycle_for_alarm=#{subscribeCycleForAlarm}" +
", expires=#{expires}" +
", server_id=#{serverId}" +
"WHERE device_id=#{deviceId}"+
" WHERE device_id=#{deviceId}"+
" </script>"})
int update(Device device);

View File

@@ -147,8 +147,8 @@ public interface PlatformChannelMapper {
" <if test='query != null'> " +
" AND (coalesce(wdc.gb_device_id, wdc.device_id) LIKE concat('%',#{query},'%') OR wpgc.custom_device_id LIKE concat('%',#{query},'%') " +
" OR coalesce(wdc.gb_name, wdc.name) LIKE concat('%',#{query},'%') OR wpgc.custom_name LIKE concat('%',#{query},'%'))</if> " +
" <if test='online == true'> AND coalesce(wpgc.status, wdc.gb_status, wdc.status) = 'ON'</if> " +
" <if test='online == false'> AND coalesce(wpgc.status, wdc.gb_status, wdc.status) = 'OFF'</if> " +
" <if test='online == true'> AND coalesce(wpgc.custom_status, wdc.gb_status, wdc.status) = 'ON'</if> " +
" <if test='online == false'> AND coalesce(wpgc.custom_status, wdc.gb_status, wdc.status) = 'OFF'</if> " +
" <if test='hasShare == true'> AND wpgc.platform_id = #{platformId}</if> " +
" <if test='hasShare == false'> AND wpgc.platform_id is null</if> " +
" <if test='dataType != null'> AND wdc.data_type = #{dataType}</if> " +

View File

@@ -386,12 +386,14 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
return;
}
// 主动查询设备状态
Boolean deviceStatus = getDeviceStatus(device);
if (deviceStatus != null && deviceStatus) {
log.info("[设备离线] 主动探测发现设备在线,暂不处理 device{}", deviceId);
online(device, null);
return;
// 主动查询设备状态, 没有HostAddress无法发送请求可能是手动添加的设备
if (device.getHostAddress() != null) {
Boolean deviceStatus = getDeviceStatus(device);
if (deviceStatus != null && deviceStatus) {
log.info("[设备离线] 主动探测发现设备在线,暂不处理 device{}", deviceId);
online(device, null);
return;
}
}
log.info("[设备离线] {}, device{} 心跳间隔: {},心跳超时次数: {} 上次心跳时间:{} 上次注册时间: {}", reason, deviceId,
device.getHeartBeatInterval(), device.getHeartBeatCount(), device.getKeepaliveTime(), device.getRegisterTime());
@@ -423,7 +425,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
return;
}
for (Device device : deviceList) {
if (device == null || !device.isOnLine() || !device.getServerId().equals(userSetting.getServerId())) {
if (device == null || !device.isOnLine() || !userSetting.getServerId().equals(device.getServerId())) {
continue;
}
if (device.getSubscribeCycleForCatalog() > 0 && !subscribeTaskRunner.containsKey(SubscribeTaskForCatalog.getKey(device))) {
@@ -879,7 +881,7 @@ public class DeviceServiceImpl implements IDeviceService, CommandLineRunner {
@Override
public WVPResult<SyncStatus> devicesSync(Device device) {
if (!userSetting.getServerId().equals(device.getServerId())) {
if (device.getServerId() != null && !userSetting.getServerId().equals(device.getServerId())) {
return redisRpcService.devicesSync(device.getServerId(), device.getDeviceId());
}
// 已存在则返回进度

View File

@@ -510,6 +510,7 @@ public class PlayServiceImpl implements IPlayService {
try {
sendRtpInfo = sendRtpServerService.createSendRtpInfo(mediaServerItem, null, null, playSsrc, device.getDeviceId(), "talk", stream,
channel.getId(), true, false);
sendRtpInfo.setPlayType(InviteStreamType.TALK);
}catch (PlayException e) {
log.info("[语音对讲]开始 获取发流端口失败 deviceId: {}, channelId: {},", device.getDeviceId(), channel.getDeviceId());
return;
@@ -582,7 +583,7 @@ public class PlayServiceImpl implements IPlayService {
sendRtpInfo.setCallId(response.getCallIdHeader().getCallId());
sendRtpServerService.update(sendRtpInfo);
SsrcTransaction ssrcTransaction = SsrcTransaction.buildForDevice(device.getDeviceId(), sendRtpInfo.getChannelId(), "talk", sendRtpInfo.getApp(),
SsrcTransaction ssrcTransaction = SsrcTransaction.buildForDevice(device.getDeviceId(), sendRtpInfo.getChannelId(), response.getCallIdHeader().getCallId(), sendRtpInfo.getApp(),
sendRtpInfo.getStream(), sendRtpInfo.getSsrc(), sendRtpInfo.getMediaServerId(),
response, InviteSessionType.TALK);
@@ -724,7 +725,6 @@ public class PlayServiceImpl implements IPlayService {
inviteInfo.setStreamInfo(streamInfo);
inviteStreamService.updateInviteInfo(inviteInfo);
}
}
return streamInfo;
}

View File

@@ -164,7 +164,8 @@ public class SIPRequestHeaderProvider {
// SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress());
// via
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), transactionInfo.getViaBranch());
// ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), transactionInfo.getViaBranch());
ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag());
// viaHeader.setRPort();
viaHeaders.add(viaHeader);
//from

View File

@@ -102,7 +102,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
SIPRequest request = (SIPRequest) evt.getRequest();
RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request, userSetting.getSipUseSourceIpAsRemoteAddress());
if (!device.getIp().equalsIgnoreCase(remoteAddressInfo.getIp()) || device.getPort() != remoteAddressInfo.getPort()) {
if (device.getIp() == null || !device.getIp().equalsIgnoreCase(remoteAddressInfo.getIp()) || device.getPort() != remoteAddressInfo.getPort()) {
log.info("[收到心跳] 地址变化, {}({}), {}:{}->{}", device.getName(), device.getDeviceId(), remoteAddressInfo.getIp(), remoteAddressInfo.getPort(), request.getLocalAddress().getHostAddress());
device.setPort(remoteAddressInfo.getPort());
device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort())));

View File

@@ -28,7 +28,7 @@ public class SendRtpServerServiceImpl implements ISendRtpServerService {
@Autowired
private RedisTemplate<Object, Object> redisTemplate;
@Override
public SendRtpInfo createSendRtpInfo(MediaServer mediaServer, String ip, Integer port, String ssrc, String requesterId,
@@ -230,31 +230,27 @@ public class SendRtpServerServiceImpl implements ISendRtpServerService {
log.warn("{}获取redis连接信息失败", mediaServer.getId());
return -1;
}
return getSendPort(startPort, endPort, sendIndexKey, sendRtpSet);
}
private synchronized int getSendPort(int startPort, int endPort, String sendIndexKey, Set<Integer> sendRtpPortSet){
// TODO 这里改为只取偶数端口
RedisAtomicInteger redisAtomicInteger = new RedisAtomicInteger(sendIndexKey , redisTemplate.getConnectionFactory());
if (redisAtomicInteger.get() < startPort) {
redisAtomicInteger.set(startPort);
return startPort;
}else {
int port = redisAtomicInteger.getAndIncrement();
if (port > endPort) {
redisAtomicInteger.set(startPort);
if (sendRtpPortSet.contains(startPort)) {
return getSendPort(startPort, endPort, sendIndexKey, sendRtpPortSet);
}else {
return startPort;
for (int i = 0; i < endPort - startPort; i++) {
int port = redisAtomicInteger.getAndIncrement();
if (port > endPort) {
redisAtomicInteger.set(startPort);
if (sendRtpSet.contains(startPort)) {
continue;
}else {
return startPort;
}
}
if (!sendRtpSet.contains(port)) {
return port;
}
}
if (sendRtpPortSet.contains(port)) {
return getSendPort(startPort, endPort, sendIndexKey, sendRtpPortSet);
}else {
return port;
}
}
log.warn("{}获取发送端口失败, 无可用端口", mediaServer.getId());
return -1;
}
}

View File

@@ -298,7 +298,7 @@
</div>
</div>
</div>
<div style="text-align: left">
<div style="text-align: left" v-if="tabActiveName === 'control'">
<el-select
v-model="ptzMethod"
style="width: 100%"