648540858
2021-11-17 c23932eb00edfa5f734b0d17eced838c5c7577c0
src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java
@@ -1,10 +1,13 @@
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.slf4j.Logger;
@@ -16,7 +19,7 @@
import java.util.*;
/**
 * @Description: 平台未注册事件,来源有二:
 * @description: 平台未注册事件,来源有二:
 *               1、平台新添加
 *               2、平台心跳超时
 * @author: panll
@@ -31,12 +34,17 @@
    private IVideoManagerStorager storager;
    @Autowired
    private IRedisCatchStorage redisCatchStorage;
    @Autowired
    private IMediaServerService mediaServerService;
    @Autowired
    private SIPCommanderFroPlatform sipCommanderFroPlatform;
    @Autowired
    private ZLMRTPServerFactory zlmrtpServerFactory;
    @Autowired
    private SipConfig config;
    // @Autowired
    // private RedisUtil redis;
@@ -58,22 +66,24 @@
            logger.info("停止[ {} ]的所有推流", event.getPlatformGbID());
            StringBuilder app = new StringBuilder();
            StringBuilder stream = new StringBuilder();
            for (int i = 0; i < sendRtpItems.size(); i++) {
            for (SendRtpItem sendRtpItem : sendRtpItems) {
                if (app.length() != 0) {
                    app.append(",");
                }
                app.append(sendRtpItems.get(i).getApp());
                app.append(sendRtpItem.getApp());
                if (stream.length() != 0) {
                    stream.append(",");
                }
                stream.append(sendRtpItems.get(i).getStreamId());
                redisCatchStorage.deleteSendRTPServer(event.getPlatformGbID(), sendRtpItems.get(i).getChannelId());
                stream.append(sendRtpItem.getStreamId());
                redisCatchStorage.deleteSendRTPServer(event.getPlatformGbID(), sendRtpItem.getChannelId());
                MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
                Map<String, Object> param = new HashMap<>();
                param.put("vhost", "__defaultVhost__");
                param.put("app", app.toString());
                param.put("stream", stream.toString());
                zlmrtpServerFactory.stopSendRtpStream(mediaInfo, param);
            }
            Map<String, Object> param = new HashMap<>();
            param.put("vhost","__defaultVhost__");
            param.put("app", app.toString());
            param.put("stream", stream.toString());
            zlmrtpServerFactory.stopSendRtpStream(param);
        }
@@ -90,6 +100,6 @@
                logger.info("再次向平台注册,平台国标ID:" + event.getPlatformGbID());
                sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
            }
        }, 15000, 15000);//十五秒后再次发起注册
        }, config.getRegisterTimeInterval()* 1000, config.getRegisterTimeInterval()* 1000);//十五秒后再次发起注册
    }
}