From 735df5a935f4e34e278ab06fcea4197d6466d960 Mon Sep 17 00:00:00 2001
From: tnt group <dodu@live.cn>
Date: 星期二, 01 八月 2023 08:27:47 +0800
Subject: [PATCH] docs: 修正日志管理控制器mapping的错误描述
---
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 118 +++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 87 insertions(+), 31 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
index 8151fef..9b2864f 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -5,6 +5,7 @@
import com.genersoft.iot.vmp.common.InviteInfo;
import com.genersoft.iot.vmp.common.InviteSessionType;
import com.genersoft.iot.vmp.common.StreamInfo;
+import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
import com.genersoft.iot.vmp.gb28181.bean.*;
@@ -23,14 +24,18 @@
import com.genersoft.iot.vmp.media.zlm.dto.hook.*;
import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
+import com.genersoft.iot.vmp.service.bean.SSRCInfo;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
+import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
+import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
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.data.redis.core.RedisTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
@@ -116,6 +121,9 @@
@Qualifier("taskExecutor")
@Autowired
private ThreadPoolTaskExecutor taskExecutor;
+
+ @Autowired
+ private RedisTemplate<Object, Object> redisTemplate;
/**
* 鏈嶅姟鍣ㄥ畾鏃朵笂鎶ユ椂闂达紝涓婃姤闂撮殧鍙厤缃紝榛樿10s涓婃姤涓�娆�
@@ -225,10 +233,7 @@
HookResultForOnPublish result = HookResultForOnPublish.SUCCESS();
- if (!"rtp".equals(param.getApp())) {
- result.setEnable_audio(true);
- }
-
+ result.setEnable_audio(true);
taskExecutor.execute(() -> {
ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json);
if (subscribe != null) {
@@ -256,7 +261,6 @@
// 濡傛灉鏄綍鍍忎笅杞藉氨璁剧疆瑙嗛闂撮殧鍗佺
if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) {
result.setMp4_max_second(10);
- result.setEnable_audio(true);
result.setEnable_mp4(true);
}
}
@@ -278,6 +282,14 @@
}
}
}
+ if (param.getApp().equalsIgnoreCase("rtp")) {
+ String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + param.getStream();
+ OtherRtpSendInfo otherRtpSendInfo = (OtherRtpSendInfo)redisTemplate.opsForValue().get(receiveKey);
+ if (otherRtpSendInfo != null) {
+ result.setEnable_mp4(true);
+ }
+ }
+ logger.info("[ZLM HOOK]鎺ㄦ祦閴存潈 鍝嶅簲锛歿}->{}->>>>{}", param.getMediaServerId(), param, result);
return result;
}
@@ -447,8 +459,6 @@
if ("rtp".equals(param.getApp())) {
ret.put("close", userSetting.getStreamOnDemand());
// 鍥芥爣娴侊紝 鐐规挱/褰曞儚鍥炴斁/褰曞儚涓嬭浇
-// StreamInfo streamInfoForPlayCatch = redisCatchStorage.queryPlayByStreamId(param.getStream());
-
InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream());
// 鐐规挱
if (inviteInfo != null) {
@@ -506,7 +516,7 @@
// 鎷夋祦浠g悊
StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream());
if (streamProxyItem != null) {
- if (streamProxyItem.isEnableDisableNoneReader()) {
+ if (streamProxyItem.isEnableRemoveNoneReader()) {
// 鏃犱汉瑙傜湅鑷姩绉婚櫎
ret.put("close", true);
streamProxyService.del(param.getApp(), param.getStream());
@@ -551,7 +561,7 @@
if ("rtp".equals(param.getApp())) {
String[] s = param.getStream().split("_");
- if (!mediaInfo.isRtpEnable() || s.length != 2) {
+ if (!mediaInfo.isRtpEnable() || (s.length != 2 && s.length != 4)) {
defaultResult.setResult(HookResult.SUCCESS());
return defaultResult;
}
@@ -567,33 +577,79 @@
defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg()));
return defaultResult;
}
- logger.info("[ZLM HOOK] 娴佹湭鎵惧埌, 鍙戣捣鑷姩鐐规挱锛歿}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
+ if (s.length == 2) {
+ logger.info("[ZLM HOOK] 棰勮娴佹湭鎵惧埌, 鍙戣捣鑷姩鐐规挱锛歿}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
- RequestMessage msg = new RequestMessage();
- String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
- boolean exist = resultHolder.exist(key, null);
- msg.setKey(key);
- String uuid = UUID.randomUUID().toString();
- msg.setId(uuid);
- DeferredResult<HookResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
+ RequestMessage msg = new RequestMessage();
+ String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId;
+ boolean exist = resultHolder.exist(key, null);
+ msg.setKey(key);
+ String uuid = UUID.randomUUID().toString();
+ msg.setId(uuid);
+ DeferredResult<HookResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
- result.onTimeout(() -> {
- logger.info("[ZLM HOOK] 鑷姩鐐规挱, 绛夊緟瓒呮椂");
- // 閲婃斁rtpserver
- msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "鐐规挱瓒呮椂"));
- resultHolder.invokeResult(msg);
- });
-
- // 褰曞儚鏌ヨ浠hannelId浣滀负deviceId鏌ヨ
- resultHolder.put(key, uuid, result);
-
- if (!exist) {
- playService.play(mediaInfo, deviceId, channelId, (code, message, data) -> {
- msg.setData(new HookResult(code, message));
+ result.onTimeout(() -> {
+ logger.info("[ZLM HOOK] 棰勮娴佽嚜鍔ㄧ偣鎾�, 绛夊緟瓒呮椂");
+ // 閲婃斁rtpserver
+ msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "鐐规挱瓒呮椂"));
resultHolder.invokeResult(msg);
});
+
+ resultHolder.put(key, uuid, result);
+
+ if (!exist) {
+ playService.play(mediaInfo, deviceId, channelId, null, (code, message, data) -> {
+ msg.setData(new HookResult(code, message));
+ resultHolder.invokeResult(msg);
+ });
+ }
+ return result;
+ }else if(s.length == 4){
+ // 姝ゆ椂涓哄綍鍍忓洖鏀撅紝 褰曞儚鍥炴斁鏍煎紡涓�> 璁惧ID_閫氶亾ID_寮�濮嬫椂闂確缁撴潫鏃堕棿
+ String startTimeStr = s[2];
+ String endTimeStr = s[3];
+ if (startTimeStr == null || endTimeStr == null || startTimeStr.length() != 14 || endTimeStr.length() != 14) {
+ defaultResult.setResult(HookResult.SUCCESS());
+ return defaultResult;
+ }
+ String startTime = DateUtil.urlToyyyy_MM_dd_HH_mm_ss(startTimeStr);
+ String endTime = DateUtil.urlToyyyy_MM_dd_HH_mm_ss(endTimeStr);
+ logger.info("[ZLM HOOK] 鍥炴斁娴佹湭鎵惧埌, 鍙戣捣鑷姩鐐规挱锛歿}->{}->{}/{}-{}-{}",
+ param.getMediaServerId(), param.getSchema(),
+ param.getApp(), param.getStream(),
+ startTime, endTime
+ );
+ RequestMessage msg = new RequestMessage();
+ String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId;
+ boolean exist = resultHolder.exist(key, null);
+ msg.setKey(key);
+ String uuid = UUID.randomUUID().toString();
+ msg.setId(uuid);
+ DeferredResult<HookResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
+
+ result.onTimeout(() -> {
+ logger.info("[ZLM HOOK] 鍥炴斁娴佽嚜鍔ㄧ偣鎾�, 绛夊緟瓒呮椂");
+ // 閲婃斁rtpserver
+ msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "鐐规挱瓒呮椂"));
+ resultHolder.invokeResult(msg);
+ });
+
+ resultHolder.put(key, uuid, result);
+
+ if (!exist) {
+ SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaInfo, param.getStream(), null,
+ device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam());
+ playService.playBack(mediaInfo, ssrcInfo, deviceId, channelId, startTime, endTime, (code, message, data) -> {
+ msg.setData(new HookResult(code, message));
+ resultHolder.invokeResult(msg);
+ });
+ }
+ return result;
+ }else {
+ defaultResult.setResult(HookResult.SUCCESS());
+ return defaultResult;
}
- return result;
+
} else {
// 鎷夋祦浠g悊
StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream());
--
Gitblit v1.8.0