From fa47f619ba9e84d5494003fe4ae50299260dcbe0 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Tue, 3 Sep 2024 18:00:35 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../genersoft/iot/vmp/common/InviteInfo.java | 86 +------
.../iot/vmp/common/VideoManagerConstants.java | 4 +-
.../iot/vmp/gb28181/bean/CommonGBChannel.java | 6 +-
.../iot/vmp/gb28181/bean/MobilePosition.java | 2 +-
.../iot/vmp/gb28181/bean/SendRtpItem.java | 215 +-----------------
.../iot/vmp/gb28181/bean/SsrcTransaction.java | 64 +-----
.../vmp/gb28181/dao/DeviceChannelMapper.java | 6 +-
.../gb28181/dao/PlatformChannelMapper.java | 33 ++-
.../subscribe/catalog/CatalogEventLister.java | 7 +-
.../mobilePosition/MobilePositionEvent.java | 13 +-
.../MobilePositionEventLister.java | 13 +-
.../service/IDeviceChannelService.java | 3 +
.../gb28181/service/IInviteStreamService.java | 24 +-
.../service/IPlatformChannelService.java | 9 +
.../vmp/gb28181/service/IPlatformService.java | 2 +-
.../iot/vmp/gb28181/service/IPlayService.java | 3 +-
.../impl/DeviceChannelServiceImpl.java | 14 +-
.../service/impl/GbChannelServiceImpl.java | 40 +++-
.../service/impl/InviteStreamServiceImpl.java | 97 ++++----
.../impl/PlatformChannelServiceImpl.java | 91 +++++++-
.../service/impl/PlatformServiceImpl.java | 65 +++---
.../gb28181/service/impl/PlayServiceImpl.java | 29 ++-
.../session/VideoStreamSessionManager.java | 47 ++--
.../cmd/ISIPCommanderForPlatform.java | 2 +-
.../cmd/impl/SIPCommanderFroPlatform.java | 8 +-
.../request/impl/ByeRequestProcessor.java | 4 +-
...tifyRequestForMobilePositionProcessor.java | 5 +-
.../request/impl/NotifyRequestProcessor.java | 34 +--
.../notify/cmd/AlarmNotifyMessageHandler.java | 12 +-
.../cmd/BroadcastNotifyMessageHandler.java | 2 +-
.../MobilePositionNotifyMessageHandler.java | 15 +-
.../MobilePositionResponseMessageHandler.java | 91 ++++----
.../iot/vmp/media/zlm/SendRtpPortManager.java | 2 +-
.../iot/vmp/service/bean/GPSMsgInfo.java | 6 +-
.../service/bean/MessageForPushChannel.java | 77 +------
.../vmp/service/impl/MediaServiceImpl.java | 25 +-
.../vmp/storager/IVideoManagerStorage.java | 4 +-
.../storager/impl/RedisCatchStorageImpl.java | 20 +-
.../impl/VideoManagerStorageImpl.java | 10 +-
.../vmp/web/gb28181/ApiStreamController.java | 2 +-
40 files changed, 472 insertions(+), 720 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/common/InviteInfo.java b/src/main/java/com/genersoft/iot/vmp/common/InviteInfo.java
index dbe9e090..8c91dc82 100644
--- a/src/main/java/com/genersoft/iot/vmp/common/InviteInfo.java
+++ b/src/main/java/com/genersoft/iot/vmp/common/InviteInfo.java
@@ -1,15 +1,17 @@
package com.genersoft.iot.vmp.common;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
+import lombok.Data;
/**
* 记录每次发送invite消息的状态
*/
+@Data
public class InviteInfo {
private String deviceId;
- private String channelId;
+ private Integer channelId;
private String stream;
@@ -28,7 +30,7 @@ public class InviteInfo {
private StreamInfo streamInfo;
- public static InviteInfo getInviteInfo(String deviceId, String channelId, String stream, SSRCInfo ssrcInfo,
+ public static InviteInfo getInviteInfo(String deviceId, Integer channelId, String stream, SSRCInfo ssrcInfo,
String receiveIp, Integer receivePort, String streamMode,
InviteSessionType type, InviteSessionStatus status) {
InviteInfo inviteInfo = new InviteInfo();
@@ -44,84 +46,4 @@ public class InviteInfo {
return inviteInfo;
}
- public String getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(String deviceId) {
- this.deviceId = deviceId;
- }
-
- public String getChannelId() {
- return channelId;
- }
-
- public void setChannelId(String channelId) {
- this.channelId = channelId;
- }
-
- public InviteSessionType getType() {
- return type;
- }
-
- public void setType(InviteSessionType type) {
- this.type = type;
- }
-
- public InviteSessionStatus getStatus() {
- return status;
- }
-
- public void setStatus(InviteSessionStatus status) {
- this.status = status;
- }
-
- public StreamInfo getStreamInfo() {
- return streamInfo;
- }
-
- public void setStreamInfo(StreamInfo streamInfo) {
- this.streamInfo = streamInfo;
- }
-
- public String getStream() {
- return stream;
- }
-
- public void setStream(String stream) {
- this.stream = stream;
- }
-
- public SSRCInfo getSsrcInfo() {
- return ssrcInfo;
- }
-
- public void setSsrcInfo(SSRCInfo ssrcInfo) {
- this.ssrcInfo = ssrcInfo;
- }
-
- public String getReceiveIp() {
- return receiveIp;
- }
-
- public void setReceiveIp(String receiveIp) {
- this.receiveIp = receiveIp;
- }
-
- public Integer getReceivePort() {
- return receivePort;
- }
-
- public void setReceivePort(Integer receivePort) {
- this.receivePort = receivePort;
- }
-
- public String getStreamMode() {
- return streamMode;
- }
-
- public void setStreamMode(String streamMode) {
- this.streamMode = streamMode;
- }
-
}
diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
index c4911e4b..ad353d3b 100644
--- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
+++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
@@ -26,7 +26,7 @@ public class VideoManagerConstants {
public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_";
// TODO 此处多了一个_,暂不修改
- public static final String INVITE_PREFIX = "VMP_INVITE";
+ public static final String INVITE_PREFIX = "VMP_INVITE_INFO_";
public static final String PLAYER_PREFIX = "VMP_INVITE_PLAY_";
public static final String PLAY_BLACK_PREFIX = "VMP_INVITE_PLAYBACK_";
public static final String DOWNLOAD_PREFIX = "VMP_INVITE_DOWNLOAD_";
@@ -39,7 +39,7 @@ public class VideoManagerConstants {
public static final String PLATFORM_REGISTER_INFO_PREFIX = "VMP_PLATFORM_REGISTER_INFO_";
- public static final String PLATFORM_SEND_RTP_INFO_PREFIX = "VMP_PLATFORM_SEND_RTP_INFO_";
+ public static final String SEND_RTP_INFO_PREFIX = "VMP_SEND_RTP_INFO";
public static final String EVENT_ONLINE_REGISTER = "1";
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java
index 74179cae..b3a41392 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CommonGBChannel.java
@@ -301,8 +301,10 @@ public class CommonGBChannel {
if (this.getGbCivilCode() != null) {
content.append("" + this.getGbCivilCode() + "\n");
}
- content.append("" + this.getGbParentId() + "\n")
- .append("" + this.getGbBusinessGroupId() + "\n");
+ if (this.getGbParentId() != null) {
+ content.append("" + this.getGbParentId() + "\n");
+ }
+ content.append("" + this.getGbBusinessGroupId() + "\n");
} else {
if (this.getGbManufacturer() != null) {
content.append("" + this.getGbManufacturer() + "\n");
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java
index 8b08930c..52b9d798 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java
@@ -18,7 +18,7 @@ public class MobilePosition {
/**
* 通道Id
*/
- private String channelId;
+ private Integer channelId;
/**
* 设备名称
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java
index 55f09df3..effcad8d 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java
@@ -3,7 +3,9 @@ package com.genersoft.iot.vmp.gb28181.bean;
import com.genersoft.iot.vmp.service.bean.RequestPushStreamMsg;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
+import lombok.Data;
+@Data
public class SendRtpItem {
/**
@@ -44,7 +46,7 @@ public class SendRtpItem {
/**
* 通道id
*/
- private String channelId;
+ private Integer channelId;
/**
* 推流状态
@@ -174,214 +176,6 @@ public class SendRtpItem {
return sendRtpItem;
}
- public String getIp() {
- return ip;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getSsrc() {
- return ssrc;
- }
-
- public void setSsrc(String ssrc) {
- this.ssrc = ssrc;
- }
-
- public String getPlatformId() {
- return platformId;
- }
-
- public void setPlatformId(String platformId) {
- this.platformId = platformId;
- }
-
- public String getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(String deviceId) {
- this.deviceId = deviceId;
- }
-
- public String getChannelId() {
- return channelId;
- }
-
- public void setChannelId(String channelId) {
- this.channelId = channelId;
- }
-
- public int getStatus() {
- return status;
- }
-
- public void setStatus(int status) {
- this.status = status;
- }
-
- public String getApp() {
- return app;
- }
-
- public void setApp(String app) {
- this.app = app;
- }
-
- public String getStream() {
- return stream;
- }
-
- public void setStream(String stream) {
- this.stream = stream;
- }
-
- public boolean isTcp() {
- return tcp;
- }
-
- public void setTcp(boolean tcp) {
- this.tcp = tcp;
- }
-
- public int getLocalPort() {
- return localPort;
- }
-
- public void setLocalPort(int localPort) {
- this.localPort = localPort;
- }
-
- public boolean isTcpActive() {
- return tcpActive;
- }
-
- public void setTcpActive(boolean tcpActive) {
- this.tcpActive = tcpActive;
- }
-
- public String getMediaServerId() {
- return mediaServerId;
- }
-
- public void setMediaServerId(String mediaServerId) {
- this.mediaServerId = mediaServerId;
- }
-
- public String getCallId() {
- return callId;
- }
-
- public void setCallId(String callId) {
- this.callId = callId;
- }
-
- public InviteStreamType getPlayType() {
- return playType;
- }
-
- public void setPlayType(InviteStreamType playType) {
- this.playType = playType;
- }
-
- public int getPt() {
- return pt;
- }
-
- public void setPt(int pt) {
- this.pt = pt;
- }
-
- public boolean isUsePs() {
- return usePs;
- }
-
- public void setUsePs(boolean usePs) {
- this.usePs = usePs;
- }
-
- public boolean isOnlyAudio() {
- return onlyAudio;
- }
-
- public void setOnlyAudio(boolean onlyAudio) {
- this.onlyAudio = onlyAudio;
- }
-
- public String getServerId() {
- return serverId;
- }
-
- public void setServerId(String serverId) {
- this.serverId = serverId;
- }
-
- public String getFromTag() {
- return fromTag;
- }
-
- public void setFromTag(String fromTag) {
- this.fromTag = fromTag;
- }
-
- public String getToTag() {
- return toTag;
- }
-
- public void setToTag(String toTag) {
- this.toTag = toTag;
- }
-
- public boolean isRtcp() {
- return rtcp;
- }
-
- public void setRtcp(boolean rtcp) {
- this.rtcp = rtcp;
- }
-
- public String getReceiveStream() {
- return receiveStream;
- }
-
- public void setReceiveStream(String receiveStream) {
- this.receiveStream = receiveStream;
- }
-
- public String getPlatformName() {
- return platformName;
- }
-
- public void setPlatformName(String platformName) {
- this.platformName = platformName;
- }
-
- public String getLocalIp() {
- return localIp;
- }
-
- public void setLocalIp(String localIp) {
- this.localIp = localIp;
- }
-
- public String getSessionName() {
- return sessionName;
- }
-
- public void setSessionName(String sessionName) {
- this.sessionName = sessionName;
- }
-
@Override
public String toString() {
return "SendRtpItem{" +
@@ -415,13 +209,12 @@ public class SendRtpItem {
}
public String getRedisKey() {
- String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX +
+ return VideoManagerConstants.SEND_RTP_INFO_PREFIX +
serverId + "_"
+ mediaServerId + "_"
+ platformId + "_"
+ channelId + "_"
+ stream + "_"
+ callId;
- return key;
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java
index 6ed8d144..27f3f4cb 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java
@@ -1,11 +1,14 @@
package com.genersoft.iot.vmp.gb28181.bean;
import com.genersoft.iot.vmp.common.InviteSessionType;
+import lombok.Data;
+@Data
public class SsrcTransaction {
private String deviceId;
- private String channelId;
+ private String platformId;
+ private Integer channelId;
private String callId;
private String stream;
private String mediaServerId;
@@ -15,67 +18,20 @@ public class SsrcTransaction {
private InviteSessionType type;
- public String getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(String deviceId) {
+ public SsrcTransaction(String deviceId, String platformId, Integer channelId, String callId,
+ String stream, String mediaServerId, String ssrc,
+ SipTransactionInfo sipTransactionInfo, InviteSessionType type) {
this.deviceId = deviceId;
- }
-
- public String getChannelId() {
- return channelId;
- }
-
- public void setChannelId(String channelId) {
+ this.platformId = platformId;
this.channelId = channelId;
- }
-
- public String getCallId() {
- return callId;
- }
-
- public void setCallId(String callId) {
this.callId = callId;
- }
-
- public String getStream() {
- return stream;
- }
-
- public void setStream(String stream) {
this.stream = stream;
- }
-
- public String getMediaServerId() {
- return mediaServerId;
- }
-
- public void setMediaServerId(String mediaServerId) {
this.mediaServerId = mediaServerId;
- }
-
- public String getSsrc() {
- return ssrc;
- }
-
- public void setSsrc(String ssrc) {
this.ssrc = ssrc;
- }
-
- public InviteSessionType getType() {
- return type;
- }
-
- public void setType(InviteSessionType type) {
+ this.sipTransactionInfo = sipTransactionInfo;
this.type = type;
}
- public SipTransactionInfo getSipTransactionInfo() {
- return sipTransactionInfo;
- }
-
- public void setSipTransactionInfo(SipTransactionInfo sipTransactionInfo) {
- this.sipTransactionInfo = sipTransactionInfo;
+ public SsrcTransaction() {
}
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
index 5659828c..74fc8d78 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java
@@ -539,7 +539,7 @@ public interface DeviceChannelMapper {
List queryAllChannels(@Param("deviceDbId") int deviceDbId);
@Select("select de.* from wvp_device de left join wvp_device_channel dc on de.device_id = dc.deviceId where dc.device_id=#{channelId}")
- List getDeviceByChannelId(String channelId);
+ List getDeviceByChannelDeviceId(String channelId);
@Delete({""})
DeviceChannel getOneByDeviceId(@Param("deviceDbId") int deviceDbId, @Param("channelId") String channelId);
+
+
+ @Update(value = {"UPDATE wvp_device_channel SET stream_id=null WHERE id=#{channelId}"})
+ void stopPlayById(@Param("channelId") Integer channelId);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java
index cc607ae2..b82b61c0 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java
@@ -39,19 +39,17 @@ public interface PlatformChannelMapper {
@Select(" ")
- List queryPlatFormListForGBWithGBId(@Param("channelId") String channelId, @Param("platforms") List platforms);
+ List queryPlatFormListForGBWithGBId(@Param("channelId") Integer channelId, List platforms);
@Select("select dc.channel_id, dc.device_id,dc.name,d.manufacturer,d.model,d.firmware\n" +
"from wvp_platform_channel pgc\n" +
@@ -336,7 +334,7 @@ public interface PlatformChannelMapper {
" (#{platformId}, #{item.id} )" +
"" +
"")
- int addPlatformGroup(List groupListNotShare, @Param("platformId") Integer platformId);
+ int addPlatformGroup(Collection groupListNotShare, @Param("platformId") Integer platformId);
@Insert("")
- Set queryShareChildrenGroup(@Param("parentId") String parentId, @Param("platformId") Integer platformId);
+ Set queryShareChildrenGroup(@Param("parentId") Integer parentId, @Param("platformId") Integer platformId);
@Select(" ")
CommonGBChannel queryShareChannel(@Param("platformId") int platformId, @Param("gbId") int gbId);
+
+
+ @Select(" ")
+ Set queryShareGroup(@Param("platformId") Integer platformId);
+
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
index 91f2bdd4..28a42264 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
@@ -4,9 +4,9 @@ import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
+import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
@@ -28,7 +28,7 @@ import java.util.Map;
public class CatalogEventLister implements ApplicationListener {
@Autowired
- private IVideoManagerStorage storager;
+ private IPlatformChannelService platformChannelService;
@Autowired
private IPlatformService platformService;
@@ -62,7 +62,8 @@ public class CatalogEventLister implements ApplicationListener {
if (event.getChannels() != null) {
if (!platforms.isEmpty()) {
for (CommonGBChannel deviceChannel : event.getChannels()) {
- List parentPlatformsForGB = storager.queryPlatFormListForGBWithGBId(deviceChannel.getGbDeviceId(), platforms);
+ List parentPlatformsForGB = platformChannelService.queryPlatFormListByChannelDeviceId(
+ deviceChannel.getGbId(), platforms);
parentPlatformMap.put(deviceChannel.getGbDeviceId(), parentPlatformsForGB);
channelMap.put(deviceChannel.getGbDeviceId(), deviceChannel);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/mobilePosition/MobilePositionEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/mobilePosition/MobilePositionEvent.java
index 06866517..f6a4ad75 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/mobilePosition/MobilePositionEvent.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/mobilePosition/MobilePositionEvent.java
@@ -1,20 +1,17 @@
package com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition;
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
+import lombok.Getter;
+import lombok.Setter;
import org.springframework.context.ApplicationEvent;
+
public class MobilePositionEvent extends ApplicationEvent {
public MobilePositionEvent(Object source) {
super(source);
}
+ @Getter
+ @Setter
private MobilePosition mobilePosition;
-
- public MobilePosition getMobilePosition() {
- return mobilePosition;
- }
-
- public void setMobilePosition(MobilePosition mobilePosition) {
- this.mobilePosition = mobilePosition;
- }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/mobilePosition/MobilePositionEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/mobilePosition/MobilePositionEventLister.java
index 83aba09d..2ba42af5 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/mobilePosition/MobilePositionEventLister.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/mobilePosition/MobilePositionEventLister.java
@@ -1,11 +1,12 @@
package com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition;
+import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
+import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
@@ -24,7 +25,7 @@ import java.util.List;
public class MobilePositionEventLister implements ApplicationListener {
@Autowired
- private IVideoManagerStorage storager;
+ private IPlatformChannelService platformChannelService;
@Autowired
private SIPCommanderFroPlatform sipCommanderFroPlatform;
@@ -39,14 +40,18 @@ public class MobilePositionEventLister implements ApplicationListener parentPlatformsForGB = storager.queryPlatFormListForGBWithGBId(event.getMobilePosition().getChannelId(), platforms);
+
+ List parentPlatformsForGB = platformChannelService.queryPlatFormListByChannelDeviceId(event.getMobilePosition().getChannelId(), platforms);
for (Platform platform : parentPlatformsForGB) {
log.info("[向上级发送MobilePosition] 通道:{},平台:{}, 位置: {}:{}", event.getMobilePosition().getChannelId(),
platform.getServerGBId(), event.getMobilePosition().getLongitude(), event.getMobilePosition().getLatitude());
SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId());
try {
- sipCommanderFroPlatform.sendNotifyMobilePosition(platform, GPSMsgInfo.getInstance(event.getMobilePosition()),
+ GPSMsgInfo gpsMsgInfo = GPSMsgInfo.getInstance(event.getMobilePosition());
+ // 获取通道编号
+ CommonGBChannel commonGBChannel = platformChannelService.queryChannelByPlatformIdAndChannelId(platform.getId(), event.getMobilePosition().getChannelId());
+ sipCommanderFroPlatform.sendNotifyMobilePosition(platform, gpsMsgInfo, commonGBChannel,
subscribe);
} catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException |
IllegalAccessException e) {
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java
index e176c355..ffb8c23a 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IDeviceChannelService.java
@@ -93,6 +93,8 @@ public interface IDeviceChannelService {
void stopPlay(String deviceId, String channelId);
+ void stopPlay(Integer channelId);
+
void batchUpdateChannelGPS(List channelList);
void batchAddMobilePosition(List addMobilePositionList);
@@ -118,4 +120,5 @@ public interface IDeviceChannelService {
DeviceChannel getRawChannel(int id);
+ DeviceChannel getOneById(Integer channelId);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IInviteStreamService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IInviteStreamService.java
index 88c43b39..9903d59b 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IInviteStreamService.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IInviteStreamService.java
@@ -5,6 +5,8 @@ import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
+import java.util.List;
+
/**
* 记录国标点播的状态,包括实时预览,下载,录像回放
*/
@@ -22,18 +24,12 @@ public interface IInviteStreamService {
/**
* 获取点播的状态信息
*/
- InviteInfo getInviteInfo(InviteSessionType type,
- String deviceId,
- String channelId,
- String stream);
+ InviteInfo getInviteInfo(InviteSessionType type, Integer channelId, String stream);
/**
* 移除点播的状态信息
*/
- void removeInviteInfo(InviteSessionType type,
- String deviceId,
- String channelId,
- String stream);
+ void removeInviteInfo(InviteSessionType type, Integer channelId, String stream);
/**
* 移除点播的状态信息
*/
@@ -41,14 +37,14 @@ public interface IInviteStreamService {
/**
* 移除点播的状态信息
*/
- void removeInviteInfoByDeviceAndChannel(InviteSessionType inviteSessionType, String deviceId, String channelId);
+ void removeInviteInfoByDeviceAndChannel(InviteSessionType inviteSessionType, Integer channelId);
+
+ List getAllInviteInfo(InviteSessionType type, Integer channelId, String stream);
/**
* 获取点播的状态信息
*/
- InviteInfo getInviteInfoByDeviceAndChannel(InviteSessionType type,
- String deviceId,
- String channelId);
+ InviteInfo getInviteInfoByDeviceAndChannel(InviteSessionType type, Integer channelId);
/**
* 获取点播的状态信息
@@ -59,12 +55,12 @@ public interface IInviteStreamService {
/**
* 添加一个invite回调
*/
- void once(InviteSessionType type, String deviceId, String channelId, String stream, ErrorCallback callback);
+ void once(InviteSessionType type, Integer channelId, String stream, ErrorCallback callback);
/**
* 调用一个invite回调
*/
- void call(InviteSessionType type, String deviceId, String channelId, String stream, int code, String msg, StreamInfo data);
+ void call(InviteSessionType type, Integer channelId, String stream, int code, String msg, StreamInfo data);
/**
* 清空一个设备的所有invite信息
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformChannelService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformChannelService.java
index 983fdf76..66233a6f 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformChannelService.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformChannelService.java
@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
+import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformChannel;
import com.github.pagehelper.PageInfo;
@@ -36,4 +37,12 @@ public interface IPlatformChannelService {
void removeChannelByDevice(Integer platformId, List deviceIds);
void updateCustomChannel(PlatformChannel channel);
+
+ void checkGroupRemove(List channelList, List groups);
+
+ void checkGroupAdd(List channelList);
+
+ List queryPlatFormListByChannelDeviceId(Integer channelId, List platforms);
+
+ CommonGBChannel queryChannelByPlatformIdAndChannelId(Integer platformId, Integer channelId);
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java
index 7d087160..6c43dcf5 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlatformService.java
@@ -75,7 +75,7 @@ public interface IPlatformService {
* @param errorEvent 信令错误事件
* @param timeoutCallback 超时事件
*/
- void broadcastInvite(Platform platform, String channelId, MediaServer mediaServerItem, HookSubscribe.Event hookEvent,
+ void broadcastInvite(Platform platform, CommonGBChannel channelId, MediaServer mediaServerItem, HookSubscribe.Event hookEvent,
SipSubscribe.Event errorEvent, InviteTimeOutCallback timeoutCallback) throws InvalidArgumentException, ParseException, SipException;
/**
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java
index 45f88406..1e7d69ef 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IPlayService.java
@@ -21,7 +21,7 @@ import java.text.ParseException;
*/
public interface IPlayService {
- void play(MediaServer mediaServerItem, SSRCInfo ssrcInfo, Device device, DeviceChannel channelId,
+ void play(MediaServer mediaServerItem, SSRCInfo ssrcInfo, Device device, DeviceChannel channel,
ErrorCallback callback);
SSRCInfo play(MediaServer mediaServerItem, String deviceId, String channelId, String ssrc, ErrorCallback callback);
@@ -30,7 +30,6 @@ public interface IPlayService {
MediaServer getNewMediaServerItem(Device device);
void playBack(String deviceId, String channelId, String startTime, String endTime, ErrorCallback callback);
- void playBack(MediaServer mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, ErrorCallback callback);
void zlmServerOffline(String mediaServerId);
void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback callback);
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java
index 9e51ff48..d9a1b6f6 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java
@@ -208,7 +208,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
@Override
public List getDeviceByChannelId(String channelId) {
- return channelMapper.getDeviceByChannelId(channelId);
+ return channelMapper.getDeviceByChannelDeviceId(channelId);
}
@Override
@@ -340,7 +340,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
}
for (DeviceChannel channel : deviceChannels) {
// 向关联了该通道并且开启移动位置订阅的上级平台发送移动位置订阅消息
- mobilePosition.setChannelId(channel.getDeviceId());
+ mobilePosition.setChannelId(channel.getId());
try {
eventPublisher.mobilePositionEventPublish(mobilePosition);
}catch (Exception e) {
@@ -378,6 +378,11 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
channelMapper.stopPlay(device.getId(), channelId);
}
+ @Override
+ public void stopPlay(Integer channelId) {
+ channelMapper.stopPlayById(channelId);
+ }
+
@Override
@Transactional
public void batchUpdateChannelGPS(List channelList) {
@@ -596,4 +601,9 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
public DeviceChannel getRawChannel(int id) {
return deviceMapper.getRawChannel(id);
}
+
+ @Override
+ public DeviceChannel getOneById(Integer channelId) {
+ return channelMapper.getOne(channelId);
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
index 2fae3b02..ffbe6f64 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java
@@ -500,12 +500,15 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
@Override
+ @Transactional
public void removeParentIdByBusinessGroup(String businessGroup) {
List channelList = commonGBChannelMapper.queryByBusinessGroup(businessGroup);
if (channelList.isEmpty()) {
return;
}
int result = commonGBChannelMapper.removeParentIdByChannels(channelList);
+ List groupList = groupMapper.queryByBusinessGroup(businessGroup);
+ platformChannelService.checkGroupRemove(channelList, groupList);
}
@@ -516,7 +519,7 @@ public class GbChannelServiceImpl implements IGbChannelService {
return;
}
commonGBChannelMapper.removeParentIdByChannels(channelList);
- // TODO 可能需要发送通道更新通知
+ platformChannelService.checkGroupRemove(channelList, groupList);
}
@Override
@@ -560,18 +563,21 @@ public class GbChannelServiceImpl implements IGbChannelService {
}
@Override
+ @Transactional
public void addChannelToGroup(String parentId, String businessGroup, List channelIds) {
List channelList = commonGBChannelMapper.queryByIds(channelIds);
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
int result = commonGBChannelMapper.updateGroup(parentId, businessGroup, channelList);
+ for (CommonGBChannel commonGBChannel : channelList) {
+ commonGBChannel.setGbParentId(parentId);
+ commonGBChannel.setGbBusinessGroupId(businessGroup);
+ }
+
// 发送通知
if (result > 0) {
- for (CommonGBChannel channel : channelList) {
- channel.setGbBusinessGroupId(businessGroup);
- channel.setGbParentId(parentId);
- }
+ platformChannelService.checkGroupAdd(channelList);
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
@@ -587,10 +593,20 @@ public class GbChannelServiceImpl implements IGbChannelService {
if (channelList.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
- int result = commonGBChannelMapper.removeParentIdByChannels(channelList);
+ commonGBChannelMapper.removeParentIdByChannels(channelList);
+
+ Group group = groupMapper.queryOneByDeviceId(parentId, businessGroup);
+ if (group == null) {
+ platformChannelService.checkGroupRemove(channelList, null);
+ }else {
+ List groupList = new ArrayList<>();
+ groupList.add(group);
+ platformChannelService.checkGroupRemove(channelList, groupList);
+ }
}
@Override
+ @Transactional
public void addChannelToGroupByGbDevice(String parentId, String businessGroup, List deviceIds) {
List channelList = commonGBChannelMapper.queryByGbDeviceIds(deviceIds);
if (channelList.isEmpty()) {
@@ -601,12 +617,14 @@ public class GbChannelServiceImpl implements IGbChannelService {
channel.setGbBusinessGroupId(businessGroup);
}
int result = commonGBChannelMapper.updateGroup(parentId, businessGroup, channelList);
+
+ for (CommonGBChannel commonGBChannel : channelList) {
+ commonGBChannel.setGbParentId(parentId);
+ commonGBChannel.setGbBusinessGroupId(businessGroup);
+ }
// 发送通知
if (result > 0) {
- for (CommonGBChannel channel : channelList) {
- channel.setGbBusinessGroupId(businessGroup);
- channel.setGbParentId(parentId);
- }
+ platformChannelService.checkGroupAdd(channelList);
try {
// 发送catalog
eventPublisher.catalogEventPublish(null, channelList, CatalogEvent.UPDATE);
@@ -623,10 +641,12 @@ public class GbChannelServiceImpl implements IGbChannelService {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "所有通道Id不存在");
}
commonGBChannelMapper.removeParentIdByChannels(channelList);
+ platformChannelService.checkGroupRemove(channelList, null);
}
@Override
public CommonGBChannel queryOneWithPlatform(Integer platformId, String channelDeviceId) {
+ // 防止共享的通道编号重复
List channelList = platformChannelMapper.queryOneWithPlatform(platformId, channelDeviceId);
if (!channelList.isEmpty()) {
return channelList.get(channelList.size() - 1);
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/InviteStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/InviteStreamServiceImpl.java
index b81f07a0..9b983336 100755
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/InviteStreamServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/InviteStreamServiceImpl.java
@@ -7,9 +7,8 @@ import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
-import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
-import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
import com.genersoft.iot.vmp.gb28181.service.IInviteStreamService;
+import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import lombok.extern.slf4j.Slf4j;
@@ -19,6 +18,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -44,17 +44,6 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
@Autowired
private DeviceChannelMapper deviceChannelMapper;
- /**
- * 流到来的处理
- */
- @Async("taskExecutor")
- @org.springframework.context.event.EventListener
- public void onApplicationEvent(MediaArrivalEvent event) {
-// if ("rtsp".equals(event.getSchema()) && "rtp".equals(event.getApp())) {
-//
-// }
- }
-
/**
* 流离开的处理
*/
@@ -67,7 +56,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
removeInviteInfo(inviteInfo);
Device device = deviceMapper.getDeviceByDeviceId(inviteInfo.getDeviceId());
if (device != null) {
- deviceChannelMapper.stopPlay(device.getId(), inviteInfo.getChannelId());
+ deviceChannelMapper.stopPlayById(inviteInfo.getChannelId());
}
}
}
@@ -87,7 +76,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
log.warn("[更新Invite信息],参数不全: {}", JSON.toJSON(inviteInfo));
return;
}
- InviteInfo inviteInfoForUpdate = null;
+ InviteInfo inviteInfoForUpdate;
if (InviteSessionStatus.ready == inviteInfo.getStatus()) {
if (inviteInfo.getDeviceId() == null
@@ -99,8 +88,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
}
inviteInfoForUpdate = inviteInfo;
} else {
- InviteInfo inviteInfoInRedis = getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(),
- inviteInfo.getChannelId(), inviteInfo.getStream());
+ InviteInfo inviteInfoInRedis = getInviteInfo(inviteInfo.getType(), inviteInfo.getChannelId(), inviteInfo.getStream());
if (inviteInfoInRedis == null) {
log.warn("[更新Invite信息],未从缓存中读取到Invite信息: deviceId: {}, channel: {}, stream: {}",
inviteInfo.getDeviceId(), inviteInfo.getChannelId(), inviteInfo.getStream());
@@ -144,7 +132,7 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
@Override
public InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream) {
- InviteInfo inviteInfoInDb = getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), inviteInfo.getChannelId(), inviteInfo.getStream());
+ InviteInfo inviteInfoInDb = getInviteInfo(inviteInfo.getType(), inviteInfo.getChannelId(), inviteInfo.getStream());
if (inviteInfoInDb == null) {
return null;
}
@@ -169,10 +157,9 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
}
@Override
- public InviteInfo getInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) {
+ public InviteInfo getInviteInfo(InviteSessionType type, Integer channelId, String stream) {
String key = VideoManagerConstants.INVITE_PREFIX +
":" + (type != null ? type : "*") +
- ":" + (deviceId != null ? deviceId : "*") +
":" + (channelId != null ? channelId : "*") +
":" + (stream != null ? stream : "*")
+ ":*";
@@ -188,25 +175,42 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
}
@Override
- public InviteInfo getInviteInfoByDeviceAndChannel(InviteSessionType type, String deviceId, String channelId) {
- return getInviteInfo(type, deviceId, channelId, null);
+ public List getAllInviteInfo(InviteSessionType type, Integer channelId, String stream) {
+ String key = VideoManagerConstants.INVITE_PREFIX +
+ ":" + (type != null ? type : "*") +
+ ":" + (channelId != null ? channelId : "*") +
+ ":" + (stream != null ? stream : "*")
+ + ":*";
+ List