Merge branch 'wvp-28181-2.0' of https://github.com/648540858/wvp-GB28181-pro into wvp-28181-2.0
commit
b675101380
14
pom.xml
14
pom.xml
|
@ -11,7 +11,7 @@
|
|||
|
||||
<groupId>com.genersoft</groupId>
|
||||
<artifactId>wvp-pro</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.0.2</version>
|
||||
<name>web video platform</name>
|
||||
<description>国标28181视频平台</description>
|
||||
|
||||
|
@ -148,12 +148,14 @@
|
|||
<version>1.3.0-91</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 取代log4j -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
<version>1.7.35</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- xml解析库 -->
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
|
@ -228,6 +230,10 @@
|
|||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<!-- <scope>test</scope>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
|||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire.PlatformKeepaliveExpireEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformCycleRegisterEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformNotRegisterEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
|
||||
|
@ -67,6 +68,16 @@ public class EventPublisher {
|
|||
platformNotRegisterEvent.setPlatformGbID(platformGbId);
|
||||
applicationEventPublisher.publishEvent(platformNotRegisterEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台周期注册事件
|
||||
* @param paltformGbId
|
||||
*/
|
||||
public void platformRegisterCycleEventPublish(String paltformGbId) {
|
||||
PlatformCycleRegisterEvent platformCycleRegisterEvent = new PlatformCycleRegisterEvent(this);
|
||||
platformCycleRegisterEvent.setPlatformGbID(paltformGbId);
|
||||
applicationEventPublisher.publishEvent(platformCycleRegisterEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备报警事件
|
||||
|
|
|
@ -66,7 +66,7 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent
|
|||
}else if (expiredKey.startsWith(PLATFORM_REGISTER_PREFIX)) {
|
||||
String platformGBId = expiredKey.substring(PLATFORM_REGISTER_PREFIX.length(),expiredKey.length());
|
||||
|
||||
publisher.platformNotRegisterEventPublish(platformGBId);
|
||||
publisher.platformRegisterCycleEventPublish(platformGBId);
|
||||
}else if (expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){
|
||||
String deviceId = expiredKey.substring(KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
|
||||
publisher.outlineEventPublish(deviceId, KEEPLIVEKEY_PREFIX);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
public class PlatformCycleRegisterEvent extends ApplicationEvent {
|
||||
/**
|
||||
* Add default serial version ID
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String platformGbID;
|
||||
|
||||
public String getPlatformGbID() {
|
||||
return platformGbID;
|
||||
}
|
||||
|
||||
public void setPlatformGbID(String platformGbID) {
|
||||
this.platformGbID = platformGbID;
|
||||
}
|
||||
|
||||
public PlatformCycleRegisterEvent(Object source) {
|
||||
super(source);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PlatformCycleRegisterEventLister implements ApplicationListener<PlatformCycleRegisterEvent> {
|
||||
@Autowired
|
||||
private IVideoManagerStorager storager;
|
||||
@Autowired
|
||||
private ISIPCommanderForPlatform sipCommanderFroPlatform;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(PlatformCycleRegisterEvent event) {
|
||||
log.info("上级平台周期注册事件");
|
||||
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformGbID());
|
||||
if (parentPlatform == null) {
|
||||
log.info("[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
|
||||
return;
|
||||
}
|
||||
Timer timer = new Timer();
|
||||
SipSubscribe.Event okEvent = (responseEvent)->{
|
||||
timer.cancel();
|
||||
};
|
||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
log.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
|
||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||
}
|
||||
}, 15*1000 ,Long.parseLong(parentPlatform.getExpires())* 1000);
|
||||
}
|
||||
}
|
|
@ -77,7 +77,14 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
|
|||
sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult);
|
||||
};
|
||||
}else {
|
||||
Element rootElement = getRootElement(evt);
|
||||
Element rootElement = null;
|
||||
try {
|
||||
rootElement = getRootElement(evt);
|
||||
} catch (DocumentException e) {
|
||||
logger.warn("解析XML消息内容异常", e);
|
||||
// 不存在则回复404
|
||||
responseAck(evt, Response.BAD_REQUEST, e.getMessage());
|
||||
}
|
||||
String name = rootElement.getName();
|
||||
IMessageHandler messageHandler = messageHandlerMap.get(name);
|
||||
if (messageHandler != null) {
|
||||
|
@ -98,8 +105,6 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
|
|||
logger.warn("参数无效", e);
|
||||
} catch (ParseException e) {
|
||||
logger.warn("SIP回复时解析异常", e);
|
||||
} catch (DocumentException e) {
|
||||
logger.warn("解析XML消息内容异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
|||
|
||||
@Override
|
||||
public List<StreamPushItem> getPushList(String mediaServerId) {
|
||||
return streamPushMapper.selectAllByMediaServerId(mediaServerId);
|
||||
return streamPushMapper.selectAllByMediaServerIdWithOutGbID(mediaServerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -204,7 +204,9 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
|||
Map<String, MediaItem> streamInfoPushItemMap = new HashMap<>();
|
||||
if (pushList.size() > 0) {
|
||||
for (StreamPushItem streamPushItem : pushList) {
|
||||
pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem);
|
||||
if (StringUtils.isEmpty(streamPushItem.getGbId())) {
|
||||
pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mediaItems.size() > 0) {
|
||||
|
@ -268,7 +270,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
|
|||
|
||||
@Override
|
||||
public void zlmServerOffline(String mediaServerId) {
|
||||
List<StreamPushItem> streamPushItems = streamPushMapper.selectAllByMediaServerId(mediaServerId);
|
||||
List<StreamPushItem> streamPushItems = streamPushMapper.selectAllByMediaServerIdWithOutGbID(mediaServerId);
|
||||
// 移除没有GBId的推流
|
||||
streamPushMapper.deleteWithoutGBId(mediaServerId);
|
||||
gbStreamMapper.deleteWithoutGBId("push", mediaServerId);
|
||||
|
|
|
@ -470,4 +470,6 @@ public interface IVideoManagerStorager {
|
|||
void delCatalogByPlatformId(String serverGBId);
|
||||
|
||||
void delRelationByPlatformId(String serverGBId);
|
||||
|
||||
PlatformCatalog queryDefaultCatalogInPlatform(String platformId);
|
||||
}
|
||||
|
|
|
@ -41,4 +41,7 @@ public interface PlatformCatalogMapper {
|
|||
|
||||
@Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.platformId=#{platformId}")
|
||||
List<PlatformCatalog> selectByPlatForm(String platformId);
|
||||
|
||||
@Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = (SELECT pp.catalogId from parent_platform pp WHERE pp.serverGBId=#{platformId})")
|
||||
PlatformCatalog selectDefaultByPlatFormId(String platformId);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,14 @@ public interface StreamPushMapper {
|
|||
@Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{stream}")
|
||||
int del(String app, String stream);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE sp FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream where " +
|
||||
"<foreach collection='streamPushItems' item='item' separator='or'>" +
|
||||
"(sp.app=#{item.app} and sp.stream=#{item.stream} and gs.gbId is null) " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int delAllWithoutGBId(List<StreamPushItem> streamPushItems);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE FROM stream_push where " +
|
||||
"<foreach collection='streamPushItems' item='item' separator='or'>" +
|
||||
|
@ -62,10 +70,13 @@ public interface StreamPushMapper {
|
|||
@Delete("DELETE FROM stream_push")
|
||||
void clear();
|
||||
|
||||
@Delete("DELETE FROM stream_push WHERE mediaServerId=#{mediaServerId}")
|
||||
@Delete("DELETE sp FROM stream_push sp left join gb_stream gs on gs.app = sp.app and gs.stream= sp.stream WHERE sp.mediaServerId=#{mediaServerId} and gs.gbId is null ")
|
||||
void deleteWithoutGBId(String mediaServerId);
|
||||
|
||||
@Select("SELECT * FROM stream_push WHERE mediaServerId=#{mediaServerId}")
|
||||
List<StreamPushItem> selectAllByMediaServerId(String mediaServerId);
|
||||
|
||||
@Select("SELECT sp.* FROM stream_push sp left join gb_stream gs on gs.app = sp.app and gs.stream= sp.stream WHERE sp.mediaServerId=#{mediaServerId} and gs.gbId is null")
|
||||
List<StreamPushItem> selectAllByMediaServerIdWithOutGbID(String mediaServerId);
|
||||
|
||||
}
|
||||
|
|
|
@ -1058,4 +1058,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
|||
platformGbStreamMapper.delByPlatformId(serverGBId);
|
||||
platformChannelMapper.delByPlatformId(serverGBId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) {
|
||||
return catalogMapper.selectDefaultByPlatFormId(platformId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,25 +465,30 @@ public class PlatformController {
|
|||
})
|
||||
@DeleteMapping("/catalog/del")
|
||||
@ResponseBody
|
||||
public ResponseEntity<WVPResult<List<PlatformCatalog>>> delCatalog(String id){
|
||||
public ResponseEntity<WVPResult<String>> delCatalog(String id, String platformId){
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除目录,{}", id);
|
||||
}
|
||||
// 如果删除的是默认目录则根目录设置为默认目录
|
||||
PlatformCatalog catalog = storager.getCatalog(id);
|
||||
if (catalog != null) {
|
||||
ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(catalog.getPlatformId());
|
||||
if (parentPlatform != null) {
|
||||
if (id.equals(parentPlatform.getCatalogId())) {
|
||||
storager.setDefaultCatalog(parentPlatform.getServerGBId(), parentPlatform.getServerGBId());
|
||||
}
|
||||
}
|
||||
WVPResult<String> result = new WVPResult<>();
|
||||
|
||||
if (StringUtils.isEmpty(id) || StringUtils.isEmpty(platformId)) {
|
||||
result.setCode(-1);
|
||||
result.setMsg("param error");
|
||||
return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
result.setCode(0);
|
||||
|
||||
int delResult = storager.delCatalog(id);
|
||||
WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
|
||||
result.setCode(0);
|
||||
// 如果删除的是默认目录则根目录设置为默认目录
|
||||
PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId);
|
||||
|
||||
// 默认节点被移除
|
||||
if (parentPlatform == null) {
|
||||
storager.setDefaultCatalog(platformId, platformId);
|
||||
result.setData(platformId);
|
||||
}
|
||||
|
||||
|
||||
if (delResult > 0) {
|
||||
result.setMsg("success");
|
||||
|
|
|
@ -20,7 +20,7 @@ spring:
|
|||
datasource:
|
||||
# 使用mysql 打开23-28行注释, 删除29-36行
|
||||
name: wvp
|
||||
url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true
|
||||
url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false
|
||||
username:
|
||||
password:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
@ -49,7 +49,7 @@ sip:
|
|||
#zlm 默认服务器配置
|
||||
media:
|
||||
# [必须修改] zlm服务器的内网IP
|
||||
ip: 127.0.0.1
|
||||
ip:
|
||||
# [必须修改] zlm服务器的http.port
|
||||
http-port: 80
|
||||
# [可选] zlm服务器的hook.admin_params=secret
|
||||
|
|
|
@ -20,7 +20,7 @@ spring:
|
|||
datasource:
|
||||
# 使用mysql 打开23-28行注释, 删除29-36行
|
||||
name: wvp
|
||||
url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true
|
||||
url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false
|
||||
username: root
|
||||
password: root
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
|
|
@ -52,13 +52,7 @@ export default {
|
|||
chooseChannelForCatalog,
|
||||
},
|
||||
computed: {
|
||||
// getPlayerShared: function () {
|
||||
// return {
|
||||
// sharedUrl: window.location.host + '/' + this.videoUrl,
|
||||
// sharedIframe: '<iframe src="' + window.location.host + '/' + this.videoUrl + '"></iframe>',
|
||||
// sharedRtmp: this.videoUrl
|
||||
// };
|
||||
// }
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -84,14 +78,6 @@ export default {
|
|||
this.closeCallback = closeCallback
|
||||
},
|
||||
tabClick (tab, event){
|
||||
console.log(tab.label)
|
||||
if (tab.label === "gbChannel") {
|
||||
this.$refs.chooseChannelForGb.catalogIdChange(this.catalogId);
|
||||
this.$refs.chooseChannelForGb.initData();
|
||||
}else {
|
||||
this.$refs.chooseChannelFoStream.catalogIdChange(this.catalogId);
|
||||
this.$refs.chooseChannelFoStream.initData();
|
||||
}
|
||||
|
||||
},
|
||||
close: function() {
|
||||
|
@ -125,11 +111,6 @@ export default {
|
|||
catalogIdChange: function (id) {
|
||||
console.log("中间模块收到: " + id)
|
||||
this.catalogId = id;
|
||||
if (this.tabActiveName === "gbChannel") {
|
||||
this.$refs.chooseChannelForGb.catalogIdChange(id);
|
||||
}else {
|
||||
this.$refs.chooseChannelFoStream.catalogIdChange(id);
|
||||
}
|
||||
},
|
||||
updateChooseChannelCallback (id){
|
||||
console.log("中间模块收到选择通道变化: " + id)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<span v-if="node.data.type === 2" class="iconfont icon-zhibo"></span>
|
||||
<span style="padding-left: 1px">{{ node.label }}</span>
|
||||
<span>
|
||||
<i style="margin-left: 5rem; color: #9d9d9d; padding-right: 20px" v-if="node.data.id === defaultCatalogId">默认</i>
|
||||
<i style="margin-left: 5rem; color: #9d9d9d; padding-right: 20px" v-if="node.data.id === defaultCatalogIdSign">默认</i>
|
||||
</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
|
@ -38,6 +38,8 @@ export default {
|
|||
name: 'chooseChannelForCatalog',
|
||||
props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange'],
|
||||
created() {
|
||||
this.chooseId = this.defaultCatalogId;
|
||||
this.defaultCatalogIdSign = this.defaultCatalogId;
|
||||
this.initData();
|
||||
setTimeout(()=>{
|
||||
if (this.catalogIdChange)this.catalogIdChange(this.defaultCatalogId);
|
||||
|
@ -54,8 +56,9 @@ export default {
|
|||
children: 'children',
|
||||
isLeaf: 'leaf'
|
||||
},
|
||||
defaultCatalogIdSign: null,
|
||||
chooseNode: null,
|
||||
chooseId: this.defaultCatalogId,
|
||||
chooseId: "",
|
||||
catalogTree: null,
|
||||
contextmenuShow: false
|
||||
|
||||
|
@ -132,6 +135,7 @@ export default {
|
|||
url:`/api/platform/catalog/del`,
|
||||
params: {
|
||||
id: id,
|
||||
platformId: this.platformId,
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
|
@ -139,8 +143,8 @@ export default {
|
|||
console.log("移除成功")
|
||||
node.parent.loaded = false
|
||||
node.parent.expand();
|
||||
if(this.defaultCatalogId === id) {
|
||||
this.defaultCatalogId = this.platformId;
|
||||
if (res.data.data) {
|
||||
this.defaultCatalogIdSign = res.data.data;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -159,7 +163,7 @@ export default {
|
|||
})
|
||||
.then((res)=> {
|
||||
if (res.data.code === 0) {
|
||||
this.defaultCatalogId = id;
|
||||
this.defaultCatalogIdSign = id;
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
|
@ -253,7 +257,7 @@ export default {
|
|||
{
|
||||
label: "设为默认",
|
||||
icon: "el-icon-folder-checked",
|
||||
disabled: node.data.id === this.defaultCatalogId,
|
||||
disabled: node.data.id === this.defaultCatalogIdSign,
|
||||
onClick: () => {
|
||||
this.setDefaultCatalog(data.id)
|
||||
},
|
||||
|
|
|
@ -253,10 +253,6 @@ export default {
|
|||
handleGBSelectionChange: function() {
|
||||
this.initData();
|
||||
},
|
||||
// catalogIdChange: function(id) {
|
||||
// this.catalogId = id;
|
||||
// console.log("直播通道选择模块收到: " + id)
|
||||
// },
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue