| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.MediaConfig; |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | //import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| | | import org.slf4j.Logger; |
| | |
| | | import org.springframework.boot.CommandLineRunner; |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | private IVideoManagerStorager storager; |
| | | |
| | | @Autowired |
| | | private IRedisCatchStorage redisCatchStorage; |
| | | |
| | | @Autowired |
| | | private MediaConfig mediaConfig; |
| | | |
| | | @Autowired |
| | | private SipConfig sipConfig; |
| | | |
| | | @Value("${server.port}") |
| | | private String serverPort; |
| | | |
| | | @Value("${server.ssl.enabled}") |
| | | @Value("${server.ssl.enabled:false}") |
| | | private boolean sslEnabled; |
| | | |
| | | private boolean startGetMedia = false; |
| | |
| | | |
| | | private void saveZLMConfig() { |
| | | logger.info("设置zlm..."); |
| | | if (StringUtils.isEmpty(mediaConfig.getHookIp())) mediaConfig.setHookIp(sipConfig.getSipIp()); |
| | | String protocol = sslEnabled ? "https" : "http"; |
| | | String hookPrex = String.format("%s://%s:%s/index/hook", protocol, mediaConfig.getHookIp(), serverPort); |
| | | String recordHookPrex = null; |
| | |
| | | if (responseJSON != null && responseJSON.getInteger("code") == 0) { |
| | | logger.info("设置zlm成功"); |
| | | }else { |
| | | logger.info("设置zlm失败: " + responseJSON.getString("msg")); |
| | | logger.info("设置zlm失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | logger.info( "[ id: " + zlmServerConfig.getGeneralMediaServerId() + "] zlm接入成功..."); |
| | | // 关闭循环获取zlm配置 |
| | | startGetMedia = false; |
| | | if (mediaConfig.getAutoConfig()) saveZLMConfig(); |
| | | if (mediaConfig.isAutoConfig()) saveZLMConfig(); |
| | | zlmServerManger.updateServerCatch(zlmServerConfig); |
| | | |
| | | // 清空所有session |
| | |
| | | // 设置为未启用 |
| | | logger.info("恢复流代理失败,请检查流地址后重新启用" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); |
| | | streamProxyService.stop(streamProxyDto.getApp(), streamProxyDto.getStream()); |
| | | }else if (jsonObject.getInteger("code") != 0){ // TODO 将错误信息存入数据库, 前端展示 |
| | | logger.info("恢复流代理失败:" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream() + "[ " + JSONObject.toJSONString(jsonObject) + " ]"); |
| | | streamProxyService.stop(streamProxyDto.getApp(), streamProxyDto.getStream()); |
| | | } |
| | | } |
| | | } |