| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.VideoManagerConstants; |
| | | import com.genersoft.iot.vmp.conf.MediaConfig; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.boot.CommandLineRunner; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | |
| | | @Autowired |
| | | private MediaConfig mediaConfig; |
| | | |
| | | @Qualifier("taskExecutor") |
| | | @Autowired |
| | | private ThreadPoolTaskExecutor taskExecutor; |
| | | |
| | | @Override |
| | | public void run(String... strings) throws Exception { |
| | | mediaServerService.clearMediaServerForOnline(); |
| | | if (mediaServerService.getDefaultMediaServer() == null) { |
| | | mediaServerService.addToDatabase(mediaConfig.getMediaSerItem()); |
| | | } |
| | |
| | | (MediaServerItem mediaServerItem, JSONObject response)->{ |
| | | ZLMServerConfig zlmServerConfig = JSONObject.toJavaObject(response, ZLMServerConfig.class); |
| | | if (zlmServerConfig !=null ) { |
| | | startGetMedia.remove(zlmServerConfig.getGeneralMediaServerId()); |
| | | if (startGetMedia != null) { |
| | | startGetMedia.remove(zlmServerConfig.getGeneralMediaServerId()); |
| | | } |
| | | mediaServerService.handLeZLMServerConfig(zlmServerConfig); |
| | | } |
| | | }); |
| | | |
| | | // TODO 订阅 zlm保活事件, 当zlm离线时做业务的处理 |
| | | |
| | | |
| | | // 获取zlm信息 |
| | | logger.info("等待默认zlm接入..."); |
| | |
| | | for (MediaServerItem mediaServerItem : all) { |
| | | if (startGetMedia == null) startGetMedia = new HashMap<>(); |
| | | startGetMedia.put(mediaServerItem.getId(), true); |
| | | connectZlmServer(mediaServerItem); |
| | | taskExecutor.execute(()->{ |
| | | connectZlmServer(mediaServerItem); |
| | | }); |
| | | } |
| | | Timer timer = new Timer(); |
| | | // 2分钟后未连接到则不再去主动连接, TODO 并对重启前使用此在zlm的通道发送bye |