调整节点管理代码结构
parent
1e0b73b939
commit
ad32da0dfd
|
@ -6,8 +6,8 @@ import com.alibaba.fastjson2.JSONObject;
|
|||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.MediaConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
|
||||
import com.genersoft.iot.vmp.media.event.MediaServerChangeEvent;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.ZLMServerConfig;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForServerStarted;
|
||||
|
@ -17,6 +17,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -35,8 +36,8 @@ public class MediaServerConfig implements CommandLineRunner {
|
|||
|
||||
private Map<String, Boolean> startGetMedia;
|
||||
|
||||
// @Autowired
|
||||
// private ZLMRESTfulUtils zlmresTfulUtils;
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@Autowired
|
||||
private ZlmHttpHookSubscribe hookSubscribe;
|
||||
|
@ -60,16 +61,15 @@ public class MediaServerConfig implements CommandLineRunner {
|
|||
MediaServerItem defaultMediaServer = mediaServerService.getDefaultMediaServer();
|
||||
if (defaultMediaServer == null) {
|
||||
mediaServerService.addToDatabase(mediaConfig.getMediaSerItem());
|
||||
// 发送媒体节点增加事件
|
||||
}else {
|
||||
MediaServerItem mediaSerItem = mediaConfig.getMediaSerItem();
|
||||
mediaServerService.updateToDatabase(mediaSerItem);
|
||||
// 发送媒体节点更新事件
|
||||
|
||||
}
|
||||
// 发送媒体节点变化事件
|
||||
mediaServerService.syncCatchFromDatabase();
|
||||
|
||||
|
||||
MediaServerChangeEvent event = new MediaServerChangeEvent(this);
|
||||
applicationEventPublisher.publishEvent(event);
|
||||
// TODO 此处以下代码弃用
|
||||
|
||||
|
||||
HookSubscribeForServerStarted hookSubscribeForServerStarted = HookSubscribeFactory.on_server_started();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.genersoft.iot.vmp.media.event;
|
||||
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
public class MediaServerChangeEvent extends ApplicationEvent {
|
||||
|
||||
public MediaServerChangeEvent(Object source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
private MediaServerItem mediaServerItem;
|
||||
|
||||
public MediaServerItem getMediaServerItem() {
|
||||
return mediaServerItem;
|
||||
}
|
||||
|
||||
public void setMediaServerItem(MediaServerItem mediaServerItem) {
|
||||
this.mediaServerItem = mediaServerItem;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.genersoft.iot.vmp.media.service;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonCallback;
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.ZLMServerConfig;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
|
||||
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.genersoft.iot.vmp.media.service.IMediaNodeServerService;
|
|||
import com.genersoft.iot.vmp.media.zlm.*;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.ZLMServerConfig;
|
||||
import com.genersoft.iot.vmp.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
|
||||
|
|
|
@ -19,10 +19,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
|
|||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.HookType;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.*;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
|
||||
import com.genersoft.iot.vmp.service.*;
|
||||
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|||
import com.genersoft.iot.vmp.common.CommonCallback;
|
||||
import com.genersoft.iot.vmp.media.service.IMediaNodeServerService;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.ZLMServerConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.genersoft.iot.vmp.media.zlm;
|
||||
|
||||
import com.genersoft.iot.vmp.media.event.MediaServerChangeEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
/**
|
||||
* 管理zlm流媒体节点的状态
|
||||
*/
|
||||
public class ZLMMediaServerStatusManger {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ZLMMediaServerStatusManger.class);
|
||||
|
||||
private final String type = "zlm";
|
||||
|
||||
@Async("taskExecutor")
|
||||
@EventListener
|
||||
public void onApplicationEvent(MediaServerChangeEvent event) {
|
||||
if (event.getMediaServerItem() == null
|
||||
|| !type.equals(event.getMediaServerItem().getType())
|
||||
|| event.getMediaServerItem().isStatus()) {
|
||||
return;
|
||||
}
|
||||
logger.info("[ZLM 待上线节点变化] ID:" + event.getMediaServerItem().getId());
|
||||
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||
|
||||
|
||||
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.genersoft.iot.vmp.media.zlm;
|
||||
package com.genersoft.iot.vmp.media.zlm.dto;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam;
|
Loading…
Reference in New Issue