From 3b1516afe54cfa95a37b3356e7910c7ad57b32db Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期六, 25 三月 2023 18:40:29 +0800 Subject: [PATCH] 优化录像配置。不再使用zlm默认的http服务器 --- src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index eab8edb..e6bdb92 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; +import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; @@ -38,6 +39,7 @@ import org.springframework.transaction.TransactionStatus; import org.springframework.util.ObjectUtils; +import java.io.File; import java.time.LocalDateTime; import java.util.*; @@ -62,6 +64,9 @@ @Autowired private UserSetting userSetting; + + @Autowired + private AssistRESTfulUtils assistRESTfulUtils; @Autowired private ZLMRESTfulUtils zlmresTfulUtils; @@ -407,13 +412,27 @@ } RedisUtil.set(key, serverItem); resetOnlineServerItem(serverItem); + + if (serverItem.isAutoConfig()) { + // 鏌ョ湅assist鏈嶅姟鐨勫綍鍍忚矾寰勯厤缃� + if (serverItem.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) { + JSONObject info = assistRESTfulUtils.getInfo(serverItem, null); + if (info != null && info.getInteger("code") != null && info.getInteger("code") == 0 ) { + JSONObject dataJson = info.getJSONObject("data"); + if (dataJson != null) { + String recordPath = dataJson.getString("record"); + userSetting.setRecordPath(recordPath); + } + } + } setZLMConfig(serverItem, "0".equals(zlmServerConfig.getHookEnable())); } final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + serverItem.getId(); dynamicTask.stop(zlmKeepaliveKey); dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(serverItem), (Math.getExponent(serverItem.getHookAliveInterval()) + 5) * 1000); publisher.zlmOnlineEventPublish(serverItem.getId()); + logger.info("[ZLM] 杩炴帴鎴愬姛 {} - {}:{} ", zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(), zlmServerConfig.getHttpPort()); } @@ -584,6 +603,13 @@ param.put("rtp_proxy.port_range", mediaServerItem.getRtpPortRange().replace(",", "-")); } + if (userSetting.getRecordPath() != null) { + File recordPathFile = new File(userSetting.getRecordPath()); + File mp4SavePathFile = recordPathFile.getParentFile().getAbsoluteFile(); + param.put("protocol.mp4_save_path", mp4SavePathFile.getAbsoluteFile()); + param.put("record.appName", recordPathFile.getName()); + } + JSONObject responseJSON = zlmresTfulUtils.setServerConfig(mediaServerItem, param); if (responseJSON != null && responseJSON.getInteger("code") == 0) { -- Gitblit v1.8.0