| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.MediaServerConfig; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyDto; |
| | | 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.vmanager.service.IStreamProxyService; |
| | | import com.genersoft.iot.vmp.service.IStreamProxyService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Override |
| | | public void run(String... strings) throws Exception { |
| | | JSONObject subscribeKey = new JSONObject(); |
| | | // 订阅 zlm启动事件 |
| | | hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,subscribeKey,(response)->{ |
| | | hookSubscribe.addSubscribe(ZLMHttpHookSubscribe.HookType.on_server_started,null,(response)->{ |
| | | MediaServerConfig mediaServerConfig = JSONObject.toJavaObject(response, MediaServerConfig.class); |
| | | zLmRunning(mediaServerConfig); |
| | | }); |
| | |
| | | param.put("ffmpeg.cmd","%s -fflags nobuffer -rtsp_transport tcp -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s"); |
| | | param.put("hook.enable","1"); |
| | | param.put("hook.on_flow_report",""); |
| | | param.put("hook.on_play",""); |
| | | param.put("hook.on_play",String.format("%s/on_play", hookPrex)); |
| | | param.put("hook.on_http_access",""); |
| | | param.put("hook.on_publish",String.format("%s/on_publish", hookPrex)); |
| | | param.put("hook.on_record_mp4",""); |
| | |
| | | logger.info("zlm接入成功..."); |
| | | if (autoConfig) saveZLMConfig(); |
| | | MediaServerConfig mediaInfo = redisCatchStorage.getMediaInfo(); |
| | | if (System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){ |
| | | if (mediaInfo != null && System.currentTimeMillis() - mediaInfo.getUpdateTime() < 50){ |
| | | logger.info("zlm刚刚更新,忽略这次更新"); |
| | | return; |
| | | } |
| | |
| | | // 更新流列表 |
| | | zlmMediaListManager.updateMediaList(); |
| | | // 恢复流代理 |
| | | List<StreamProxyDto> streamProxyListForEnable = storager.getStreamProxyListForEnable(true); |
| | | for (StreamProxyDto streamProxyDto : streamProxyListForEnable) { |
| | | List<StreamProxyItem> streamProxyListForEnable = storager.getStreamProxyListForEnable(true); |
| | | for (StreamProxyItem streamProxyDto : streamProxyListForEnable) { |
| | | logger.info("恢复流代理," + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); |
| | | streamProxyService.addStreamProxyToZlm(streamProxyDto); |
| | | } |