From 952d38d69b52491fabb909e9d563002238e7d6e6 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Wed, 29 Oct 2025 14:31:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E5=9D=90?= =?UTF-8?q?=E6=A0=87=E7=B3=BB=E6=97=B6=E5=8F=82=E6=95=B0=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E7=B3=BB=E8=BD=AC=E6=8D=A2=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/common/enums/ChannelDataType.java | 13 +++++++++ .../impl/GbChannelPlayServiceImpl.java | 27 ++++++++++--------- .../gb28181/service/impl/PlayServiceImpl.java | 12 ++++----- .../impl/message/MessageRequestProcessor.java | 3 +-- .../web/custom/CameraChannelController.java | 14 ++++++++++ .../custom/service/CameraChannelService.java | 6 ++--- 6 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java b/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java index 27a09eafc..f4b6b863d 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java +++ b/src/main/java/com/genersoft/iot/vmp/common/enums/ChannelDataType.java @@ -17,5 +17,18 @@ public class ChannelDataType { public final static String PTZ_SERVICE = "sourceChannelPTZService"; + public static String getDateTypeDesc(Integer dataType) { + if (dataType == null) { + return "未知"; + } + return switch (dataType) { + case ChannelDataType.GB28181 -> "国标28181"; + case ChannelDataType.STREAM_PUSH -> "推流设备"; + case ChannelDataType.STREAM_PROXY -> "拉流代理"; + case ChannelDataType.JT_1078 -> "部标设备"; + default -> "未知"; + }; + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java index 9285f1849..51571989c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelPlayServiceImpl.java @@ -6,9 +6,10 @@ import com.genersoft.iot.vmp.common.enums.ChannelDataType; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; -import com.genersoft.iot.vmp.gb28181.service.*; import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService; -import com.genersoft.iot.vmp.gb28181.service.IPlayService; +import com.genersoft.iot.vmp.gb28181.service.ISourceDownloadService; +import com.genersoft.iot.vmp.gb28181.service.ISourcePlayService; +import com.genersoft.iot.vmp.gb28181.service.ISourcePlaybackService; import com.genersoft.iot.vmp.jt1078.service.Ijt1078PlayService; import com.genersoft.iot.vmp.service.bean.ErrorCallback; import com.genersoft.iot.vmp.service.bean.InviteErrorCode; @@ -89,12 +90,12 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void play(CommonGBChannel channel, Platform platform, Boolean record, ErrorCallback callback) { - log.info("[通用通道] 播放, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + log.info("[通用通道] 播放, 类型: {}, 编号:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId()); Integer dataType = channel.getDataType(); ISourcePlayService sourceChannelPlayService = sourcePlayServiceMap.get(ChannelDataType.PLAY_SERVICE + dataType); if (sourceChannelPlayService == null) { // 通道数据异常 - log.error("[点播通用通道] 类型编号: {} 不支持实时流预览", dataType); + log.error("[点播通用通道] 类型编号: {} 不支持实时流预览", ChannelDataType.getDateTypeDesc(channel.getDataType())); throw new PlayException(Response.BUSY_HERE, "channel not support"); } sourceChannelPlayService.play(channel, platform, record, (code, msg, data) -> { @@ -109,7 +110,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { } @Override public void playback(CommonGBChannel channel, Long startTime, Long stopTime, ErrorCallback callback) { - log.info("[通用通道] 回放, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + log.info("[通用通道] 回放, 类型: {}, 编号:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId()); Integer dataType = channel.getDataType(); ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); if (playbackService == null) { @@ -123,7 +124,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void download(CommonGBChannel channel, Long startTime, Long stopTime, Integer downloadSpeed, ErrorCallback callback){ - log.info("[通用通道] 录像下载, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + log.info("[通用通道] 录像下载, 类型: {}, 编号:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId()); Integer dataType = channel.getDataType(); ISourceDownloadService downloadService = sourceDownloadServiceMap.get(ChannelDataType.DOWNLOAD_SERVICE + dataType); if (downloadService == null) { @@ -148,7 +149,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void stopPlayback(CommonGBChannel channel, String stream) { - log.info("[通用通道] 停止回放, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + log.info("[通用通道] 停止回放, 类型: {}, 编号:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId()); Integer dataType = channel.getDataType(); ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); if (playbackService == null) { @@ -161,7 +162,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void stopDownload(CommonGBChannel channel, String stream) { - log.info("[通用通道] 停止录像下载, 类型: {}, 编号:{} stream: {}", channel.getDataType(), channel.getGbDeviceId(), stream); + log.info("[通用通道] 停止录像下载, 类型: {}, 编号:{} stream: {}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId(), stream); Integer dataType = channel.getDataType(); ISourceDownloadService downloadService = sourceDownloadServiceMap.get(ChannelDataType.DOWNLOAD_SERVICE + dataType); if (downloadService == null) { @@ -174,7 +175,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void playbackPause(CommonGBChannel channel, String stream) { - log.info("[通用通道] 回放暂停, 类型: {}, 编号:{} stream:{}", channel.getDataType(), channel.getGbDeviceId(), stream); + log.info("[通用通道] 回放暂停, 类型: {}, 编号:{} stream:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId(), stream); Integer dataType = channel.getDataType(); ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); if (playbackService == null) { @@ -187,7 +188,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void playbackResume(CommonGBChannel channel, String stream) { - log.info("[通用通道] 回放暂停恢复, 类型: {}, 编号:{} stream:{}", channel.getDataType(), channel.getGbDeviceId(), stream); + log.info("[通用通道] 回放暂停恢复, 类型: {}, 编号:{} stream:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId(), stream); Integer dataType = channel.getDataType(); ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); if (playbackService == null) { @@ -200,7 +201,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void playbackSeek(CommonGBChannel channel, String stream, long seekTime) { - log.info("[通用通道] 回放拖动播放, 类型: {}, 编号:{} stream:{}", channel.getDataType(), channel.getGbDeviceId(), stream); + log.info("[通用通道] 回放拖动播放, 类型: {}, 编号:{} stream:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId(), stream); Integer dataType = channel.getDataType(); ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); if (playbackService == null) { @@ -213,7 +214,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void playbackSpeed(CommonGBChannel channel, String stream, Double speed) { - log.info("[通用通道] 回放倍速播放, 类型: {}, 编号:{} stream:{}", channel.getDataType(), channel.getGbDeviceId(), stream); + log.info("[通用通道] 回放倍速播放, 类型: {}, 编号:{} stream:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId(), stream); Integer dataType = channel.getDataType(); ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); if (playbackService == null) { @@ -226,7 +227,7 @@ public class GbChannelPlayServiceImpl implements IGbChannelPlayService { @Override public void queryRecord(CommonGBChannel channel, String startTime, String endTime, ErrorCallback> callback) { - log.info("[通用通道] 录像查询, 类型: {}, 编号:{}", channel.getDataType(), channel.getGbDeviceId()); + log.info("[通用通道] 录像查询, 类型: {}, 编号:{}", ChannelDataType.getDateTypeDesc(channel.getDataType()), channel.getGbDeviceId()); Integer dataType = channel.getDataType(); ISourcePlaybackService playbackService = sourcePlaybackServiceMap.get(ChannelDataType.PLAYBACK_SERVICE + dataType); if (playbackService == null) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index 02ea5fa44..8085ba43e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -366,7 +366,7 @@ public class PlayServiceImpl implements IPlayService { InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); - log.info("[点播已存在] 直接返回, deviceId: {}, channelId: {}", device.getDeviceId(), channel.getDeviceId()); + log.info("[点播已存在] 直接返回, 设备编号: {}, 通道编号: {}", device.getDeviceId(), channel.getDeviceId()); return inviteInfoInCatch.getSsrcInfo(); }else { // 点播发起了但是尚未成功, 仅注册回调等待结果即可 @@ -413,7 +413,7 @@ public class PlayServiceImpl implements IPlayService { InviteErrorCode.SUCCESS.getMsg(), streamInfo); - log.info("[点播成功] deviceId: {}, channelId:{}, 码流类型:{}", device.getDeviceId(), channel.getDeviceId(), + log.info("[点播成功] 设备编号: {}, 通道编号:{}, 码流类型:{}", device.getDeviceId(), channel.getDeviceId(), channel.getStreamIdentification()); snapOnPlay(result.getHookData().getMediaServer(), device.getDeviceId(), channel.getDeviceId(), streamId); }else { @@ -435,7 +435,7 @@ public class PlayServiceImpl implements IPlayService { } }); if (ssrcInfo == null || ssrcInfo.getPort() <= 0) { - log.info("[点播端口/SSRC]获取失败,deviceId={},channelId={},ssrcInfo={}", device.getDeviceId(), channel.getDeviceId(), ssrcInfo); + log.info("[点播端口/SSRC]获取失败,设备编号:{}, 通道编号:{},ssrcInfo;{}", device.getDeviceId(), channel.getDeviceId(), ssrcInfo); callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "获取端口或者ssrc失败", null); inviteStreamService.call(InviteSessionType.PLAY, channel.getId(), null, InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), @@ -443,9 +443,9 @@ public class PlayServiceImpl implements IPlayService { null); return null; } - log.info("[点播开始] deviceId: {}, channelId({}): {},码流类型:{}, 收流端口: {}, 码流:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}", - device.getDeviceId(), channel.getDeviceId(), channel.getId(), channel.getStreamIdentification(), ssrcInfo.getPort(), ssrcInfo.getStream(), - device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck()); + log.info("[点播开始] 设备编号: {}, 通道编号: {}, 收流端口: {}, 流ID:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}", + device.getDeviceId(), channel.getDeviceId(), channel.getStreamIdentification(), ssrcInfo.getPort(), ssrcInfo.getStream(), + ssrcInfo.getSsrc(), device.isSsrcCheck()); // 初始化redis中的invite消息状态 InviteInfo inviteInfo = InviteInfo.getInviteInfo(device.getDeviceId(), channel.getId(), ssrcInfo.getStream(), ssrcInfo, mediaServerItem.getId(), diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index 587063068..a8c106281 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -81,8 +81,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement // 查询设备是否存在 Device device = redisCatchStorage.getDevice(deviceId); // 查询上级平台是否存在 -// Platform parentPlatform = platformService.queryPlatformByServerGBId(deviceId); - Platform parentPlatform = null; + Platform parentPlatform = platformService.queryPlatformByServerGBId(deviceId); try { if (device != null && parentPlatform != null) { String hostAddress = request.getRemoteAddress().getHostAddress(); diff --git a/src/main/java/com/genersoft/iot/vmp/web/custom/CameraChannelController.java b/src/main/java/com/genersoft/iot/vmp/web/custom/CameraChannelController.java index e8f201f88..85d818761 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/custom/CameraChannelController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/custom/CameraChannelController.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.web.custom; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.conf.security.JwtUtils; @@ -33,6 +34,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; @@ -44,6 +46,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -73,9 +76,14 @@ public class CameraChannelController { @Autowired private IStreamPushPlayService streamPushPlayService; + @Autowired + private DynamicTask dynamicTask; + @Autowired private IStreamProxyService streamProxyService; + @Value("${sy.ptz-control-time-interval}") + private int ptzControlTimeInterval = 300; @GetMapping(value = "/camera/list") @ResponseBody @@ -308,6 +316,12 @@ public class CameraChannelController { wvpResult.setData(data); result.setResult(wvpResult); }); + // 设置时间间隔后自动发送停止 + if (!command.equalsIgnoreCase("stop")) { + dynamicTask.startDelay(UUID.randomUUID().toString(), () -> { + channelService.ptz(deviceId, deviceCode, "stop", speed, (code, msg, data) -> {}); + }, ptzControlTimeInterval); + } return result; } diff --git a/src/main/java/com/genersoft/iot/vmp/web/custom/service/CameraChannelService.java b/src/main/java/com/genersoft/iot/vmp/web/custom/service/CameraChannelService.java index 3e6cd541e..5392eb913 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/custom/service/CameraChannelService.java +++ b/src/main/java/com/genersoft/iot/vmp/web/custom/service/CameraChannelService.java @@ -513,12 +513,12 @@ public class CameraChannelService implements CommandLineRunner { if (geoCoordSys != null && longitude != null && latitude != null && longitude > 0 && latitude > 0) { if (geoCoordSys.equalsIgnoreCase("GCJ02")) { - Double[] position = Coordtransform.WGS84ToGCJ02(longitude, latitude); + Double[] position = Coordtransform.GCJ02ToWGS84(longitude, latitude); commonGBChannel.setGbLongitude(position[0]); commonGBChannel.setGbLatitude(position[1]); }else if (geoCoordSys.equalsIgnoreCase("BD09")) { - Double[] gcj02Position = Coordtransform.WGS84ToGCJ02(longitude, latitude); - Double[] position = Coordtransform.GCJ02ToBD09(gcj02Position[0], gcj02Position[1]); + Double[] gcj02Position = Coordtransform.BD09ToGCJ02(longitude, latitude); + Double[] position = Coordtransform.GCJ02ToWGS84(gcj02Position[0], gcj02Position[1]); commonGBChannel.setGbLongitude(position[0]); commonGBChannel.setGbLatitude(position[1]); }else {